@grapesjs/studio-sdk-plugins 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accordionComponent/index.cjs.js +3 -3
- package/dist/accordionComponent/index.es.js +29 -30
- package/dist/accordionComponent/index.umd.js +4 -4
- package/dist/canvasEmptyState/index.cjs.js +1 -1
- package/dist/canvasEmptyState/index.es.js +14 -15
- package/dist/canvasEmptyState/index.umd.js +1 -1
- package/dist/canvasFullSize/index.cjs.d.ts +2 -2
- package/dist/canvasFullSize/index.cjs.js +1 -1
- package/dist/canvasFullSize/index.d.ts +2 -2
- package/dist/canvasFullSize/index.es.d.ts +2 -2
- package/dist/canvasFullSize/index.es.js +2 -3
- package/dist/canvasFullSize/index.umd.js +2 -2
- package/dist/canvasFullSize/types.d.ts +1 -1
- package/dist/dialogComponent/index.cjs.js +2 -2
- package/dist/dialogComponent/index.es.js +2 -3
- package/dist/dialogComponent/index.umd.js +2 -2
- package/dist/flexComponent/index.cjs.js +1 -1
- package/dist/flexComponent/index.es.js +2 -3
- package/dist/flexComponent/index.umd.js +1 -1
- package/dist/fsLightboxComponent/index.cjs.js +2 -2
- package/dist/fsLightboxComponent/index.es.js +2 -3
- package/dist/fsLightboxComponent/index.umd.js +2 -2
- package/dist/googleFontsAssetProvider/index.cjs.js +1 -1
- package/dist/googleFontsAssetProvider/index.es.js +39 -40
- package/dist/googleFontsAssetProvider/index.umd.js +1 -1
- package/dist/iconifyComponent/index.cjs.js +2 -2
- package/dist/iconifyComponent/index.es.js +31 -32
- package/dist/iconifyComponent/index.umd.js +2 -2
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +42 -42
- package/dist/index.d.ts +1 -0
- package/dist/index.es.d.ts +1 -0
- package/dist/index.es.js +3171 -2944
- package/dist/index.umd.js +36 -36
- package/dist/layoutSidebarButtons/index.cjs.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.cjs.js +1 -0
- package/dist/layoutSidebarButtons/index.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.es.d.ts +3 -0
- package/dist/layoutSidebarButtons/index.es.js +328 -0
- package/dist/layoutSidebarButtons/index.umd.js +1 -0
- package/dist/layoutSidebarButtons/layout.d.ts +8 -0
- package/dist/layoutSidebarButtons/types.d.ts +75 -0
- package/dist/layoutSidebarButtons/typesSchema.d.ts +49 -0
- package/dist/lightGalleryComponent/index.cjs.js +1 -1
- package/dist/lightGalleryComponent/index.es.js +2 -3
- package/dist/lightGalleryComponent/index.umd.js +1 -1
- package/dist/listPagesComponent/index.cjs.js +3 -3
- package/dist/listPagesComponent/index.es.js +2 -3
- package/dist/listPagesComponent/index.umd.js +3 -3
- package/dist/prosemirror/index.cjs.js +2 -2
- package/dist/prosemirror/index.es.js +3 -4
- package/dist/prosemirror/index.umd.js +2 -2
- package/dist/rteTinyMce/index.cjs.js +1 -1
- package/dist/rteTinyMce/index.es.js +20 -21
- package/dist/rteTinyMce/index.umd.js +1 -1
- package/dist/swiperComponent/index.cjs.js +3 -3
- package/dist/swiperComponent/index.es.js +2 -3
- package/dist/swiperComponent/index.umd.js +3 -3
- package/dist/tableComponent/index.cjs.js +1 -1
- package/dist/tableComponent/index.es.js +13 -14
- package/dist/tableComponent/index.umd.js +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/youtubeAssetProvider/index.cjs.js +1 -1
- package/dist/youtubeAssetProvider/index.es.js +7 -8
- package/dist/youtubeAssetProvider/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Rl="app.grapesjs.com",Dl="app-stage.grapesjs.com",Li=[Rl,Dl,"localhost","127.0.0.1",".local-credentialless.webcontainer.io",".local.webcontainer.io","-sandpack.codesandbox.io"],id="license:check:start",rd="license:check:end",ld=()=>typeof window<"u",ad=({isDev:n,isStage:e})=>`${n?"":`https://${e?Dl:Rl}`}/api`,cd=()=>{const n=ld()&&window.location.hostname;return!!n&&(Li.includes(n)||Li.some(e=>n.endsWith(e)))},dd=n=>n.replace(/[A-Z]+(?![a-z])|[A-Z]/g,(e,t)=>(t?"-":"")+e.toLowerCase()),ud=n=>typeof n<"u";function Hs(n){return typeof n=="function"}async function hd({path:n,baseApiUrl:e,method:t="GET",headers:s={},params:o,body:i}){const l=`${e||ad({isDev:!1,isStage:!1})}${n}`,a={method:t,headers:{"Content-Type":"application/json",...s}};i&&(a.body=JSON.stringify(i));const c=o?new URLSearchParams(o).toString():"",d=c?`?${c}`:"",u=await fetch(`${l}${d}`,a);if(!u.ok)throw new Error(`HTTP error! status: ${u.status}`);return u.json()}var F=(n=>(n.free="free",n.startup="startup",n.business="business",n.enterprise="enterprise",n))(F||{}),zl=(n=>(n.Info="info",n.Error="error",n.Success="success",n.Warning="warning",n))(zl||{}),B=(n=>(n.toastAdd="studio:toastAdd",n.dialogOpen="studio:dialogOpen",n.dialogClose="studio:dialogClose",n.sidebarLeftSet="studio:sidebarLeft:set",n.sidebarLeftGet="studio:sidebarLeft:get",n.sidebarLeftToggle="studio:sidebarLeft:toggle",n.sidebarRightSet="studio:sidebarRight:set",n.sidebarRightGet="studio:sidebarRight:get",n.sidebarRightToggle="studio:sidebarRight:toggle",n.sidebarTopSet="studio:sidebarTop:set",n.sidebarTopGet="studio:sidebarTop:get",n.sidebarTopToggle="studio:sidebarTop:toggle",n.sidebarBottomSet="studio:sidebarBottom:set",n.sidebarBottomGet="studio:sidebarBottom:get",n.sidebarBottomToggle="studio:sidebarBottom:toggle",n.symbolAdd="studio:symbolAdd",n.symbolDetach="studio:symbolDetach",n.symbolOverride="studio:symbolOverride",n.symbolPropagateStyles="studio:propagateStyles",n.getPagesConfig="studio:getPagesConfig",n.setPagesConfig="studio:setPagesConfig",n.getPageSettings="studio:getPageSettings",n.setPageSettings="studio:setPageSettings",n.projectFiles="studio:projectFiles",n.canvasReload="studio:canvasReload",n.getBlocksPanel="studio:getBlocksPanel",n.setBlocksPanel="studio:setBlocksPanel",n.getStateContextMenu="studio:getStateContextMenu",n.setStateContextMenu="studio:setStateContextMenu",n.contextMenuComponent="studio:contextMenuComponent",n.layoutAdd="studio:layoutAdd",n.layoutRemove="studio:layoutRemove",n.layoutToggle="studio:layoutToggle",n.layoutUpdate="studio:layoutUpdate",n.layoutGet="studio:layoutGet",n.layoutConfigGet="studio:layoutConfigGet",n.layoutConfigSet="studio:layoutConfigSet",n.getStateTheme="studio:getStateTheme",n.setStateTheme="studio:setStateTheme",n.assetProviderGet="studio:assetProviderGet",n.assetProviderAdd="studio:assetProviderAdd",n.assetProviderRemove="studio:assetProviderRemove",n.fontGet="studio:fontGet",n.fontAdd="studio:fontAdd",n.fontRemove="studio:fontRemove",n))(B||{}),Ll=(n=>(n.layoutToggleId="studio:layoutToggle:",n.toggleBlocksPanel="studio:toggleBlocksPanel",n.pageSettingsUpdate="studio:pageSettingsUpdate",n))(Ll||{}),Vl=(n=>(n.dark="dark",n.light="light",n.auto="auto",n))(Vl||{}),Bl=(n=>(n.web="web",n.email="email",n))(Bl||{});const Vi={[F.free]:0,[F.startup]:10,[F.business]:20,[F.enterprise]:30};function fd(n){const e=n;return e.init=t=>s=>n(s,t),e}const ee=n=>fd(n);async function te({editor:n,plan:e,pluginName:t,licenseKey:s,cleanup:o}){let i="",r=!1;const l=cd(),a=d=>{console.warn("Cleanup plugin:",t,"Reason:",d),o()},c=(d={})=>{var m;const{error:u,sdkLicense:h}=d,f=(m=d.plan)==null?void 0:m.category;if(!(h||d.license)||u)a(u||"Invalid license");else if(f){const g=Vi[e],b=Vi[f];g>b&&a({pluginRequiredPlan:e,licensePlan:f})}};n.on(id,d=>{i=d==null?void 0:d.baseApiUrl,r=!0}),n.on(rd,d=>{c(d)}),setTimeout(async()=>{if(!r){if(l)return;if(s){const d=await pd({licenseKey:s,pluginName:t,baseApiUrl:i});d&&c(d)}else a("The `licenseKey` option not provided")}},2e3)}async function pd(n){const{licenseKey:e,pluginName:t,baseApiUrl:s}=n;try{return(await hd({baseApiUrl:s,path:`/sdk/${e||"na"}`,method:"POST",params:{d:window.location.hostname,pn:t}})).result||{}}catch(o){return console.error("Error during SDK license check:",o),!1}}const as=(n,e)=>{var t;return!!((t=n==null?void 0:n.hasAttribute)!=null&&t.call(n,e))},Mt=(n,e)=>{var t;return!!((t=n==null?void 0:n.classList)!=null&&t.contains(e))},Pt=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,rt))===n},di=(...n)=>e=>n.some(t=>e.is(t)),Hl=(...n)=>(e,t)=>n.some(s=>t.is(s)),md=(n,e={})=>{var i;const t={},s=[],o=[];for(const r in n){const{value:l,...a}=n[r];s.push({id:r,name:r,changeProp:!0,category:e.category,...a}),t[r]=l,!ud(l)&&o.push(r);const{subTraits:c={}}=a;for(const d in a.subTraits)(i=c[d])==null||i.forEach(u=>{const h=u.id||u.name;t[h]=u.value})}return{propKeys:Object.keys(t),propsNoValues:o,props:t,traits:s}},gd=(n,e)=>{e.forEach(t=>{if(t.subTraits){const s=`${t.id||t.name}`,o=t.changeProp?`change:${s}`:`change:attributes:${s}`;n.on(o,()=>Bi(n,s)),Bi(n,s)}})},Bi=(n,e)=>{const t=n.getTrait(e),s=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:s,...c})),{at:a})},yd=(n,e)=>{e.forEach(t=>{const s=dd(t);s!==t&&n.has(s)&&n.set({[t]:n.get(s),[s]:void 0})})},Fe="gjs-plg-",rt="data-type-role",Hi=(...n)=>n.map(e=>`[data-gjs-type="${e}"]`).join(","),bd="dialogComponent",vd=function(n,e={}){const{Blocks:t,Components:s}=n,{licenseKey:o}=e,i="gjs-plg-dialog",r="gjs-plg-dialog-overlay",l="gjs-plg-dialog-content",a="gjs-plg-dialog-close",c="gjs-plg-dialog-title",d="gjs-plg-dialog-body",u="gjs-plg-dialog-description",h="gjs-plg-dialog-placeholder";t.add(i,{label:"Dialog",media:`
|
|
2
2
|
<svg viewBox="0 0 24 24">
|
|
3
3
|
<path d="M4 4h16v10H8l-4 4V4z"></path>
|
|
4
4
|
</svg>
|
|
5
|
-
`,category:"Extra",content:{type:i},activate:!0,...e.block}),s.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:
|
|
5
|
+
`,category:"Extra",content:{type:i},activate:!0,...e.block}),s.addType(i,{model:{defaults:{tagName:"div",attributes:{class:i,"data-type-role":i},components:[{type:r},{type:h}],draggable:Hi("wrapper"),droppable:Hi(i),styles:`
|
|
6
6
|
.${i} {
|
|
7
7
|
position: relative;
|
|
8
8
|
z-index: 1;
|
|
@@ -47,33 +47,33 @@
|
|
|
47
47
|
margin: 0;
|
|
48
48
|
padding: 0 40px 20px 0;
|
|
49
49
|
}
|
|
50
|
-
`}}}),s.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:
|
|
50
|
+
`}}}),s.addType(d,{model:{defaults:{tagName:"div",attributes:{class:d,"data-type-role":d},components:[{type:u}],styles:`
|
|
51
51
|
.${d} {
|
|
52
52
|
height: 90%;
|
|
53
53
|
overflow: auto;
|
|
54
54
|
}
|
|
55
|
-
`}}}),s.addType(
|
|
56
|
-
.${
|
|
55
|
+
`}}}),s.addType(u,{model:{defaults:{tagName:"p",attributes:{class:u,"data-type-role":u},components:"This is a customizable dialog!",editable:!0,styles:`
|
|
56
|
+
.${u} {
|
|
57
57
|
margin: 0;
|
|
58
58
|
}
|
|
59
|
-
`}}}),s.addType(
|
|
59
|
+
`}}}),s.addType(h,{model:{toHTML(){return""},defaults:{tagName:"button",attributes:{class:h,"data-type-role":h},components:"Dialog (click me to open)",droppable:!1,draggable:!1}},view:{init(){const{em:p,el:m}=this,g="core:preview",b=p.Commands.events;this.listenTo(p,`${b.runCommand}${g}`,()=>{m.style.display="none"}),this.listenTo(p,`${b.stopCommand}${g}`,()=>{m.style.display=""})}}}),te({editor:n,licenseKey:o,plan:F.startup,pluginName:bd,cleanup:()=>{t.remove(i),s.removeType(i)}})},wd=ee(vd),Sd={ratioDefault:!0,tc:!1,cl:!1,cr:!1,bc:!1},Ys=`<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>`,Dl="layout-icon-picker",hd="icons-layout-",zl="icons-list-layout",Vl="gs-iconify-picker",li="__iconify_collection",ud="https://api.iconify.design",Zs=new Map;let jn;const fd=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function Ll({collectionId:n,editor:e}){try{if(Zs.has(n))return Zs.get(n);const t=await fetch(fd({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const s=await t.json();return Zs.set(n,s),s}catch(t){console.error("Error fetching collection",t),e.runCommand(j.toastAdd,Sd());return}}async function pd({collectionIds:n,editor:e}){try{if(jn)return jn;const t=n?`?prefixes=${n.join(",")}`:"",s=await fetch(`${ud}/collections${t}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return jn=await s.json(),jn}catch(t){console.error("Error fetching collections",t),e.runCommand(j.toastAdd,Bl());return}}function Vi(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function md({collectionIds:n,editor:e,component:t}){const s=await pd({collectionIds:n,editor:e});if(!s)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(s).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(j.layoutToggle,{id:Dl,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[bd({collectionsList:i,collectionId:r,editor:e,handleClick:o}),{id:zl,type:"column",grow:!0}]}});const l=await Ll({collectionId:r,editor:e});l&&xo({editor:e,collection:l,handleClick:o,collectionId:r})}function gd({editor:n,collection:e}){n.em.set(li,e)}function yd(n){return n.em.get(li)}function xo(n){const{editor:e}=n,t={id:hd,layout:vd(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:zl}};e.runCommand(j.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(j.layoutAdd,t),10)}function bd(n){const{collectionsList:e,collectionId:t,editor:s,handleClick:o}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Vl}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await Ll({collectionId:l,editor:s});a&&(r({value:l}),gd({editor:s,collection:a}),xo({editor:s,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${li}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=yd(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([h])=>h.includes(l)));r({value:l}),xo({editor:a,collection:c,handleClick:o,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function vd({collection:n,collectionFiltered:e,handleClick:t}){const{height:s=24,width:o=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Vl}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:h,removeEl:u}=c,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("xmlns","http://www.w3.org/2000/svg"),f.innerHTML=a.body,f.setAttribute("viewBox",`0 0 ${o} ${s}`);const{cssWidth:p,cssHeight:m}=wd(o,s);f.style.cssText=`width: ${p}px; height: ${m}px; cursor: pointer;`,f.addEventListener("mouseover",()=>{f.style.border="2px solid currentColor",f.style.borderRadius="4px",f.style.padding="4px"}),f.addEventListener("mouseout",()=>{f.style.border="none"});const g=()=>{const b=f.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(j.layoutRemove,{id:Dl})};return f.addEventListener("click",g),h(f),()=>{f.removeEventListener("click",g),u(f)}}}]}}}function wd(n,e){const t=n/e;let s=48,o=48;return t>1?o=48/t:t<1&&(s=48*t),{cssWidth:s,cssHeight:o}}function Bl(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:Nl.Error}}function Sd(){return{...Bl(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Cd="iconifyComponent",xd=function(n,e={}){var f;const{Components:t,Blocks:s}=n,{collections:o,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",h="data-type-iconify",u={events:()=>({dblclick:"onActive"}),onActive(){md({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Us,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>ls(p,h),model:{defaults:{name:d,icon:Us,droppable:!1,attributes:{[h]:!0},resizable:dd,components:Us,style:{width:"50px",height:"50px"},traits:[Vi()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:u}),i){const p=(f=t.getType(a))==null?void 0:f.model,[m,g,...b]=p.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,Vi(),...b]}},view:u})}re({editor:n,licenseKey:r,plan:W.startup,pluginName:Cd,cleanup:()=>{s.remove(c),t.removeType(c)}})},kd=ie(xd);function ai(n,e,t){let s,o,i,r,l;const a=e===void 0?100:e;function c(){const h=Date.now()-r;h<a&&h>=0?s=setTimeout(c,a-h):(s=null,l=n.apply(i,o),i=o=null)}const d=function(){return i=this,o=arguments,r=Date.now(),s||(s=setTimeout(c,a)),l};return d.clear=function(){s&&(clearTimeout(s),s=null)},d.flush=function(){s&&(l=n.apply(i,o),i=o=null,clearTimeout(s),s=null)},d}var O=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(O||{});const 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>'},Oe="table",Hl="thead",$l="tfoot",ko="tbody",de="row",$="cell",ci="clipboardTable",Td=[Oe,Hl,$l,ko,de,$],Bs=n=>n.em.get(ci)||[],Md=n=>n.every(e=>e.is($)),di=(n,e)=>{const{editor:t,event:s,opts:o}=n,i=s.currentTarget||s.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};Ls(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(j.layoutToggle,d)},Ad=(n,{rows:e=1,cells:t=5,text:s}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:de,components:Array.from(Array(t).keys()).map(i=>({type:$,components:s?{type:"text",content:Ls(s)?s({y:o,x:i}):s}:void 0}))}))}),Fl="Table settings",Wl=n=>{const{component:e}=n;return e.is(Oe)?e:e.closestType(Oe)},Ed=n=>{var e;(e=Wl(n))==null||e.remove(n.opts)},Od=n=>{const e=Wl(n);e&&(n.editor.select(e),di(n,{id:"tableSettings",header:{label:Fl}}))},_l=n=>[{id:O.table,icon:z[O.table],label:"Table",items:[{id:O.tableSettings,label:Fl,icon:z[O.tableSettings],onClick:({event:t})=>Od({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:z[O.tableDelete],onClick:()=>Ed(n)}]}],ql=({editor:n})=>{const e=Bs(n);return e.length&&Md(e)},Li=({component:n,editor:e,after:t})=>{if(!n.is($))return;const s=n.closestType(Oe),o=n.closestType(de),i=n.index()+(t?1:0);s==null||s.findType(de).forEach(l=>l.append({type:$},{at:i}));const r=o==null?void 0:o.components().at(i);r&&e.select(r)},Gl=({component:n,opts:e})=>{if(!n.is($))return;const t=n.closestType(Oe),s=n.index();t==null||t.findType(de).forEach(o=>{var i;return(i=o.components().at(s))==null?void 0:i.remove(e)})},jl=({component:n,editor:e})=>{if(!n.is($))return;const t=n.closestType(Oe),s=n.index(),o=(t==null?void 0:t.findType(de).map(i=>i.components().at(s)))||[];o.length&&e.em.set(ci,o)},Bi=n=>{const{component:e,editor:t,after:s}=n;if(!e.is($)||!ql(n))return;const o=Bs(t),i=e.closestType(Oe),r=e.index()+(s?1:0);i==null||i.findType(de).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:$};l.append(d,{at:r})})},Nd=n=>{const{component:e}=n;e.is($)&&(jl(n),Gl({...n,opts:{temporary:!0}}))},Pd=n=>{const e=ql(n);return[{id:O.tableColumnItems,icon:z[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:z[O.tableColumnInsertBefore],onClick:()=>Li(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:z[O.tableColumnInsertAfter],onClick:()=>Li({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:z[O.tableColumnDelete],onClick:()=>Gl(n)},{id:O.tableColumnCut,label:"Cut column",icon:z[O.tableColumnCut],onClick:()=>Nd(n)},{id:O.tableColumnCopy,label:"Copy column",icon:z[O.tableColumnCopy],onClick:()=>jl(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:z[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Bi(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:z[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Bi({...n,after:!0})}]}]},Kl="Row settings",Id=n=>n.every(e=>e.is(de)),ln=n=>{const{component:e}=n,t=e.is($),s=e.is(de);if(!(!t&&!s))return s?e:e.closestType(de)},Hi=n=>{const{component:e,editor:t,after:s}=n,o=ln(n);if(!o)return;const i=o.index()+(s?1:0),r=o.components().length,l=Array.from(Array(r).keys()).map(()=>({type:$})),a=o.parent();if(a){const c=a.append({type:de,components:l},{at:i})[0];if(e.is($)&&c){const d=e.index(),h=c.components().at(d);h&&t.select(h)}}},Jl=n=>{var e;(e=ln(n))==null||e.remove(n.opts)},Ul=n=>{const e=ln(n);e&&n.editor.em.set(ci,[e])},$i=n=>{var l;const{editor:e,after:t}=n,s=ln(n);if(!s||!Zl(n))return;const i=Bs(e)[0],r=s.index()+(t?1:0);i&&((l=s.parent())==null||l.append(i.clone(),{at:r}))},Rd=n=>{ln(n)&&(Ul(n),Jl({...n,opts:{temporary:!0}}))},Zl=({editor:n})=>{const e=Bs(n);return e.length&&Id(e)},Dd=n=>{const e=ln(n);e&&(n.editor.select(e),di(n,{id:"tableRowSettings",header:{label:Kl}}))},Yl=n=>{const e=Zl(n);return[{id:O.tableRowItems,icon:z[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:z[O.tableRowInsertBefore],onClick:()=>Hi(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:z[O.tableRowInsertAfter],onClick:()=>Hi({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:z[O.tableRowDelete],onClick:()=>Jl(n)},{id:O.tableRowProperties,label:Kl,icon:z[O.tableRowProperties],onClick:({event:s})=>Dd({...n,event:s})},{id:O.tableRowCut,label:"Cut row",icon:z[O.tableRowCut],onClick:()=>Rd(n)},{id:O.tableRowCopy,label:"Copy row",icon:z[O.tableRowCopy],onClick:()=>Ul(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:z[O.tableRowPasteBefore],disabled:!e,onClick:()=>$i(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:z[O.tableRowPasteAfter],disabled:!e,onClick:()=>$i({...n,after:!0})}]},..._l(n)]},hi=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),s=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:s}};function Xl(n){const e=[];return n.components().forEach((t,s)=>{t.components().each((o,i)=>{const{rowspan:r,colspan:l}=hi(o);if(e[s])for(;e[s][i];)i++;for(let a=s;a<s+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===s&&c===i,cell:o,rowspan:r,colspan:l}}})}),e}function Wt(n,e,t){var s;return(s=n[t])==null?void 0:s[e]}const To=n=>n.closestType(de);function zd(n,{x:e,y:t,rows:s,cols:o}){var l;let i=To(n[t][e].cell),r;for(let a=1;a<=s;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=To(c);if(d===i){for(let h=1;h<=o;h++){const u=c.index();d.append({type:$},{at:u+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let h=1;h<=o;h++)i.append({type:$},{at:d})}}}function Ql(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const o=n[e][t].cell;if(o.em.selected.hasComponent(o)){const{rowspan:i,colspan:r}=hi(o);if(r>1||i>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=o.index();To(o).append({type:$},{at:a+1})}zd(n,{x:t,y:e,rows:i-1,cols:r})}}}}function Vd(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Hs=(n,e={})=>{var r;const t=Xl(n),{em:s}=n;let o,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||s.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),i=d}}return{grid:t,startPos:o,endPos:i}};function Ld(n,e={}){const t=Hs(n),{startPos:s,endPos:o}=t;let{grid:i}=t;const{em:r}=n;if(!s||!o)return;const l=s.x,a=s.y,c=o.x,d=o.y,h=Wt(i,l,a),u=Wt(i,c,d);if(h&&u){Ql(i),i=Xl(n);const f=[],p=Wt(i,l,a).cell;p.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=Wt(i,g,m);if(!b)continue;const{cell:C}=b;C!==p&&f.push(C)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),r.setSelected(p),Vd(n)}}const ea="Cell settings",Bd="Merge cells",Hd="Split cell",$d=n=>n.closestType(de),Xt=n=>{var e;return(e=$d(n))==null?void 0:e.parent()},Fd=n=>{const e=n.editor.getSelectedAll(),t=Xt(e[0]),s=e[0];if(!t||!(s!=null&&s.is($))||e.length>1)return!1;const{rowspan:o,colspan:i}=hi(s);return!(i<2&&o<2)},Wd=n=>{const t=n.editor.getSelectedAll()[0],s=Xt(t),{grid:o}=Hs(s);Ql(o)},ta=n=>{const e=n.editor.getSelectedAll(),t=Xt(e[0]);if(!t||e.length<2||e.some(l=>!l.is($)||Xt(l)!==t))return!1;const{grid:s,startPos:o,endPos:i}=Hs(t),{em:r}=t;if(!o||!i)return!1;for(let l=o.y;l<=i.y;l++)for(let a=o.x;a<=i.x;a++){const c=Wt(s,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},_d=n=>{const{editor:e}=n;if(!ta(n))return;const t=e.getSelectedAll(),s=Xt(t[0]);Ld(s,{mergeContent:!0})},qd=n=>{di(n,{id:"tableCellSettings",header:{label:ea}})},Gd=n=>[{id:O.tableCellItems,icon:z[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:ea,icon:z[O.tableCellProperties],onClick:({event:t})=>qd({...n,event:t})},{id:O.tableCellMerge,label:Bd,icon:z[O.tableCellMerge],onClick:()=>_d(n),disabled:!ta(n)},{id:O.tableCellSplit,label:Hd,icon:z[O.tableCellSplit],onClick:()=>Wd(n),disabled:!Fd(n)}]},...Pd(n),...Yl(n)],jd=n=>{const e=n[0]&&Xt(n[0]);if(!e)return;const{grid:t,startPos:s,endPos:o}=Hs(e,{selected:n});if(!s||!o)return;const i=[];for(let r=s.y;r<=o.y;r++)for(let l=s.x;l<=o.x;l++){const a=Wt(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},Kd="tableComponent",Jd=function(n,e={}){const t={block:{},...e},{Components:s}=n,o={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};s.addType(Oe,{block:t.block&&{label:"Table",media:z.table,category:"Extra",content:{type:Oe,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:Ad(ko,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[..._l({editor:l,component:a,opts:t}),...r]}}}),s.addType(Hl,{model:{defaults:{icon:z.tableHead,...o}}}),s.addType($l,{model:{defaults:{icon:z.tableFoot,...o}}}),s.addType(ko,{model:{defaults:{icon:z.tableRowProperties,...o}}}),s.addType(de,{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})=>[...Yl({editor:l,component:a,opts:t}),...r]}}}),s.addType($,{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})=>[...Gd({editor:l,component:a,opts:t}),...r]}}});const i=ai((r,l)=>{var h;const a=n.getSelectedAll(),c=!!((h=l==null?void 0:l.event)!=null&&h.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(u=>u.is($)?u:u.closestType($)).filter(Boolean);d.length===a.length&&jd(d)},0);n.on("component:select",i),re({editor:n,plan:W.startup,licenseKey:t.licenseKey,pluginName:Kd,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(Oe),Td.forEach(r=>s.removeType(r))}})},Ud=ie(Jd),Fi="page://",ct="list-pages",Rt="list-pages-item",dt="list-pages-link",Zd=n=>n.components().reduce((e,t)=>{var r;const s=t.findFirstType(dt),o=(r=s==null?void 0:s.attributes.attributes)==null?void 0:r.href,i=o!=null&&o.startsWith(Fi)?o.replace(Fi,""):"";if(i&&s){const l=e[i];l?l.push(s):e[i]=[s]}return e},{}),Yd="listPagesComponent",as="data-type-role",Xd="page_root",Qd=n=>e=>e.is(n),eh=n=>(e,t)=>t.is(n),Ys=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,as))===n},th=function(n,e={}){const{Blocks:t,Components:s,Pages:o}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Fe}${ct}`,h=`${Fe}${dt}`,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>';s.addType(ct,{block:r&&{label:l,media:u,category:"Extra",select:!0,...e.block},isComponent:Ys(ct),model:{defaults:{tagName:"ul",name:l,[Xd]:"",classes:d,attributes:{[as]:ct,role:"navigation"},droppable:Qd(Rt),styles:`
|
|
61
|
+
</svg>`,$l="layout-icon-picker",Cd="icons-layout-",Fl="icons-list-layout",Wl="gs-iconify-picker",ui="__iconify_collection",xd="https://api.iconify.design",Xs=new Map;let Kn;const kd=({collectionId:n})=>`https://cdn.jsdelivr.net/npm/@iconify-json/${n}@latest/icons.json`;async function _l({collectionId:n,editor:e}){try{if(Xs.has(n))return Xs.get(n);const t=await fetch(kd({collectionId:n}));if(!t.ok)throw new Error(`Failed to fetch collection: ${t.statusText}`);const s=await t.json();return Xs.set(n,s),s}catch(t){console.error("Error fetching collection",t),e.runCommand(B.toastAdd,Id());return}}async function Td({collectionIds:n,editor:e}){try{if(Kn)return Kn;const t=n?`?prefixes=${n.join(",")}`:"",s=await fetch(`${xd}/collections${t}`);if(!s.ok)throw new Error(`Failed to fetch collections: ${s.statusText}`);return Kn=await s.json(),Kn}catch(t){console.error("Error fetching collections",t),e.runCommand(B.toastAdd,ql());return}}function $i(){return{type:"button",label:"Open Icon Picker",name:"onActive",changeProp:!0,command(n){var e;(e=n.getSelected())==null||e.trigger("active")}}}async function Md({collectionIds:n,editor:e,component:t}){const s=await Td({collectionIds:n,editor:e});if(!s)return;const o=({icon:a,collectionId:c,iconId:d})=>{t.components(a),t.set({collectionId:c,iconId:d})},i=Object.entries(s).map(([a,c])=>({id:a,...c})).sort((a,c)=>a.name.localeCompare(c.name)),r=t.get("collectionId")??i[0].id;e.runCommand(B.layoutToggle,{id:$l,placer:{type:"dialog",size:"l",title:"Select Icon"},header:!1,layout:{type:"column",style:{height:500,gap:10},children:[Od({collectionsList:i,collectionId:r,editor:e,handleClick:o}),{id:Fl,type:"column",grow:!0}]}});const l=await _l({collectionId:r,editor:e});l&&Ao({editor:e,collection:l,handleClick:o,collectionId:r})}function Ad({editor:n,collection:e}){n.em.set(ui,e)}function Ed(n){return n.em.get(ui)}function Ao(n){const{editor:e}=n,t={id:Cd,layout:Nd(n),header:!1,style:{height:"100%"},placer:{type:"static",layoutId:Fl}};e.runCommand(B.layoutRemove,{id:t.id,force:!0}),setTimeout(()=>e.runCommand(B.layoutAdd,t),10)}function Od(n){const{collectionsList:e,collectionId:t,editor:s,handleClick:o}=n,i=e.map(({id:r,name:l,total:a})=>({id:r,label:`${l} (${a})`})).sort((r,l)=>r.label.localeCompare(l.label));return{type:"column",style:{gap:10},className:`${Wl}__header`,children:[{type:"selectField",value:t,options:i,emptyState:"Select an icon collection",onChange:async({setState:r,value:l})=>{const a=await _l({collectionId:l,editor:s});a&&(r({value:l}),Ad({editor:s,collection:a}),Ao({editor:s,collection:a,handleClick:o,collectionId:l}))}},{type:"inputField",value:"",placeholder:"Search icons inside collection...",editorEvents:{[`change:${ui}`]:({setState:r})=>r({value:""})},onInput:({setState:r,value:l,editor:a})=>{const c=Ed(a);if(!c)return;const d=Object.fromEntries(Object.entries(c.icons).filter(([u])=>u.includes(l)));r({value:l}),Ao({editor:a,collection:c,handleClick:o,collectionId:l,collectionFiltered:{...c,icons:d}})}}]}}function Nd({collection:n,collectionFiltered:e,handleClick:t}){const{height:s=24,width:o=24,icons:i,prefix:r}=e||n,l=Object.entries(i).map(([a,{body:c}])=>({name:a,body:c}),{});return{type:"column",className:`${Wl}__content`,style:{height:"100%"},children:{type:"virtualList",items:l,itemLayout:({item:a})=>[{type:"custom",render:c=>{const{editor:d,addEl:u,removeEl:h}=c,f=document.createElementNS("http://www.w3.org/2000/svg","svg");f.setAttribute("xmlns","http://www.w3.org/2000/svg"),f.innerHTML=a.body,f.setAttribute("viewBox",`0 0 ${o} ${s}`);const{cssWidth:p,cssHeight:m}=Pd(o,s);f.style.cssText=`width: ${p}px; height: ${m}px; cursor: pointer;`,f.addEventListener("mouseover",()=>{f.style.border="2px solid currentColor",f.style.borderRadius="4px",f.style.padding="4px"}),f.addEventListener("mouseout",()=>{f.style.border="none"});const g=()=>{const b=f.cloneNode(!0);b.removeAttribute("style");const C=b.outerHTML;t({icon:C,collectionId:r,iconId:a.name}),d==null||d.runCommand(B.layoutRemove,{id:$l})};return f.addEventListener("click",g),u(f),()=>{f.removeEventListener("click",g),h(f)}}}]}}}function Pd(n,e){const t=n/e;let s=48,o=48;return t>1?o=48/t:t<1&&(s=48*t),{cssWidth:s,cssHeight:o}}function ql(){return{id:"toast-error-getCollections",header:"Error",content:"Error fetching collections",variant:zl.Error}}function Id(){return{...ql(),id:"toast-error-getCollection",content:"Error fetching collection"}}const Rd="iconifyComponent",Dd=function(n,e={}){var f;const{Components:t,Blocks:s}=n,{collections:o,extendIconComponent:i=!0,licenseKey:r,block:l={}}=e,a="icon",c="iconify",d="Iconify",u="data-type-iconify",h={events:()=>({dblclick:"onActive"}),onActive(){Md({collectionIds:o,editor:n,component:this.model})}};if(t.addType(c,{block:l&&{label:d,media:Ys,content:{type:c},category:"Extra",activate:!0,...l},isComponent:p=>as(p,u),model:{defaults:{name:d,icon:Ys,droppable:!1,attributes:{[u]:!0},resizable:Sd,components:Ys,style:{width:"50px",height:"50px"},traits:[$i()]},init(){this.listenTo(this.components(),"change add",this.disableLayers),this.disableLayers()},disableLayers(){this.components().forEach(p=>p.set({layerable:!1,locked:!0}))}},view:h}),i){const p=(f=t.getType(a))==null?void 0:f.model,[m,g,...b]=p.getDefaults().traits;t.addType(a,{model:{defaults:{traits:[m,g,$i(),...b]}},view:h})}te({editor:n,licenseKey:r,plan:F.startup,pluginName:Rd,cleanup:()=>{s.remove(c),t.removeType(c)}})},zd=ee(Dd);function hi(n,e,t){let s,o,i,r,l;const a=e===void 0?100:e;function c(){const u=Date.now()-r;u<a&&u>=0?s=setTimeout(c,a-u):(s=null,l=n.apply(i,o),i=o=null)}const d=function(){return i=this,o=arguments,r=Date.now(),s||(s=setTimeout(c,a)),l};return d.clear=function(){s&&(clearTimeout(s),s=null)},d.flush=function(){s&&(l=n.apply(i,o),i=o=null,clearTimeout(s),s=null)},d}var O=(n=>(n.table="table",n.tableSettings="tableSettings",n.tableDelete="tableDelete",n.tableHead="tableHead",n.tableFoot="tableFoot",n.tableCellItems="tableCellItems",n.tableCellProperties="tableCellProperties",n.tableCellMerge="tableCellMerge",n.tableCellSplit="tableCellSplit",n.tableRowItems="tableRowItems",n.tableRowInsertBefore="tableRowInsertBefore",n.tableRowInsertAfter="tableRowInsertAfter",n.tableRowDelete="tableRowDelete",n.tableRowProperties="tableRowProperties",n.tableRowCut="tableRowCut",n.tableRowCopy="tableRowCopy",n.tableRowPasteBefore="tableRowPasteBefore",n.tableRowPasteAfter="tableRowPasteAfter",n.tableColumn="tableColumn",n.tableColumnItems="tableColumnItems",n.tableColumnInsertBefore="tableColumnInsertBefore",n.tableColumnInsertAfter="tableColumnInsertAfter",n.tableColumnDelete="tableColumnDelete",n.tableColumnCut="tableColumnCut",n.tableColumnCopy="tableColumnCopy",n.tableColumnPasteBefore="tableColumnPasteBefore",n.tableColumnPasteAfter="tableColumnPasteAfter",n))(O||{});const 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>'},Oe="table",Gl="thead",jl="tfoot",Eo="tbody",de="row",W="cell",fi="clipboardTable",Ld=[Oe,Gl,jl,Eo,de,W],$s=n=>n.em.get(fi)||[],Vd=n=>n.every(e=>e.is(W)),pi=(n,e)=>{const{editor:t,event:s,opts:o}=n,i=s.currentTarget||s.target,{x:r,y:l,width:a,height:c}=i.getBoundingClientRect(),d={style:{width:240,height:300},placer:{type:"popover",closeOnClickAway:!0,x:r,y:l,w:a,h:c},layout:{type:"tabs",value:"props",tabs:[{id:"styles",label:"Styles",children:{type:"panelStyles"}},{id:"props",label:"Properties",children:{type:"panelProperties",style:{padding:"14px 7px"}}}]},...e};Hs(o.openSettings)?o.openSettings({...n,layoutProps:d}):t.runCommand(B.layoutToggle,d)},Bd=(n,{rows:e=1,cells:t=5,text:s}={})=>({type:n,components:Array.from(Array(e).keys()).map(o=>({type:de,components:Array.from(Array(t).keys()).map(i=>({type:W,components:s?{type:"text",content:Hs(s)?s({y:o,x:i}):s}:void 0}))}))}),Kl="Table settings",Jl=n=>{const{component:e}=n;return e.is(Oe)?e:e.closestType(Oe)},Hd=n=>{var e;(e=Jl(n))==null||e.remove(n.opts)},$d=n=>{const e=Jl(n);e&&(n.editor.select(e),pi(n,{id:"tableSettings",header:{label:Kl}}))},Ul=n=>[{id:O.table,icon:z[O.table],label:"Table",items:[{id:O.tableSettings,label:Kl,icon:z[O.tableSettings],onClick:({event:t})=>$d({...n,event:t})},{id:O.tableDelete,label:"Delete table",icon:z[O.tableDelete],onClick:()=>Hd(n)}]}],Zl=({editor:n})=>{const e=$s(n);return e.length&&Vd(e)},Fi=({component:n,editor:e,after:t})=>{if(!n.is(W))return;const s=n.closestType(Oe),o=n.closestType(de),i=n.index()+(t?1:0);s==null||s.findType(de).forEach(l=>l.append({type:W},{at:i}));const r=o==null?void 0:o.components().at(i);r&&e.select(r)},Yl=({component:n,opts:e})=>{if(!n.is(W))return;const t=n.closestType(Oe),s=n.index();t==null||t.findType(de).forEach(o=>{var i;return(i=o.components().at(s))==null?void 0:i.remove(e)})},Xl=({component:n,editor:e})=>{if(!n.is(W))return;const t=n.closestType(Oe),s=n.index(),o=(t==null?void 0:t.findType(de).map(i=>i.components().at(s)))||[];o.length&&e.em.set(fi,o)},Wi=n=>{const{component:e,editor:t,after:s}=n;if(!e.is(W)||!Zl(n))return;const o=$s(t),i=e.closestType(Oe),r=e.index()+(s?1:0);i==null||i.findType(de).forEach((l,a)=>{const c=o[a],d=(c==null?void 0:c.clone())||{type:W};l.append(d,{at:r})})},Fd=n=>{const{component:e}=n;e.is(W)&&(Xl(n),Yl({...n,opts:{temporary:!0}}))},Wd=n=>{const e=Zl(n);return[{id:O.tableColumnItems,icon:z[O.tableColumn],label:"Column",items:[{id:O.tableColumnInsertBefore,label:"Insert column before",icon:z[O.tableColumnInsertBefore],onClick:()=>Fi(n)},{id:O.tableColumnInsertAfter,label:"Insert column after",icon:z[O.tableColumnInsertAfter],onClick:()=>Fi({...n,after:!0})},{id:O.tableColumnDelete,label:"Delete column",icon:z[O.tableColumnDelete],onClick:()=>Yl(n)},{id:O.tableColumnCut,label:"Cut column",icon:z[O.tableColumnCut],onClick:()=>Fd(n)},{id:O.tableColumnCopy,label:"Copy column",icon:z[O.tableColumnCopy],onClick:()=>Xl(n)},{id:O.tableColumnPasteBefore,label:"Paste column before",icon:z[O.tableColumnPasteBefore],disabled:!e,onClick:()=>Wi(n)},{id:O.tableColumnPasteAfter,label:"Paste column after",icon:z[O.tableColumnPasteAfter],disabled:!e,onClick:()=>Wi({...n,after:!0})}]}]},Ql="Row settings",_d=n=>n.every(e=>e.is(de)),an=n=>{const{component:e}=n,t=e.is(W),s=e.is(de);if(!(!t&&!s))return s?e:e.closestType(de)},_i=n=>{const{component:e,editor:t,after:s}=n,o=an(n);if(!o)return;const i=o.index()+(s?1:0),r=o.components().length,l=Array.from(Array(r).keys()).map(()=>({type:W})),a=o.parent();if(a){const c=a.append({type:de,components:l},{at:i})[0];if(e.is(W)&&c){const d=e.index(),u=c.components().at(d);u&&t.select(u)}}},ea=n=>{var e;(e=an(n))==null||e.remove(n.opts)},ta=n=>{const e=an(n);e&&n.editor.em.set(fi,[e])},qi=n=>{var l;const{editor:e,after:t}=n,s=an(n);if(!s||!na(n))return;const i=$s(e)[0],r=s.index()+(t?1:0);i&&((l=s.parent())==null||l.append(i.clone(),{at:r}))},qd=n=>{an(n)&&(ta(n),ea({...n,opts:{temporary:!0}}))},na=({editor:n})=>{const e=$s(n);return e.length&&_d(e)},Gd=n=>{const e=an(n);e&&(n.editor.select(e),pi(n,{id:"tableRowSettings",header:{label:Ql}}))},sa=n=>{const e=na(n);return[{id:O.tableRowItems,icon:z[O.tableRowProperties],label:"Row",items:[{id:O.tableRowInsertBefore,label:"Insert row before",icon:z[O.tableRowInsertBefore],onClick:()=>_i(n)},{id:O.tableRowInsertAfter,label:"Insert row after",icon:z[O.tableRowInsertAfter],onClick:()=>_i({...n,after:!0})},{id:O.tableRowDelete,label:"Delete row",icon:z[O.tableRowDelete],onClick:()=>ea(n)},{id:O.tableRowProperties,label:Ql,icon:z[O.tableRowProperties],onClick:({event:s})=>Gd({...n,event:s})},{id:O.tableRowCut,label:"Cut row",icon:z[O.tableRowCut],onClick:()=>qd(n)},{id:O.tableRowCopy,label:"Copy row",icon:z[O.tableRowCopy],onClick:()=>ta(n)},{id:O.tableRowPasteBefore,label:"Paste row before",icon:z[O.tableRowPasteBefore],disabled:!e,onClick:()=>qi(n)},{id:O.tableRowPasteAfter,label:"Paste row after",icon:z[O.tableRowPasteAfter],disabled:!e,onClick:()=>qi({...n,after:!0})}]},...Ul(n)]},mi=n=>{const e=n.attributes.attributes||{},t=parseInt(`${e.rowspan||1}`,10),s=parseInt(`${e.colspan||1}`,10);return{rowspan:t,colspan:s}};function oa(n){const e=[];return n.components().forEach((t,s)=>{t.components().each((o,i)=>{const{rowspan:r,colspan:l}=mi(o);if(e[s])for(;e[s][i];)i++;for(let a=s;a<s+r;a++){e[a]||(e[a]=[]);for(let c=i;c<i+l;c++)e[a][c]={real:a===s&&c===i,cell:o,rowspan:r,colspan:l}}})}),e}function _t(n,e,t){var s;return(s=n[t])==null?void 0:s[e]}const Oo=n=>n.closestType(de);function jd(n,{x:e,y:t,rows:s,cols:o}){var l;let i=Oo(n[t][e].cell),r;for(let a=1;a<=s;a++)if(i=(l=i==null?void 0:i.parent())==null?void 0:l.components().at(i.index()+1),i){for(r=e;r>=0;r--){const{cell:c}=n[t+a][r],d=Oo(c);if(d===i){for(let u=1;u<=o;u++){const h=c.index();d.append({type:W},{at:h+1})}break}}if(r===-1){const d=i.components().at(0).index();for(let u=1;u<=o;u++)i.append({type:W},{at:d})}}}function ia(n){for(let e=0;e<n.length;e++)for(let t=0;t<n[e].length;t++){const o=n[e][t].cell;if(o.em.selected.hasComponent(o)){const{rowspan:i,colspan:r}=mi(o);if(r>1||i>1){o.addAttributes({colspan:1,rowspan:1});for(let l=0;l<r-1;l++){const a=o.index();Oo(o).append({type:W},{at:a+1})}jd(n,{x:t,y:e,rows:i-1,cols:r})}}}}function Kd(n){const e=[];n.components().forEach(t=>{t.components().length||e.push(t)}),e.forEach(t=>t.remove())}const Fs=(n,e={})=>{var r;const t=oa(n),{em:s}=n;let o,i;for(let l=0;l<t.length;l++)for(let a=0;a<t[l].length;a++){const c=t[l][a];if((r=e.selected)!=null&&r.includes(c.cell)||s.selected.hasComponent(c.cell)){const d={x:a,y:l};o||(o=d),i=d}}return{grid:t,startPos:o,endPos:i}};function Jd(n,e={}){const t=Fs(n),{startPos:s,endPos:o}=t;let{grid:i}=t;const{em:r}=n;if(!s||!o)return;const l=s.x,a=s.y,c=o.x,d=o.y,u=_t(i,l,a),h=_t(i,c,d);if(u&&h){ia(i),i=oa(n);const f=[],p=_t(i,l,a).cell;p.addAttributes({colspan:c-l+1,rowspan:d-a+1});for(let m=a;m<=d;m++)for(let g=l;g<=c;g++){const b=_t(i,g,m);if(!b)continue;const{cell:C}=b;C!==p&&f.push(C)}f.forEach(m=>{e.mergeContent&&p.append(m.components().models),m.remove()}),r.setSelected(p),Kd(n)}}const ra="Cell settings",Ud="Merge cells",Zd="Split cell",Yd=n=>n.closestType(de),Qt=n=>{var e;return(e=Yd(n))==null?void 0:e.parent()},Xd=n=>{const e=n.editor.getSelectedAll(),t=Qt(e[0]),s=e[0];if(!t||!(s!=null&&s.is(W))||e.length>1)return!1;const{rowspan:o,colspan:i}=mi(s);return!(i<2&&o<2)},Qd=n=>{const t=n.editor.getSelectedAll()[0],s=Qt(t),{grid:o}=Fs(s);ia(o)},la=n=>{const e=n.editor.getSelectedAll(),t=Qt(e[0]);if(!t||e.length<2||e.some(l=>!l.is(W)||Qt(l)!==t))return!1;const{grid:s,startPos:o,endPos:i}=Fs(t),{em:r}=t;if(!o||!i)return!1;for(let l=o.y;l<=i.y;l++)for(let a=o.x;a<=i.x;a++){const c=_t(s,a,l);if(!c||!r.selected.hasComponent(c.cell))return!1}return!0},eu=n=>{const{editor:e}=n;if(!la(n))return;const t=e.getSelectedAll(),s=Qt(t[0]);Jd(s,{mergeContent:!0})},tu=n=>{pi(n,{id:"tableCellSettings",header:{label:ra}})},nu=n=>[{id:O.tableCellItems,icon:z[O.tableCellProperties],label:"Cell",items:[{id:O.tableCellProperties,label:ra,icon:z[O.tableCellProperties],onClick:({event:t})=>tu({...n,event:t})},{id:O.tableCellMerge,label:Ud,icon:z[O.tableCellMerge],onClick:()=>eu(n),disabled:!la(n)},{id:O.tableCellSplit,label:Zd,icon:z[O.tableCellSplit],onClick:()=>Qd(n),disabled:!Xd(n)}]},...Wd(n),...sa(n)],su=n=>{const e=n[0]&&Qt(n[0]);if(!e)return;const{grid:t,startPos:s,endPos:o}=Fs(e,{selected:n});if(!s||!o)return;const i=[];for(let r=s.y;r<=o.y;r++)for(let l=s.x;l<=o.x;l++){const a=_t(t,l,r);a&&i.push(a.cell)}i.length&&e.em.setSelected(i,{fromCell:!0})},ou="tableComponent",iu=function(n,e={}){const t={block:{},...e},{Components:s}=n,o={copyable:!1,emptyState:!0,highlightable:!1,stylable:["color","font-family","font-size","font-weight","line-height","text-align","vertical-align","background-color","border-width","border-style","border-color"]};s.addType(Oe,{block:t.block&&{label:"Table",media:z.table,category:"Extra",content:{type:Oe,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:Bd(Eo,{rows:5}),contextMenu:({items:r,editor:l,component:a})=>[...Ul({editor:l,component:a,opts:t}),...r]}}}),s.addType(Gl,{model:{defaults:{icon:z.tableHead,...o}}}),s.addType(jl,{model:{defaults:{icon:z.tableFoot,...o}}}),s.addType(Eo,{model:{defaults:{icon:z.tableRowProperties,...o}}}),s.addType(de,{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})=>[...sa({editor:l,component:a,opts:t}),...r]}}}),s.addType(W,{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})=>[...nu({editor:l,component:a,opts:t}),...r]}}});const i=hi((r,l)=>{var u;const a=n.getSelectedAll(),c=!!((u=l==null?void 0:l.event)!=null&&u.shiftKey);if(a.length<2||!c||l.fromCell)return;const d=a.map(h=>h.is(W)?h:h.closestType(W)).filter(Boolean);d.length===a.length&&su(d)},0);n.on("component:select",i),te({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:ou,cleanup:()=>{n.off("component:select",i),n.Blocks.remove(Oe),Ld.forEach(r=>s.removeType(r))}})},ru=ee(iu),Gi="page://",dt="list-pages",Dt="list-pages-item",ut="list-pages-link",lu=n=>n.components().reduce((e,t)=>{var r;const s=t.findFirstType(ut),o=(r=s==null?void 0:s.attributes.attributes)==null?void 0:r.href,i=o!=null&&o.startsWith(Gi)?o.replace(Gi,""):"";if(i&&s){const l=e[i];l?l.push(s):e[i]=[s]}return e},{}),au="listPagesComponent",cs="data-type-role",cu="page_root",du=n=>e=>e.is(n),uu=n=>(e,t)=>t.is(n),Qs=n=>e=>{var t;return((t=e.getAttribute)==null?void 0:t.call(e,cs))===n},hu=function(n,e={}){const{Blocks:t,Components:s,Pages:o}=n,{licenseKey:i,block:r={}}=e,l="List Pages",a="List Pages Item",c="Link",d=`${Fe}${dt}`,u=`${Fe}${ut}`,h='<svg viewBox="0 0 24 24"><path d="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z"/></svg>',f='<svg viewBox="0 0 24 24"><path d="M7,5H21V7H7V5M7,13V11H21V13H7M4,4.5A1.5,1.5 0 0,1 5.5,6A1.5,1.5 0 0,1 4,7.5A1.5,1.5 0 0,1 2.5,6A1.5,1.5 0 0,1 4,4.5M4,10.5A1.5,1.5 0 0,1 5.5,12A1.5,1.5 0 0,1 4,13.5A1.5,1.5 0 0,1 2.5,12A1.5,1.5 0 0,1 4,10.5M7,19V17H21V19H7M4,16.5A1.5,1.5 0 0,1 5.5,18A1.5,1.5 0 0,1 4,19.5A1.5,1.5 0 0,1 2.5,18A1.5,1.5 0 0,1 4,16.5Z" /></svg>';s.addType(dt,{block:r&&{label:l,media:h,category:"Extra",select:!0,...e.block},isComponent:Qs(dt),model:{defaults:{tagName:"ul",name:l,[cu]:"",classes:d,attributes:{[cs]:dt,role:"navigation"},droppable:du(Dt),styles:`
|
|
62
62
|
.${d} {
|
|
63
63
|
list-style: none;
|
|
64
64
|
margin: 0;
|
|
65
65
|
padding: 0;
|
|
66
66
|
}
|
|
67
|
-
`},init(){this.syncPageItems=
|
|
68
|
-
.${
|
|
67
|
+
`},init(){this.syncPageItems=hi(this.syncPageItems.bind(this),0),this.listenTo(this.em,o.events.all,this.syncPageItems),this.syncPageItems()},syncPageItems(){if(n.Components.getSymbolInfo(this).isInstance)return;const p=this.em.Pages.getAll(),m=this.components(),g=lu(this);p.forEach((b,C)=>{const y=b.id,v=b.getName(),w=g[y];w?w==null||w.forEach(S=>{S.getInnerHTML()!==v&&S.components(v)}):m.add({type:Dt,components:[{type:ut,attributes:{href:`page://${y}`},components:{type:"textnode",content:v}}]},{at:C})})}}}),s.addType(Dt,{isComponent:Qs(Dt),model:{defaults:{name:a,tagName:"li",icon:f,attributes:{[cs]:Dt},components:{type:ut},draggable:uu(dt)}}}),s.addType(ut,{extend:"link",isComponent:Qs(ut),model:{defaults:{removable:!1,copyable:!1,delegate:{move:p=>p.closestType(Dt)},name:c,classes:u,attributes:{[cs]:ut},components:{type:"textnode",content:"Item"},styles:`
|
|
68
|
+
.${u} {
|
|
69
69
|
text-decoration: none;
|
|
70
70
|
}
|
|
71
|
-
`}}}),
|
|
71
|
+
`}}}),te({editor:n,licenseKey:i,plan:F.startup,pluginName:au,cleanup:()=>{t.remove(dt),s.removeType(dt)}})},fu=ee(hu),pu="fsLightboxComponent",Jn="data-fslightbox",Un="data-type",mu="fslightbox-open",zt="fslightbox",Lt={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>'},gu=function(n,e={}){const{Blocks:t,Components:s}=n,o="Lightbox",i=`${Fe}${zt}`,r={toolbarIconOpen:Lt.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(C){const y=this,v="data-fslightbox",w=window,S=()=>{var A;const x=w.refreshFsLightbox;x==null||x();const E=y.getAttribute(v);if((A=w.fsLightboxInstances)==null||A[E],!w._isEditor)return;Array.from(document.querySelectorAll(`[${v}]`)).forEach(P=>{const D=P.onclick;P.onclick=function(L){L.preventDefault();const H=P;!H.__skipLb&&(D==null||D(L)),H.__skipLb=!0}})};if(w.refreshFsLightbox)S();else{const x=document.createElement("script");x.src=C.cdnScript,x.onload=S,document.head.appendChild(x)}},u=C=>({id:`${zt}-open-lb`,label:a,command:()=>{const y=C.getView();y==null||y.toggleLightbox()}}),h="source-type",f={type:"radio",name:h,label:"Source type",changeProp:!0,options:[{id:"image",label:"Image",icon:Lt.image},{id:"video",label:"Video",icon:Lt.video},{id:"el",label:"Custom Element",icon:Lt.external}],labelToTitle:!0},p={id:"href-image",name:"href",type:"file",label:"Source Image"},m={id:"href-video",name:"href",label:"Source Video",placeholder:"https://www.youtube.com/watch?v=..."},g={id:"href-el",name:"href",label:"Source Element",placeholder:"#custom-element-id"},b={image:[p],video:[m],el:[g]};s.addType(zt,{block:l&&{label:o,media:Lt.imageLightbox,category:"Extra",select:!0,...r.block},isComponent:C=>{var y;return(y=C.hasAttribute)==null?void 0:y.call(C,Jn)},extendFn:["initToolbar"],model:{defaults:{tagName:"a",name:o,icon:Lt.imageLightbox,classes:i,draggable:(C,y)=>!y.is(zt),attributes:{[Jn]:"lightbox",[Un]:"image",href:c},components:{type:"image",src:c},script:d,cdnScript:r.cdnScript,"script-props":["attributes","cdnScript"],[h]:"image",traits:[f,{name:Jn,label:"Group name"},{type:"button",label:"Toggle Lightbox",command(C,y){var w;const v=(w=y.target)==null?void 0:w.getView();v==null||v.toggleLightbox()}}],styles:`
|
|
72
72
|
.${i} {
|
|
73
73
|
display: inline-block;
|
|
74
74
|
padding: 10px;
|
|
75
75
|
}
|
|
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 S=this.get(u)==="video"?"video":"image";this.addAttributes({[Jn]:S,href:""})},adjustSourceType(){const C=this.get(u),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[Jn]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(u,"el",v):C==="image"&&this.addAttributes({[Jn]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[f.name]||v){this.removeTrait([p.name,m.name,g.name]);const w=this.get(u)||"image",S=this.getTraitIndex(u)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=h(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[Kn],{defaultView:x,documentElement:E}=y.ownerDocument,T=(P=x.fsLightboxInstances)==null?void 0:P[S];if(E.classList.contains(oh))T.close();else{y.__skipLb=!1;let D;T.props.onOpen=()=>{D=w.getSpots(),setTimeout(()=>w.removeSpots())},T.props.onClose=()=>{D.forEach(V=>w.addSpot(V.attributes))},y.click()}}}}),re({editor:n,plan:W.startup,licenseKey:r.licenseKey,pluginName:sh,cleanup:()=>{t.remove(Dt),s.removeType(Dt)}})},rh=ie(ih);var Ht=(n=>(n.image="image",n.video="video",n.external="external",n))(Ht||{});const ht="lightGallery",Wi=`${ht}-item`,cs="data-lightgallery",_i=`${cs}-item`,ms="toggle",pt={image:'<svg viewBox="0 0 24 24"><path d="m8.5 13.5 2.5 3 3.5-4.5 4.5 6H5m16 1V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2Z"/></svg>',video:'<svg viewBox="0 0 24 24"><path d="M17 10.5V7a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-3.5l4 4v-11l-4 4Z"/></svg>',gallery:'<svg viewBox="0 0 24 24"><path d="M4,2H20A2,2 0 0,1 22,4V16A2,2 0 0,1 20,18H16L12,22L8,18H4A2,2 0 0,1 2,16V4A2,2 0 0,1 4,2M19,15V7L15,11L13,9L7,15H19M7,5A2,2 0 0,0 5,7A2,2 0 0,0 7,9A2,2 0 0,0 9,7A2,2 0 0,0 7,5Z" /></svg>',galleryItem:'<svg viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M8 14H6v-2h2v2m0-3H6V9h2v2m0-3H6V6h2v2m7 6h-5v-2h5v2m3-3h-8V9h8v2m0-3h-8V6h8v2Z"/></svg>',external:'<svg viewBox="0 0 24 24"><path d="M14 3v2h3.6l-9.8 9.8 1.4 1.4L19 6.4V10h2V3m-2 16H5V5h7V3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2v-7h-2v7z"/></svg>',eye:'<svg viewBox="0 0 24 24"><path d="M12 9a3 3 0 0 0-3 3 3 3 0 0 0 3 3 3 3 0 0 0 3-3 3 3 0 0 0-3-3m0 8a5 5 0 0 1-5-5 5 5 0 0 1 5-5 5 5 0 0 1 5 5 5 5 0 0 1-5 5m0-12.5C7 4.5 2.7 7.6 1 12a11.8 11.8 0 0 0 22 0c-1.7-4.4-6-7.5-11-7.5Z"/></svg>'},Xs={propKeys:[],props:{},traits:[]},cn=(n,e={})=>{var o;const t={},s=[];for(const i in n){const{value:r,...l}=n[i];s.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const h=d.id||d.name;t[h]=d.value})}return{propKeys:Object.keys(t),props:t,traits:s}},Mo=(n,e)=>{const t=n.getTrait(e),s=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:s,...c})),{at:a})},Qs=(n,e)=>{e.forEach(t=>{const s=n.getTrait(t);if(!s||!s.get("subTraits"))return;const o=s.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>Mo(n,t)),Mo(n,t)})},lh=(n,e,t)=>{const o=n.getTrait(e).get("subTraits")||{},r=(Object.values(o).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},ah={[ms]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,s;return(s=(t=e.target)==null?void 0:t.getView())==null?void 0:s.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},ch={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"}]}}},dh={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}]}}},hh={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},qe="sourceType",Un="data-iframe",Ao={name:"href",type:"file",label:"Image Source"},gs={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Eo={name:"data-poster",label:"Video Poster",type:"file"},qi={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},na={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},uh={[ms]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,i;const t=e.target,s=(o=t==null?void 0:t.closestType(ht))==null?void 0:o.getView();if(s&&t){const r=((i=s.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&s.toggleGallery(l)}}},[qe]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Ao],video:[gs,Eo],external:[qi]},options:[{id:"image",label:Ao.label||"",icon:pt.image},{id:"video",label:gs.label||"",icon:pt.video},{id:"external",label:qi.label||"",icon:pt.external}]},subHtml:na},fh="lightGalleryComponent",Gi="lgThumbnail",ph="lgVideo",ji="lgAutoplay",Ki="lgZoom",Vt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",mh=function(n,e={}){const{Blocks:t,Components:s}=n,o="LightGallery",i="LightGallery Item",r={toolbarIconOpen:pt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Gi,ph,ji,Ki],cdnScript:[`${Vt}/lightgallery.min.js`,`${Vt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Vt}/plugins/video/lg-video.min.js`,`${Vt}/plugins/autoplay/lg-autoplay.min.js`,`${Vt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Vt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:E,inline:T,lgLicenseKey:A,...P}=y||{},D=B=>isNaN(B)?void 0:parseInt(B,10),V=()=>{var ve;const B={...P,licenseKey:A,speed:D(P.speed),startAnimationDuration:D(P.startAnimationDuration),thumbMargin:D(P.thumbMargin),thumbWidth:D(P.thumbWidth),slideShowInterval:D(P.slideShowInterval),scale:D(P.scale),enableZoomAfter:D(P.enableZoomAfter),plugins:(S||[]).map(at=>w[at])};T&&(B.container=v,B.closable=!1);const be=(ve=w.lightGallery)==null?void 0:ve.call(w,v,B);T&&be.openGallery()};if(w.lightGallery)V();else{const{head:B}=document,be=Array.isArray(x)?[...x]:[x],ve=Array.isArray(E)?[...E]:[E],at=Me=>{if(Me.length){const _e=document.createElement("link");_e.href=Me.shift(),_e.rel="stylesheet",B.appendChild(_e),at(Me)}},we=Me=>{if(Me.length){const _e=document.createElement("script");_e.src=Me.shift(),_e.onerror=_e.onload=we.bind(null,Me),B.appendChild(_e)}else V()};at(ve),we(be)}},h=y=>{const v=y.getTrait(ms);if(!a||!v)return;const{toolbar:w}=y,S={id:ms,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(E=>E.id===S.id)&&(w==null||w.unshift(S))};let u=[];const f=r.plugins||[],p=cn(ah),m=f.includes(Gi)?cn(ch):Xs,g=f.includes(ji)?cn(dh):Xs,b=f.includes(Ki)?cn(hh):Xs;s.addType(ht,{block:l&&{label:o,media:pt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>ls(y,cs),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:pt.gallery,draggable:(y,v)=>!v.is(ht),attributes:{[cs]:!0},components:{type:Wi},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...p.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...p.props,...m.props,...g.props,...b.props,traits:[...p.traits,...m.traits,...g.traits,...b.traits]},init(){Qs(this,["thumbnail"]),Qs(this,["autoplay"]),Qs(this,["zoom"])},initToolbar(){h(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,s.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var 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,w=this.getLightGallery();u=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__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=cn(uh);s.addType(Wi,{isComponent:y=>ls(y,_i)||y.tagName==="A"&&ls(y.parentElement,cs),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:pt.galleryItem,attributes:{[_i]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[qe].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),lh(this,qe,this.triggerGalleryUpdate)},initToolbar(){h(this)},initScriptUpdate(){const y=[na.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(ht))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[qe]||w){Mo(this,qe);const S=this.getTrait(qe).getValue();if(S===Ht.image){this.removeAttributes([gs.name,Eo.name,Un]);const x=this.getTrait(Ao.name);x.setValue(x.getValue()||c)}else S===Ht.video?this.removeAttributes([Un]):S===Ht.external&&this.addAttributes({[Un]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[Un]?this.set(qe,Ht.external):(y[gs.name]||y[Eo.name])&&this.set(qe,Ht.video)}}}),re({editor:n,plan:W.startup,licenseKey:r.licenseKey,pluginName:fh,cleanup:()=>{t.remove(ht),s.removeType(ht)}})},gh=ie(mh),ke="swiper",Nn=`${ke}-slide`,Gt=`${ke}-wrapper`,jt=`${ke}-nav-prev`,ys=`${ke}-nav-next`,Kt=`${ke}-pagination`,vn=`${ke}-scrollbar`,te={slider:`<svg viewBox="0 0 24 24">
|
|
76
|
+
`},init(){const C=[h].map(y=>`change:${y}`).join(" ");this.on(C,this.updateTraits),this.on(`change:${h}`,this.onSourceTypeChange),this.on("change:attributes:href",this.adjustSourceType),this.updateTraits({init:!0}),this.adjustSourceType()},onSourceTypeChange(C,y,v){if(v.adjust)return;const S=this.get(h)==="video"?"video":"image";this.addAttributes({[Un]:S,href:""})},adjustSourceType(){const C=this.get(h),y=this.getAttributes().href||"",v={adjust:!0};if(C==="video"){const w=y.includes("youtube.com")?"youtube":"video";this.addAttributes({[Un]:w},v)}else C!=="el"&&y.startsWith("#")?this.set(h,"el",v):C==="image"&&this.addAttributes({[Un]:"image"},v)},updateTraits(C={}){const{changed:y}=this,{init:v}=C;if(y[f.name]||v){this.removeTrait([p.name,m.name,g.name]);const w=this.get(h)||"image",S=this.getTraitIndex(h)+1;this.addTrait(b[w],{at:S})}},initToolbar(){if(!a)return;const{toolbar:C}=this,y=u(this);!C.find(w=>w.id===y.id)&&(C==null||C.unshift(y))}},view:{onRender(){this.el.__skipLb=!0},toggleLightbox(){var P;const{em:C,el:y,model:v}=this,{Canvas:w}=C,S=v.getAttributes()[Jn],{defaultView:x,documentElement:E}=y.ownerDocument,T=(P=x.fsLightboxInstances)==null?void 0:P[S];if(E.classList.contains(mu))T.close();else{y.__skipLb=!1;let D;T.props.onOpen=()=>{D=w.getSpots(),setTimeout(()=>w.removeSpots())},T.props.onClose=()=>{D.forEach(L=>w.addSpot(L.attributes))},y.click()}}}}),te({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:pu,cleanup:()=>{t.remove(zt),s.removeType(zt)}})},yu=ee(gu);var $t=(n=>(n.image="image",n.video="video",n.external="external",n))($t||{});const ht="lightGallery",ji=`${ht}-item`,ds="data-lightgallery",Ki=`${ds}-item`,ys="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>'},eo={propKeys:[],props:{},traits:[]},dn=(n,e={})=>{var o;const t={},s=[];for(const i in n){const{value:r,...l}=n[i];s.push({id:i,name:i,changeProp:!0,category:e.category,...l}),t[i]=r;const{subTraits:a={}}=l;for(const c in l.subTraits)(o=a[c])==null||o.forEach(d=>{const u=d.id||d.name;t[u]=d.value})}return{propKeys:Object.keys(t),props:t,traits:s}},No=(n,e)=>{const t=n.getTrait(e),s=t.get("category"),o=t.get("subTraits")||{},r=(Object.values(o).flat()||[]).map(c=>c.id||c.name);n.removeTrait(r);const l=o[t.getValue()],a=n.getTraitIndex(e)+1;l&&n.addTrait(l.map(c=>({category:s,...c})),{at:a})},to=(n,e)=>{e.forEach(t=>{const s=n.getTrait(t);if(!s||!s.get("subTraits"))return;const o=s.changeProp?`change:${t}`:`change:attributes:${t}`;n.on(o,()=>No(n,t)),No(n,t)})},bu=(n,e,t)=>{const o=n.getTrait(e).get("subTraits")||{},r=(Object.values(o).flat()||[]).map(a=>{const c=a.name||a.id;return a.changeProp?`change:${c}`:`change:attributes:${c}`}),l=Array.from(new Set(r));l.length&&n.on(l.join(" "),t)},vu={[ys]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var t,s;return(s=(t=e.target)==null?void 0:t.getView())==null?void 0:s.toggleGallery()}},speed:{type:"number",label:"Speed",tip:"Transition duration between slides (in ms)",value:400,step:50,min:0},inline:{type:"checkbox",label:"Inline Gallery",value:!1},allowMediaOverlap:{type:"checkbox",label:"Allow media overlap",tip:"If enabled, toolbar, captions and thumbnails will overlap with the media element",value:!1},controls:{type:"checkbox",label:"Show controls",tip:"If disabled, prev/next buttons will not be displayed",value:!0},counter:{type:"checkbox",label:"Show counter",tip:"Display the total number of images and index number of the currently displayed slide",value:!0},download:{type:"checkbox",label:"Download icon",tip:"Enable download button",value:!0},enableDrag:{type:"checkbox",label:"Enable drag",tip:"Enables desktop mouse drag support",value:!0},enableSwipe:{type:"checkbox",label:"Enable swipe",tip:"Enables swipe support for mobile devices",value:!0},escKey:{type:"checkbox",label:"Enable Esc key",tip:'Whether the gallery could be closed by pressing the "Esc" key',value:!0},keyPress:{type:"checkbox",label:"Enable keyboard navigation",value:!1},loop:{type:"checkbox",label:"Loop",tip:"If false, will disable the ability to loop back to the beginning of the gallery from the last slide",value:!0},getCaptionFromTitleOrAlt:{type:"checkbox",label:"Caption from title or alt",tip:"Get captions from alt or title tags",value:!0},showMaximizeIcon:{type:"checkbox",label:"Show maximize icon",value:!1},closable:{type:"checkbox",label:"Closable",tip:"If false, it won't be possible to close the gallery",value:!0},showCloseIcon:{type:"checkbox",label:"Show close icon",tip:"If false, close button won't be displayed.",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0},closeOnTap:{type:"checkbox",label:"Close on tap",tip:"Allows clicks on black area to close gallery",visible:({component:n})=>!!n.getTrait("closable").getValue(),value:!0}},wu={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"}]}}},Su={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}]}}},Cu={zoom:{category:{id:"zoom-options",label:"Zoom options"},type:"checkbox",label:"Zoom",value:!0,subTraits:{false:[],true:[{type:"checkbox",name:"actualSize",label:"Show actual size icon",changeProp:!0,value:!0},{type:"checkbox",name:"infiniteZoom",label:"Infinte zoom",changeProp:!0,value:!0},{type:"checkbox",name:"showZoomInOutIcons",label:"Show zoom in/out icons",changeProp:!0,value:!1},{type:"number",name:"scale",label:"Scale",tip:"Value of zoom should be incremented/decremented",changeProp:!0,min:0,value:1}]}}},qe="sourceType",Zn="data-iframe",Po={name:"href",type:"file",label:"Image Source"},bs={name:"data-src",label:"Video Source",placeholder:"https://www.youtube.com/watch?v=..."},Io={name:"data-poster",label:"Video Poster",type:"file"},Ji={name:"data-src",label:"External Source",placeholder:"https://some-external-source.com/...."},aa={label:"Caption",name:"data-sub-html",placeholder:"My caption",changeProp:!1},xu={[ys]:{type:"button",label:"Toggle Gallery",command:(n,e)=>{var o,i;const t=e.target,s=(o=t==null?void 0:t.closestType(ht))==null?void 0:o.getView();if(s&&t){const r=((i=s.getLightGallery())==null?void 0:i.items)||[],l=Array.from(r).indexOf(t.getEl());l>=0&&s.toggleGallery(l)}}},[qe]:{type:"radio",label:"Source type",labelToTitle:!0,value:"image",subTraits:{image:[Po],video:[bs,Io],external:[Ji]},options:[{id:"image",label:Po.label||"",icon:mt.image},{id:"video",label:bs.label||"",icon:mt.video},{id:"external",label:Ji.label||"",icon:mt.external}]},subHtml:aa},ku="lightGalleryComponent",Ui="lgThumbnail",Tu="lgVideo",Zi="lgAutoplay",Yi="lgZoom",Vt="https://cdn.jsdelivr.net/npm/lightgallery@2.8.2",Mu=function(n,e={}){const{Blocks:t,Components:s}=n,o="LightGallery",i="LightGallery Item",r={toolbarIconOpen:mt.eye,block:{},lgLicenseKey:"92DE1DB8-7986-4F02-B908-514F97678D28",defaultSrc:"https://placehold.co/200/777/white.png?text=Image",plugins:[Ui,Tu,Zi,Yi],cdnScript:[`${Vt}/lightgallery.min.js`,`${Vt}/plugins/thumbnail/lg-thumbnail.min.js`,`${Vt}/plugins/video/lg-video.min.js`,`${Vt}/plugins/autoplay/lg-autoplay.min.js`,`${Vt}/plugins/zoom/lg-zoom.min.js`],cdnStyle:`${Vt}/css/lightgallery-bundle.min.css`,...e},{block:l,toolbarIconOpen:a,defaultSrc:c}=r,d=function(y){const v=this,w=window,{plugins:S,cdnScript:x,cdnStyle:E,inline:T,lgLicenseKey:A,...P}=y||{},D=H=>isNaN(H)?void 0:parseInt(H,10),L=()=>{var ve;const H={...P,licenseKey:A,speed:D(P.speed),startAnimationDuration:D(P.startAnimationDuration),thumbMargin:D(P.thumbMargin),thumbWidth:D(P.thumbWidth),slideShowInterval:D(P.slideShowInterval),scale:D(P.scale),enableZoomAfter:D(P.enableZoomAfter),plugins:(S||[]).map(ct=>w[ct])};T&&(H.container=v,H.closable=!1);const be=(ve=w.lightGallery)==null?void 0:ve.call(w,v,H);T&&be.openGallery()};if(w.lightGallery)L();else{const{head:H}=document,be=Array.isArray(x)?[...x]:[x],ve=Array.isArray(E)?[...E]:[E],ct=Me=>{if(Me.length){const _e=document.createElement("link");_e.href=Me.shift(),_e.rel="stylesheet",H.appendChild(_e),ct(Me)}},we=Me=>{if(Me.length){const _e=document.createElement("script");_e.src=Me.shift(),_e.onerror=_e.onload=we.bind(null,Me),H.appendChild(_e)}else L()};ct(ve),we(be)}},u=y=>{const v=y.getTrait(ys);if(!a||!v)return;const{toolbar:w}=y,S={id:ys,label:a,command:()=>setTimeout(()=>v.runCommand(),100)};!w.find(E=>E.id===S.id)&&(w==null||w.unshift(S))};let h=[];const f=r.plugins||[],p=dn(vu),m=f.includes(Ui)?dn(wu):eo,g=f.includes(Zi)?dn(Su):eo,b=f.includes(Yi)?dn(Cu):eo;s.addType(ht,{block:l&&{label:o,media:mt.gallery,category:"Extra",select:!0,...r.block},isComponent:y=>as(y,ds),extendFn:["init","initToolbar"],model:{defaults:{name:o,icon:mt.gallery,draggable:(y,v)=>!v.is(ht),attributes:{[ds]:!0},components:{type:ji},script:d,selector:"",exThumbImage:"",cdnScript:r.cdnScript,cdnStyle:r.cdnStyle,plugins:r.plugins,lgLicenseKey:r.lgLicenseKey,"script-props":["lgLicenseKey","cdnScript","cdnStyle","plugins","selector","exThumbImage",...p.propKeys,...m.propKeys,...g.propKeys,...b.propKeys],...p.props,...m.props,...g.props,...b.props,traits:[...p.traits,...m.traits,...g.traits,...b.traits]},init(){to(this,["thumbnail"]),to(this,["autoplay"]),to(this,["zoom"])},initToolbar(){u(this)}},extendFnView:["init"],view:{events:()=>({lgInit:"onLgInit",lgBeforeOpen:"onLgOpen",lgAfterClose:"onLgClose"}),init(){this.listenTo(this.model,s.events.scriptUnmount,this.destroyLightGallery)},getLightGallery(){return this.el.__lg},destroyLightGallery(){const y=this.getLightGallery();y==null||y.destroy()},disableLgInCanvas(){const y=this.getLightGallery();y.lgOpened=!0},isInlineGallery(){var 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,w=this.getLightGallery();h=v.getSpots(),setTimeout(()=>v.removeSpots()),w.__lgOpened=!0},onLgClose(){const y=this.getLightGallery();h.forEach(v=>this.em.Canvas.addSpot(v.attributes)),h=[],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=dn(xu);s.addType(ji,{isComponent:y=>as(y,Ki)||y.tagName==="A"&&as(y.parentElement,ds),extendFn:["init","initToolbar"],model:{defaults:{tagName:"a",name:i,icon:mt.galleryItem,attributes:{[Ki]:!0,href:c},components:{type:"image",attributes:{alt:"Image",src:c}},...C.props,traits:[...C.traits]},init(){const y=[qe].map(v=>`change:${v}`).join(" ");this.initSourceType(),this.on(y,this.updateTraits),this.updateTraits({init:!0}),this.initScriptUpdate(),bu(this,qe,this.triggerGalleryUpdate)},initToolbar(){u(this)},initScriptUpdate(){const y=[aa.name].map(v=>`change:attributes:${v}`).join(" ");this.on(y,this.triggerGalleryUpdate)},triggerGalleryUpdate(...y){var v;(v=this.closestType(ht))==null||v.__scriptPropsChange(...y)},updateTraits(y={}){const{changed:v}=this,{init:w}=y;if(v[qe]||w){No(this,qe);const S=this.getTrait(qe).getValue();if(S===$t.image){this.removeAttributes([bs.name,Io.name,Zn]);const x=this.getTrait(Po.name);x.setValue(x.getValue()||c)}else S===$t.video?this.removeAttributes([Zn]):S===$t.external&&this.addAttributes({[Zn]:!0})}},initSourceType(){const y=this.getAttributes({noClass:!0,noStyle:!0});y[Zn]?this.set(qe,$t.external):(y[bs.name]||y[Io.name])&&this.set(qe,$t.video)}}}),te({editor:n,plan:F.startup,licenseKey:r.licenseKey,pluginName:ku,cleanup:()=>{t.remove(ht),s.removeType(ht)}})},Au=ee(Mu),ke="swiper",Pn=`${ke}-slide`,jt=`${ke}-wrapper`,Kt=`${ke}-nav-prev`,vs=`${ke}-nav-next`,Jt=`${ke}-pagination`,wn=`${ke}-scrollbar`,se={slider:`<svg viewBox="0 0 24 24">
|
|
77
77
|
<path d="M22 7.6c0-1-.5-1.6-1.3-1.6H3.4C2.5 6 2 6.7 2 7.6v9.8c0 1 .5 1.6 1.3 1.6h17.4c.8 0 1.3-.6 1.3-1.6V7.6zM21 18H3V7h18v11z" fill-rule="nonzero"/>
|
|
78
78
|
<path d="M4 12.5L6 14v-3zM20 12.5L18 14v-3z"/>
|
|
79
79
|
</svg>`,effect:`<svg viewBox="0 0 24 24">
|
|
@@ -96,28 +96,28 @@
|
|
|
96
96
|
<path d="M2 12c0 5 4 9 9 9 2.4 0 4.7-1 6.4-2.6l-1.5-1.5A6.7 6.7 0 0 1 11 19a7 7 0 1 1 7-7h-3l4 4h.1l3.9-4h-3a9 9 0 0 0-18 0Z"/>
|
|
97
97
|
</svg>`,prev:'<svg viewBox="0 0 24 24"><path d="M15.4 16.6 10.8 12l4.6-4.6L14 6l-6 6 6 6 1.4-1.4Z"/></svg>',next:'<svg viewBox="0 0 24 24"><path d="m8.6 16.6 4.6-4.6-4.6-4.6L10 6l6 6-6 6-1.4-1.4Z"/></svg>',add:`<svg viewBox="0 0 24 24">
|
|
98
98
|
<path d="M12 20a8 8 0 1 1 0-16 8 8 0 0 1 0 16m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10 10 10 0 0 0 10-10A10 10 0 0 0 12 2m1 5h-2v4H7v2h4v4h2v-4h4v-2h-4V7Z"/>
|
|
99
|
-
</svg>`},Ji={id:"swiper-responsive",label:"Responsive",icon:te.responsive},Ui={id:"swiper-extra",label:"Extra",icon:te.extra},yh={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:te.reload},{id:"p",label:"Previous slide",icon:te.prev},{id:"n",label:"Next slide",icon:te.next},{id:"a",label:"Add new slide",icon:te.add}],setValue:({component:n,value:e})=>{var s;const t=(s=n.getView())==null?void 0:s.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(jt),setValue:({component:n,value:e})=>{var t,s;e?n.append([{type:jt},{type:ys}]):((t=n.findFirstType(jt))==null||t.remove(),(s=n.findFirstType(ys))==null||s.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:te.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:te.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:te.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(Kt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Kt);t==null||t.remove(),e!=="none"&&n.append({type:Kt}),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:te.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(vn),setValue:({component:n,value:e})=>{const t=n.findFirstType(vn);t==null||t.remove(),e&&n.append({type:vn}),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:te.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Ji,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:Ji,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:Ui,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Ui,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},Zi="Slider",Oo="swiper",an=`${Oo}-`,bh=(n,e)=>{const{Components:t,Blocks:s,Commands:o}=n,{block:i}=e,r=od(yh),l="core:preview",a=o.events,c=function(u){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,b=f.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:v}=u||{},w=x=>isNaN(x)?void 0:parseFloat(x),S=()=>{const x={loop:u.loop,speed:u.speed,initialSlide:u.initialSlide,direction:u.vertical?"vertical":"horizontal",effect:u.effect,freeMode:u.freeMode,parallax:u.parallax,autoHeight:u.autoHeight,allowTouchMove:u.allowTouchMove,grabCursor:u.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(v)?v:w(v),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&&{delay:u.autoplayDelay,disableOnInteraction:u.autoplayDisableOnInteraction,pauseOnMouseEnter:u.autoplayPauseOnMouseEnter,reverseDirection:u.autoplayReverseDirection,stopOnLastSlide:u.autoplayStopOnLastSlide,waitForTransition:u.autoplayWaitForTransition}};if(u.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:A}=u,P=w(T);x.breakpoints[P]={slidesPerView:isNaN(A)?A:w(A),slidesPerGroup:w(u.tabletSlidesPerGroup),spaceBetween:w(u.tabletSpaceBetween)}}if(u.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:A}=u,P=w(T);x.breakpoints[P]={slidesPerView:isNaN(A)?A:w(A),slidesPerGroup:w(u.mobileSlidesPerGroup),spaceBetween:w(u.mobileSpaceBetween)}}m&&!b&&(x.simulateTouch=!1),g&&(x.initialSlide=g);const E=new p.Swiper(f,x);m==null||m(E)};if(p.Swiper)S();else{const{head:x}=document,E=Array.isArray(C)?[...C]:[C],T=Array.isArray(y)?[...y]:[y],A=D=>{if(D.length){const V=document.createElement("link");V.href=D.shift(),V.rel="stylesheet",x.appendChild(V),A(D)}},P=D=>{if(D.length){const V=document.createElement("script");V.src=D.shift(),V.onerror=V.onload=P.bind(null,D),x.appendChild(V)}else S()};A(T),P(E)}},d=(u=0)=>({type:Nn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${u}`}}}),h=t.getType("default").model;return t.addType(ke,{block:i&&{label:Zi,media:te.slider,category:"Extra",select:!0,...e.block},isComponent:u=>Tt(u,Oo),model:{defaults:()=>({name:Zi,icon:te.slider,classes:Oo,draggable:(u,f)=>!f.is(ke),components:[{type:Gt,components:[d(1),d(2),d(3)]},{type:Kt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:u}=this;id(this,r.traits),rd(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(Gt);u==null||u.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const u=((f=this.findFirstType(Gt))==null?void 0:f.components().length)||0;return{type:Nn,components:{type:"text",components:{type:"textnode",content:`Slide ${u+1}`}}}},toJSON(...u){const f=h.prototype.toJSON.apply(this,u);return r.propsNoValues.forEach(p=>delete f[p]),delete f["script-props"],f}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var u;(u=this.getSwiper())==null||u.destroy()},onRender(){const u=this.el;u.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),u.__activeSlide=this.__activeSlide,u.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(ke),s.remove(ke)}},vh="Nav Prev",wh="Nav Next",Zn=`${an}button-prev`,Yn=`${an}button-next`,Sh=n=>{const{Components:e}=n,t=s=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:s,fill:"currentColor"}}});return e.addType(jt,{isComponent:s=>Tt(s,Zn),model:{defaults:{name:vh,classes:Zn,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
|
-
.${
|
|
99
|
+
</svg>`},Xi={id:"swiper-responsive",label:"Responsive",icon:se.responsive},Qi={id:"swiper-extra",label:"Extra",icon:se.extra},Eu={actions:{type:"radio",label:!1,labelToTitle:!0,options:[{id:"r",label:"Reload slider",icon:se.reload},{id:"p",label:"Previous slide",icon:se.prev},{id:"n",label:"Next slide",icon:se.next},{id:"a",label:"Add new slide",icon:se.add}],setValue:({component:n,value:e})=>{var s;const t=(s=n.getView())==null?void 0:s.getSwiper();switch(e){case"r":n.reloadSlider();break;case"p":t==null||t.slidePrev();break;case"n":t==null||t.slideNext();break;case"a":n.addSlide();break}}},vertical:{type:"checkbox",label:"Vertical",value:!1},loop:{type:"checkbox",label:"Loop",value:!1},freeMode:{type:"checkbox",label:"Free mode",value:!1},autoHeight:{type:"checkbox",label:"Auto height",value:!1},navigation:{type:"checkbox",label:"Navigation",getValue:({component:n})=>!!n.findFirstType(Kt),setValue:({component:n,value:e})=>{var t,s;e?n.append([{type:Kt},{type:vs}]):((t=n.findFirstType(Kt))==null||t.remove(),(s=n.findFirstType(vs))==null||s.remove()),n.set({navigation:e})}},initialSlide:{type:"number",label:"Initial slide",min:0,value:"0"},speed:{type:"number",label:"Speed",tip:"Transition duration (in ms)",step:500,min:0,value:300},effect:{category:{id:"swiper-effect",label:"Effects",icon:se.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:se.autoplay},type:"checkbox",label:"Enable Autoplay",value:!1,subTraits:{true:[{type:"number",name:"autoplayDelay",label:"Delay",changeProp:!0,value:3e3},{type:"checkbox",name:"autoplayDisableOnInteraction",label:"Disable on interaction",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayWaitForTransition",label:"Wait for transition",changeProp:!0,value:!0},{type:"checkbox",name:"autoplayPauseOnMouseEnter",label:"Pause on mouse enter",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayReverseDirection",label:"Reverse direction",changeProp:!0,value:!1},{type:"checkbox",name:"autoplayStopOnLastSlide",label:"Stop on last slide",changeProp:!0,value:!1}]}},pagination:{category:{id:"swiper-pagination",label:"Pagination",icon:se.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(Jt)?n.get("pagination")||"bullets":"none",setValue:({component:n,value:e})=>{const t=n.findFirstType(Jt);t==null||t.remove(),e!=="none"&&n.append({type:Jt}),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:se.scrollbar},type:"checkbox",label:"Enable Scrollbar",getValue:({component:n})=>!!n.findFirstType(wn),setValue:({component:n,value:e})=>{const t=n.findFirstType(wn);t==null||t.remove(),e&&n.append({type:wn}),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:se.parallax},type:"checkbox",label:"Enable Parallax",value:!1},mobile:{category:Xi,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:Xi,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:Qi,type:"checkbox",label:"Allow touch move",tip:"Allow touch interactions",value:!0},grabCursor:{category:Qi,type:"checkbox",label:"Grab cursor",tip:'If enabled, the user will see the "grab" cursor when hover the slider',value:!1}},er="Slider",Ro="swiper",cn=`${Ro}-`,Ou=(n,e)=>{const{Components:t,Blocks:s,Commands:o}=n,{block:i}=e,r=md(Eu),l="core:preview",a=o.events,c=function(h){const f=this,p=window,m=f.__onLoad,g=f.__activeSlide,b=f.__inPreview,{cdnScript:C,cdnStyle:y,slidesPerView:v}=h||{},w=x=>isNaN(x)?void 0:parseFloat(x),S=()=>{const x={loop:h.loop,speed:h.speed,initialSlide:h.initialSlide,direction:h.vertical?"vertical":"horizontal",effect:h.effect,freeMode:h.freeMode,parallax:h.parallax,autoHeight:h.autoHeight,allowTouchMove:h.allowTouchMove,grabCursor:h.grabCursor,simulateTouch:!0,breakpoints:{},slidesPerView:isNaN(v)?v:w(v),slidesPerGroup:w(h.slidesPerGroup),spaceBetween:w(h.spaceBetween),slidesOffsetBefore:w(h.slidesOffsetBefore),slidesOffsetAfter:w(h.slidesOffsetAfter),centeredSlides:h.centeredSlides,fadeEffect:{crossFade:h.crossFade},cubeEffect:{shadow:h.cubeEffectShadow,slideShadows:h.cubeEffectSlideShadows,shadowOffset:w(h.cubeEffectShadowOffset),shadowScale:w(h.cubeEffectShadowScale)},coverflowEffect:{depth:w(h.coverflowEffectDepth),modifier:w(h.coverflowEffectModifier),rotate:w(h.coverflowEffectRotate),scale:w(h.coverflowEffectScale),stretch:w(h.coverflowEffectStretch),slideShadows:h.coverflowEffectSlideShadows},flipEffect:{limitRotation:h.flipEffectLimitRotation,slideShadows:h.flipEffectSlideShadows},cardsEffect:{perSlideOffset:w(h.cardsEffectPerSlideOffset),perSlideRotate:w(h.cardsEffectPerSlideRotate),rotate:h.cardsEffectRotate,slideShadows:h.cardsEffectSlideShadows},navigation:{nextEl:f.querySelector(".swiper-button-next"),prevEl:f.querySelector(".swiper-button-prev")},pagination:{type:h.pagination||"bullets",dynamicBullets:h.dynamicBullets,clickable:h.clickableBullets,progressbarOpposite:h.progressbarOpposite,el:f.querySelector(".swiper-pagination")},scrollbar:{el:f.querySelector(".swiper-scrollbar"),draggable:h.scrollbarDraggable,hide:h.scrollbarHide},autoplay:h.autoplay&&{delay:h.autoplayDelay,disableOnInteraction:h.autoplayDisableOnInteraction,pauseOnMouseEnter:h.autoplayPauseOnMouseEnter,reverseDirection:h.autoplayReverseDirection,stopOnLastSlide:h.autoplayStopOnLastSlide,waitForTransition:h.autoplayWaitForTransition}};if(h.tablet){const{tabletBreakpoint:T,tabletSlidesPerView:A}=h,P=w(T);x.breakpoints[P]={slidesPerView:isNaN(A)?A:w(A),slidesPerGroup:w(h.tabletSlidesPerGroup),spaceBetween:w(h.tabletSpaceBetween)}}if(h.mobile){const{mobileBreakpoint:T,mobileSlidesPerView:A}=h,P=w(T);x.breakpoints[P]={slidesPerView:isNaN(A)?A:w(A),slidesPerGroup:w(h.mobileSlidesPerGroup),spaceBetween:w(h.mobileSpaceBetween)}}m&&!b&&(x.simulateTouch=!1),g&&(x.initialSlide=g);const E=new p.Swiper(f,x);m==null||m(E)};if(p.Swiper)S();else{const{head:x}=document,E=Array.isArray(C)?[...C]:[C],T=Array.isArray(y)?[...y]:[y],A=D=>{if(D.length){const L=document.createElement("link");L.href=D.shift(),L.rel="stylesheet",x.appendChild(L),A(D)}},P=D=>{if(D.length){const L=document.createElement("script");L.src=D.shift(),L.onerror=L.onload=P.bind(null,D),x.appendChild(L)}else S()};A(T),P(E)}},d=(h=0)=>({type:Pn,style:{padding:"50px"},components:{type:"text",components:{type:"textnode",content:`Slide ${h}`}}}),u=t.getType("default").model;return t.addType(ke,{block:i&&{label:er,media:se.slider,category:"Extra",select:!0,...e.block},isComponent:h=>Mt(h,Ro),model:{defaults:()=>({name:er,icon:se.slider,classes:Ro,draggable:(h,f)=>!f.is(ke),components:[{type:jt,components:[d(1),d(2),d(3)]},{type:Jt}],script:c,cdnScript:e.cdnScript,cdnStyle:e.cdnStyle,"script-props":["cdnScript","cdnStyle",...r.propKeys],...r.props,traits:[...r.traits]}),init(){const{em:h}=this;gd(this,r.traits),yd(this,r.propKeys),this.listenTo(h,`${a.runCommand}${l}`,this.onPreviewOn),this.listenTo(h,`${a.stopCommand}${l}`,this.onPreviewOff)},onPreviewOn(){this.__inPreview=!0,this.reloadSlider()},onPreviewOff(){this.__inPreview=!1,this.reloadSlider()},reloadSlider(){this.trigger("rerender")},addSlide(){const h=this.findFirstType(jt);h==null||h.append(this.getNewSlideComponentDef())},getNewSlideComponentDef(){var f;const h=((f=this.findFirstType(jt))==null?void 0:f.components().length)||0;return{type:Pn,components:{type:"text",components:{type:"textnode",content:`Slide ${h+1}`}}}},toJSON(...h){const f=u.prototype.toJSON.apply(this,h);return r.propsNoValues.forEach(p=>delete f[p]),delete f["script-props"],f}},view:{init(){this.listenTo(this.model,t.events.scriptUnmount,this.destroySwiper)},getSwiper(){return this.el.swiper},destroySwiper(){var h;(h=this.getSwiper())==null||h.destroy()},onRender(){const h=this.el;h.__onLoad=f=>f.on("slideChange",()=>this.__activeSlide=f.activeIndex),h.__activeSlide=this.__activeSlide,h.__inPreview=this.model.__inPreview}}}),()=>{t.removeType(ke),s.remove(ke)}},Nu="Nav Prev",Pu="Nav Next",Yn=`${cn}button-prev`,Xn=`${cn}button-next`,Iu=n=>{const{Components:e}=n,t=s=>({type:"svg",selectable:!1,hoverable:!1,attributes:{viewBox:"0 0 27 44"},components:{type:"svg-in",tagName:"path",attributes:{d:s,fill:"currentColor"}}});return e.addType(Kt,{isComponent:s=>Mt(s,Yn),model:{defaults:{name:Nu,classes:Yn,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
|
+
.${Yn} {
|
|
101
101
|
color: inherit;
|
|
102
102
|
}
|
|
103
|
-
.${
|
|
103
|
+
.${Yn}:after {
|
|
104
104
|
content: none;
|
|
105
105
|
}
|
|
106
|
-
`}}}),e.addType(
|
|
107
|
-
.${
|
|
106
|
+
`}}}),e.addType(vs,{extend:Kt,isComponent:s=>Mt(s,Xn),model:{defaults:{name:Pu,classes:Xn,components:t("M27,22L27,22L5,44l-2.1-2.1L22.8,22L2.9,2.1L5,0L27,22L27,22z"),styles:`
|
|
107
|
+
.${Xn} {
|
|
108
108
|
color: inherit;
|
|
109
109
|
}
|
|
110
|
-
.${
|
|
110
|
+
.${Xn}:after {
|
|
111
111
|
content: none;
|
|
112
112
|
}
|
|
113
|
-
`}}}),()=>{e.removeType(
|
|
113
|
+
`}}}),()=>{e.removeType(Kt),e.removeType(vs)}},Ru=n=>{const{Components:e}=n,t=`${cn}pagination`;return e.addType(Jt,{isComponent:s=>Mt(s,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(
|
|
120
|
+
`}}}),()=>{e.removeType(Jt)}},Du="Scrollbar",tr=`${cn}scrollbar`,zu=n=>{const{Components:e}=n;return e.addType(wn,{isComponent:t=>Mt(t,tr),model:{defaults:{name:Du,classes:tr,copyable:!1,highlightable:!1,removable:!1,selectable:!1,hoverable:!1,layerable:!1,droppable:!1,draggable:!1}}}),()=>{e.removeType(wn)}},Lu="Slide",nr=`${cn}slide`,Vu=n=>{const{Components:e}=n;return e.addType(Pn,{isComponent:t=>Mt(t,nr),model:{defaults:{name:Lu,classes:nr,icon:se.slider,draggable:(t,s)=>s.is(jt)}}}),()=>{e.removeType(Pn)}},Bu="Wrapper",sr=`${cn}wrapper`,Hu=n=>{const{Components:e}=n,{events:t}=e;return e.addType(jt,{isComponent:s=>Mt(s,sr),model:{defaults:{name:Bu,icon:se.slider,classes:sr,copyable:!1,removable:!1,draggable:!1,highlightable:!1,droppable:s=>s.is(Pn)},init(){const s=this.components();this.listenTo(s,"add remove",this.updateSlider)},updateSlider(s){const o=this.closestType(ke);if(o){const i=o.getView();o.reloadSlider(),this.em.once(t.scriptMount,()=>{setTimeout(()=>{var r;return(r=i.getSwiper())==null?void 0:r.slideTo(s.index())},100)})}}}}),()=>{e.removeType(jt)}},$u="swiperComponent",Fu=function(n,e={}){const t={block:{},cdnScript:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.js",cdnStyle:"https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css",...e},s=[Ou(n,t),Iu(n),Hu(n),Vu(n),Ru(n),zu(n)];te({editor:n,plan:F.startup,licenseKey:t.licenseKey,pluginName:$u,cleanup:()=>{s.forEach(o=>o())}})},Wu=ee(Fu),le="accordion",un=`${le}-group`,He=`${le}-header`,Xe=`${le}-content`,gt=`${le}-marker`,or=`${Fe}${He}`,Do=`${Fe}${gt}`,_u=`${Fe}${Xe}`,ca=`${Do}-open`,At={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>'},da=(n,e)=>{const{toolbarIconOpen:t=At.eye}=e,s=n.is(le)?n:n.closestType(le);if(!t||!s)return;const{toolbar:o}=n,i={id:"accordion-toggle-open",label:t,command:()=>s.toggleOpen()};!o.find(l=>l.id===i.id)&&(o==null||o.unshift(i))},qu=(n,e)=>{const{Components:t,Blocks:s}=n,{block:o={}}=e,i="Accordion",r=`${Fe}${le}`,l=function(a={}){const c=this,d=()=>{const{clsMarkerOpen:u}=a,h=c.querySelector('[data-type-role="accordion-marker"]');!h||!u||(c.open?h.classList.add(u):h.classList.remove(u))};c.addEventListener("toggle",()=>{d(),c.dispatchEvent(new CustomEvent("details-toggle",{bubbles:!0}))}),d()};return t.addType(le,{block:o&&{label:i,media:At.accordion,category:"Extra",select:!0,...o},isComponent:Pt(le),extendFn:["initToolbar"],model:{defaults:{tagName:"details",name:i,classes:r,emptyState:!0,clsMarkerOpen:ca,attributes:{[rt]:le},droppable:di(He,Xe),components:[{type:He},{type:Xe}],"script-props":["clsMarkerOpen"],script:l,traits:[{type:"checkbox",name:"open",label:"Open"}],styles:`
|
|
121
121
|
.${r}::details-content {
|
|
122
122
|
opacity: 0;
|
|
123
123
|
block-size: 0;
|
|
@@ -134,40 +134,40 @@
|
|
|
134
134
|
transform: translateY(0);
|
|
135
135
|
block-size: auto;
|
|
136
136
|
}
|
|
137
|
-
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){
|
|
137
|
+
`},toggleOpen(){this.addAttributes({open:!this.getAttributes().open})},initToolbar(){da(this,e)}}}),()=>{s.remove(le),t.removeType(le)}},Gu=n=>{const{Components:e}=n;return e.addType(Xe,{isComponent:Pt(Xe),model:{defaults:{name:"Accordion Content",removable:!1,copyable:!1,draggable:!1,emptyState:!0,classes:_u,icon:At.accordionContent,attributes:{[rt]:Xe},components:"<div>Accordion content</div>"}}}),()=>{e.removeType(Xe)}},ju=(n,e)=>{const{Components:t,Blocks:s}=n,{blockGroup:o={}}=e,i="Accordion Group",r=function(a={}){if(!a.single)return;const c=this;c.addEventListener("details-toggle",d=>{const u=d.target;if(!a.single||!u||!u.open)return;c.querySelectorAll('[data-type-role="accordion"]').forEach(f=>{u!==f&&f.open&&(f.open=!1)})})},l=(a={})=>({type:le,attributes:{open:a.open},components:[{type:He,components:[`<div>${a.header}</div>`,{type:gt}]},{type:Xe,components:`<div>${a.content}</div>`}]});return t.addType(un,{block:o&&{label:i,media:At.accordionGroup,category:"Extra",select:!0,...o},isComponent:Pt(un),model:{defaults:{name:i,attributes:{[rt]:un},droppable:di(le),single:!0,emptyState:!0,components:Array(3).fill(0).map((a,c)=>l({open:c===0,header:`Accordion header ${c+1}`,content:`Accordion content ${c+1}`})),traits:[{type:"checkbox",name:"single",changeProp:!0,tip:"Only one accordion can be open at a time",label:"Single open"}],"script-props":["single"],script:r}}}),()=>{s.remove(un),t.removeType(un)}},Ku=(n,e)=>{const{Components:t}=n;return t.addType(He,{isComponent:Pt(He),extendFn:["initToolbar"],model:{defaults:{tagName:"summary",name:"Accordion Header",removable:!1,copyable:!1,draggable:!1,emptyState:!0,icon:At.accordionHeader,classes:or,attributes:{[rt]:He},components:["<div>Accordion header</div>",{type:gt}],styles:`
|
|
138
138
|
summary {
|
|
139
139
|
list-style: none;
|
|
140
140
|
}
|
|
141
|
-
.${
|
|
141
|
+
.${or} {
|
|
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(){
|
|
149
|
-
.${
|
|
148
|
+
`},initToolbar(){da(this,e)}}}),()=>{t.removeType(He)}},Ju=n=>{const{Components:e}=n;return e.addType(gt,{extend:"icon",isComponent:Pt(gt),model:{defaults:{name:"Accordion Marker",icon:At.accordionMarker,classes:Do,attributes:{[rt]:gt},components:At.caret,droppable:!1,draggable:Hl(He),styles:`
|
|
149
|
+
.${Do} {
|
|
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
|
-
.${
|
|
155
|
+
.${ca} {
|
|
156
156
|
transform: rotateZ(180deg);
|
|
157
157
|
}
|
|
158
|
-
`}}}),()=>{e.removeType(
|
|
159
|
-
${
|
|
160
|
-
</div>`,a=(h
|
|
158
|
+
`}}}),()=>{e.removeType(gt)}},Uu="accordionComponent",Zu=function(n,e={}){const t=[qu(n,e),ju(n,e),Ku(n,e),Ju(n),Gu(n)];te({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:Uu,cleanup:()=>{t.forEach(s=>s())}})},Yu=ee(Zu),En=class En{constructor(e){this.config=e}getSize(e){var t;return(t=this.config)!=null&&t.getSize?this.config.getSize(e):gi(e.componentColumn,En.CSS_FLEX_BASIS)}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:o,partial:i}=e;s.addStyle({[En.CSS_FLEX_BASIS]:o},{partial:i})}}};En.CSS_FLEX_BASIS="flex-basis";let zo=En;const On=class On{constructor(e){this.config=e}isGapSupported(){return!0}getGap(e){var t;return(t=this.config)!=null&&t.getGap?this.config.getGap(e):gi(e.componentRow,On.CSS_GAP)}setGap(e){var t;if((t=this.config)!=null&&t.setGap)this.config.setGap(e);else{const{componentRow:s,gapValue:o,partial:i}=e;s.addStyle({[On.CSS_GAP]:o},{partial:i})}}};On.CSS_GAP="gap";let Lo=On;const Vs=class Vs{constructor(e){this.config=e}getParentSize(e){var i;if((i=this.config)!=null&&i.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,o=t.getEl();return o?s?o.clientHeight:o.clientWidth:0}isLayoutVertical(e){var s;if((s=this.config)!=null&&s.isParentVertical)return this.config.isParentVertical(e);const t=gi(e.componentRow,Vs.CSS_FLEX_DIRECTION,!0);return t==="column"||t==="column-reverse"}};Vs.CSS_FLEX_DIRECTION="flex-direction";let Vo=Vs;const Nn=class Nn{constructor(e){this.config=e}getSize(e){var s;if((s=this.config)!=null&&s.getSize)return this.config.getSize(e);const t=e.componentColumn;if(t.is(Nn.MJML_COLUMN_TYPE)){const i=t.getAttributes().width;if(i&&(i.includes("%")||!isNaN(parseFloat(i))))return parseFloat(i);const r=t.parent();return 100/(r?r.components().length:1)}return 0}setSize(e){var t;if((t=this.config)!=null&&t.setSize)this.config.setSize(e);else{const{componentColumn:s,sizeValue:o,partial:i}=e;s.is(Nn.MJML_COLUMN_TYPE)&&s.addAttributes({width:`${parseFloat(o)}%`},{partial:i})}}};Nn.MJML_COLUMN_TYPE="mj-column";let Bo=Nn;const Bs=class Bs{constructor(e){this.config=e}isGapSupported(){return!1}getGap(e){var s;if((s=this.config)!=null&&s.getGap)return this.config.getGap(e);const{componentRow:t}=e;if(t.is(Bs.MJML_SECTION_TYPE)){const o=t.getAttributes();if(o&&o.padding)return parseInt(o.padding,10)||0}return 0}setGap(e){var t,s;(s=(t=this.config)==null?void 0:t.setGap)==null||s.call(t,e)}};Bs.MJML_SECTION_TYPE="mj-section";let Ho=Bs;class Xu{constructor(e){this.config=e}getParentSize(e){var r;if((r=this.config)!=null&&r.getParentSize)return this.config.getParentSize(e);const{componentRow:t,isVertical:s}=e,o=t.getEl();if(!o)return 0;let i=o;if(o.tagName!=="TABLE"){const l=o.querySelectorAll("table");l.length&&(i=l[0])}return s?i.clientHeight:i.clientWidth}isLayoutVertical(e){var t;return(t=this.config)!=null&&t.isParentVertical?this.config.isParentVertical(e):!1}}class qt{constructor(){this.handlerCache=new Map}static getInstance(){return qt.instance||(qt.instance=new qt),qt.instance}getHandlers(e){const t=`${e.projectType}-${e.disableGapHandler?"nogap":"gap"}`;return this.handlerCache.has(t)||(en(e)?this.handlerCache.set(t,{sizeHandler:new Bo(e),gapHandler:new Ho(e),parentSizeHandler:new Xu(e)}):this.handlerCache.set(t,{sizeHandler:new zo(e),gapHandler:new Lo(e),parentSizeHandler:new Vo(e)})),this.handlerCache.get(t)}}function It(n){return qt.getInstance().getHandlers(n)}const ir=n=>{n.style.display="none"},rr=n=>{n.style.display="block"},Sn=n=>+parseFloat(`${n}`).toFixed(2),en=n=>n.projectType===Bl.email,Qn=(n,e)=>{const t=n.Canvas.getFramesEl();t&&(t.style.pointerEvents=e?"none":"")},Qu=n=>n?["top","bottom"]:["left","right"],eh=n=>{const e=n.parent();return e?e.components().models.indexOf(n)===0:!1},th=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.indexOf(n)===t.length-1},nh=n=>{const e=n.parent();if(!e)return!1;const t=e.components().models;return t.length>1&&n.index()===t.length-1},sh=(n,e,t,s)=>{const i=n+(t?e==="top"?-1:e==="bottom"?1:0:e==="left"?-1:e==="right"?1:0);return i>=0&&i<s?i:-1},ws=n=>n==="top"||n==="bottom",oh=(n,e)=>!!(eh(n)&&(e==="left"||e==="top")||th(n)&&(e==="right"||e==="bottom")),ih=n=>{const e=n.parent();return e?e.components().models.length>1:!1},lr=(n,e)=>n==="right"||n==="bottom"?e>0:e<0,gi=(n,e,t=!1)=>{const s=!t,o=n.getEl();if(!o)return s?0:"";const r=window.getComputedStyle(o)[e]||"";if(s){let l;return typeof r=="string"?(l=parseFloat(r.replace(/[^-\d.]/g,"")),isNaN(l)&&(l=0)):l=Number(r)||0,l}return r},ar=(n,e,t)=>{const s=$o({componentRow:n,isVertical:e},t),o=n.components().models;return s*(o.length-1)},In=(n,e)=>It(e).parentSizeHandler.isLayoutVertical({componentRow:n}),Rn=(n,e)=>It(e).sizeHandler.getSize(n),$o=(n,e)=>{if(e!=null&&e.disableGapHandler)return 0;const{gapHandler:t,parentSizeHandler:s}=It(e);if(!t.isGapSupported())return 0;const o=t.getGap(n),i=s.getParentSize(n);return o/100*i},Fo=(n,e)=>It(e).parentSizeHandler.getParentSize(n),Cn=(n,e)=>{It(e).sizeHandler.setSize(n)},ua=(n,e)=>{const t=Rn(n,e);Cn({...n,sizeValue:`${t}%`,partial:!1},e)},ha=(n,e)=>{if(e!=null&&e.disableGapHandler)return;const{gapHandler:t}=It(e);t.isGapSupported()&&t.setGap(n)},rh=(n,e)=>{const t=n.getStyle().gap;if(!t)return;const s=n.components().models,o={componentRow:n,isVertical:In(n,e)};s.map(i=>ua({...o,componentColumn:i},e)),ha({...o,gapValue:String(t),partial:!1},e)};function lh(n,e){const{Blocks:t}=n,{typeColumn:s,typeRow:o,blocks:i}=e;if(i===!1||en(e))return;const r=u=>({type:o,components:u.map(h=>({type:s,style:{"flex-basis":`${h}%`}}))}),l=u=>`<div class="gs-block-item__flex-row" style="display: flex; height: 1.75rem; width: 100%; flex-wrap: nowrap; gap: 0.5rem;">
|
|
159
|
+
${u.map(h=>`<div style="flex-basis: ${h}%; border-color: currentColor; border-width: 2px; border-radius: 0.12rem;"></div>`).join("")}
|
|
160
|
+
</div>`,a=(u,h)=>({id:`flex-row-${h.join("-")}`,label:u,category:"Layout",select:!0,full:!0,attributes:{class:"gs-block-item__flex gs-utl-w-full"},media:l(h),content:r(h)}),c=[a("1 Column",[100]),a("2 Columns 50/50",[50,50]),a("2 Columns 25/75",[25,75]),a("2 Columns 75/25",[75,25]),a("3 Columns",[33.33,33.33,33.33]),a("3 Columns 50/25/25",[50,25,25]),a("3 Columns 25/50/25",[25,50,25]),a("3 Columns 25/25/50",[25,25,50]),a("4 Columns",[25,25,25,25]),a("5 Columns",[20,20,20,20,20])],d=Hs(i)?i({blocks:c}):c;return d.forEach(u=>t.add(u.id,u)),()=>{d.forEach(u=>t.remove(u.id))}}const ah=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:o,extendTypeColumn:i}=e,r=`${Fe}${o}`,a=!!o&&!!t.getType(o)&&!i;if(!(!o||a||en(e)))return t.addType(o,{isComponent:Pt(o),model:{defaults:{name:"Column",resizable:!1,emptyState:!0,classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M14.5 2.3A1.8 1.8 0 0 0 12.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8zm-8 0A1.8 1.8 0 0 0 4.7 4v16c0 1 .8 1.8 1.8 1.8h3a1.8 1.8 0 0 0 1.8-1.8V4a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',draggable:Hl(s),attributes:{[rt]:o},styles:`
|
|
161
161
|
.${r} {
|
|
162
162
|
flex-grow: 1;
|
|
163
163
|
}
|
|
164
|
-
`}}}),()=>{t.removeType(o)}},
|
|
164
|
+
`}}}),()=>{t.removeType(o)}},ch=(n,e)=>{const{Components:t}=n,{typeRow:s,typeColumn:o,extendTypeRow:i}=e,r=`${Fe}${s}`,a=!!s&&!!t.getType(s)&&!i;if(!(!s||a||en(e)))return t.addType(s,{isComponent:Pt(s),model:{defaults:{name:"Row",classes:r,icon:'<svg viewBox="0 0 24 24"><path d="M4 4.8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3A1.8 1.8 0 0 0 20 4.7zm0 8a1.8 1.8 0 0 0-1.8 1.7v3c0 1 .8 1.8 1.8 1.8h16a1.8 1.8 0 0 0 1.8-1.8v-3a1.8 1.8 0 0 0-1.8-1.8z"/></svg>',emptyState:{styleIn:"width: 100%"},attributes:{[rt]:s},droppable:di(o),traits:[{type:"checkbox",name:"snap",label:"Enable Snap",default:e.snapEnabled,changeProp:!0},{type:"number",name:"snap-divisions",label:"Snap Divisions",min:1,max:12,step:1,default:e.snapDivisions,changeProp:!0}],resizable:{tl:0,tc:0,tr:0,cl:0,bl:0,br:0},styles:`
|
|
165
165
|
.${r} {
|
|
166
166
|
display: flex;
|
|
167
167
|
align-items: stretch;
|
|
168
168
|
flex-wrap: nowrap;
|
|
169
169
|
}
|
|
170
|
-
`}}}),()=>{t.removeType(s)}};class
|
|
170
|
+
`}}}),()=>{t.removeType(s)}};class dh{constructor(){this.resizableChildTypes=new Set,this.gapAdjustableParentTypes=new Set,this.typeRelationships=new Map}registerResizableChild(e){this.resizableChildTypes.add(e)}registerGapAdjustableParent(e){this.gapAdjustableParentTypes.add(e)}registerTypeRelationship(e,t){this.typeRelationships.has(e)||this.typeRelationships.set(e,new Set),this.typeRelationships.get(e).add(t),this.registerResizableChild(t),this.registerGapAdjustableParent(e)}isResizableChild(e){return this.resizableChildTypes.has(e.get("type"))}isGapAdjustableParent(e){return this.gapAdjustableParentTypes.has(e.get("type"))}isValidRelationship(e,t){const s=e.get("type"),o=t.get("type");return this.typeRelationships.has(s)?this.typeRelationships.get(s).has(o):!1}}class uh{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeState=new WeakMap}getState(e){return this.resizeState.has(e)||this.resizeState.set(e,{}),this.resizeState.get(e)}clearState(e){return this.resizeState.delete(e)}startResize(e,t,s){const{opts:o}=this,i=this.getState(e);i.direction=t,i.startX=s.clientX,i.startY=s.clientY,i.resizing=!0,i.lastSnappedPercent=void 0;const r=e.parent();if(!r||!this.registry.isValidRelationship(r,e))return;i.snapEnabled=r.get("snap")??o.snapEnabled,i.snapDivisions=r.get("snap-divisions")??o.snapDivisions??12;const l=r.components().models,a=l.findIndex(h=>h.cid===e.cid),c=In(r,o),d=sh(a,t,c,l.length);d!==-1&&(i.adjacentIdx=d);const u={componentColumn:e,componentRow:r,isVertical:c};if(i.startPercent=Rn(u,o),typeof i.adjacentIdx<"u"){const h=l[i.adjacentIdx];i.neighborStartPercent=Rn({...u,componentColumn:h},o)}}updateResizeByDelta(e,t,s){const o=this.getState(e),i=e.parent();!o.resizing||!i||(o.snapEnabled?this.updateSnapResize(e,t,s):this.updateContinuesResize(e,t,s))}finishResize(e){const t=e.parent(),s=t==null?void 0:t.components().models,o={componentRow:t,isVertical:!!t&&In(t,this.opts)};s==null||s.forEach(i=>ua({...o,componentColumn:i},this.opts)),this.clearState(e)}updateContinuesResize(e,t,s){const o=this.getState(e),i=e.parent(),{opts:r}=this;if(!i)return;const l=r.minItemPercent??0,a=ws(t),c=Fo({componentRow:i,isVertical:a},r),d=ar(i,a,this.opts),h=100-d/c*100,f=s/(c-d)*h,{startPercent:p=0,neighborStartPercent:m=0}=o,g={componentRow:i,isVertical:a,componentColumn:e,partial:!0},b=lr(t,s)?p+Math.abs(f):p-Math.abs(f);if(typeof o.adjacentIdx<"u"){const C=i.components().models[o.adjacentIdx],y=p+m,v=y-l,S=Math.min(v,Math.max(l,b)),x=y-S;Cn({...g,sizeValue:`${Sn(S)}%`},r),Cn({...g,componentColumn:C,sizeValue:`${Sn(x)}%`},r)}else{const C=Math.max(l,Math.min(h,b));Cn({...g,sizeValue:`${Sn(C)}%`},r)}}updateSnapResize(e,t,s){const o=this.getState(e),i=e.parent(),r=ws(t),l=Fo({componentRow:i,isVertical:r},this.opts),a=ar(i,r,this.opts),c=l-a,d=s/c*100,u=lr(t,s),{startPercent:h=0,snapDivisions:f=12}=o,p=u?h+Math.abs(d):h-Math.abs(d),m=100/f,g=Math.floor(p/m)*m,b=Math.ceil(p/m)*m,C=Math.abs(b-p),y=Math.abs(p-g),v=m*.2,w=C<y?b:g;if(w>0&&w<100&&(C<v||y<v)&&o.lastSnappedPercent!==w){o.lastSnappedPercent=w;let E=Math.abs(w-h)/100*c;(u&&(t==="left"||t==="top")||!u&&(t==="right"||t==="bottom"))&&(E=-E),this.updateContinuesResize(e,t,E)}else C>=v&&y>=v&&(o.lastSnappedPercent=void 0)}}class hh{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s}updateGapByDelta(e,t,s,o){if(!this.registry.isGapAdjustableParent(e))return;const{opts:i}=this,r=Math.max(0,s+t),l=Fo({componentRow:e,isVertical:o},i),a=r/l*100,c=e.components().models,d=c.length-1,u={componentRow:e,isVertical:o},h=c.reduce((v,w)=>v+Rn({...u,componentColumn:w},i),0),p=100-a*d,m=i.minItemPercent||5;if(p<m*c.length)return;const b=100-d*a,C=h-b,y={componentRow:e,isVertical:o,partial:!0};c.map(v=>{const w=Rn({...u,componentColumn:v},i),S=w-w/h*C;Cn({...y,componentColumn:v,sizeValue:`${Sn(S)}%`},i)}),ha({...y,gapValue:`${Sn(a)}%`},i)}finishGapAdjust(e){rh(e,this.opts)}}class fh{constructor(e,t,s){this.editor=e,this.registry=t,this.opts=s,this.resizeHandler=new uh(e,t,s),this.gapHandler=new hh(e,t,s)}startResize(e,t,s){this.resizeHandler.startResize(e,t,s)}updateResizeByDelta(e,t,s){this.resizeHandler.updateResizeByDelta(e,t,s)}finishResize(e){this.resizeHandler.finishResize(e)}updateGapByDelta(e,t,s,o){this.gapHandler.updateGapByDelta(e,t,s,o)}finishGapAdjust(e){this.gapHandler.finishGapAdjust(e)}canResize(e){const t=e.parent();return t?this.registry.isValidRelationship(t,e):!1}canAdjustGap(e){return this.registry.isGapAdjustableParent(e)}}const Ss="gs-flex-spots",cr=`${Ss}__handle-size`,ph=`${Ss}__handle-gap`;function mh(n,e){const{Canvas:t}=n,s="flex-resize-spot";let o,i,r,l,a=null,c=null;const d=new dh,u=new fh(n,d,e),h=()=>{var S;o=document.createElement("div"),o.className=Ss,o.style.display="none",i=document.createElement("div"),i.className=`${Ss}__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 T=x,A=ws(T);E.className=`${cr} ${cr}-${T} gjs-resizer-h gjs-cv-unscale`,E.style.cssText=`
|
|
171
171
|
pointer-events: all;
|
|
172
172
|
position: absolute;
|
|
173
173
|
z-index: 1;
|
|
@@ -177,7 +177,7 @@
|
|
|
177
177
|
${T==="right"?"right: 0px;":""}
|
|
178
178
|
${T==="top"?"top: 0px;":""}
|
|
179
179
|
${T==="bottom"?"bottom: 0px;":""}
|
|
180
|
-
`,E.addEventListener("pointerdown",f(T)),i.appendChild(E)}),!e.disableGapHandler&&!
|
|
180
|
+
`,E.addEventListener("pointerdown",f(T)),i.appendChild(E)}),!e.disableGapHandler&&!en(e)&&(l=document.createElement("div"),l.className=ph,l.style.cssText=`
|
|
181
181
|
position: absolute;
|
|
182
182
|
background-color: #3b97e3;
|
|
183
183
|
border-width: 2px;
|
|
@@ -187,17 +187,17 @@
|
|
|
187
187
|
pointer-events: all;
|
|
188
188
|
max-width: 3rem;
|
|
189
189
|
max-height: 3rem;
|
|
190
|
-
`,l.addEventListener("pointerdown",p()),i.appendChild(l)),o.append(i),(S=t.getSpotsEl())==null||S.appendChild(o)},f=S=>x=>{if(!a)return;Xn(n,!0),x.stopPropagation(),x.preventDefault(),h.startResize(a,S,x);const E=x.clientX,T=x.clientY;x.target.setPointerCapture(x.pointerId);const A=D=>{const V=n.Canvas.getZoomMultiplier(),B=(D.clientX-E)*V,be=(D.clientY-T)*V,ve=bs(S)?be:B;h.updateResizeByDelta(a,S,ve)},P=()=>{Xn(n,!1),h.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",A),document.addEventListener("pointerup",P)},p=()=>S=>{if(!c)return;const x=c;Xn(n,!0),S.stopPropagation(),S.preventDefault();const E=Pn(x,e),T=Vo({componentRow:x,isVertical:E},e),A=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const D=B=>{const be=n.Canvas.getZoomMultiplier(),ve=E?(B.clientY-P)*be:(B.clientX-A)*be;h.updateGapByDelta(x,ve,T,E)},V=()=>{Xn(n,!1),h.finishGapAdjust(x),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",V)};document.addEventListener("pointermove",D),document.addEventListener("pointerup",V)},m=S=>{const x=S.component;if(!x||!o||(a=x,c=x.parent(),!c))return;const E=c;nr(o);const T=S.getStyle();i&&Object.assign(i.style,T);const A=Pn(E,e),P=Wh(A);if(Object.values(r).forEach(tr),P.forEach(V=>{if(Kh(x,V))return;const B=r[V];nr(B)}),Pt(e).gapHandler.isGapSupported()&&l&&Jh(x)){const V=Vo({componentRow:E,isVertical:A},e);g(V,A,Gh(x))}},g=(S,x,E=!1)=>{const T=e.gapHandleSize,A=l.style;if(x){A.height=`${T}px`;const P=l.offsetHeight;E?(A.top=`-${(S+P)/2}px`,A.bottom=""):(A.bottom=`-${(S+P)/2}px`,A.top=""),A.width="50%",A.left="50%",A.transform="translateX(-50%)",A.cursor="row-resize"}else{A.width=`${T}px`;const P=l.offsetWidth;E?(A.left=`-${(S+P)/2}px`,A.right=""):(A.right=`-${(S+P)/2}px`,A.left=""),A.height="50%",A.top="50%",A.transform="translateY(-50%)",A.cursor="col-resize"}},b=()=>{o&&(tr(o),a=null,c=null)},C=()=>{t.removeSpots({type:s});const S=n.getSelected(),x=S==null?void 0:S.parent();S&&x&&d.isValidRelationship(x,S)?t.addSpot({type:s,component:S}):b()},y=()=>{const S=t.getSpots().filter(x=>x.type===s)[0];S&&m(S)},v=(S,x)=>{d.registerTypeRelationship(S,x)};n.onReady(()=>{u(),Qt(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const w="component:toggled";return n.on(t.events.spot,y),n.on(w,C),()=>{n.off(t.events.spot,y),n.off(w,C)}}const iu="flexComponent",ru=function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[Xh(n,t),Yh(n,t)],o=ou(n,t),i=Zh(n,t);re({editor:n,licenseKey:t.licenseKey,plan:W.startup,pluginName:iu,cleanup:()=>{s.forEach(r=>r==null?void 0:r()),o(),i==null||i()}})},lu=ie(ru),au=n=>n.dispatchEvent(new CustomEvent("input"));function cu(n,e){if(!e)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{s(d)&&o(d)&&!r(d)&&l(d,h)},c=(d,h)=>{if(s(d)&&!o(d)&&i(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const fi=new WeakMap,du=(n,e)=>{fi.set(n,e)},hu=n=>{fi.delete(n)},eo=n=>fi.get(n),Qn=n=>{const e=n.target,t=e.closest(".tox"),s=e.matches(".ephox-snooker-resizer-bar");(t||s)&&n.stopPropagation()},rr=n=>{n.stopPropagation(),n.preventDefault()},uu=(n,e)=>{const t=n.getDoc(),s=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:i,clientY:r}=o;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=s.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},fu=n=>{var c,d;const{el:e,editor:t,componentView:s}=n,o=t.runCommand(j.getStateTheme),i=s.model,r={target:e,inline:!0,skin:(o==null?void 0:o.theme)===Pl.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:s,component:i}))||{};return{...r,...l}},lr=(n,e=document)=>new Promise((t,s)=>{const o=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=s,i.appendChild(a)}else t()};r(o)}),pu="rteTinyMce",mu=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:s}=t,o=n.Canvas.events,i=async(a,c)=>{const d=a.ownerDocument,h=d.defaultView,u=c==null?void 0:c.view;if(!h||!u){console.warn("Missing required data",{win:h,componentView:u});return}const f=fu({el:a,editor:n,componentView:u,pluginOpts:t}),m=(await h.tinymce.init(f))[0];if(!m)return;const b=(await window.tinymce.init({...f,target:document.createElement("div")}))[0];return m.ui.show(),d.body.addEventListener("mousedown",Qn),document.body.addEventListener("mousedown",Qn),m.on("Change",()=>au(a)),m.on("blur",()=>m.ui.show()),m.on("OpenWindow",function(){var v;const C=(v=d.querySelector(".tox-dialog"))==null?void 0:v.closest(".tox");C&&(C==null?void 0:C.ownerDocument)!==document&&(document.body.appendChild(C),m.once("CloseWindow",()=>{C&&C.ownerDocument===document&&d.body.appendChild(C)}))}),a.addEventListener("dragstart",rr,{capture:!0}),n.runCommand(j.setStateContextMenu,{enabled:!1}),uu(m,c),{rteEditor:m,rteEditorShallow:b}},r=(a,c)=>{a.ownerDocument.body.removeEventListener("mousedown",Qn),document.body.removeEventListener("mousedown",Qn),a.removeEventListener("dragstart",rr,{capture:!0}),n.runCommand(j.setStateContextMenu,{enabled:!0}),c.rteEditor.destroy(),c.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:a})=>{lr(s,a.document)}),n.onReady(()=>{lr(s,document)}),n.setCustomRte({parseContent:!0,async enable(a,c,d){const h=eo(a);if(h)return h.rteEditor;const u=await i(a,d);return u&&du(a,u),u==null?void 0:u.rteEditor},disable(a){const c=eo(a);c&&(hu(a),r(a,c))},getContent(a){var d,h;const c=eo(a);return c?(h=(d=c.rteEditor).getContent)==null?void 0:h.call(d):a.innerHTML}});const l=cu(n,t.enableOnClick);re({editor:n,licenseKey:t.licenseKey,plan:W.startup,pluginName:pu,cleanup:()=>{n.RichTextEditor.customRte=void 0,l()}})},gu=ie(mu);function K(n){this.content=n}K.prototype={constructor:K,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var s=t&&t!=n?this.remove(t):this,o=s.find(n),i=s.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new K(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 K(t)},addToStart:function(n,e){return new K([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new K(t)},addBefore:function(n,e,t){var s=this.remove(e),o=s.content.slice(),i=s.find(n);return o.splice(i==-1?o.length:i,0,e,t),new K(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=K.from(n),n.size?new K(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=K.from(n),n.size?new K(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=K.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}};K.from=function(n){if(n instanceof K)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new K(e)};function la(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(s),i=e.child(s);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let r=0;o.text[r]==i.text[r];r++)t++;return t}if(o.content.size||i.content.size){let r=la(o.content,i.content,t+1);if(r!=null)return r}t+=o.nodeSize}}function aa(n,e,t,s){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:s};let r=n.child(--o),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,s-=a;continue}if(!r.sameMarkup(l))return{a:t,b:s};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,s--;return{a:t,b:s}}if(r.content.size||l.content.size){let c=aa(r.content,l.content,t-1,s-1);if(c)return c}t-=a,s-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,t,s,o=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&s(a,o+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),s,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,o){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&s&&(r?r=!1:i+=s),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(s)&&(o[o.length-1]=t.withText(t.text+s.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new k(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let s=[],o=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),s.push(l),o+=l.nodeSize),r=a}return new k(s,o)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-s.nodeSize;return o[e]=t,new k(o,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,s=0;t<this.content.length;t++){let o=this.content[t];e(o,s,t),s+=o.nodeSize}}findDiffStart(e,t=0){return la(this,e,t)}findDiffEnd(e,t=this.size,s=e.size){return aa(this,e,t,s)}findIndex(e,t=-1){if(e==0)return es(0,e);if(e==this.size)return es(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let s=0,o=0;;s++){let i=this.child(s),r=o+i.nodeSize;if(r>=e)return r==e||t>0?es(s+1,r):es(s,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,s=0;for(let o=0;o<e.length;o++){let i=e[o];s+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,s)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const to={index:0,offset:0};function es(n,e){return to.index=n,to.offset=e,to}function ws(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let s=0;s<n.length;s++)if(!ws(n[s],e[s]))return!1}else{for(let s in n)if(!(s in e)||!ws(n[s],e[s]))return!1;for(let s in e)if(!(s in n))return!1}return!0}class L{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,s=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!s&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),s=!0),t&&t.push(i)}}return t||(t=e.slice()),s||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ws(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let s=e.marks[t.type];if(!s)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=s.create(t.attrs);return s.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(t[s]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return L.none;if(e instanceof L)return[e];let t=e.slice();return t.sort((s,o)=>s.type.rank-o.type.rank),t}}L.none=[];class Ss extends Error{}class M{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=da(this.content,e+this.openStart,t);return s&&new M(s,this.openStart,this.openEnd)}removeBetween(e,t){return new M(ca(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return M.empty;let s=t.openStart||0,o=t.openEnd||0;if(typeof s!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new M(k.fromJSON(e,t.content),s,o)}static maxOpen(e,t=!0){let s=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new M(e,s,o)}}M.empty=new M(k.empty,0,0);function ca(n,e,t){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s),{index:r,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(s!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(s,i.copy(ca(i.content,e-o-1,t-o-1)))}function da(n,e,t,s){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=da(r.content,e-i-1,t);return l&&n.replaceChild(o,r.copy(l))}function yu(n,e,t){if(t.openStart>n.depth)throw new Ss("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Ss("Inconsistent open depths");return ha(n,e,t,0)}function ha(n,e,t,s){let o=n.index(s),i=n.node(s);if(o==e.index(s)&&s<n.depth-t.openStart){let r=ha(n,e,t,s+1);return i.copy(i.content.replaceChild(o,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==s&&e.depth==s){let r=n.parent,l=r.content;return wt(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=bu(t,n);return wt(i,fa(n,r,l,e,s))}else return wt(i,Cs(n,e,s))}function ua(n,e){if(!e.type.compatibleContent(n.type))throw new Ss("Cannot join "+e.type.name+" onto "+n.type.name)}function Bo(n,e,t){let s=n.node(t);return ua(s,e.node(t)),s}function vt(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 Cn(n,e,t,s){let o=(e||n).node(t),i=0,r=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(vt(n.nodeAfter,s),i++));for(let l=i;l<r;l++)vt(o.child(l),s);e&&e.depth==t&&e.textOffset&&vt(e.nodeBefore,s)}function wt(n,e){return n.type.checkContent(e),n.copy(e)}function fa(n,e,t,s,o){let i=n.depth>o&&Bo(n,e,o+1),r=s.depth>o&&Bo(t,s,o+1),l=[];return Cn(null,n,o,l),i&&r&&e.index(o)==t.index(o)?(ua(i,r),vt(wt(i,fa(n,e,t,s,o+1)),l)):(i&&vt(wt(i,Cs(n,e,o+1)),l),Cn(e,t,o,l),r&&vt(wt(r,Cs(t,s,o+1)),l)),Cn(s,null,o,l),new k(l)}function Cs(n,e,t){let s=[];if(Cn(null,n,t,s),n.depth>t){let o=Bo(n,e,t+1);vt(wt(o,Cs(n,e,t+1)),s)}return Cn(e,null,t,s),new k(s)}function bu(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(k.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Rn{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],o=e.child(t);return s?e.child(t).cut(s):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let s=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=s.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return L.none;if(this.textOffset)return e.child(t).marks;let s=e.maybeChild(t-1),o=e.maybeChild(t);if(!s){let l=s;s=o,o=l}let i=s.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!o||!i[r].isInSet(o.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let s=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new xs(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let s=[],o=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(s.push(r,l,o+a),!c||(r=r.child(l),r.isText))break;i=c-1,o+=a+1}return new Rn(t,s,i)}static resolveCached(e,t){let s=ar.get(e);if(s)for(let i=0;i<s.elts.length;i++){let r=s.elts[i];if(r.pos==t)return r}else ar.set(e,s=new vu);let o=s.elts[s.i]=Rn.resolve(e,t);return s.i=(s.i+1)%wu,o}}class vu{constructor(){this.elts=[],this.i=0}}const wu=12,ar=new WeakMap;class xs{constructor(e,t,s){this.$from=e,this.$to=t,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Su=Object.create(null);let St=class Ho{constructor(e,t,s,o=L.none){this.type=e,this.attrs=t,this.marks=o,this.content=s||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,s,o=0){this.content.nodesBetween(e,t,s,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,s,o){return this.content.textBetween(e,t,s,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,s){return this.type==e&&ws(this.attrs,t||e.defaultAttrs||Su)&&L.sameSet(this.marks,s||L.none)}copy(e=null){return e==this.content?this:new Ho(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ho(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,s=!1){if(e==t)return M.empty;let o=this.resolve(e),i=this.resolve(t),r=s?0:o.sharedDepth(t),l=o.start(r),c=o.node(r).content.cut(o.pos-l,i.pos-l);return new M(c,o.depth-r,i.depth-r)}replace(e,t,s){return yu(this.resolve(e),this.resolve(t),s)}nodeAt(e){for(let t=this;;){let{index:s,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(s),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(t),index:t,offset:s};let o=this.content.child(t-1);return{node:o,index:t-1,offset:s-o.nodeSize}}resolve(e){return Rn.resolveCached(this,e)}resolveNoCache(e){return Rn.resolve(this,e)}rangeHasMark(e,t,s){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(s.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),pa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,s=k.empty,o=0,i=s.childCount){let r=this.contentMatchAt(e).matchFragment(s,o,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(s.child(a).marks))return!1;return!0}canReplaceWith(e,t,s,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(s),r=i&&i.matchFragment(this.content,t);return r?r.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=L.none;for(let t=0;t<this.marks.length;t++){let s=this.marks[t];s.type.checkAttrs(s.attrs),e=s.addToSet(e)}if(!L.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,s)}let o=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,s);return i.type.checkAttrs(i.attrs),i}};St.prototype.text=void 0;class ks extends St{constructor(e,t,s,o){if(super(e,t,null,o),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):pa(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 ks(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new ks(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 pa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new Cu(e,t);if(s.next==null)return At.empty;let o=ma(s);s.next&&s.err("Unexpected trailing text");let i=Ou(Eu(o));return Nu(i,s),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,s=e.childCount){let o=this;for(let i=t;o&&i<s;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let s=0;s<e.next.length;s++)if(this.next[t].type==e.next[s].type)return!0;return!1}fillBefore(e,t=!1,s=0){let o=[this];function i(r,l){let a=r.matchFragment(e,s);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:h}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(h)==-1){o.push(h);let u=i(h,l.concat(d));if(u)return u}}return null}return i(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let o=s.shift(),i=o.match;if(i.matchType(e)){let r=[];for(let l=o;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(s.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(s){e.push(s);for(let o=0;o<s.next.length;o++)e.indexOf(s.next[o].next)==-1&&t(s.next[o].next)}return t(this),e.map((s,o)=>{let i=o+(s.validEnd?"*":" ")+" ";for(let r=0;r<s.next.length;r++)i+=(r?", ":"")+s.next[r].type.name+"->"+e.indexOf(s.next[r].next);return i}).join(`
|
|
191
|
-
`)}}At.empty=new At(!0);class Cu{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 ma(n){let e=[];do e.push(xu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function xu(n){let e=[];do e.push(ku(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ku(n){let e=Au(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=Tu(n,e);else break;return e}function cr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Tu(n,e){let t=cr(n),s=t;return n.eat(",")&&(n.next!="}"?s=cr(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function Mu(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let o=[];for(let i in t){let r=t[i];r.isInGroup(e)&&o.push(r)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Au(n){if(n.eat("(")){let e=ma(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=Mu(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 Eu(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function s(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function o(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;o(c,l=t())}else if(r.type=="star"){let a=t();return s(l,a),o(i(r.expr,a),a),[s(a)]}else if(r.type=="plus"){let a=t();return o(i(r.expr,l),a),o(i(r.expr,a),a),[s(a)]}else{if(r.type=="opt")return[s(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();o(i(r.expr,a),d),a=d}if(r.max==-1)o(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();s(a,d),o(i(r.expr,a),d),a=d}return[s(a)]}else{if(r.type=="name")return[s(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function ga(n,e){return e-n}function dr(n,e){let t=[];return s(e),t.sort(ga);function s(o){let i=n[o];if(i.length==1&&!i[0].term)return s(i[0].to);t.push(o);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&s(a)}}}function Ou(n){let e=Object.create(null);return t(dr(n,0));function t(s){let o=[];s.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);dr(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[s.join(",")]=new At(s.indexOf(n.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(ga);i.next.push({type:o[r][0],next:e[l.join(",")]||t(l)})}return i}}function Nu(n,e){for(let t=0,s=[n];t<s.length;t++){let o=s[t],i=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),s.indexOf(c)==-1&&s.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ya(n){let e=Object.create(null);for(let t in n){let s=n[t];if(!s.hasDefault)return null;e[t]=s.default}return e}function ba(n,e){let t=Object.create(null);for(let s in n){let o=e&&e[s];if(o===void 0){let i=n[s];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+s)}t[s]=o}return t}function va(n,e,t,s){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let i=n[o];i.validate&&i.validate(e[o])}}function wa(n,e){let t=Object.create(null);if(e)for(let s in e)t[s]=new Iu(n,s,e[s]);return t}let hr=class Sa{constructor(e,t,s){this.name=e,this.schema=t,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=wa(e,s.attrs),this.defaultAttrs=ya(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.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:ba(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new St(this,this.computeAttrs(e),k.from(t),L.setFrom(s))}createChecked(e=null,t,s){return t=k.from(t),this.checkContent(t),new St(this,this.computeAttrs(e),t,L.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=k.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(k.empty,!0);return i?new St(this,e,t.append(i),L.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){va(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?t&&t.push(e[s]):t||(t=e.slice(0,s));return t?t.length?t:L.none:e}static compile(e,t){let s=Object.create(null);e.forEach((i,r)=>s[i]=new Sa(i,t,r));let o=t.spec.topNode||"doc";if(!s[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function Pu(n,e,t){let s=t.split("|");return o=>{let i=o===null?"null":typeof o;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${i}`)}}class Iu{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?Pu(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class $s{constructor(e,t,s,o){this.name=e,this.rank=t,this.schema=s,this.spec=o,this.attrs=wa(e,o.attrs),this.excluded=null;let i=ya(this.attrs);this.instance=i?new L(this,i):null}create(e=null){return!e&&this.instance?this.instance:new L(this,ba(this.attrs,e))}static compile(e,t){let s=Object.create(null),o=0;return e.forEach((i,r)=>s[i]=new $s(i,o++,t,r)),s}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){va(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ru{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=K.from(e.nodes),t.marks=K.from(e.marks||{}),this.nodes=hr.compile(this.spec.nodes,this),this.marks=$s.compile(this.spec.marks,this);let s=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=s[r]||(s[r]=At.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?ur(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:ur(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,s,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof hr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,s,o)}text(e,t){let s=this.nodes.text;return new ks(s,s.defaultAttrs,e,L.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return St.fromJSON(this,e)}markFromJSON(e){return L.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function ur(n,e){let t=[];for(let s=0;s<e.length;s++){let o=e[s],i=n.marks[o],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function Du(n){return n.tag!=null}function zu(n){return n.style!=null}class en{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(o=>{if(Du(o))this.tags.push(o);else if(zu(o)){let i=/[^=]*/.exec(o.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let s=new pr(this,t,!1);return s.addAll(e,L.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new pr(this,t,!0);return s.addAll(e,L.none,t.from,t.to),M.maxOpen(s.finish())}matchTag(e,t,s){for(let o=s?this.tags.indexOf(s)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Bu(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,s,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!s.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function s(o){let i=o.priority==null?50:o.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(r=>{s(r=mr(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(r=>{s(r=mr(r)),r.node||r.ignore||r.mark||(r.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new en(e,en.schemaRules(e)))}}const Ca={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},Vu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},xa={ol:!0,ul:!0},Ts=1,Ms=2,xn=4;function fr(n,e,t){return e!=null?(e?Ts:0)|(e==="full"?Ms:0):n&&n.whitespace=="pre"?Ts|Ms:t&~xn}class ts{constructor(e,t,s,o,i,r){this.type=e,this.attrs=t,this.marks=s,this.solid=o,this.options=r,this.content=[],this.activeMarks=L.none,this.match=i||(r&xn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,o;return(o=s.findWrapping(e.type))?(this.match=s,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ts)){let s=this.content[this.content.length-1],o;if(s&&s.isText&&(o=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ca.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class pr{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0;let o=t.topNode,i,r=fr(null,t.preserveWhitespace,0)|(s?xn:0);o?i=new ts(o.type,o.attrs,L.none,!0,t.topMatch||o.type.contentMatch,r):s?i=new ts(null,null,L.none,!0,null,r):i=new ts(e.schema.topNodeType,null,L.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,o=this.top;if(o.options&Ms||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(o.options&Ts)o.options&Ms?s=s.replace(/\r\n?/g,`
|
|
192
|
-
`):s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(s=s.slice(1))}s&&this.insertNode(this.parser.schema.text(s),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,s){let o=e.nodeName.toLowerCase(),i;
|
|
193
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let s=e.style;if(s&&s.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],r=s.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,r,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,s,o){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),s)||this.leafFallback(e,s);else{let a=this.enter(r,t.attrs||null,s,t.preserveWhitespace);a&&(i=!0,s=a)}else{let a=this.parser.schema.marks[t.mark];s=s.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(o)this.addElement(e,s,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,s));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,s),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,s,o){let i=s||0;for(let r=s?e.childNodes[s]:e.firstChild,l=o==null?null:e.childNodes[o];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let s,o;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!s||s.length>l.length)&&(s=l,o=r,!l.length)||r.solid)break}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=L.none;for(let r of s.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):gr(r.type,e.type))&&(i=r.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,s,o){let i=this.findPlace(e.create(t),s);return i&&(i=this.enterInner(e,t,s,!0,o)),i}enterInner(e,t,s,o=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=fr(e,i,r.options);r.options&xn&&r.content.length==0&&(l|=xn);let a=L.none;return s=s.filter(c=>(r.type?r.type.allowsMarkType(c.type):gr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ts(e,t,a,o,null,l)),this.open++,s}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let s=this.nodes[t].content;for(let o=s.length-1;o>=0;o--)e+=s[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==t&&(this.find[s].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,s){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(s?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),s=this.options.context,o=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(o?0:1),r=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:s&&a>=i?s.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function Lu(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&xa.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function Bu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function mr(n){let e={};for(let t in n)e[t]=n[t];return e}function gr(n,e){let t=e.schema.nodes;for(let s in t){let o=t[s];if(!o.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(o.contentMatch))return!0}}class It{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},s){s||(s=no(t).createDocumentFragment());let o=s,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(r,t))}),s}serializeNodeInner(e,t){let{dom:s,contentDOM:o}=ds(no(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return s}serializeNode(e,t={}){let s=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,t,s={}){let o=this.marks[e.type.name];return o&&ds(no(s),o(e,t),null,e.attrs)}static renderSpec(e,t,s=null,o){return ds(e,t,s,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new It(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=yr(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return yr(e.marks)}}function yr(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function no(n){return n.document||window.document}const br=new WeakMap;function Hu(n){let e=br.get(n);return e===void 0&&br.set(n,e=$u(n)),e}function $u(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let o=0;o<s.length;o++)t(s[o]);else for(let o in s)t(s[o])}return t(n),e}function ds(n,e,t,s){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(i=Hu(s))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=o.indexOf(" ");r>0&&(t=o.slice(0,r),o=o.slice(r+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let h in c)if(c[h]!=null){let u=h.indexOf(" ");u>0?a.setAttributeNS(h.slice(0,u),h.slice(u+1),c[h]):a.setAttribute(h,c[h])}}for(let h=d;h<e.length;h++){let u=e[h];if(u===0){if(h<e.length-1||h>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=ds(n,u,t,s);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const ka=65535,Ta=Math.pow(2,16);function Fu(n,e){return n+e*Ta}function vr(n){return n&ka}function Wu(n){return(n-(n&ka))/Ta}const Ma=1,Aa=2,hs=4,Ea=8;class $o{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&Ea)>0}get deletedBefore(){return(this.delInfo&(Ma|hs))>0}get deletedAfter(){return(this.delInfo&(Aa|hs))>0}get deletedAcross(){return(this.delInfo&hs)>0}}class he{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&he.empty)return he.empty}recover(e){let t=0,s=vr(e);if(!this.inverted)for(let o=0;o<s;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[s*3]+t+Wu(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,s){let o=0,i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],h=a+c;if(e<=h){let u=c?e==a?-1:e==h?1:t:t,f=a+o+(u<0?0:d);if(s)return f;let p=e==(t<0?a:h)?null:Fu(l/3,e-a),m=e==a?Aa:e==h?Ma:hs;return(t<0?e!=a:e!=h)&&(m|=Ea),new $o(f,m,p)}o+=d-c}return s?e+o:new $o(e+o,0,null)}touches(e,t){let s=0,o=vr(t),i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;s+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+s];e(l,l+c,a,a+d),i+=d-c}}invert(){return new he(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?he.empty:new he(e<0?[0,-e,0]:[0,0,e])}}he.empty=new he([]);class Jt{constructor(e=[],t,s=0,o=e.length){this.maps=e,this.mirror=t,this.from=s,this.to=o}slice(e=0,t=this.maps.length){return new Jt(this.maps,this.mirror,e,t)}copy(){return new Jt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,s=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?s+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,s=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?s-o-1:void 0)}}invert(){let e=new Jt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;s<this.to;s++)e=this.maps[s].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,s){let o=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return s?e:new $o(e,o,null)}}const so=Object.create(null);class ee{getMap(){return he.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=so[t.stepType];if(!s)throw new RangeError(`No step type ${t.stepType} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in so)throw new RangeError("Duplicate use of step JSON ID "+e);return so[e]=t,t.prototype.jsonID=e,t}}class _{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new _(e,null)}static fail(e){return new _(null,e)}static fromReplace(e,t,s,o){try{return _.ok(e.replace(t,s,o))}catch(i){if(i instanceof Ss)return _.fail(i.message);throw i}}}function pi(n,e,t){let s=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(pi(i.content,e,i))),i.isInline&&(i=e(i,t,o)),s.push(i)}return k.fromArray(s)}class Xe extends ee{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=e.resolve(this.from),o=s.node(s.sharedDepth(this.to)),i=new M(pi(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),o),t.openStart,t.openEnd);return _.fromReplace(e,this.from,this.to,i)}invert(){return new Ee(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Xe(t.pos,s.pos,this.mark)}merge(e){return e instanceof Xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xe(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 Xe(t.from,t.to,e.markFromJSON(t.mark))}}ee.jsonID("addMark",Xe);class Ee extends ee{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new M(pi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return _.fromReplace(e,this.from,this.to,s)}invert(){return new Xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Ee(t.pos,s.pos,this.mark)}merge(e){return e instanceof Ee&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ee(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 Ee(t.from,t.to,e.markFromJSON(t.mark))}}ee.jsonID("removeMark",Ee);class Qe extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return _.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return _.fromReplace(e,this.pos,this.pos+1,new M(k.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(s))return new Qe(this.pos,t.marks[o]);return new Qe(this.pos,this.mark)}}return new tn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Qe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Qe(t.pos,e.markFromJSON(t.mark))}}ee.jsonID("addNodeMark",Qe);class tn extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return _.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return _.fromReplace(e,this.pos,this.pos+1,new M(k.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new tn(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 tn(t.pos,e.markFromJSON(t.mark))}}ee.jsonID("removeNodeMark",tn);class X extends ee{constructor(e,t,s,o=!1){super(),this.from=e,this.to=t,this.slice=s,this.structure=o}apply(e){return this.structure&&Fo(e,this.from,this.to)?_.fail("Structure replace would overwrite content"):_.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new he([this.from,this.to-this.from,this.slice.size])}invert(e){return new X(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deletedAcross&&s.deletedAcross?null:new X(t.pos,Math.max(t.pos,s.pos),this.slice)}merge(e){if(!(e instanceof X)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?M.empty:new M(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new X(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?M.empty:new M(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new X(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 X(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}ee.jsonID("replace",X);class Z extends ee{constructor(e,t,s,o,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=s,this.gapTo=o,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(Fo(e,this.from,this.gapFrom)||Fo(e,this.gapTo,this.to)))return _.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return _.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,t.content);return s?_.fromReplace(e,this.from,this.to,s):_.fail("Content does not fit in gap")}getMap(){return new he([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 Z(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return t.deletedAcross&&s.deletedAcross||o<t.pos||i>s.pos?null:new Z(t.pos,s.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Z(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}}ee.jsonID("replaceAround",Z);function Fo(n,e,t){let s=n.resolve(e),o=t-e,i=s.depth;for(;o>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,o--;if(o>0){let r=s.node(i).maybeChild(s.indexAfter(i));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function _u(n,e,t,s){let o=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let h=a.marks;if(!s.isInSet(h)&&d.type.allowsMarkType(s.type)){let u=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=s.addToSet(h);for(let m=0;m<h.length;m++)h[m].isInSet(p)||(r&&r.to==u&&r.mark.eq(h[m])?r.to=f:o.push(r=new Ee(u,f,h[m])));l&&l.to==u?l.to=f:i.push(l=new Xe(u,f,s))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function qu(n,e,t,s){let o=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(s instanceof $s){let c=r.marks,d;for(;d=s.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else s?s.isInSet(r.marks)&&(a=[s]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let h=a[d],u;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&h.eq(o[f].style)&&(u=p)}u?(u.to=c,u.step=i):o.push({style:h,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(r=>n.step(new Ee(r.from,r.to,r.style)))}function mi(n,e,t,s=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,h=s.matchType(c.type);if(!h)r.push(new X(l,d,M.empty));else{s=h;for(let u=0;u<c.marks.length;u++)t.allowsMarkType(c.marks[u].type)||n.step(new Ee(l,d,c.marks[u]));if(o&&c.isText&&t.whitespace!="pre"){let u,f=/\r?\n|\r/g,p;for(;u=f.exec(c.text);)p||(p=new M(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new X(l+u.index,l+u.index+u[0].length,p))}}l=d}if(!s.validEnd){let a=s.fillBefore(k.empty,!0);n.replace(l,l,new M(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function Gu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Fs(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth;;--s){let o=n.$from.node(s),i=n.$from.index(s),r=n.$to.indexAfter(s);if(s<n.depth&&o.canReplace(i,r,t))return s;if(s==0||o.type.spec.isolating||!Gu(o,i,r))break}return null}function ju(n,e,t){let{$from:s,$to:o,depth:i}=e,r=s.before(i+1),l=o.after(i+1),a=r,c=l,d=k.empty,h=0;for(let p=i,m=!1;p>t;p--)m||s.index(p)>0?(m=!0,d=k.from(s.node(p).copy(d)),h++):a--;let u=k.empty,f=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,u=k.from(o.node(p).copy(u)),f++):c++;n.step(new Z(a,c,r,l,new M(d.append(u),h,f),d.size-h,!0))}function Oa(n,e,t=null,s=n){let o=Ku(n,e),i=o&&Ju(s,e);return i?o.map(wr).concat({type:e,attrs:t}).concat(i.map(wr)):null}function wr(n){return{type:n,attrs:null}}function Ku(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.contentMatchAt(s).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(s,o,r)?i:null}function Ju(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.child(s),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=s;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function Uu(n,e,t){let s=k.empty;for(let r=t.length-1;r>=0;r--){if(s.size){let l=t[r].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=k.from(t[r].type.create(t[r].attrs,s))}let o=e.start,i=e.end;n.step(new Z(o,i,o,i,new M(s,0,0),t.length,!0))}function Zu(n,e,t,s,o){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(s,a)&&Yu(n.doc,n.mapping.slice(i).map(l),s)){let c=null;if(s.schema.linebreakReplacement){let f=s.whitespace=="pre",p=!!s.contentMatch.matchType(s.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Pa(n,r,l,i),mi(n,n.mapping.slice(i).map(l,1),s,void 0,c===null);let d=n.mapping.slice(i),h=d.map(l,1),u=d.map(l+r.nodeSize,1);return n.step(new Z(h,u,h+1,u-1,new M(k.from(s.create(a,null,r.marks)),0,0),1,!0)),c===!0&&Na(n,r,l,i),!1}})}function Na(n,e,t,s){e.forEach((o,i)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=n.mapping.slice(s).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Pa(n,e,t,s){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let r=n.mapping.slice(s).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
|
|
194
|
-
`))}})}function Yu(n,e,t){let s=n.resolve(e),o=s.index();return s.parent.canReplaceWith(o,o+1,t)}function Xu(n,e,t,s,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(s,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Z(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new M(k.from(r),0,0),1,!0))}function Ut(n,e,t=1,s){let o=n.resolve(e),i=o.depth-t,r=s&&s[s.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!r.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>i;c--,d--){let h=o.node(c),u=o.index(c);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(u,h.childCount),p=s&&s[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=s&&s[d]||h;if(!h.canReplace(u+1,h.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=s&&s[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Qu(n,e,t=1,s){let o=n.doc.resolve(e),i=k.empty,r=k.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=k.from(o.node(l).copy(i));let d=s&&s[c];r=k.from(d?d.type.create(d.attrs,r):o.node(l).copy(r))}n.step(new X(e,e,new M(i.append(r),t,t),!0))}function Ws(n,e){let t=n.resolve(e),s=t.index();return tf(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function ef(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),r=i.type==s?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function tf(n,e){return!!(n&&e&&!n.isLeaf&&ef(n,e))}function nf(n,e,t){let s=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(o&&r.inlineContent){let d=r.whitespace=="pre",h=!!r.contentMatch.matchType(o);d&&!h?s=!1:!d&&h&&(s=!0)}let l=n.steps.length;if(s===!1){let d=n.doc.resolve(e+t);Pa(n,d.node(),d.before(),l)}r.inlineContent&&mi(n,e+t-1,r,i.node().contentMatchAt(i.index()),s==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new X(c,a.map(e+t,-1),M.empty,!0)),s===!0){let d=n.doc.resolve(c);Na(n,d.node(),d.before(),n.steps.length)}return n}function sf(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let o=s.depth-1;o>=0;o--){let i=s.index(o);if(s.node(o).canReplaceWith(i,i,t))return s.before(o+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let o=s.depth-1;o>=0;o--){let i=s.indexAfter(o);if(s.node(o).canReplaceWith(i,i,t))return s.after(o+1);if(i<s.node(o).childCount)return null}return null}function of(n,e,t){let s=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=s.depth;r>=0;r--){let l=r==s.depth?0:s.pos<=(s.start(r+1)+s.end(r+1))/2?-1:1,a=s.index(r)+(l>0?1:0),c=s.node(r),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let h=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=h&&c.canReplaceWith(a,a,h[0])}if(d)return l==0?s.pos:l<0?s.before(r+1):s.after(r+1)}return null}function gi(n,e,t=e,s=M.empty){if(e==t&&!s.size)return null;let o=n.resolve(e),i=n.resolve(t);return Ia(o,i,s)?new X(e,t,s):new rf(o,i,s).fit()}function Ia(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class rf{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=k.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=k.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,s=this.$from,o=this.close(e<0?this.$to:s.doc.resolve(e));if(!o)return null;let i=this.placed,r=s.depth,l=o.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new M(i,r,l);return e>-1?new Z(s.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||s.pos!=this.$to.pos?new X(s.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,o=this.unplaced.openEnd;s<e;s++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=s){e=s;break}t=i.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let o,i=null;s?(i=oo(this.unplaced.content,s-1).firstChild,o=i.content):o=this.unplaced.content;let r=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,h=null;if(t==1&&(r?c.matchType(r.type)||(h=c.fillBefore(k.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:l,parent:i,inject:h};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:s,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=oo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(s,o.size+t>=e.size-s?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=oo(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new M(gn(e,t-1,1),t-1,i?t-1:s)}else this.unplaced=new M(gn(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=s?s.content:r.content,a=r.openStart-e,c=0,d=[],{match:h,type:u}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));h=h.matchFragment(o)}let f=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=h.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(h=g,d.push(Ra(m.mark(u.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=yn(this.placed,t,k.from(d)),this.frontier[t].match=h,p&&f<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?M.empty:new M(gn(r.content,e-1,1),e-1,f<0?r.openEnd:e-1):new M(gn(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||!io(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:s}=this.$to,o=this.$to.after(s);for(;s>1&&o==this.$to.end(--s);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=io(e,t,o,s,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=io(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=yn(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let o=e.node(s),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(s));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,s){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=yn(this.placed,this.depth,k.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=yn(this.placed,this.frontier.length,t))}}function gn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(gn(n.firstChild.content,e-1,t)))}function yn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(yn(n.lastChild.content,e-1,t)))}function oo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ra(n,e,t){if(e<=0)return n;let s=n.content;return e>1&&(s=s.replaceChild(0,Ra(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore(k.empty,!0)))),n.copy(s)}function io(n,e,t,s,o){let i=n.node(e),r=o?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=s.fillBefore(i.content,!0,r);return l&&!lf(t,i.content,r)?l:null}function lf(n,e,t){for(let s=t;s<e.childCount;s++)if(!n.allowsMarks(e.child(s).marks))return!0;return!1}function af(n){return n.spec.defining||n.spec.definingForContent}function cf(n,e,t,s){if(!s.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(Ia(o,i,s))return n.step(new X(e,t,s));let r=za(o,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let u=o.depth,f=o.pos-1;u>0;u--,f--){let p=o.node(u).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(u)>-1?l=u:o.before(u)==f&&r.splice(1,0,-u)}let a=r.indexOf(l),c=[],d=s.openStart;for(let u=s.content,f=0;;f++){let p=u.firstChild;if(c.push(p),f==s.openStart)break;u=p.content}for(let u=d-1;u>=0;u--){let f=c[u],p=af(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=u;else if(p||!f.type.isTextblock)break}for(let u=s.openStart;u>=0;u--){let f=(u+d+1)%(s.openStart+1),p=c[f];if(p)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let C=o.node(g-1),y=o.index(g-1);if(C.canReplaceWith(y,y,p.type,p.marks))return n.replace(o.before(g),b?i.after(g):t,new M(Da(s.content,0,s.openStart,f),f,s.openEnd))}}let h=n.steps.length;for(let u=r.length-1;u>=0&&(n.replace(e,t,s),!(n.steps.length>h));u--){let f=r[u];f<0||(e=o.before(f),t=i.after(f))}}function Da(n,e,t,s,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(Da(i.content,e+1,t,s,i)))}if(e>s){let i=o.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(k.empty,!0))}return n}function df(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=sf(n.doc,e,s.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new M(k.from(s),0,0))}function hf(n,e,t){let s=n.doc.resolve(e),o=n.doc.resolve(t),i=za(s,o);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||s.node(l).type.contentMatch.validEnd)return n.delete(s.start(l),o.end(l));if(l>0&&(a||s.node(l-1).canReplace(s.index(l-1),o.indexAfter(l-1))))return n.delete(s.before(l),o.after(l))}for(let r=1;r<=s.depth&&r<=o.depth;r++)if(e-s.start(r)==s.depth-r&&t>s.end(r)&&o.end(r)-t!=o.depth-r&&s.start(r-1)==o.start(r-1)&&s.node(r-1).canReplace(s.index(r-1),o.index(r-1)))return n.delete(s.before(r),t);n.delete(e,t)}function za(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let o=s;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class Zt extends ee{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return _.fail("No node at attribute step's position");let s=Object.create(null);for(let i in t.attrs)s[i]=t.attrs[i];s[this.attr]=this.value;let o=t.type.create(s,null,t.marks);return _.fromReplace(e,this.pos,this.pos+1,new M(k.from(o),0,t.isLeaf?0:1))}getMap(){return he.empty}invert(e){return new Zt(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 Zt(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 Zt(t.pos,t.attr,t.value)}}ee.jsonID("attr",Zt);class Dn extends ee{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return _.ok(s)}getMap(){return he.empty}invert(e){return new Dn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Dn(t.attr,t.value)}}ee.jsonID("docAttr",Dn);let nn=class extends Error{};nn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};nn.prototype=Object.create(Error.prototype);nn.prototype.constructor=nn;nn.prototype.name="TransformError";class Va{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new nn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,s=M.empty){let o=gi(this.doc,e,t,s);return o&&this.step(o),this}replaceWith(e,t,s){return this.replace(e,t,new M(k.from(s),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return cf(this,e,t,s),this}replaceRangeWith(e,t,s){return df(this,e,t,s),this}deleteRange(e,t){return hf(this,e,t),this}lift(e,t){return ju(this,e,t),this}join(e,t=1){return nf(this,e,t),this}wrap(e,t){return Uu(this,e,t),this}setBlockType(e,t=e,s,o=null){return Zu(this,e,t,s,o),this}setNodeMarkup(e,t,s=null,o){return Xu(this,e,t,s,o),this}setNodeAttribute(e,t,s){return this.step(new Zt(e,t,s)),this}setDocAttribute(e,t){return this.step(new Dn(e,t)),this}addNodeMark(e,t){return this.step(new Qe(e,t)),this}removeNodeMark(e,t){if(!(t instanceof L)){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t=t.isInSet(s.marks),!t)return this}return this.step(new tn(e,t)),this}split(e,t=1,s){return Qu(this,e,t,s),this}addMark(e,t,s){return _u(this,e,t,s),this}removeMark(e,t,s){return qu(this,e,t,s),this}clearIncompatible(e,t,s){return mi(this,e,t,s),this}}const ro=Object.create(null);class I{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new La(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=M.empty){let s=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=s,s=s.lastChild;let i=e.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:a,$to:c}=r[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?M.empty:t),l==0&&xr(e,i,(s?s.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:r,$to:l}=o[i],a=e.mapping.slice(s),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),xr(e,s,t.isInline?-1:1))}}static findFrom(e,t,s=!1){let o=e.parent.inlineContent?new R(e):$t(e.node(0),e.parent,e.pos,e.index(),t,s);if(o)return o;for(let i=e.depth-1;i>=0;i--){let r=t<0?$t(e.node(0),e.node(i),e.before(i+1),e.index(i),t,s):$t(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,s);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fe(e.node(0))}static atStart(e){return $t(e,e,0,0,1)||new fe(e)}static atEnd(e){return $t(e,e,e.content.size,e.childCount,-1)||new fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=ro[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in ro)throw new RangeError("Duplicate use of selection JSON ID "+e);return ro[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class La{constructor(e,t){this.$from=e,this.$to=t}}let Sr=!1;function Cr(n){!Sr&&!n.parent.inlineContent&&(Sr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class R extends I{constructor(e,t=e){Cr(e),Cr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return I.near(s);let o=e.resolve(t.map(this.anchor));return new R(o.parent.inlineContent?o:s,s)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new _s(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new R(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let o=e.resolve(t);return new this(o,s==t?o:e.resolve(s))}static between(e,t,s){let o=e.pos-t.pos;if((!s||o)&&(s=o>=0?1:-1),!t.parent.inlineContent){let i=I.findFrom(t,s,!0)||I.findFrom(t,-s,!0);if(i)t=i.$head;else return I.near(t,s)}return e.parent.inlineContent||(o==0?e=t:(e=(I.findFrom(e,-s,!0)||I.findFrom(e,s,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new R(e,t)}}I.jsonID("text",R);class _s{constructor(e,t){this.anchor=e,this.head=t}map(e){return new _s(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class N extends I{constructor(e){let t=e.nodeAfter,s=e.node(0).resolve(e.pos+t.nodeSize);super(e,s),this.node=t}map(e,t){let{deleted:s,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return s?I.near(i):new N(i)}content(){return new M(k.from(this.node),0,0)}eq(e){return e instanceof N&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new yi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new N(e.resolve(t.anchor))}static create(e,t){return new N(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}N.prototype.visible=!1;I.jsonID("node",N);class yi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:s}=e.mapResult(this.anchor);return t?new _s(s,s):new yi(s)}resolve(e){let t=e.resolve(this.anchor),s=t.nodeAfter;return s&&N.isSelectable(s)?new N(t):I.near(t)}}class fe extends I{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=M.empty){if(t==M.empty){e.delete(0,e.doc.content.size);let s=I.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new fe(e)}map(e){return new fe(e)}eq(e){return e instanceof fe}getBookmark(){return uf}}I.jsonID("all",fe);const uf={map(){return this},resolve(n){return new fe(n)}};function $t(n,e,t,s,o,i=!1){if(e.inlineContent)return R.create(n,t);for(let r=s-(o>0?0:1);o>0?r<e.childCount:r>=0;r+=o){let l=e.child(r);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(n,t-(o<0?l.nodeSize:0))}else{let a=$t(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function xr(n,e,t){let s=n.steps.length-1;if(s<e)return;let o=n.steps[s];if(!(o instanceof X||o instanceof Z))return;let i=n.mapping.maps[s],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(I.near(n.doc.resolve(r),t))}const kr=1,ns=2,Tr=4;class ff extends Va{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|kr)&~ns,this.storedMarks=null,this}get selectionSet(){return(this.updated&kr)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ns,this}ensureMarks(e){return L.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ns)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ns,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||L.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),s=s??t,!e)return this.deleteRange(t,s);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=s==t?r.marks():r.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,o.text(e,i)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Tr,this}get scrolledIntoView(){return(this.updated&Tr)>0}}function Mr(n,e){return!e||!n?n:n.bind(e)}class bn{constructor(e,t,s){this.name=e,this.init=Mr(t.init,s),this.apply=Mr(t.apply,s)}}const pf=[new bn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new bn("selection",{init(n,e){return n.selection||I.atStart(e.doc)},apply(n){return n.selection}}),new bn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new bn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class lo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pf.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new bn(s.key,s.spec.state,s))})}}class qt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let s=0;s<this.config.plugins.length;s++)if(s!=t){let o=this.config.plugins[s];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],s=this.applyInner(e),o=null;for(;;){let i=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=o?o[r].n:0,c=o?o[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,s);if(d&&s.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let h=0;h<this.config.plugins.length;h++)o.push(h<r?{state:s,n:t.length}:{state:this,n:0})}t.push(d),s=s.applyInner(d),i=!0}o&&(o[r]={state:s,n:t.length})}}if(!i)return{state:s,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new qt(this.config),s=this.config.fields;for(let o=0;o<s.length;o++){let i=s[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new ff(this)}static create(e){let t=new lo(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new qt(t);for(let o=0;o<t.fields.length;o++)s[t.fields[o].name]=t.fields[o].init(e,s);return s}reconfigure(e){let t=new lo(this.schema,e.plugins),s=t.fields,o=new qt(t);for(let i=0;i<s.length;i++){let r=s[i].name;o[r]=this.hasOwnProperty(r)?this[r]:s[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[s],i=o.spec.state;i&&i.toJSON&&(t[s]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new lo(e.schema,e.plugins),i=new qt(o);return o.fields.forEach(r=>{if(r.name=="doc")i.doc=St.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=I.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let a=s[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function Ba(n,e,t){for(let s in n){let o=n[s];o instanceof Function?o=o.bind(e):s=="handleDOMEvents"&&(o=Ba(o,e,{})),t[s]=o}return t}class $n{constructor(e){this.spec=e,this.props={},e.props&&Ba(e.props,this,this.props),this.key=e.key?e.key.key:Ha("plugin")}getState(e){return e[this.key]}}const ao=Object.create(null);function Ha(n){return n in ao?n+"$"+ ++ao[n]:(ao[n]=0,n+"$")}class Fn{constructor(e="key"){this.key=Ha(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const $a=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function mf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const gf=(n,e,t)=>{let s=mf(n,t);if(!s)return!1;let o=Fa(s);if(!o){let r=s.blockRange(),l=r&&Fs(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Ka(n,o,e,-1))return!0;if(s.parent.content.size==0&&(sn(i,"end")||N.isSelectable(i)))for(let r=s.depth;;r--){let l=gi(n.doc,s.before(r),s.after(r),M.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(sn(i,"end")?I.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):N.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||s.node(r-1).childCount>1)break}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function sn(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const yf=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;i=Fa(s)}let r=i&&i.nodeBefore;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function 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 bf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const vf=(n,e,t)=>{let s=bf(n,t);if(!s)return!1;let o=Wa(s);if(!o)return!1;let i=o.nodeAfter;if(Ka(n,o,e,1))return!0;if(s.parent.content.size==0&&(sn(i,"start")||N.isSelectable(i))){let r=gi(n.doc,s.before(),s.after(),M.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(sn(i,"start")?I.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):N.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},wf=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset<s.parent.content.size)return!1;i=Wa(s)}let r=i&&i.nodeAfter;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos)).scrollIntoView()),!0)};function Wa(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 Sf=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(`
|
|
195
|
-
`).scrollIntoView()),!0)};function 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 _a=(n,e)=>{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let o=t.node(-1),i=t.indexAfter(-1),r=bi(o.contentMatchAt(i));if(!r||!o.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Cf=(n,e)=>{let t=n.selection,{$from:s,$to:o}=t;if(t instanceof fe||s.parent.inlineContent||o.parent.inlineContent)return!1;let i=bi(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!s.parentOffset&&o.index()<o.parent.childCount?s:o).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection(R.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},qa=(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(Ut(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let s=t.blockRange(),o=s&&Fs(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)};function Ga(n){return(e,t)=>{let{$from:s,$to:o}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!s.parentOffset||!Ut(e.doc,s.pos)?!1:(t&&t(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let f=s.depth;;f--)if(s.node(f).isBlock){a=s.end(f)==s.pos+(s.depth-f),c=s.start(f)==s.pos-(s.depth-f),l=bi(s.node(f-1).contentMatchAt(s.indexAfter(f-1)));let m=n&&n(o.parent,a,s);i.unshift(m||(a&&l?{type:l}:null)),r=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof fe)&&d.deleteSelection();let h=d.mapping.map(s.pos),u=Ut(d.doc,h,i.length,i);if(u||(i[0]=l?{type:l}:null,u=Ut(d.doc,h,i.length,i)),d.split(h,i.length,i),!a&&c&&s.node(r).type!=l){let f=d.mapping.map(s.before(r)),p=d.doc.resolve(f);l&&s.node(r-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(s.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const xf=Ga(),ja=(n,e)=>(e&&e(n.tr.setSelection(new fe(n.doc))),!0);function kf(n,e,t){let s=e.nodeBefore,o=e.nodeAfter,i=e.index();return!s||!o||!s.type.compatibleContent(o.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Ws(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Ka(n,e,t,s){let o=e.nodeBefore,i=e.nodeAfter,r,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&kf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,p=k.empty;for(let b=r.length-1;b>=0;b--)p=k.from(r[b].create(null,p));p=k.from(o.copy(p));let m=n.tr.step(new Z(e.pos-1,f,e.pos,f,new M(p,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Ws(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||s>0&&a?null:I.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),u=h&&Fs(h);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(h,u).scrollIntoView()),!0;if(c&&sn(i,"start",!0)&&sn(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let b=k.empty;for(let y=p.length-1;y>=0;y--)b=k.from(p[y].copy(b));let C=n.tr.step(new Z(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new M(b,p.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function Ja(n){return function(e,t){let s=e.selection,o=n<0?s.$from:s.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const Tf=Ja(-1),Mf=Ja(1);function Af(n,e=null){return function(t,s){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),h=d.index();o=d.parent.canReplaceWith(h,h+1,n)}})}if(!o)return!1;if(s){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}s(i.scrollIntoView())}return!0}}function Ef(n,e,t,s){for(let o=0;o<e.length;o++){let{$from:i,$to:r}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!s)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ut(n,e=null,t){let s=t!==!1;return function(o,i){let{empty:r,$cursor:l,ranges:a}=o.selection;if(r&&!l||!Ef(o.doc,a,n,s))return!1;if(i)if(l)n.isInSet(o.storedMarks||l.marks())?i(o.tr.removeStoredMark(n)):i(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(h=>o.doc.rangeHasMark(h.$from.pos,h.$to.pos,n));for(let h=0;h<a.length;h++){let{$from:u,$to:f}=a[h];if(!c)d.removeMark(u.pos,f.pos,n);else{let p=u.pos,m=f.pos,g=u.nodeAfter,b=f.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;p+C<m&&(p+=C,m-=y),d.addMark(p,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function zn(...n){return function(e,t,s){for(let o=0;o<n.length;o++)if(n[o](e,t,s))return!0;return!1}}let co=zn($a,gf,yf),Ar=zn($a,vf,wf);const Be={Enter:zn(Sf,Cf,qa,xf),"Mod-Enter":_a,Backspace:co,"Mod-Backspace":co,"Shift-Backspace":co,Delete:Ar,"Mod-Delete":Ar,"Mod-a":ja},Ua={"Ctrl-h":Be.Backspace,"Alt-Backspace":Be["Mod-Backspace"],"Ctrl-d":Be.Delete,"Ctrl-Alt-Backspace":Be["Mod-Delete"],"Alt-Delete":Be["Mod-Delete"],"Alt-d":Be["Mod-Delete"],"Ctrl-a":Tf,"Ctrl-e":Mf};for(let n in Be)Ua[n]=Be[n];const Of=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Nf=Of?Ua:Be;var As=200,q=function(){};q.prototype.append=function(e){return e.length?(e=q.from(e),!this.length&&e||e.length<As&&this.leafAppend(e)||this.length<As&&e.leafPrepend(this)||this.appendInner(e)):this};q.prototype.prepend=function(e){return e.length?q.from(e).append(this):this};q.prototype.appendInner=function(e){return new Pf(this,e)};q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};q.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};q.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var o=[];return this.forEach(function(i,r){return o.push(e(i,r))},t,s),o};q.from=function(e){return e instanceof q?e:e&&e.length?new Za(e):q.empty};var Za=function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,r,l){for(var a=i;a<r;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,l){for(var a=i-1;a>=r;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=As)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=As)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(q);q.empty=new Za([]);var Pf=function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,o,i,r){var l=this.left.length;if(o<l&&this.left.forEachInner(s,o,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(s,Math.max(o-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,r){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(s,o-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(s,Math.min(o,l),i,r)===!1)return!1},e.prototype.sliceInner=function(s,o){if(s==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(s,o):s>=i?this.right.slice(s-i,o-i):this.left.slice(s,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(s){var o=this.right.leafAppend(s);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(s){var o=this.left.leafPrepend(s);if(o)return new e(o,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e}(q);const If=500;class xe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let o,i;t&&(o=this.remapping(s,this.items.length),i=o.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((h,u)=>{if(!h.step){o||(o=this.remapping(s,u+1),i=o.maps.length),i--,d.push(h);return}if(o){d.push(new Ae(h.map));let f=h.step.map(o.slice(i)),p;f&&r.maybeStep(f).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new Ae(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else r.maybeStep(h.step);if(h.selection)return l=o?h.selection.map(o.slice(i)):h.selection,a=new xe(this.items.slice(0,s).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,s,o){let i=[],r=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let h=e.steps[d].invert(e.docs[d]),u=new Ae(e.mapping.maps[d],h,t),f;(f=a&&a.merge(u))&&(u=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(u),t&&(r++,t=void 0),o||(a=u)}let c=r-s.depth;return c>Df&&(l=Rf(l,c),r-=c),new xe(l.append(i),r)}remapping(e,t){let s=new Jt;return this.items.forEach((o,i)=>{let r=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?s.maps.length-o.mirrorOffset:void 0;s.appendMap(o.map,r)},e,t),s}addMaps(e){return this.eventCount==0?this:new xe(this.items.append(e.map(t=>new Ae(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let s=[],o=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(u=>{u.selection&&l--},o);let a=t;this.items.forEach(u=>{let f=i.getMirror(--a);if(f==null)return;r=Math.min(r,f);let p=i.maps[f];if(u.step){let m=e.steps[f].invert(e.docs[f]),g=u.selection&&u.selection.map(i.slice(a+1,f));g&&l++,s.push(new Ae(p,m,g))}else s.push(new Ae(p))},o);let c=[];for(let u=t;u<r;u++)c.push(new Ae(i.maps[u]));let d=this.items.slice(0,o).append(c).append(s),h=new xe(d,l);return h.emptyItemCount()>If&&(h=h.compress(this.items.length-s.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,o=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)o.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(s)),c=a&&a.getMap();if(s--,c&&t.appendMap(c,s),a){let d=r.selection&&r.selection.map(t.slice(s));d&&i++;let h=new Ae(c.invert(),a,d),u,f=o.length-1;(u=o.length&&o[f].merge(h))?o[f]=u:o.push(h)}}else r.map&&s--},this.items.length,0),new xe(q.from(o.reverse()),i)}}xe.empty=new xe(q.empty,0);function Rf(n,e){let t;return n.forEach((s,o)=>{if(s.selection&&e--==0)return t=o,!1}),n.slice(t)}class Ae{constructor(e,t,s,o){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ae(t.getMap().invert(),t,this.selection)}}}class je{constructor(e,t,s,o,i){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=o,this.prevComposition=i}}const Df=20;function zf(n,e,t,s){let o=t.getMeta(Ct),i;if(o)return o.historyState;t.getMeta(Bf)&&(n=new je(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(Ct))return r.getMeta(Ct).redo?new je(n.done.addTransform(t,void 0,s,us(e)),n.undone,Er(t.mapping.maps),n.prevTime,n.prevComposition):new je(n.done,n.undone.addTransform(t,void 0,s,us(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!r&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-s.newGroupDelay||!Vf(t,n.prevRanges)),c=r?ho(n.prevRanges,t.mapping):Er(t.mapping.maps);return new je(n.done.addTransform(t,a?e.selection.getBookmark():void 0,s,us(e)),xe.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new je(n.done.rebased(t,i),n.undone.rebased(t,i),ho(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new je(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),ho(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Vf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,o)=>{for(let i=0;i<e.length;i+=2)s<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function Er(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,o,i,r)=>e.push(i,r));return e}function ho(n,e){if(!n)return null;let t=[];for(let s=0;s<n.length;s+=2){let o=e.map(n[s],1),i=e.map(n[s+1],-1);o<=i&&t.push(o,i)}return t}function Lf(n,e,t){let s=us(e),o=Ct.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,s);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,s),a=new je(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(Ct,{redo:t,historyState:a})}let uo=!1,Or=null;function us(n){let e=n.plugins;if(Or!=e){uo=!1,Or=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){uo=!0;break}}return uo}const Ct=new Fn("history"),Bf=new Fn("closeHistory");function Hf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new $n({key:Ct,state:{init(){return new je(xe.empty,xe.empty,null,0,-1)},apply(e,t,s){return zf(t,s,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let s=t.inputType,o=s=="historyUndo"?Xa:s=="historyRedo"?Wo:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function Ya(n,e){return(t,s)=>{let o=Ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(s){let i=Lf(o,t,n);i&&s(e?i.scrollIntoView():i)}return!0}}const Xa=Ya(!1,!0),Wo=Ya(!0,!0);var ot={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:"'"},Es={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},$f=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ff=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var J=0;J<10;J++)ot[48+J]=ot[96+J]=String(J);for(var J=1;J<=24;J++)ot[J+111]="F"+J;for(var J=65;J<=90;J++)ot[J]=String.fromCharCode(J+32),Es[J]=String.fromCharCode(J);for(var fo in ot)Es.hasOwnProperty(fo)||(Es[fo]=ot[fo]);function Wf(n){var e=$f&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ff&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Es:ot)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const _f=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function qf(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,o,i,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))s=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))_f?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(t="Alt-"+t),o&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Gf(n){let e=Object.create(null);for(let t in n)e[qf(t)]=n[t];return e}function po(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 mo(n){return new $n({props:{handleKeyDown:Qa(n)}})}function Qa(n){let e=Gf(n);return function(t,s){let o=Wf(s),i,r=e[po(o,s)];if(r&&r(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(s.shiftKey){let l=e[po(o,s,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((s.shiftKey||s.altKey||s.metaKey||o.charCodeAt(0)>127)&&(i=ot[s.keyCode])&&i!=o){let l=e[po(i,s)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Nr(n,e=null){return function(t,s){let{$from:o,$to:i}=t.selection,r=o.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&o.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(o.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new xs(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new xs(o,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=Oa(a,n,e,r);return c?(s&&s(jf(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function jf(n,e,t,s,o){let i=k.empty;for(let d=t.length-1;d>=0;d--)i=k.from(t[d].type.create(t[d].attrs,i));n.step(new Z(e.start-(s?2:0),e.end,e.start,e.end,new M(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==o&&(r=d+1);let l=t.length-r,a=e.start+t.length-(s?2:0),c=e.parent;for(let d=e.startIndex,h=e.endIndex,u=!0;d<h;d++,u=!1)!u&&Ut(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function Kf(n,e){return function(t,s){let{$from:o,$to:i,node:r}=t.selection;if(r&&r.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(s){let h=k.empty,u=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-u;b>=o.depth-3;b--)h=k.from(o.node(b).copy(h));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;h=h.append(k.from(n.createAndFill()));let p=o.before(o.depth-(u-1)),m=t.tr.replace(p,o.after(-f),new M(h,4-u,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(I.near(m.doc.resolve(g))),s(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),d=a?[null,{type:a}]:void 0;return Ut(c.doc,o.pos,2,d)?(s&&s(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function _o(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,r=>r.childCount>0&&r.firstChild.type==n);return i?t?s.node(i.depth-1).type==n?Jf(e,t,n,i):Uf(e,t,i):!0:!1}}function Jf(n,e,t,s){let o=n.tr,i=s.end,r=s.$to.end(s.depth);i<r&&(o.step(new Z(i-1,r,i,r,new M(k.from(t.create(null,s.parent.copy())),1,0),1,!0)),s=new xs(o.doc.resolve(s.$from.pos),o.doc.resolve(r),s.depth));const l=Fs(s);if(l==null)return!1;o.lift(s,l);let a=o.mapping.map(i,-1)-1;return Ws(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Uf(n,e,t){let s=n.tr,o=t.parent;for(let f=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)f-=o.child(p).nodeSize,s.delete(f-1,f+1);let i=s.doc.resolve(t.start),r=i.nodeAfter;if(s.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?k.empty:k.from(o))))return!1;let h=i.pos,u=h+r.nodeSize;return s.step(new Z(h-(l?1:0),u+(a?1:0),h+1,u-1,new M((l?k.empty:k.from(o.copy(k.empty))).append(a?k.empty:k.from(o.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(s.scrollIntoView()),!0}function Zf(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?n.create():null),h=new M(k.from(n.create(null,k.from(l.type.create(null,d)))),c?3:1,0),u=i.start,f=i.end;t(e.tr.step(new Z(u-(c?3:1),f,u,f,h,1,!0)).scrollIntoView())}return!0}}const U=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Vn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let qo=null;const Le=function(n,e,t){let s=qo||(qo=document.createRange());return s.setEnd(n,t??n.nodeValue.length),s.setStart(n,e||0),s},Yf=function(){qo=null},Et=function(n,e,t,s){return t&&(Pr(n,e,t,s,-1)||Pr(n,e,t,s,1))},Xf=/^(img|br|input|textarea|hr)$/i;function Pr(n,e,t,s,o){for(;;){if(n==t&&e==s)return!0;if(e==(o<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Wn(n)||Xf.test(n.nodeName)||n.contentEditable=="false")return!1;e=U(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Qf(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ge(n)}else if(n.parentNode&&!Wn(n))e=U(n),n=n.parentNode;else return null}}function ep(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Wn(n))e=U(n)+1,n=n.parentNode;else return null}}function tp(n,e,t){for(let s=e==0,o=e==ge(n);s||o;){if(n==t)return!0;let i=U(n);if(n=n.parentNode,!n)return!1;s=s&&i==0,o=o&&i==ge(n)}}function Wn(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 qs=function(n){return n.focusNode&&Et(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function ft(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function np(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function sp(n,e,t){if(n.caretPositionFromPoint)try{let s=n.caretPositionFromPoint(e,t);if(s)return{node:s.offsetNode,offset:Math.min(ge(s.offsetNode),s.offset)}}catch{}if(n.caretRangeFromPoint){let s=n.caretRangeFromPoint(e,t);if(s)return{node:s.startContainer,offset:Math.min(ge(s.startContainer),s.startOffset)}}}const Ne=typeof navigator<"u"?navigator:null,Ir=typeof document<"u"?document:null,rt=Ne&&Ne.userAgent||"",Go=/Edge\/(\d+)/.exec(rt),ec=/MSIE \d/.exec(rt),jo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(rt),ce=!!(ec||jo||Go),tt=ec?document.documentMode:jo?+jo[1]:Go?+Go[1]:0,Te=!ce&&/gecko\/(\d+)/i.test(rt);Te&&+(/Firefox\/(\d+)/.exec(rt)||[0,0])[1];const Ko=!ce&&/Chrome\/(\d+)/.exec(rt),Q=!!Ko,tc=Ko?+Ko[1]:0,ne=!ce&&!!Ne&&/Apple Computer/.test(Ne.vendor),on=ne&&(/Mobile\/\w+/.test(rt)||!!Ne&&Ne.maxTouchPoints>2),me=on||(Ne?/Mac/.test(Ne.platform):!1),op=Ne?/Win/.test(Ne.platform):!1,Ce=/Android \d/.test(rt),_n=!!Ir&&"webkitFontSmoothing"in Ir.documentElement.style,ip=_n?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rp(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Re(n,e){return typeof n=="number"?n:n[e]}function lp(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function Rr(n,e,t){let s=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=Vn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?rp(i):lp(l),d=0,h=0;if(e.top<c.top+Re(s,"top")?h=-(c.top-e.top+Re(o,"top")):e.bottom>c.bottom-Re(s,"bottom")&&(h=e.bottom-e.top>c.bottom-c.top?e.top+Re(o,"top")-c.top:e.bottom-c.bottom+Re(o,"bottom")),e.left<c.left+Re(s,"left")?d=-(c.left-e.left+Re(o,"left")):e.right>c.right-Re(s,"right")&&(d=e.right-c.right+Re(o,"right")),d||h)if(a)i.defaultView.scrollBy(d,h);else{let u=l.scrollLeft,f=l.scrollTop;h&&(l.scrollTop+=h),d&&(l.scrollLeft+=d);let p=l.scrollLeft-u,m=l.scrollTop-f;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(r).position))break}}function ap(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,o;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){s=l,o=a.top;break}}return{refDOM:s,refTop:o,stack:nc(n.dom)}}function nc(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=Vn(s));return e}function cp({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;sc(t,s==0?0:s-e)}function sc(n,e){for(let t=0;t<n.length;t++){let{dom:s,top:o,left:i}=n[t];s.scrollTop!=o+e&&(s.scrollTop=o+e),s.scrollLeft!=i&&(s.scrollLeft=i)}}let Lt=null;function dp(n){if(n.setActive)return n.setActive();if(Lt)return n.focus(Lt);let e=nc(n);n.focus(Lt==null?{get preventScroll(){return Lt={preventScroll:!0},!0}}:void 0),Lt||(Lt=!1,sc(e,0))}function oc(n,e){let t,s=2e8,o,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,h=0;d;d=d.nextSibling,h++){let u;if(d.nodeType==1)u=d.getClientRects();else if(d.nodeType==3)u=Le(d).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.top<=r&&p.bottom>=l){r=Math.max(p.bottom,r),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<s){t=d,s=m,o=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=h+1)}}return!t&&a&&(t=a,o=c,s=0),t&&t.nodeType==3?hp(t,o):!t||s&&t.nodeType==1?{node:n,offset:i}:oc(t,o)}function hp(n,e){let t=n.nodeValue.length,s=document.createRange();for(let o=0;o<t;o++){s.setEnd(n,o+1),s.setStart(n,o);let i=Ge(s,1);if(i.top!=i.bottom&&vi(e,i))return{node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function vi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function up(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function fp(n,e,t){let{node:s,offset:o}=oc(e,t),i=-1;if(s.nodeType==1&&!s.firstChild){let r=s.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(s,o,i)}function pp(n,e,t,s){let o=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!r&&a.left>s.left||a.top>s.top?o=l.posBefore:(!r&&a.right<s.left||a.bottom<s.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?s.top<(a.top+a.bottom)/2:s.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function ic(n,e,t){let s=n.childNodes.length;if(s&&t.top<t.bottom)for(let o=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(vi(e,c))return ic(r,e,c)}}if((i=(i+1)%s)==o)break}return n}function mp(n,e){let t=n.dom.ownerDocument,s,o=0,i=sp(t,e.left,e.top);i&&({node:s,offset:o}=i);let r=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!r||!n.dom.contains(r.nodeType!=1?r.parentNode:r)){let c=n.dom.getBoundingClientRect();if(!vi(e,c)||(r=ic(n.dom,e,c),!r))return null}if(ne)for(let c=r;s&&c;c=Vn(c))c.draggable&&(s=void 0);if(r=up(r,e),s){if(Te&&s.nodeType==1&&(o=Math.min(o,s.childNodes.length),o<s.childNodes.length)){let d=s.childNodes[o],h;d.nodeName=="IMG"&&(h=d.getBoundingClientRect()).right<=e.left&&h.bottom>e.top&&o++}let c;_n&&o&&s.nodeType==1&&(c=s.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,s==n.dom&&o==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||s.nodeType!=1||s.childNodes[o-1].nodeName!="BR")&&(l=pp(n,s,o,e))}l==null&&(l=fp(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Dr(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let s=t[e<0?0:t.length-1];if(Dr(s))return s}return Array.prototype.find.call(t,Dr)||n.getBoundingClientRect()}const gp=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function rc(n,e,t){let{node:s,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=_n||Te;if(s.nodeType==3)if(r&&(gp.test(s.nodeValue)||(t<0?!o:o==s.nodeValue.length))){let a=Ge(Le(s,o,o),t);if(Te&&o&&/\s/.test(s.nodeValue[o-1])&&o<s.nodeValue.length){let c=Ge(Le(s,o-1,o-1),-1);if(c.top==a.top){let d=Ge(Le(s,o,o+1),-1);if(d.top!=a.top)return hn(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==s.nodeValue.length?(a--,d=1):t<0?a--:c++,hn(Ge(Le(s,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1];if(a.nodeType==1)return go(a.getBoundingClientRect(),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];if(a.nodeType==1)return go(a.getBoundingClientRect(),!0)}return go(s.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1],c=a.nodeType==3?Le(a,ge(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return hn(Ge(c,1),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Le(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return hn(Ge(c,-1),!0)}return hn(Ge(s.nodeType==3?Le(s):s,-t),t>=0)}function hn(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 go(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 s=n.state,o=n.root.activeElement;s!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),o!=n.dom&&o&&o.focus()}}function yp(n,e,t){let s=e.selection,o=t=="up"?s.$from:s.$to;return lc(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=rc(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Le(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?r.top-d.top>(d.bottom-r.top)*2:d.bottom-r.bottom>(r.bottom-d.top)*2))return!1}}return!0})}const bp=/[\u0590-\u08ac]/;function vp(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let o=s.parentOffset,i=!o,r=o==s.parent.content.size,l=n.domSelection();return l?!bp.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:lc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:h}=n.domSelectionRange(),u=l.caretBidiLevel;l.modify("move",t,"character");let f=s.depth?n.docView.domAfterPos(s.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,h),a&&(a!=d||c!=h)&&l.extend&&l.extend(a,c)}catch{}return u!=null&&(l.caretBidiLevel=u),g}):s.pos==s.start()||s.pos==s.end()}let zr=null,Vr=null,Lr=!1;function wp(n,e,t){return zr==e&&Vr==t?Lr:(zr=e,Vr=t,Lr=t=="up"||t=="down"?yp(n,e,t):vp(n,e,t))}const ye=0,Br=1,gt=2,Pe=3;class qn{constructor(e,t,s,o){this.parent=e,this.children=t,this.dom=s,this.contentDOM=o,this.dirty=ye,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,s=this.posAtStart;;t++){let o=this.children[t];if(o==e)return s;s+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>U(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),r;if(i&&(!t||i.node))if(s&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))s=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;t<this.children.length;t++){let o=this.children[t],i=s+o.size;if(s==e&&i!=s){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<i)return o.descAt(e-s-o.border);s=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,o=0;for(let i=0;s<this.children.length;s++){let r=this.children[s],l=i+r.size;if(l>e||r instanceof cc){o=e-i;break}i=l}if(o)return this.children[s].domFromPos(o-this.children[s].border,t);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof ac&&i.side>=0;s--);if(t<=0){let i,r=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?U(i.dom)+1:0}}else{let i,r=!0;for(;i=s<this.children.length?this.children[s]:null,!(!i||i.dom.parentNode==this.contentDOM);s++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?U(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let r=s,l=0;;l++){let a=this.children[l],c=r+a.size;if(o==-1&&e<=c){let d=r+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=r;for(let h=l;h>0;h--){let u=this.children[h-1];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(1)){o=U(u.dom)+1;break}e-=u.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let h=this.children[d];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(-1)){i=U(h.dom);break}t+=h.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:s}=this.domFromPos(e,0);if(t.nodeType!=1||s==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[s]}setSelection(e,t,s,o=!1){let i=Math.min(e,t),r=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(i>p&&r<g)return m.setSelection(e-p-m.border,t-p-m.border,s,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=s.root.getSelection(),d=s.domSelectionRange(),h=!1;if((Te||ne)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(h=!!(p&&f.nodeValue[p-1]==`
|
|
196
|
-
`),h&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:U(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];h=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Te&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||h&&ne)&&Et(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Et(a.node,a.offset,d.focusNode,d.focusOffset))return;let u=!1;if((c.extend||e==t)&&!h){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),u=!0}catch{}}if(!u){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let s=0,o=0;o<this.children.length;o++){let i=this.children[o],r=s+i.size;if(s==r?e<=r&&t>=s:e<r&&t>s){let l=s+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==s||t==r?gt:Br,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Pe:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?gt:Pe}s=r}this.dirty=gt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?gt:Br;t.dirty<s&&(t.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class ac extends qn{constructor(e,t,s,o){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(s,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==ye&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Sp extends qn{constructor(e,t,s,o){super(e,[],t,null),this.textDOM=s,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ot extends qn{constructor(e,t,s,o,i){super(e,[],s,o),this.mark=t,this.spec=i}static create(e,t,s,o){let i=o.nodeViews[t.type.name],r=i&&i(t,o,s);return(!r||!r.dom)&&(r=It.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new Ot(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Pe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=ye}}slice(e,t,s){let o=Ot.create(this.parent,this.mark,!0,s),i=this.children,r=this.size;t<r&&(i=Uo(i,t,r,s)),e>0&&(i=Uo(i,0,e,s));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class nt extends qn{constructor(e,t,s,o,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=s,this.innerDeco=o,this.nodeDOM=l}static create(e,t,s,o,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},s,o),d=c&&c.dom,h=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:h}=It.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!h&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let u=d;return d=uc(d,s,t),c?a=new Cp(e,t,s,o,d,h||null,u,c,i,r+1):t.isText?new Gs(e,t,s,o,d,u,i):new nt(e,t,s,o,d,h||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 s=this.children[t];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,s){return this.dirty==ye&&e.eq(this.node)&&Os(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new kp(this,r&&r.node,e);Ap(this.node,this.innerDeco,(c,d,h)=>{c.spec.marks?a.syncToMarks(c.spec.marks,s,e):c.type.side>=0&&!h&&a.syncToMarks(d==this.node.childCount?L.none:this.node.child(d).marks,s,e),a.placeWidget(c,e,o)},(c,d,h,u)=>{a.syncToMarks(c.marks,s,e);let f;a.findNodeMatch(c,d,h,u)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,h,f,e)||a.updateNextNode(c,d,h,e,u,o)||a.addNode(c,d,h,e,o),o+=c.nodeSize}),a.syncToMarks([],s,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==gt)&&(r&&this.protectLocalComposition(e,r),dc(this.contentDOM,this.children,e),on&&Ep(this.dom))}localCompositionInfo(e,t){let{from:s,to:o}=e.state.selection;if(!(e.state.selection instanceof R)||s<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=Op(this.node.content,r,s-t,o-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new Sp(this,i,t,o);e.input.compositionNodes.push(r),this.children=Uo(this.children,s,s+o.length,e,r)}update(e,t,s,o){return this.dirty==Pe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,o),!0)}updateInner(e,t,s,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ye}updateOuterDeco(e){if(Os(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=hc(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Hr(n,e,t,s,o){uc(s,e,n);let i=new nt(void 0,n,e,t,s,s,s,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Gs extends nt{constructor(e,t,s,o,i,r,l){super(e,t,s,o,i,null,r,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,s,o){return this.dirty==Pe||this.dirty!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ye,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new Gs(this.parent,o,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Pe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class cc extends qn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Cp extends nt{constructor(e,t,s,o,i,r,l,a,c,d){super(e,t,s,o,i,r,l,c,d),this.spec=a}update(e,t,s,o){if(this.dirty==Pe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,s);return i&&this.updateInner(e,t,s,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,o){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function dc(n,e,t){let s=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=s;)s=$r(s),o=!0;s=s.nextSibling}else o=!0,n.insertBefore(l,s);if(r instanceof Ot){let a=s?s.previousSibling:n.lastChild;dc(r.contentDOM,r.children,t),s=a?a.nextSibling:n.firstChild}}for(;s;)s=$r(s),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const kn=function(n){n&&(this.nodeName=n)};kn.prototype=Object.create(null);const yt=[new kn];function Jo(n,e,t){if(n.length==0)return yt;let s=t?yt[0]:new kn,o=[s];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&o.push(s=new kn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&o.length==1&&o.push(s=new kn(e.isInline?"span":"div")),l=="class"?s.class=(s.class?s.class+" ":"")+a:l=="style"?s.style=(s.style?s.style+";":"")+a:l!="nodeName"&&(s[l]=a))}}}return o}function hc(n,e,t,s){if(t==yt&&s==yt)return e;let o=e;for(let i=0;i<s.length;i++){let r=s[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=yt[0]),o=a}xp(o,l||yt[0],r)}return o}function xp(n,e,t){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in t)&&n.removeAttribute(s);for(let s in t)s!="class"&&s!="style"&&s!="nodeName"&&t[s]!=e[s]&&n.setAttribute(s,t[s]);if(e.class!=t.class){let s=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.remove(s[i]);for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=s.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function uc(n,e,t){return hc(n,n,yt,Jo(e,t,n.nodeType!=1))}function Os(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 $r(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class kp{constructor(e,t,s){this.lock=t,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Tp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let s=e;s<t;s++)this.top.children[s].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,s){let o=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;o<r&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=ye,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=Ot.create(this.top,e[i],t,s);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,s,o){let i=-1,r;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,s))i=this.top.children.indexOf(r,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,s)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,s,o,i){let r=this.top.children[o];return r.dirty==Pe&&r.dom==r.contentDOM&&(r.dirty=gt),r.update(e,t,s,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==s)return o}return-1}e=t}}updateNextNode(e,t,s,o,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof nt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,h,u=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Pe&&Os(t,a.outerDeco));if(!u&&a.update(e,t,s,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!u&&(h=this.recreateWrapper(a,e,t,s,o,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=h,h.contentDOM&&(h.dirty=gt,h.updateChildren(o,r+1),h.dirty=ye),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,s,o,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Os(s,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=nt.create(this.top,t,s,o,i,r);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,s,o,i){let r=nt.create(this.top,e,t,s,o,i);r.contentDOM&&r.updateChildren(o,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,s){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new ac(this.top,e,t,s);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ot;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Gs)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ne||Q)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let o=new cc(this.top,[],s,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Tp(n,e){let t=e,s=t.children.length,o=n.childCount,i=new Map,r=[];e:for(;o>0;){let l;for(;;)if(s){let c=t.children[s-1];if(c instanceof Ot)t=c,s=c.children.length;else{l=c,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),r.push(l)}}return{index:o,matched:i,matches:r.reverse()}}function Mp(n,e){return n.type.side-e.type.side}function Ap(n,e,t,s){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);s(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,h;for(;r<o.length&&o[r].to==i;){let g=o[r++];g.widget&&(d?(h||(h=[d])).push(g):d=g)}if(d)if(h){h.sort(Mp);for(let g=0;g<h.length;g++)t(h[g],c,!!a)}else t(d,c,!!a);let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<o.length&&o[r].from<=i&&o[r].to>i;)l.push(o[r++]);let p=i+u.nodeSize;if(u.isText){let g=p;r<o.length&&o[r].from<g&&(g=o[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=u.cut(g-i),u=u.cut(0,g-i),p=g,f=-1)}else for(;r<o.length&&o[r].to<p;)r++;let m=u.isInline&&!u.isLeaf?l.filter(g=>!g.inline):l.slice();s(u,m,e.forChild(i,u),f),i=p}}function Ep(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Op(n,e,t,s){for(let o=0,i=0;o<n.childCount&&i<=s;){let r=n.child(o++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=s&&a.slice(s-e.length-l,s-l)==e)return s-e.length;let c=l<s?a.lastIndexOf(e,s-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==s&&a.length>=s+e.length-l&&a.slice(s-l,s-l+e.length)==e)return s}}return-1}function Uo(n,e,t,s,o){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,s)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,s)))}return i}function wi(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=s.resolve(r),a,c;if(qs(t)){for(a=r;o&&!o.node;)o=o.parent;let h=o.node;if(o&&h.isAtom&&N.isSelectable(h)&&o.parent&&!(h.isInline&&tp(t.focusNode,t.focusOffset,o.dom))){let u=o.posBefore;c=new N(r==u?l:s.resolve(u))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let h=r,u=r;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);h=Math.min(h,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),u=Math.max(u,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(h<0)return null;[a,r]=u==n.state.selection.anchor?[u,h]:[h,u],l=s.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=s.resolve(a);if(!c){let h=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Si(n,d,l,h)}return c}function fc(n){return n.editable?n.hasFocus():mc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function $e(n,e=!1){let t=n.state.selection;if(pc(n,t),!!fc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Q){let s=n.domSelectionRange(),o=n.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Et(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Pp(n);else{let{anchor:s,head:o}=t,i,r;Fr&&!(t instanceof R)&&(t.$from.parent.inlineContent||(i=Wr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=Wr(n,t.to))),n.docView.setSelection(s,o,n,e),Fr&&(i&&_r(i),r&&_r(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Np(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Fr=ne||Q&&tc<63;function Wr(n,e){let{node:t,offset:s}=n.docView.domFromPos(e,0),o=s<t.childNodes.length?t.childNodes[s]:null,i=s?t.childNodes[s-1]:null;if(ne&&o&&o.contentEditable=="false")return yo(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return yo(o);if(i)return yo(i)}}function yo(n){return n.contentEditable="true",ne&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function _r(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Np(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),s=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=s||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!fc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Pp(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let s=n.cursorWrapper.dom,o=s.nodeName=="IMG";o?t.setStart(s.parentNode,U(s)+1):t.setStart(s,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ce&&tt<=11&&(s.disabled=!0,s.disabled=!1)}function pc(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(qr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else qr(n)}function qr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Si(n,e,t,s){return n.someProp("createSelectionBetween",o=>o(n,e,t))||R.between(e,t,s)}function Gr(n){return n.editable&&!n.hasFocus()?!1:mc(n)}function mc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ip(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Et(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Zo(n,e){let{$anchor:t,$head:s}=n.selection,o=e>0?t.max(s):t.min(s),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&I.findFrom(i,e)}function Ke(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function jr(n,e,t){let s=n.state.selection;if(s instanceof R)if(t.indexOf("s")>-1){let{$head:o}=s,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Ke(n,new R(s.$anchor,r))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Zo(n.state,e);return o&&o instanceof N?Ke(n,o):!1}else if(!(me&&t.indexOf("m")>-1)){let o=s.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?N.isSelectable(i)?Ke(n,new N(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):_n?Ke(n,new R(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof N&&s.node.isInline)return Ke(n,new R(e>0?s.$to:s.$from));{let o=Zo(n.state,e);return o?Ke(n,o):!1}}}function Ns(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Tn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Bt(n,e){return e<0?Rp(n):Dp(n)}function Rp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o,i,r=!1;for(Te&&t.nodeType==1&&s<Ns(t)&&Tn(t.childNodes[s],-1)&&(r=!0);;)if(s>0){if(t.nodeType!=1)break;{let l=t.childNodes[s-1];if(Tn(l,-1))o=t,i=--s;else if(l.nodeType==3)t=l,s=t.nodeValue.length;else break}}else{if(gc(t))break;{let l=t.previousSibling;for(;l&&Tn(l,-1);)o=t.parentNode,i=U(l),l=l.previousSibling;if(l)t=l,s=Ns(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}r?Yo(n,t,s):o&&Yo(n,o,i)}function Dp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o=Ns(t),i,r;for(;;)if(s<o){if(t.nodeType!=1)break;let l=t.childNodes[s];if(Tn(l,1))i=t,r=++s;else break}else{if(gc(t))break;{let l=t.nextSibling;for(;l&&Tn(l,1);)i=l.parentNode,r=U(l)+1,l=l.nextSibling;if(l)t=l,s=0,o=Ns(t);else{if(t=t.parentNode,t==n.dom)break;s=o=0}}}i&&Yo(n,i,r)}function gc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function zp(n,e){for(;n&&e==n.childNodes.length&&!Wn(n);)e=U(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 Vp(n,e){for(;n&&!e&&!Wn(n);)e=U(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 Yo(n,e,t){if(e.nodeType!=3){let i,r;(r=zp(e,t))?(e=r,t=0):(i=Vp(e,t))&&(e=i,t=i.nodeValue.length)}let s=n.domSelection();if(!s)return;if(qs(s)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),s.removeAllRanges(),s.addRange(i)}else s.extend&&s.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&$e(n)},50)}function Kr(n,e){let t=n.state.doc.resolve(e);if(!(Q||op)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Jr(n,e,t){let s=n.state.selection;if(s instanceof R&&!s.empty||t.indexOf("s")>-1||me&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=s;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=Zo(n.state,e);if(r&&r instanceof N)return Ke(n,r)}if(!o.parent.inlineContent){let r=e<0?o:i,l=s instanceof fe?I.near(r,e):I.findFrom(r,e);return l?Ke(n,l):!1}return!1}function Ur(n,e){if(!(n.state.selection instanceof R))return!0;let{$head:t,$anchor:s,empty:o}=n.state.selection;if(!t.sameParent(s))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function Zr(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Lp(n){if(!ne||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;Zr(n,s,"true"),setTimeout(()=>Zr(n,s,"false"),20)}return!1}function Bp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Hp(n,e){let t=e.keyCode,s=Bp(e);if(t==8||me&&t==72&&s=="c")return Ur(n,-1)||Bt(n,-1);if(t==46&&!e.shiftKey||me&&t==68&&s=="c")return Ur(n,1)||Bt(n,1);if(t==13||t==27)return!0;if(t==37||me&&t==66&&s=="c"){let o=t==37?Kr(n,n.state.selection.from)=="ltr"?-1:1:-1;return jr(n,o,s)||Bt(n,o)}else if(t==39||me&&t==70&&s=="c"){let o=t==39?Kr(n,n.state.selection.from)=="ltr"?1:-1:1;return jr(n,o,s)||Bt(n,o)}else{if(t==38||me&&t==80&&s=="c")return Jr(n,-1,s)||Bt(n,-1);if(t==40||me&&t==78&&s=="c")return Lp(n)||Jr(n,1,s)||Bt(n,1);if(s==(me?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function yc(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:s,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){o--,i--;let f=s.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),s=f.content}let r=n.someProp("clipboardSerializer")||It.fromSchema(n.state.schema),l=xc(),a=l.createElement("div");a.appendChild(r.serializeFragment(s,{document:l}));let c=a.firstChild,d,h=0;for(;c&&c.nodeType==1&&(d=Cc[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),h++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${h?` -${h}`:""} ${JSON.stringify(t)}`);let u=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
|
|
190
|
+
`,l.addEventListener("pointerdown",p()),i.appendChild(l)),o.append(i),(S=t.getSpotsEl())==null||S.appendChild(o)},f=S=>x=>{if(!a)return;Qn(n,!0),x.stopPropagation(),x.preventDefault(),u.startResize(a,S,x);const E=x.clientX,T=x.clientY;x.target.setPointerCapture(x.pointerId);const A=D=>{const L=n.Canvas.getZoomMultiplier(),H=(D.clientX-E)*L,be=(D.clientY-T)*L,ve=ws(S)?be:H;u.updateResizeByDelta(a,S,ve)},P=()=>{Qn(n,!1),u.finishResize(a),x.target.releasePointerCapture(x.pointerId),document.removeEventListener("pointermove",A),document.removeEventListener("pointerup",P)};document.addEventListener("pointermove",A),document.addEventListener("pointerup",P)},p=()=>S=>{if(!c)return;const x=c;Qn(n,!0),S.stopPropagation(),S.preventDefault();const E=In(x,e),T=$o({componentRow:x,isVertical:E},e),A=S.clientX,P=S.clientY;S.target.setPointerCapture(S.pointerId);const D=H=>{const be=n.Canvas.getZoomMultiplier(),ve=E?(H.clientY-P)*be:(H.clientX-A)*be;u.updateGapByDelta(x,ve,T,E)},L=()=>{Qn(n,!1),u.finishGapAdjust(x),S.target.releasePointerCapture(S.pointerId),document.removeEventListener("pointermove",D),document.removeEventListener("pointerup",L)};document.addEventListener("pointermove",D),document.addEventListener("pointerup",L)},m=S=>{const x=S.component;if(!x||!o||(a=x,c=x.parent(),!c))return;const E=c;rr(o);const T=S.getStyle();i&&Object.assign(i.style,T);const A=In(E,e),P=Qu(A);if(Object.values(r).forEach(ir),P.forEach(L=>{if(oh(x,L))return;const H=r[L];rr(H)}),It(e).gapHandler.isGapSupported()&&l&&ih(x)){const L=$o({componentRow:E,isVertical:A},e);g(L,A,nh(x))}},g=(S,x,E=!1)=>{const T=e.gapHandleSize,A=l.style;if(x){A.height=`${T}px`;const P=l.offsetHeight;E?(A.top=`-${(S+P)/2}px`,A.bottom=""):(A.bottom=`-${(S+P)/2}px`,A.top=""),A.width="50%",A.left="50%",A.transform="translateX(-50%)",A.cursor="row-resize"}else{A.width=`${T}px`;const P=l.offsetWidth;E?(A.left=`-${(S+P)/2}px`,A.right=""):(A.right=`-${(S+P)/2}px`,A.left=""),A.height="50%",A.top="50%",A.transform="translateY(-50%)",A.cursor="col-resize"}},b=()=>{o&&(ir(o),a=null,c=null)},C=()=>{t.removeSpots({type:s});const S=n.getSelected(),x=S==null?void 0:S.parent();S&&x&&d.isValidRelationship(x,S)?t.addSpot({type:s,component:S}):b()},y=()=>{const S=t.getSpots().filter(x=>x.type===s)[0];S&&m(S)},v=(S,x)=>{d.registerTypeRelationship(S,x)};n.onReady(()=>{h(),en(e)?v("mj-section","mj-column"):v(e.typeRow,e.typeColumn)});const w="component:toggled";return n.on(t.events.spot,y),n.on(w,C),()=>{n.off(t.events.spot,y),n.off(w,C)}}const gh="flexComponent",yh=function(n,e={}){const t={typeRow:"flex-row",typeColumn:"flex-column",gapHandleSize:3,snapDivisions:12,minItemPercent:5,...e},s=[ch(n,t),ah(n,t)],o=mh(n,t),i=lh(n,t);te({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:gh,cleanup:()=>{s.forEach(r=>r==null?void 0:r()),o(),i==null||i()}})},bh=ee(yh),vh=n=>n.dispatchEvent(new CustomEvent("input"));function wh(n,e){if(!e)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{s(d)&&o(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(s(d)&&!o(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const yi=new WeakMap,Sh=(n,e)=>{yi.set(n,e)},Ch=n=>{yi.delete(n)},no=n=>yi.get(n),es=n=>{const e=n.target,t=e.closest(".tox"),s=e.matches(".ephox-snooker-resizer-bar");(t||s)&&n.stopPropagation()},dr=n=>{n.stopPropagation(),n.preventDefault()},xh=(n,e)=>{const t=n.getDoc(),s=n.getWin();if(e!=null&&e.event){const{event:o}=e,{clientX:i,clientY:r}=o;let l;if(t.caretRangeFromPoint)l=t.caretRangeFromPoint(i,r);else if(t.caretPositionFromPoint){const a=t.caretPositionFromPoint(i,r);l=t.createRange(),l==null||l.setStart(a.offsetNode,a.offset)}if(l){const a=s.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(l),n.selection.setRng(l)}}else n.execCommand("SelectAll")},kh=n=>{var c,d;const{el:e,editor:t,componentView:s}=n,o=t.runCommand(B.getStateTheme),i=s.model,r={target:e,inline:!0,skin:(o==null?void 0:o.theme)===Vl.dark?"oxide-dark":"oxide",menubar:!1,image_advtab:!0,paste_data_images:!0,statusbar:!1,branding:!1,forced_root_block:"div",plugins:"advlist autolink lists link image media table",toolbar_mode:"sliding",toolbar:"bold italic underline strikethrough forecolor backcolor alignleft aligncenter alignright alignjustify link image | fontfamily fontsize bullist numlist outdent indent table"},l=((d=(c=n.pluginOpts)==null?void 0:c.loadConfig)==null?void 0:d.call(c,{config:r,editor:t,componentView:s,component:i}))||{};return{...r,...l}},ur=(n,e=document)=>new Promise((t,s)=>{const o=Array.isArray(n)?[...n]:[n],{head:i}=e,r=l=>{if(l.length){const a=e.createElement("script");a.src=l.shift(),a.onload=r.bind(null,l),a.onerror=s,i.appendChild(a)}else t()};r(o)}),Th="rteTinyMce",Mh=function(n,e={}){const t={cdnScript:"https://cdn.jsdelivr.net/npm/tinymce@6.8.5/tinymce.min.js",...e},{cdnScript:s}=t,o=n.Canvas.events,i=async(a,c)=>{const d=a.ownerDocument,u=d.defaultView,h=c==null?void 0:c.view;if(!u||!h){console.warn("Missing required data",{win:u,componentView:h});return}const f=kh({el:a,editor:n,componentView:h,pluginOpts:t}),m=(await u.tinymce.init(f))[0];if(!m)return;const b=(await window.tinymce.init({...f,target:document.createElement("div")}))[0];return m.ui.show(),d.body.addEventListener("mousedown",es),document.body.addEventListener("mousedown",es),m.on("Change",()=>vh(a)),m.on("blur",()=>m.ui.show()),m.on("OpenWindow",function(){var v;const C=(v=d.querySelector(".tox-dialog"))==null?void 0:v.closest(".tox");C&&(C==null?void 0:C.ownerDocument)!==document&&(document.body.appendChild(C),m.once("CloseWindow",()=>{C&&C.ownerDocument===document&&d.body.appendChild(C)}))}),a.addEventListener("dragstart",dr,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!1}),xh(m,c),{rteEditor:m,rteEditorShallow:b}},r=(a,c)=>{a.ownerDocument.body.removeEventListener("mousedown",es),document.body.removeEventListener("mousedown",es),a.removeEventListener("dragstart",dr,{capture:!0}),n.runCommand(B.setStateContextMenu,{enabled:!0}),c.rteEditor.destroy(),c.rteEditorShallow.destroy()};n.on(o.frameLoad,async({window:a})=>{ur(s,a.document)}),n.onReady(()=>{ur(s,document)}),n.setCustomRte({parseContent:!0,async enable(a,c,d){const u=no(a);if(u)return u.rteEditor;const h=await i(a,d);return h&&Sh(a,h),h==null?void 0:h.rteEditor},disable(a){const c=no(a);c&&(Ch(a),r(a,c))},getContent(a){var d,u;const c=no(a);return c?(u=(d=c.rteEditor).getContent)==null?void 0:u.call(d):a.innerHTML}});const l=wh(n,t.enableOnClick);te({editor:n,licenseKey:t.licenseKey,plan:F.startup,pluginName:Th,cleanup:()=>{n.RichTextEditor.customRte=void 0,l()}})},Ah=ee(Mh);function K(n){this.content=n}K.prototype={constructor:K,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var s=t&&t!=n?this.remove(t):this,o=s.find(n),i=s.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new K(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 K(t)},addToStart:function(n,e){return new K([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new K(t)},addBefore:function(n,e,t){var s=this.remove(e),o=s.content.slice(),i=s.find(n);return o.splice(i==-1?o.length:i,0,e,t),new K(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=K.from(n),n.size?new K(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=K.from(n),n.size?new K(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=K.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}};K.from=function(n){if(n instanceof K)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new K(e)};function fa(n,e,t){for(let s=0;;s++){if(s==n.childCount||s==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(s),i=e.child(s);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let r=0;o.text[r]==i.text[r];r++)t++;return t}if(o.content.size||i.content.size){let r=fa(o.content,i.content,t+1);if(r!=null)return r}t+=o.nodeSize}}function pa(n,e,t,s){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:s};let r=n.child(--o),l=e.child(--i),a=r.nodeSize;if(r==l){t-=a,s-=a;continue}if(!r.sameMarkup(l))return{a:t,b:s};if(r.isText&&r.text!=l.text){let c=0,d=Math.min(r.text.length,l.text.length);for(;c<d&&r.text[r.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,s--;return{a:t,b:s}}if(r.content.size||l.content.size){let c=pa(r.content,l.content,t-1,s-1);if(c)return c}t-=a,s-=a}}class k{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let s=0;s<e.length;s++)this.size+=e[s].nodeSize}nodesBetween(e,t,s,o=0,i){for(let r=0,l=0;l<t;r++){let a=this.content[r],c=l+a.nodeSize;if(c>e&&s(a,o+l,i||null,r)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),s,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,s,o){let i="",r=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&s&&(r?r=!1:i+=s),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,s=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(s)&&(o[o.length-1]=t.withText(t.text+s.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new k(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let s=[],o=0;if(t>e)for(let i=0,r=0;r<t;i++){let l=this.content[i],a=r+l.nodeSize;a>e&&((r<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-r),Math.min(l.text.length,t-r)):l=l.cut(Math.max(0,e-r-1),Math.min(l.content.size,t-r-1))),s.push(l),o+=l.nodeSize),r=a}return new k(s,o)}cutByIndex(e,t){return e==t?k.empty:e==0&&t==this.content.length?this:new k(this.content.slice(e,t))}replaceChild(e,t){let s=this.content[e];if(s==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-s.nodeSize;return o[e]=t,new k(o,i)}addToStart(e){return new k([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new k(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,s=0;t<this.content.length;t++){let o=this.content[t];e(o,s,t),s+=o.nodeSize}}findDiffStart(e,t=0){return fa(this,e,t)}findDiffEnd(e,t=this.size,s=e.size){return pa(this,e,t,s)}findIndex(e,t=-1){if(e==0)return ts(0,e);if(e==this.size)return ts(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let s=0,o=0;;s++){let i=this.child(s),r=o+i.nodeSize;if(r>=e)return r==e||t>0?ts(s+1,r):ts(s,o);o=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return k.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new k(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return k.empty;let t,s=0;for(let o=0;o<e.length;o++){let i=e[o];s+=i.nodeSize,o&&i.isText&&e[o-1].sameMarkup(i)?(t||(t=e.slice(0,o)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new k(t||e,s)}static from(e){if(!e)return k.empty;if(e instanceof k)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new k([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}k.empty=new k([],0);const so={index:0,offset:0};function ts(n,e){return so.index=n,so.offset=e,so}function Cs(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let s=0;s<n.length;s++)if(!Cs(n[s],e[s]))return!1}else{for(let s in n)if(!(s in e)||!Cs(n[s],e[s]))return!1;for(let s in e)if(!(s in n))return!1}return!0}class V{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,s=!1;for(let o=0;o<e.length;o++){let i=e[o];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,o));else{if(i.type.excludes(this.type))return e;!s&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),s=!0),t&&t.push(i)}}return t||(t=e.slice()),s||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Cs(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let s=e.marks[t.type];if(!s)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=s.create(t.attrs);return s.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!e[s].eq(t[s]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return V.none;if(e instanceof V)return[e];let t=e.slice();return t.sort((s,o)=>s.type.rank-o.type.rank),t}}V.none=[];class xs extends Error{}class M{constructor(e,t,s){this.content=e,this.openStart=t,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let s=ga(this.content,e+this.openStart,t);return s&&new M(s,this.openStart,this.openEnd)}removeBetween(e,t){return new M(ma(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return M.empty;let s=t.openStart||0,o=t.openEnd||0;if(typeof s!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new M(k.fromJSON(e,t.content),s,o)}static maxOpen(e,t=!0){let s=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)s++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new M(e,s,o)}}M.empty=new M(k.empty,0,0);function ma(n,e,t){let{index:s,offset:o}=n.findIndex(e),i=n.maybeChild(s),{index:r,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(r).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(s!=r)throw new RangeError("Removing non-flat range");return n.replaceChild(s,i.copy(ma(i.content,e-o-1,t-o-1)))}function ga(n,e,t,s){let{index:o,offset:i}=n.findIndex(e),r=n.maybeChild(o);if(i==e||r.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=ga(r.content,e-i-1,t);return l&&n.replaceChild(o,r.copy(l))}function Eh(n,e,t){if(t.openStart>n.depth)throw new xs("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new xs("Inconsistent open depths");return ya(n,e,t,0)}function ya(n,e,t,s){let o=n.index(s),i=n.node(s);if(o==e.index(s)&&s<n.depth-t.openStart){let r=ya(n,e,t,s+1);return i.copy(i.content.replaceChild(o,r))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==s&&e.depth==s){let r=n.parent,l=r.content;return St(r,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:r,end:l}=Oh(t,n);return St(i,va(n,r,l,e,s))}else return St(i,ks(n,e,s))}function ba(n,e){if(!e.type.compatibleContent(n.type))throw new xs("Cannot join "+e.type.name+" onto "+n.type.name)}function Wo(n,e,t){let s=n.node(t);return ba(s,e.node(t)),s}function wt(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 xn(n,e,t,s){let o=(e||n).node(t),i=0,r=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(wt(n.nodeAfter,s),i++));for(let l=i;l<r;l++)wt(o.child(l),s);e&&e.depth==t&&e.textOffset&&wt(e.nodeBefore,s)}function St(n,e){return n.type.checkContent(e),n.copy(e)}function va(n,e,t,s,o){let i=n.depth>o&&Wo(n,e,o+1),r=s.depth>o&&Wo(t,s,o+1),l=[];return xn(null,n,o,l),i&&r&&e.index(o)==t.index(o)?(ba(i,r),wt(St(i,va(n,e,t,s,o+1)),l)):(i&&wt(St(i,ks(n,e,o+1)),l),xn(e,t,o,l),r&&wt(St(r,ks(t,s,o+1)),l)),xn(s,null,o,l),new k(l)}function ks(n,e,t){let s=[];if(xn(null,n,t,s),n.depth>t){let o=Wo(n,e,t+1);wt(St(o,ks(n,e,t+1)),s)}return xn(e,null,t,s),new k(s)}function Oh(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(k.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Dn{constructor(e,t,s){this.pos=e,this.path=t,this.parentOffset=s,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let s=this.pos-this.path[this.path.length-1],o=e.child(t);return s?e.child(t).cut(s):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let s=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=s.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return V.none;if(this.textOffset)return e.child(t).marks;let s=e.maybeChild(t-1),o=e.maybeChild(t);if(!s){let l=s;s=o,o=l}let i=s.marks;for(var r=0;r<i.length;r++)i[r].type.spec.inclusive===!1&&(!o||!i[r].isInSet(o.marks))&&(i=i[r--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let s=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let s=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);s>=0;s--)if(e.pos<=this.end(s)&&(!t||t(this.node(s))))return new Ts(this,e,s);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let s=[],o=0,i=t;for(let r=e;;){let{index:l,offset:a}=r.content.findIndex(i),c=i-a;if(s.push(r,l,o+a),!c||(r=r.child(l),r.isText))break;i=c-1,o+=a+1}return new Dn(t,s,i)}static resolveCached(e,t){let s=hr.get(e);if(s)for(let i=0;i<s.elts.length;i++){let r=s.elts[i];if(r.pos==t)return r}else hr.set(e,s=new Nh);let o=s.elts[s.i]=Dn.resolve(e,t);return s.i=(s.i+1)%Ph,o}}class Nh{constructor(){this.elts=[],this.i=0}}const Ph=12,hr=new WeakMap;class Ts{constructor(e,t,s){this.$from=e,this.$to=t,this.depth=s}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Ih=Object.create(null);let Ct=class _o{constructor(e,t,s,o=V.none){this.type=e,this.attrs=t,this.marks=o,this.content=s||k.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,s,o=0){this.content.nodesBetween(e,t,s,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,s,o){return this.content.textBetween(e,t,s,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,s){return this.type==e&&Cs(this.attrs,t||e.defaultAttrs||Ih)&&V.sameSet(this.marks,s||V.none)}copy(e=null){return e==this.content?this:new _o(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new _o(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,s=!1){if(e==t)return M.empty;let o=this.resolve(e),i=this.resolve(t),r=s?0:o.sharedDepth(t),l=o.start(r),c=o.node(r).content.cut(o.pos-l,i.pos-l);return new M(c,o.depth-r,i.depth-r)}replace(e,t,s){return Eh(this.resolve(e),this.resolve(t),s)}nodeAt(e){for(let t=this;;){let{index:s,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(s),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:s}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:s}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:s}=this.content.findIndex(e);if(s<e)return{node:this.content.child(t),index:t,offset:s};let o=this.content.child(t-1);return{node:o,index:t-1,offset:s-o.nodeSize}}resolve(e){return Dn.resolveCached(this,e)}resolveNoCache(e){return Dn.resolve(this,e)}rangeHasMark(e,t,s){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(s.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),wa(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,s=k.empty,o=0,i=s.childCount){let r=this.contentMatchAt(e).matchFragment(s,o,i),l=r&&r.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(s.child(a).marks))return!1;return!0}canReplaceWith(e,t,s,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(s),r=i&&i.matchFragment(this.content,t);return r?r.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=V.none;for(let t=0;t<this.marks.length;t++){let s=this.marks[t];s.type.checkAttrs(s.attrs),e=s.addToSet(e)}if(!V.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let s;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");s=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,s)}let o=k.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,s);return i.type.checkAttrs(i.attrs),i}};Ct.prototype.text=void 0;class Ms extends Ct{constructor(e,t,s,o){if(super(e,t,null,o),!s)throw new RangeError("Empty text nodes are not allowed");this.text=s}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wa(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 Ms(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Ms(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 wa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Et{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let s=new Rh(e,t);if(s.next==null)return Et.empty;let o=Sa(s);s.next&&s.err("Unexpected trailing text");let i=$h(Hh(o));return Fh(i,s),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,s=e.childCount){let o=this;for(let i=t;o&&i<s;i++)o=o.matchType(e.child(i).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let s=0;s<e.next.length;s++)if(this.next[t].type==e.next[s].type)return!0;return!1}fillBefore(e,t=!1,s=0){let o=[this];function i(r,l){let a=r.matchFragment(e,s);if(a&&(!t||a.validEnd))return k.from(l.map(c=>c.createAndFill()));for(let c=0;c<r.next.length;c++){let{type:d,next:u}=r.next[c];if(!(d.isText||d.hasRequiredAttrs())&&o.indexOf(u)==-1){o.push(u);let h=i(u,l.concat(d));if(h)return h}}return null}return i(this,[])}findWrapping(e){for(let s=0;s<this.wrapCache.length;s+=2)if(this.wrapCache[s]==e)return this.wrapCache[s+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),s=[{match:this,type:null,via:null}];for(;s.length;){let o=s.shift(),i=o.match;if(i.matchType(e)){let r=[];for(let l=o;l.type;l=l.via)r.push(l.type);return r.reverse()}for(let r=0;r<i.next.length;r++){let{type:l,next:a}=i.next[r];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(s.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(s){e.push(s);for(let o=0;o<s.next.length;o++)e.indexOf(s.next[o].next)==-1&&t(s.next[o].next)}return t(this),e.map((s,o)=>{let i=o+(s.validEnd?"*":" ")+" ";for(let r=0;r<s.next.length;r++)i+=(r?", ":"")+s.next[r].type.name+"->"+e.indexOf(s.next[r].next);return i}).join(`
|
|
191
|
+
`)}}Et.empty=new Et(!0);class Rh{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 Sa(n){let e=[];do e.push(Dh(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Dh(n){let e=[];do e.push(zh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function zh(n){let e=Bh(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=Lh(n,e);else break;return e}function fr(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Lh(n,e){let t=fr(n),s=t;return n.eat(",")&&(n.next!="}"?s=fr(n):s=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:s,expr:e}}function Vh(n,e){let t=n.nodeTypes,s=t[e];if(s)return[s];let o=[];for(let i in t){let r=t[i];r.isInGroup(e)&&o.push(r)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Bh(n){if(n.eat("(")){let e=Sa(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=Vh(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 Hh(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function s(r,l,a){let c={term:a,to:l};return e[r].push(c),c}function o(r,l){r.forEach(a=>a.to=l)}function i(r,l){if(r.type=="choice")return r.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(r.type=="seq")for(let a=0;;a++){let c=i(r.exprs[a],l);if(a==r.exprs.length-1)return c;o(c,l=t())}else if(r.type=="star"){let a=t();return s(l,a),o(i(r.expr,a),a),[s(a)]}else if(r.type=="plus"){let a=t();return o(i(r.expr,l),a),o(i(r.expr,a),a),[s(a)]}else{if(r.type=="opt")return[s(l)].concat(i(r.expr,l));if(r.type=="range"){let a=l;for(let c=0;c<r.min;c++){let d=t();o(i(r.expr,a),d),a=d}if(r.max==-1)o(i(r.expr,a),a);else for(let c=r.min;c<r.max;c++){let d=t();s(a,d),o(i(r.expr,a),d),a=d}return[s(a)]}else{if(r.type=="name")return[s(l,void 0,r.value)];throw new Error("Unknown expr type")}}}}function Ca(n,e){return e-n}function pr(n,e){let t=[];return s(e),t.sort(Ca);function s(o){let i=n[o];if(i.length==1&&!i[0].term)return s(i[0].to);t.push(o);for(let r=0;r<i.length;r++){let{term:l,to:a}=i[r];!l&&t.indexOf(a)==-1&&s(a)}}}function $h(n){let e=Object.create(null);return t(pr(n,0));function t(s){let o=[];s.forEach(r=>{n[r].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d<o.length;d++)o[d][0]==l&&(c=o[d][1]);pr(n,a).forEach(d=>{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[s.join(",")]=new Et(s.indexOf(n.length-1)>-1);for(let r=0;r<o.length;r++){let l=o[r][1].sort(Ca);i.next.push({type:o[r][0],next:e[l.join(",")]||t(l)})}return i}}function Fh(n,e){for(let t=0,s=[n];t<s.length;t++){let o=s[t],i=!o.validEnd,r=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];r.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),s.indexOf(c)==-1&&s.push(c)}i&&e.err("Only non-generatable nodes ("+r.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function xa(n){let e=Object.create(null);for(let t in n){let s=n[t];if(!s.hasDefault)return null;e[t]=s.default}return e}function ka(n,e){let t=Object.create(null);for(let s in n){let o=e&&e[s];if(o===void 0){let i=n[s];if(i.hasDefault)o=i.default;else throw new RangeError("No value supplied for attribute "+s)}t[s]=o}return t}function Ta(n,e,t,s){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let i=n[o];i.validate&&i.validate(e[o])}}function Ma(n,e){let t=Object.create(null);if(e)for(let s in e)t[s]=new _h(n,s,e[s]);return t}let mr=class Aa{constructor(e,t,s){this.name=e,this.schema=t,this.spec=s,this.markSet=null,this.groups=s.group?s.group.split(" "):[],this.attrs=Ma(e,s.attrs),this.defaultAttrs=xa(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(s.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Et.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:ka(this.attrs,e)}create(e=null,t,s){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ct(this,this.computeAttrs(e),k.from(t),V.setFrom(s))}createChecked(e=null,t,s){return t=k.from(t),this.checkContent(t),new Ct(this,this.computeAttrs(e),t,V.setFrom(s))}createAndFill(e=null,t,s){if(e=this.computeAttrs(e),t=k.from(t),t.size){let r=this.contentMatch.fillBefore(t);if(!r)return null;t=r.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(k.empty,!0);return i?new Ct(this,e,t.append(i),V.setFrom(s)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let s=0;s<e.childCount;s++)if(!this.allowsMarks(e.child(s).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ta(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let s=0;s<e.length;s++)this.allowsMarkType(e[s].type)?t&&t.push(e[s]):t||(t=e.slice(0,s));return t?t.length?t:V.none:e}static compile(e,t){let s=Object.create(null);e.forEach((i,r)=>s[i]=new Aa(i,t,r));let o=t.spec.topNode||"doc";if(!s[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!s.text)throw new RangeError("Every schema needs a 'text' type");for(let i in s.text.attrs)throw new RangeError("The text node type should not have attributes");return s}};function Wh(n,e,t){let s=t.split("|");return o=>{let i=o===null?"null":typeof o;if(s.indexOf(i)<0)throw new RangeError(`Expected value of type ${s} for attribute ${e} on type ${n}, got ${i}`)}}class _h{constructor(e,t,s){this.hasDefault=Object.prototype.hasOwnProperty.call(s,"default"),this.default=s.default,this.validate=typeof s.validate=="string"?Wh(e,t,s.validate):s.validate}get isRequired(){return!this.hasDefault}}class Ws{constructor(e,t,s,o){this.name=e,this.rank=t,this.schema=s,this.spec=o,this.attrs=Ma(e,o.attrs),this.excluded=null;let i=xa(this.attrs);this.instance=i?new V(this,i):null}create(e=null){return!e&&this.instance?this.instance:new V(this,ka(this.attrs,e))}static compile(e,t){let s=Object.create(null),o=0;return e.forEach((i,r)=>s[i]=new Ws(i,o++,t,r)),s}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ta(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class qh{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=K.from(e.nodes),t.marks=K.from(e.marks||{}),this.nodes=mr.compile(this.spec.nodes,this),this.marks=Ws.compile(this.spec.marks,this);let s=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],r=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=s[r]||(s[r]=Et.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?gr(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],r=i.spec.excludes;i.excluded=r==null?[i]:r==""?[]:gr(this,r.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,s,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof mr){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,s,o)}text(e,t){let s=this.nodes.text;return new Ms(s,s.defaultAttrs,e,V.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return Ct.fromJSON(this,e)}markFromJSON(e){return V.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function gr(n,e){let t=[];for(let s=0;s<e.length;s++){let o=e[s],i=n.marks[o],r=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(r=a)}if(!r)throw new SyntaxError("Unknown mark type: '"+e[s]+"'")}return t}function Gh(n){return n.tag!=null}function jh(n){return n.style!=null}class tn{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let s=this.matchedStyles=[];t.forEach(o=>{if(Gh(o))this.tags.push(o);else if(jh(o)){let i=/[^=]*/.exec(o.style)[0];s.indexOf(i)<0&&s.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let s=new br(this,t,!1);return s.addAll(e,V.none,t.from,t.to),s.finish()}parseSlice(e,t={}){let s=new br(this,t,!0);return s.addAll(e,V.none,t.from,t.to),M.maxOpen(s.finish())}matchTag(e,t,s){for(let o=s?this.tags.indexOf(s)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Uh(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let r=i.getAttrs(e);if(r===!1)continue;i.attrs=r||void 0}return i}}}matchStyle(e,t,s,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let r=this.styles[i],l=r.style;if(!(l.indexOf(e)!=0||r.context&&!s.matchesContext(r.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(r.getAttrs){let a=r.getAttrs(t);if(a===!1)continue;r.attrs=a||void 0}return r}}}static schemaRules(e){let t=[];function s(o){let i=o.priority==null?50:o.priority,r=0;for(;r<t.length;r++){let l=t[r];if((l.priority==null?50:l.priority)<i)break}t.splice(r,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(r=>{s(r=vr(r)),r.mark||r.ignore||r.clearMark||(r.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(r=>{s(r=vr(r)),r.node||r.ignore||r.mark||(r.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new tn(e,tn.schemaRules(e)))}}const Ea={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Kh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Oa={ol:!0,ul:!0},As=1,Es=2,kn=4;function yr(n,e,t){return e!=null?(e?As:0)|(e==="full"?Es:0):n&&n.whitespace=="pre"?As|Es:t&~kn}class ns{constructor(e,t,s,o,i,r){this.type=e,this.attrs=t,this.marks=s,this.solid=o,this.options=r,this.content=[],this.activeMarks=V.none,this.match=i||(r&kn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(k.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let s=this.type.contentMatch,o;return(o=s.findWrapping(e.type))?(this.match=s,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&As)){let s=this.content[this.content.length-1],o;if(s&&s.isText&&(o=/[ \t\r\n\u000c]+$/.exec(s.text))){let i=s;s.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=k.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(k.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ea.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class br{constructor(e,t,s){this.parser=e,this.options=t,this.isOpen=s,this.open=0;let o=t.topNode,i,r=yr(null,t.preserveWhitespace,0)|(s?kn:0);o?i=new ns(o.type,o.attrs,V.none,!0,t.topMatch||o.type.contentMatch,r):s?i=new ns(null,null,V.none,!0,null,r):i=new ns(e.schema.topNodeType,null,V.none,!0,null,r),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let s=e.nodeValue,o=this.top;if(o.options&Es||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(s)){if(o.options&As)o.options&Es?s=s.replace(/\r\n?/g,`
|
|
192
|
+
`):s=s.replace(/\r?\n|\r/g," ");else if(s=s.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(s)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],r=e.previousSibling;(!i||r&&r.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(s=s.slice(1))}s&&this.insertNode(this.parser.schema.text(s),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,s){let o=e.nodeName.toLowerCase(),i;Oa.hasOwnProperty(o)&&this.parser.normalizeLists&&Jh(e);let r=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,s));if(r?r.ignore:Kh.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!r||r.skip||r.closeParent){r&&r.closeParent?this.open=Math.max(0,this.open-1):r&&r.skip.nodeType&&(e=r.skip);let l,a=this.top,c=this.needsBlock;if(Ea.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let d=r&&r.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,r,l,r.consuming===!1?i:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
193
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let s=e.style;if(s&&s.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],r=s.getPropertyValue(i);if(r)for(let l=void 0;;){let a=this.parser.matchStyle(i,r,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,s,o){let i,r;if(t.node)if(r=this.parser.schema.nodes[t.node],r.isLeaf)this.insertNode(r.create(t.attrs),s)||this.leafFallback(e,s);else{let a=this.enter(r,t.attrs||null,s,t.preserveWhitespace);a&&(i=!0,s=a)}else{let a=this.parser.schema.marks[t.mark];s=s.concat(a.create(t.attrs))}let l=this.top;if(r&&r.isLeaf)this.findInside(e);else if(o)this.addElement(e,s,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,s));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,s),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,s,o){let i=s||0;for(let r=s?e.childNodes[s]:e.firstChild,l=o==null?null:e.childNodes[o];r!=l;r=r.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(r,t);this.findAtPoint(e,i)}findPlace(e,t){let s,o;for(let i=this.open;i>=0;i--){let r=this.nodes[i],l=r.findWrapping(e);if(l&&(!s||s.length>l.length)&&(s=l,o=r,!l.length)||r.solid)break}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)t=this.enterInner(s[i],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let s=this.findPlace(e,t);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=V.none;for(let r of s.concat(e.marks))(o.type?o.type.allowsMarkType(r.type):wr(r.type,e.type))&&(i=r.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,t,s,o){let i=this.findPlace(e.create(t),s);return i&&(i=this.enterInner(e,t,s,!0,o)),i}enterInner(e,t,s,o=!1,i){this.closeExtra();let r=this.top;r.match=r.match&&r.match.matchType(e);let l=yr(e,i,r.options);r.options&kn&&r.content.length==0&&(l|=kn);let a=V.none;return s=s.filter(c=>(r.type?r.type.allowsMarkType(c.type):wr(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new ns(e,t,a,o,null,l)),this.open++,s}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let s=this.nodes[t].content;for(let o=s.length-1;o>=0;o--)e+=s[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==e&&this.find[s].offset==t&&(this.find[s].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,s){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(s?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),s=this.options.context,o=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),i=-(s?s.depth+1:0)+(o?0:1),r=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(r(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:s&&a>=i?s.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return r(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let s=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let t in this.parser.schema.nodes){let s=this.parser.schema.nodes[t];if(s.isTextblock&&s.defaultAttrs)return s}}}function Jh(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let s=e.nodeType==1?e.nodeName.toLowerCase():null;s&&Oa.hasOwnProperty(s)&&t?(t.appendChild(e),e=t):s=="li"?t=e:s&&(t=null)}}function Uh(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function vr(n){let e={};for(let t in n)e[t]=n[t];return e}function wr(n,e){let t=e.schema.nodes;for(let s in t){let o=t[s];if(!o.allowsMarkType(n))continue;let i=[],r=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:d}=l.edge(a);if(c==e||i.indexOf(d)<0&&r(d))return!0}};if(r(o.contentMatch))return!0}}class Rt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},s){s||(s=oo(t).createDocumentFragment());let o=s,i=[];return e.forEach(r=>{if(i.length||r.marks.length){let l=0,a=0;for(;l<i.length&&a<r.marks.length;){let c=r.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(i[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<i.length;)o=i.pop()[1];for(;a<r.marks.length;){let c=r.marks[a++],d=this.serializeMark(c,r.isInline,t);d&&(i.push([c,o]),o.appendChild(d.dom),o=d.contentDOM||d.dom)}}o.appendChild(this.serializeNodeInner(r,t))}),s}serializeNodeInner(e,t){let{dom:s,contentDOM:o}=us(oo(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return s}serializeNode(e,t={}){let s=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(s),s=i.dom)}return s}serializeMark(e,t,s={}){let o=this.marks[e.type.name];return o&&us(oo(s),o(e,t),null,e.attrs)}static renderSpec(e,t,s=null,o){return us(e,t,s,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Rt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Sr(e.nodes);return t.text||(t.text=s=>s.text),t}static marksFromSchema(e){return Sr(e.marks)}}function Sr(n){let e={};for(let t in n){let s=n[t].spec.toDOM;s&&(e[t]=s)}return e}function oo(n){return n.document||window.document}const Cr=new WeakMap;function Zh(n){let e=Cr.get(n);return e===void 0&&Cr.set(n,e=Yh(n)),e}function Yh(n){let e=null;function t(s){if(s&&typeof s=="object")if(Array.isArray(s))if(typeof s[0]=="string")e||(e=[]),e.push(s);else for(let o=0;o<s.length;o++)t(s[o]);else for(let o in s)t(s[o])}return t(n),e}function us(n,e,t,s){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(s&&(i=Zh(s))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let r=o.indexOf(" ");r>0&&(t=o.slice(0,r),o=o.slice(r+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let h=u.indexOf(" ");h>0?a.setAttributeNS(u.slice(0,h),u.slice(h+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;u<e.length;u++){let h=e[u];if(h===0){if(u<e.length-1||u>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=us(n,h,t,s);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Na=65535,Pa=Math.pow(2,16);function Xh(n,e){return n+e*Pa}function xr(n){return n&Na}function Qh(n){return(n-(n&Na))/Pa}const Ia=1,Ra=2,hs=4,Da=8;class qo{constructor(e,t,s){this.pos=e,this.delInfo=t,this.recover=s}get deleted(){return(this.delInfo&Da)>0}get deletedBefore(){return(this.delInfo&(Ia|hs))>0}get deletedAfter(){return(this.delInfo&(Ra|hs))>0}get deletedAcross(){return(this.delInfo&hs)>0}}class ue{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ue.empty)return ue.empty}recover(e){let t=0,s=xr(e);if(!this.inverted)for(let o=0;o<s;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[s*3]+t+Qh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,s){let o=0,i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],d=this.ranges[l+r],u=a+c;if(e<=u){let h=c?e==a?-1:e==u?1:t:t,f=a+o+(h<0?0:d);if(s)return f;let p=e==(t<0?a:u)?null:Xh(l/3,e-a),m=e==a?Ra:e==u?Ia:hs;return(t<0?e!=a:e!=u)&&(m|=Da),new qo(f,m,p)}o+=d-c}return s?e+o:new qo(e+o,0,null)}touches(e,t){let s=0,o=xr(t),i=this.inverted?2:1,r=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;s+=this.ranges[l+r]-c}return!1}forEach(e){let t=this.inverted?2:1,s=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let r=this.ranges[o],l=r-(this.inverted?i:0),a=r+(this.inverted?0:i),c=this.ranges[o+t],d=this.ranges[o+s];e(l,l+c,a,a+d),i+=d-c}}invert(){return new ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?ue.empty:new ue(e<0?[0,-e,0]:[0,0,e])}}ue.empty=new ue([]);class Ut{constructor(e=[],t,s=0,o=e.length){this.maps=e,this.mirror=t,this.from=s,this.to=o}slice(e=0,t=this.maps.length){return new Ut(this.maps,this.mirror,e,t)}copy(){return new Ut(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,s=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?s+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,s=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?s-o-1:void 0)}}invert(){let e=new Ut;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let s=this.from;s<this.to;s++)e=this.maps[s].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,s){let o=0;for(let i=this.from;i<this.to;i++){let r=this.maps[i],l=r.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(i);if(a!=null&&a>i&&a<this.to){i=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return s?e:new qo(e,o,null)}}const io=Object.create(null);class ne{getMap(){return ue.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=io[t.stepType];if(!s)throw new RangeError(`No step type ${t.stepType} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in io)throw new RangeError("Duplicate use of step JSON ID "+e);return io[e]=t,t.prototype.jsonID=e,t}}class q{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new q(e,null)}static fail(e){return new q(null,e)}static fromReplace(e,t,s,o){try{return q.ok(e.replace(t,s,o))}catch(i){if(i instanceof xs)return q.fail(i.message);throw i}}}function bi(n,e,t){let s=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(bi(i.content,e,i))),i.isInline&&(i=e(i,t,o)),s.push(i)}return k.fromArray(s)}class Qe extends ne{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=e.resolve(this.from),o=s.node(s.sharedDepth(this.to)),i=new M(bi(t.content,(r,l)=>!r.isAtom||!l.type.allowsMarkType(this.mark.type)?r:r.mark(this.mark.addToSet(r.marks)),o),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,i)}invert(){return new Ee(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Qe(t.pos,s.pos,this.mark)}merge(e){return e instanceof Qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Qe(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 Qe(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("addMark",Qe);class Ee extends ne{constructor(e,t,s){super(),this.from=e,this.to=t,this.mark=s}apply(e){let t=e.slice(this.from,this.to),s=new M(bi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return q.fromReplace(e,this.from,this.to,s)}invert(){return new Qe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deleted&&s.deleted||t.pos>=s.pos?null:new Ee(t.pos,s.pos,this.mark)}merge(e){return e instanceof Ee&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ee(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 Ee(t.from,t.to,e.markFromJSON(t.mark))}}ne.jsonID("removeMark",Ee);class et extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let s=this.mark.addToSet(t.marks);if(s.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(s))return new et(this.pos,t.marks[o]);return new et(this.pos,this.mark)}}return new nn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new et(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 et(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("addNodeMark",et);class nn extends ne{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at mark step's position");let s=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(s),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new et(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new nn(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 nn(t.pos,e.markFromJSON(t.mark))}}ne.jsonID("removeNodeMark",nn);class X extends ne{constructor(e,t,s,o=!1){super(),this.from=e,this.to=t,this.slice=s,this.structure=o}apply(e){return this.structure&&Go(e,this.from,this.to)?q.fail("Structure replace would overwrite content"):q.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new X(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1);return t.deletedAcross&&s.deletedAcross?null:new X(t.pos,Math.max(t.pos,s.pos),this.slice)}merge(e){if(!(e instanceof X)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?M.empty:new M(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new X(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?M.empty:new M(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new X(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 X(t.from,t.to,M.fromJSON(e,t.slice),!!t.structure)}}ne.jsonID("replace",X);class Z extends ne{constructor(e,t,s,o,i,r,l=!1){super(),this.from=e,this.to=t,this.gapFrom=s,this.gapTo=o,this.slice=i,this.insert=r,this.structure=l}apply(e){if(this.structure&&(Go(e,this.from,this.gapFrom)||Go(e,this.gapTo,this.to)))return q.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return q.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,t.content);return s?q.fromReplace(e,this.from,this.to,s):q.fail("Content does not fit in gap")}getMap(){return new ue([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 Z(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),s=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?s.pos:e.map(this.gapTo,1);return t.deletedAcross&&s.deletedAcross||o<t.pos||i>s.pos?null:new Z(t.pos,s.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Z(t.from,t.to,t.gapFrom,t.gapTo,M.fromJSON(e,t.slice),t.insert,!!t.structure)}}ne.jsonID("replaceAround",Z);function Go(n,e,t){let s=n.resolve(e),o=t-e,i=s.depth;for(;o>0&&i>0&&s.indexAfter(i)==s.node(i).childCount;)i--,o--;if(o>0){let r=s.node(i).maybeChild(s.indexAfter(i));for(;o>0;){if(!r||r.isLeaf)return!0;r=r.firstChild,o--}}return!1}function ef(n,e,t,s){let o=[],i=[],r,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!s.isInSet(u)&&d.type.allowsMarkType(s.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,t),p=s.addToSet(u);for(let m=0;m<u.length;m++)u[m].isInSet(p)||(r&&r.to==h&&r.mark.eq(u[m])?r.to=f:o.push(r=new Ee(h,f,u[m])));l&&l.to==h?l.to=f:i.push(l=new Qe(h,f,s))}}),o.forEach(a=>n.step(a)),i.forEach(a=>n.step(a))}function tf(n,e,t,s){let o=[],i=0;n.doc.nodesBetween(e,t,(r,l)=>{if(!r.isInline)return;i++;let a=null;if(s instanceof Ws){let c=r.marks,d;for(;d=s.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else s?s.isInSet(r.marks)&&(a=[s]):a=r.marks;if(a&&a.length){let c=Math.min(l+r.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],h;for(let f=0;f<o.length;f++){let p=o[f];p.step==i-1&&u.eq(o[f].style)&&(h=p)}h?(h.to=c,h.step=i):o.push({style:u,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(r=>n.step(new Ee(r.from,r.to,r.style)))}function vi(n,e,t,s=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),r=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),d=l+c.nodeSize,u=s.matchType(c.type);if(!u)r.push(new X(l,d,M.empty));else{s=u;for(let h=0;h<c.marks.length;h++)t.allowsMarkType(c.marks[h].type)||n.step(new Ee(l,d,c.marks[h]));if(o&&c.isText&&t.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new M(k.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),r.push(new X(l+h.index,l+h.index+h[0].length,p))}}l=d}if(!s.validEnd){let a=s.fillBefore(k.empty,!0);n.replace(l,l,new M(a,0,0))}for(let a=r.length-1;a>=0;a--)n.step(r[a])}function nf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function _s(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let s=n.depth;;--s){let o=n.$from.node(s),i=n.$from.index(s),r=n.$to.indexAfter(s);if(s<n.depth&&o.canReplace(i,r,t))return s;if(s==0||o.type.spec.isolating||!nf(o,i,r))break}return null}function sf(n,e,t){let{$from:s,$to:o,depth:i}=e,r=s.before(i+1),l=o.after(i+1),a=r,c=l,d=k.empty,u=0;for(let p=i,m=!1;p>t;p--)m||s.index(p)>0?(m=!0,d=k.from(s.node(p).copy(d)),u++):a--;let h=k.empty,f=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,h=k.from(o.node(p).copy(h)),f++):c++;n.step(new Z(a,c,r,l,new M(d.append(h),u,f),d.size-u,!0))}function za(n,e,t=null,s=n){let o=of(n,e),i=o&&rf(s,e);return i?o.map(kr).concat({type:e,attrs:t}).concat(i.map(kr)):null}function kr(n){return{type:n,attrs:null}}function of(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.contentMatchAt(s).findWrapping(e);if(!i)return null;let r=i.length?i[0]:e;return t.canReplaceWith(s,o,r)?i:null}function rf(n,e){let{parent:t,startIndex:s,endIndex:o}=n,i=t.child(s),r=e.contentMatch.findWrapping(i.type);if(!r)return null;let a=(r.length?r[r.length-1]:e).contentMatch;for(let c=s;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:r}function lf(n,e,t){let s=k.empty;for(let r=t.length-1;r>=0;r--){if(s.size){let l=t[r].type.contentMatch.matchFragment(s);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}s=k.from(t[r].type.create(t[r].attrs,s))}let o=e.start,i=e.end;n.step(new Z(o,i,o,i,new M(s,0,0),t.length,!0))}function af(n,e,t,s,o){if(!s.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(r,l)=>{let a=typeof o=="function"?o(r):o;if(r.isTextblock&&!r.hasMarkup(s,a)&&cf(n.doc,n.mapping.slice(i).map(l),s)){let c=null;if(s.schema.linebreakReplacement){let f=s.whitespace=="pre",p=!!s.contentMatch.matchType(s.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&Va(n,r,l,i),vi(n,n.mapping.slice(i).map(l,1),s,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),h=d.map(l+r.nodeSize,1);return n.step(new Z(u,h,u+1,h-1,new M(k.from(s.create(a,null,r.marks)),0,0),1,!0)),c===!0&&La(n,r,l,i),!1}})}function La(n,e,t,s){e.forEach((o,i)=>{if(o.isText){let r,l=/\r?\n|\r/g;for(;r=l.exec(o.text);){let a=n.mapping.slice(s).map(t+1+i+r.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Va(n,e,t,s){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let r=n.mapping.slice(s).map(t+1+i);n.replaceWith(r,r+1,e.type.schema.text(`
|
|
194
|
+
`))}})}function cf(n,e,t){let s=n.resolve(e),o=s.index();return s.parent.canReplaceWith(o,o+1,t)}function df(n,e,t,s,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let r=t.create(s,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,r);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new Z(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new M(k.from(r),0,0),1,!0))}function Zt(n,e,t=1,s){let o=n.resolve(e),i=o.depth-t,r=s&&s[s.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!r.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,d=t-2;c>i;c--,d--){let u=o.node(c),h=o.index(c);if(u.type.spec.isolating)return!1;let f=u.content.cutByIndex(h,u.childCount),p=s&&s[d+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let m=s&&s[d]||u;if(!u.canReplace(h+1,u.childCount)||!m.type.validContent(f))return!1}let l=o.indexAfter(i),a=s&&s[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function uf(n,e,t=1,s){let o=n.doc.resolve(e),i=k.empty,r=k.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=k.from(o.node(l).copy(i));let d=s&&s[c];r=k.from(d?d.type.create(d.attrs,r):o.node(l).copy(r))}n.step(new X(e,e,new M(i.append(r),t,t),!0))}function qs(n,e){let t=n.resolve(e),s=t.index();return ff(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(s,s+1)}function hf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:s}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),r=i.type==s?n.type.schema.nodes.text:i.type;if(t=t.matchType(r),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function ff(n,e){return!!(n&&e&&!n.isLeaf&&hf(n,e))}function pf(n,e,t){let s=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),r=i.node().type;if(o&&r.inlineContent){let d=r.whitespace=="pre",u=!!r.contentMatch.matchType(o);d&&!u?s=!1:!d&&u&&(s=!0)}let l=n.steps.length;if(s===!1){let d=n.doc.resolve(e+t);Va(n,d.node(),d.before(),l)}r.inlineContent&&vi(n,e+t-1,r,i.node().contentMatchAt(i.index()),s==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new X(c,a.map(e+t,-1),M.empty,!0)),s===!0){let d=n.doc.resolve(c);La(n,d.node(),d.before(),n.steps.length)}return n}function mf(n,e,t){let s=n.resolve(e);if(s.parent.canReplaceWith(s.index(),s.index(),t))return e;if(s.parentOffset==0)for(let o=s.depth-1;o>=0;o--){let i=s.index(o);if(s.node(o).canReplaceWith(i,i,t))return s.before(o+1);if(i>0)return null}if(s.parentOffset==s.parent.content.size)for(let o=s.depth-1;o>=0;o--){let i=s.indexAfter(o);if(s.node(o).canReplaceWith(i,i,t))return s.after(o+1);if(i<s.node(o).childCount)return null}return null}function gf(n,e,t){let s=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let i=0;i<t.openStart;i++)o=o.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let r=s.depth;r>=0;r--){let l=r==s.depth?0:s.pos<=(s.start(r+1)+s.end(r+1))/2?-1:1,a=s.index(r)+(l>0?1:0),c=s.node(r),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?s.pos:l<0?s.before(r+1):s.after(r+1)}return null}function wi(n,e,t=e,s=M.empty){if(e==t&&!s.size)return null;let o=n.resolve(e),i=n.resolve(t);return Ba(o,i,s)?new X(e,t,s):new yf(o,i,s).fit()}function Ba(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class yf{constructor(e,t,s){this.$from=e,this.$to=t,this.unplaced=s,this.frontier=[],this.placed=k.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=k.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,s=this.$from,o=this.close(e<0?this.$to:s.doc.resolve(e));if(!o)return null;let i=this.placed,r=s.depth,l=o.depth;for(;r&&l&&i.childCount==1;)i=i.firstChild.content,r--,l--;let a=new M(i,r,l);return e>-1?new Z(s.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||s.pos!=this.$to.pos?new X(s.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,s=0,o=this.unplaced.openEnd;s<e;s++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=s){e=s;break}t=i.content}for(let t=1;t<=2;t++)for(let s=t==1?e:this.unplaced.openStart;s>=0;s--){let o,i=null;s?(i=ro(this.unplaced.content,s-1).firstChild,o=i.content):o=this.unplaced.content;let r=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(r?c.matchType(r.type)||(u=c.fillBefore(k.from(r),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:s,frontierDepth:l,parent:i,inject:u};if(t==2&&r&&(d=c.findWrapping(r.type)))return{sliceDepth:s,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=ro(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new M(e,t+1,Math.max(s,o.size+t>=e.size-s?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:s}=this.unplaced,o=ro(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new M(yn(e,t-1,1),t-1,i?t-1:s)}else this.unplaced=new M(yn(e,t,1),t,s)}placeNodes({sliceDepth:e,frontierDepth:t,parent:s,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m<i.length;m++)this.openFrontierNode(i[m]);let r=this.unplaced,l=s?s.content:r.content,a=r.openStart-e,c=0,d=[],{match:u,type:h}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)d.push(o.child(m));u=u.matchFragment(o)}let f=l.size+e-(r.content.size-r.openEnd);for(;c<l.childCount;){let m=l.child(c),g=u.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(u=g,d.push(Ha(m.mark(h.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=bn(this.placed,t,k.from(d)),this.frontier[t].match=u,p&&f<0&&s&&s.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<f;m++){let b=g.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),g=b.content}this.unplaced=p?e==0?M.empty:new M(yn(r.content,e-1,1),e-1,f<0?r.openEnd:e-1):new M(yn(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||!lo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:s}=this.$to,o=this.$to.after(s);for(;s>1&&o==this.$to.end(--s);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:s,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),r=lo(e,t,o,s,i);if(r){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=lo(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=bn(this.placed,t.depth,t.fit)),e=t.move;for(let s=t.depth+1;s<=e.depth;s++){let o=e.node(s),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(s));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,s){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=bn(this.placed,this.depth,k.from(e.create(t,s))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(k.empty,!0);t.childCount&&(this.placed=bn(this.placed,this.frontier.length,t))}}function yn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(yn(n.firstChild.content,e-1,t)))}function bn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(bn(n.lastChild.content,e-1,t)))}function ro(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ha(n,e,t){if(e<=0)return n;let s=n.content;return e>1&&(s=s.replaceChild(0,Ha(s.firstChild,e-1,s.childCount==1?t-1:0))),e>0&&(s=n.type.contentMatch.fillBefore(s).append(s),t<=0&&(s=s.append(n.type.contentMatch.matchFragment(s).fillBefore(k.empty,!0)))),n.copy(s)}function lo(n,e,t,s,o){let i=n.node(e),r=o?n.indexAfter(e):n.index(e);if(r==i.childCount&&!t.compatibleContent(i.type))return null;let l=s.fillBefore(i.content,!0,r);return l&&!bf(t,i.content,r)?l:null}function bf(n,e,t){for(let s=t;s<e.childCount;s++)if(!n.allowsMarks(e.child(s).marks))return!0;return!1}function vf(n){return n.spec.defining||n.spec.definingForContent}function wf(n,e,t,s){if(!s.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(Ba(o,i,s))return n.step(new X(e,t,s));let r=Fa(o,n.doc.resolve(t));r[r.length-1]==0&&r.pop();let l=-(o.depth+1);r.unshift(l);for(let h=o.depth,f=o.pos-1;h>0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;r.indexOf(h)>-1?l=h:o.before(h)==f&&r.splice(1,0,-h)}let a=r.indexOf(l),c=[],d=s.openStart;for(let h=s.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==s.openStart)break;h=p.content}for(let h=d-1;h>=0;h--){let f=c[h],p=vf(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))d=h;else if(p||!f.type.isTextblock)break}for(let h=s.openStart;h>=0;h--){let f=(h+d+1)%(s.openStart+1),p=c[f];if(p)for(let m=0;m<r.length;m++){let g=r[(m+a)%r.length],b=!0;g<0&&(b=!1,g=-g);let C=o.node(g-1),y=o.index(g-1);if(C.canReplaceWith(y,y,p.type,p.marks))return n.replace(o.before(g),b?i.after(g):t,new M($a(s.content,0,s.openStart,f),f,s.openEnd))}}let u=n.steps.length;for(let h=r.length-1;h>=0&&(n.replace(e,t,s),!(n.steps.length>u));h--){let f=r[h];f<0||(e=o.before(f),t=i.after(f))}}function $a(n,e,t,s,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy($a(i.content,e+1,t,s,i)))}if(e>s){let i=o.contentMatchAt(0),r=i.fillBefore(n).append(n);n=r.append(i.matchFragment(r).fillBefore(k.empty,!0))}return n}function Sf(n,e,t,s){if(!s.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=mf(n.doc,e,s.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new M(k.from(s),0,0))}function Cf(n,e,t){let s=n.doc.resolve(e),o=n.doc.resolve(t),i=Fa(s,o);for(let r=0;r<i.length;r++){let l=i[r],a=r==i.length-1;if(a&&l==0||s.node(l).type.contentMatch.validEnd)return n.delete(s.start(l),o.end(l));if(l>0&&(a||s.node(l-1).canReplace(s.index(l-1),o.indexAfter(l-1))))return n.delete(s.before(l),o.after(l))}for(let r=1;r<=s.depth&&r<=o.depth;r++)if(e-s.start(r)==s.depth-r&&t>s.end(r)&&o.end(r)-t!=o.depth-r&&s.start(r-1)==o.start(r-1)&&s.node(r-1).canReplace(s.index(r-1),o.index(r-1)))return n.delete(s.before(r),t);n.delete(e,t)}function Fa(n,e){let t=[],s=Math.min(n.depth,e.depth);for(let o=s;o>=0;o--){let i=n.start(o);if(i<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}class Yt extends ne{constructor(e,t,s){super(),this.pos=e,this.attr=t,this.value=s}apply(e){let t=e.nodeAt(this.pos);if(!t)return q.fail("No node at attribute step's position");let s=Object.create(null);for(let i in t.attrs)s[i]=t.attrs[i];s[this.attr]=this.value;let o=t.type.create(s,null,t.marks);return q.fromReplace(e,this.pos,this.pos+1,new M(k.from(o),0,t.isLeaf?0:1))}getMap(){return ue.empty}invert(e){return new Yt(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 Yt(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 Yt(t.pos,t.attr,t.value)}}ne.jsonID("attr",Yt);class zn extends ne{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let s=e.type.create(t,e.content,e.marks);return q.ok(s)}getMap(){return ue.empty}invert(e){return new zn(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new zn(t.attr,t.value)}}ne.jsonID("docAttr",zn);let sn=class extends Error{};sn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};sn.prototype=Object.create(Error.prototype);sn.prototype.constructor=sn;sn.prototype.name="TransformError";class Wa{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ut}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new sn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,s=M.empty){let o=wi(this.doc,e,t,s);return o&&this.step(o),this}replaceWith(e,t,s){return this.replace(e,t,new M(k.from(s),0,0))}delete(e,t){return this.replace(e,t,M.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,s){return wf(this,e,t,s),this}replaceRangeWith(e,t,s){return Sf(this,e,t,s),this}deleteRange(e,t){return Cf(this,e,t),this}lift(e,t){return sf(this,e,t),this}join(e,t=1){return pf(this,e,t),this}wrap(e,t){return lf(this,e,t),this}setBlockType(e,t=e,s,o=null){return af(this,e,t,s,o),this}setNodeMarkup(e,t,s=null,o){return df(this,e,t,s,o),this}setNodeAttribute(e,t,s){return this.step(new Yt(e,t,s)),this}setDocAttribute(e,t){return this.step(new zn(e,t)),this}addNodeMark(e,t){return this.step(new et(e,t)),this}removeNodeMark(e,t){if(!(t instanceof V)){let s=this.doc.nodeAt(e);if(!s)throw new RangeError("No node at position "+e);if(t=t.isInSet(s.marks),!t)return this}return this.step(new nn(e,t)),this}split(e,t=1,s){return uf(this,e,t,s),this}addMark(e,t,s){return ef(this,e,t,s),this}removeMark(e,t,s){return tf(this,e,t,s),this}clearIncompatible(e,t,s){return vi(this,e,t,s),this}}const ao=Object.create(null);class I{constructor(e,t,s){this.$anchor=e,this.$head=t,this.ranges=s||[new _a(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=M.empty){let s=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=s,s=s.lastChild;let i=e.steps.length,r=this.ranges;for(let l=0;l<r.length;l++){let{$from:a,$to:c}=r[l],d=e.mapping.slice(i);e.replaceRange(d.map(a.pos),d.map(c.pos),l?M.empty:t),l==0&&Ar(e,i,(s?s.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let s=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:r,$to:l}=o[i],a=e.mapping.slice(s),c=a.map(r.pos),d=a.map(l.pos);i?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),Ar(e,s,t.isInline?-1:1))}}static findFrom(e,t,s=!1){let o=e.parent.inlineContent?new R(e):Ft(e.node(0),e.parent,e.pos,e.index(),t,s);if(o)return o;for(let i=e.depth-1;i>=0;i--){let r=t<0?Ft(e.node(0),e.node(i),e.before(i+1),e.index(i),t,s):Ft(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,s);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new fe(e.node(0))}static atStart(e){return Ft(e,e,0,0,1)||new fe(e)}static atEnd(e){return Ft(e,e,e.content.size,e.childCount,-1)||new fe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=ao[t.type];if(!s)throw new RangeError(`No selection type ${t.type} defined`);return s.fromJSON(e,t)}static jsonID(e,t){if(e in ao)throw new RangeError("Duplicate use of selection JSON ID "+e);return ao[e]=t,t.prototype.jsonID=e,t}getBookmark(){return R.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class _a{constructor(e,t){this.$from=e,this.$to=t}}let Tr=!1;function Mr(n){!Tr&&!n.parent.inlineContent&&(Tr=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class R extends I{constructor(e,t=e){Mr(e),Mr(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let s=e.resolve(t.map(this.head));if(!s.parent.inlineContent)return I.near(s);let o=e.resolve(t.map(this.anchor));return new R(o.parent.inlineContent?o:s,s)}replace(e,t=M.empty){if(super.replace(e,t),t==M.empty){let s=this.$from.marksAcross(this.$to);s&&e.ensureMarks(s)}}eq(e){return e instanceof R&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Gs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new R(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){let o=e.resolve(t);return new this(o,s==t?o:e.resolve(s))}static between(e,t,s){let o=e.pos-t.pos;if((!s||o)&&(s=o>=0?1:-1),!t.parent.inlineContent){let i=I.findFrom(t,s,!0)||I.findFrom(t,-s,!0);if(i)t=i.$head;else return I.near(t,s)}return e.parent.inlineContent||(o==0?e=t:(e=(I.findFrom(e,-s,!0)||I.findFrom(e,s,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new R(e,t)}}I.jsonID("text",R);class Gs{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Gs(e.map(this.anchor),e.map(this.head))}resolve(e){return R.between(e.resolve(this.anchor),e.resolve(this.head))}}class N extends I{constructor(e){let t=e.nodeAfter,s=e.node(0).resolve(e.pos+t.nodeSize);super(e,s),this.node=t}map(e,t){let{deleted:s,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return s?I.near(i):new N(i)}content(){return new M(k.from(this.node),0,0)}eq(e){return e instanceof N&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Si(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new N(e.resolve(t.anchor))}static create(e,t){return new N(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}N.prototype.visible=!1;I.jsonID("node",N);class Si{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:s}=e.mapResult(this.anchor);return t?new Gs(s,s):new Si(s)}resolve(e){let t=e.resolve(this.anchor),s=t.nodeAfter;return s&&N.isSelectable(s)?new N(t):I.near(t)}}class fe extends I{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=M.empty){if(t==M.empty){e.delete(0,e.doc.content.size);let s=I.atStart(e.doc);s.eq(e.selection)||e.setSelection(s)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new fe(e)}map(e){return new fe(e)}eq(e){return e instanceof fe}getBookmark(){return xf}}I.jsonID("all",fe);const xf={map(){return this},resolve(n){return new fe(n)}};function Ft(n,e,t,s,o,i=!1){if(e.inlineContent)return R.create(n,t);for(let r=s-(o>0?0:1);o>0?r<e.childCount:r>=0;r+=o){let l=e.child(r);if(l.isAtom){if(!i&&N.isSelectable(l))return N.create(n,t-(o<0?l.nodeSize:0))}else{let a=Ft(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function Ar(n,e,t){let s=n.steps.length-1;if(s<e)return;let o=n.steps[s];if(!(o instanceof X||o instanceof Z))return;let i=n.mapping.maps[s],r;i.forEach((l,a,c,d)=>{r==null&&(r=d)}),n.setSelection(I.near(n.doc.resolve(r),t))}const Er=1,ss=2,Or=4;class kf extends Wa{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Er)&~ss,this.storedMarks=null,this}get selectionSet(){return(this.updated&Er)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ss,this}ensureMarks(e){return V.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ss)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ss,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let s=this.selection;return t&&(e=e.mark(this.storedMarks||(s.empty?s.$from.marks():s.$from.marksAcross(s.$to)||V.none))),s.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,s){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(s==null&&(s=t),s=s??t,!e)return this.deleteRange(t,s);let i=this.storedMarks;if(!i){let r=this.doc.resolve(t);i=s==t?r.marks():r.marksAcross(this.doc.resolve(s))}return this.replaceRangeWith(t,s,o.text(e,i)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Or,this}get scrolledIntoView(){return(this.updated&Or)>0}}function Nr(n,e){return!e||!n?n:n.bind(e)}class vn{constructor(e,t,s){this.name=e,this.init=Nr(t.init,s),this.apply=Nr(t.apply,s)}}const Tf=[new vn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new vn("selection",{init(n,e){return n.selection||I.atStart(e.doc)},apply(n){return n.selection}}),new vn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,s){return s.selection.$cursor?n.storedMarks:null}}),new vn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class co{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Tf.slice(),t&&t.forEach(s=>{if(this.pluginsByKey[s.key])throw new RangeError("Adding different instances of a keyed plugin ("+s.key+")");this.plugins.push(s),this.pluginsByKey[s.key]=s,s.spec.state&&this.fields.push(new vn(s.key,s.spec.state,s))})}}class Gt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let s=0;s<this.config.plugins.length;s++)if(s!=t){let o=this.config.plugins[s];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],s=this.applyInner(e),o=null;for(;;){let i=!1;for(let r=0;r<this.config.plugins.length;r++){let l=this.config.plugins[r];if(l.spec.appendTransaction){let a=o?o[r].n:0,c=o?o[r].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,s);if(d&&s.filterTransaction(d,r)){if(d.setMeta("appendedTransaction",e),!o){o=[];for(let u=0;u<this.config.plugins.length;u++)o.push(u<r?{state:s,n:t.length}:{state:this,n:0})}t.push(d),s=s.applyInner(d),i=!0}o&&(o[r]={state:s,n:t.length})}}if(!i)return{state:s,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Gt(this.config),s=this.config.fields;for(let o=0;o<s.length;o++){let i=s[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new kf(this)}static create(e){let t=new co(e.doc?e.doc.type.schema:e.schema,e.plugins),s=new Gt(t);for(let o=0;o<t.fields.length;o++)s[t.fields[o].name]=t.fields[o].init(e,s);return s}reconfigure(e){let t=new co(this.schema,e.plugins),s=t.fields,o=new Gt(t);for(let i=0;i<s.length;i++){let r=s[i].name;o[r]=this.hasOwnProperty(r)?this[r]:s[i].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(s=>s.toJSON())),e&&typeof e=="object")for(let s in e){if(s=="doc"||s=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[s],i=o.spec.state;i&&i.toJSON&&(t[s]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,s){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new co(e.schema,e.plugins),i=new Gt(o);return o.fields.forEach(r=>{if(r.name=="doc")i.doc=Ct.fromJSON(e.schema,t.doc);else if(r.name=="selection")i.selection=I.fromJSON(i.doc,t.selection);else if(r.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(s)for(let l in s){let a=s[l],c=a.spec.state;if(a.key==r.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[r.name]=c.fromJSON.call(a,e,t[l],i);return}}i[r.name]=r.init(e,i)}}),i}}function qa(n,e,t){for(let s in n){let o=n[s];o instanceof Function?o=o.bind(e):s=="handleDOMEvents"&&(o=qa(o,e,{})),t[s]=o}return t}class Fn{constructor(e){this.spec=e,this.props={},e.props&&qa(e.props,this,this.props),this.key=e.key?e.key.key:Ga("plugin")}getState(e){return e[this.key]}}const uo=Object.create(null);function Ga(n){return n in uo?n+"$"+ ++uo[n]:(uo[n]=0,n+"$")}class Wn{constructor(e="key"){this.key=Ga(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const ja=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Mf(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Af=(n,e,t)=>{let s=Mf(n,t);if(!s)return!1;let o=Ka(s);if(!o){let r=s.blockRange(),l=r&&_s(r);return l==null?!1:(e&&e(n.tr.lift(r,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Qa(n,o,e,-1))return!0;if(s.parent.content.size==0&&(on(i,"end")||N.isSelectable(i)))for(let r=s.depth;;r--){let l=wi(n.doc,s.before(r),s.after(r),M.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(on(i,"end")?I.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):N.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(r==1||s.node(r-1).childCount>1)break}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function on(n,e,t=!1){for(let s=n;s;s=e=="start"?s.firstChild:s.lastChild){if(s.isTextblock)return!0;if(t&&s.childCount!=1)return!1}return!1}const Ef=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):s.parentOffset>0)return!1;i=Ka(s)}let r=i&&i.nodeBefore;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos-r.nodeSize)).scrollIntoView()),!0)};function Ka(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 Of(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Nf=(n,e,t)=>{let s=Of(n,t);if(!s)return!1;let o=Ja(s);if(!o)return!1;let i=o.nodeAfter;if(Qa(n,o,e,1))return!0;if(s.parent.content.size==0&&(on(i,"start")||N.isSelectable(i))){let r=wi(n.doc,s.before(),s.after(),M.empty);if(r&&r.slice.size<r.to-r.from){if(e){let l=n.tr.step(r);l.setSelection(on(i,"start")?I.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):N.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==s.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Pf=(n,e,t)=>{let{$head:s,empty:o}=n.selection,i=s;if(!o)return!1;if(s.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):s.parentOffset<s.parent.content.size)return!1;i=Ja(s)}let r=i&&i.nodeAfter;return!r||!N.isSelectable(r)?!1:(e&&e(n.tr.setSelection(N.create(n.doc,i.pos)).scrollIntoView()),!0)};function Ja(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 If=(n,e)=>{let{$head:t,$anchor:s}=n.selection;return!t.parent.type.spec.code||!t.sameParent(s)?!1:(e&&e(n.tr.insertText(`
|
|
195
|
+
`).scrollIntoView()),!0)};function Ci(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 Ua=(n,e)=>{let{$head:t,$anchor:s}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(s))return!1;let o=t.node(-1),i=t.indexAfter(-1),r=Ci(o.contentMatchAt(i));if(!r||!o.canReplaceWith(i,i,r))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,r.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Rf=(n,e)=>{let t=n.selection,{$from:s,$to:o}=t;if(t instanceof fe||s.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ci(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let r=(!s.parentOffset&&o.index()<o.parent.childCount?s:o).pos,l=n.tr.insert(r,i.createAndFill());l.setSelection(R.create(l.doc,r+1)),e(l.scrollIntoView())}return!0},Za=(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(Zt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let s=t.blockRange(),o=s&&_s(s);return o==null?!1:(e&&e(n.tr.lift(s,o).scrollIntoView()),!0)};function Ya(n){return(e,t)=>{let{$from:s,$to:o}=e.selection;if(e.selection instanceof N&&e.selection.node.isBlock)return!s.parentOffset||!Zt(e.doc,s.pos)?!1:(t&&t(e.tr.split(s.pos).scrollIntoView()),!0);if(!s.depth)return!1;let i=[],r,l,a=!1,c=!1;for(let f=s.depth;;f--)if(s.node(f).isBlock){a=s.end(f)==s.pos+(s.depth-f),c=s.start(f)==s.pos-(s.depth-f),l=Ci(s.node(f-1).contentMatchAt(s.indexAfter(f-1)));let m=n&&n(o.parent,a,s);i.unshift(m||(a&&l?{type:l}:null)),r=f;break}else{if(f==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof R||e.selection instanceof fe)&&d.deleteSelection();let u=d.mapping.map(s.pos),h=Zt(d.doc,u,i.length,i);if(h||(i[0]=l?{type:l}:null,h=Zt(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&s.node(r).type!=l){let f=d.mapping.map(s.before(r)),p=d.doc.resolve(f);l&&s.node(r-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(s.before(r)),l)}return t&&t(d.scrollIntoView()),!0}}const Df=Ya(),Xa=(n,e)=>(e&&e(n.tr.setSelection(new fe(n.doc))),!0);function zf(n,e,t){let s=e.nodeBefore,o=e.nodeAfter,i=e.index();return!s||!o||!s.type.compatibleContent(o.type)?!1:!s.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-s.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||qs(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Qa(n,e,t,s){let o=e.nodeBefore,i=e.nodeAfter,r,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&zf(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(r=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(r[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,p=k.empty;for(let b=r.length-1;b>=0;b--)p=k.from(r[b].create(null,p));p=k.from(o.copy(p));let m=n.tr.step(new Z(e.pos-1,f,e.pos,f,new M(p,1,0),r.length,!0)),g=m.doc.resolve(f+2*r.length);g.nodeAfter&&g.nodeAfter.type==o.type&&qs(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||s>0&&a?null:I.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),h=u&&_s(u);if(h!=null&&h>=e.depth)return t&&t(n.tr.lift(u,h).scrollIntoView()),!0;if(c&&on(i,"start",!0)&&on(o,"end")){let f=o,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(f.canReplace(f.childCount,f.childCount,m.content)){if(t){let b=k.empty;for(let y=p.length-1;y>=0;y--)b=k.from(p[y].copy(b));let C=n.tr.step(new Z(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new M(b,p.length,0),0,!0));t(C.scrollIntoView())}return!0}}return!1}function ec(n){return function(e,t){let s=e.selection,o=n<0?s.$from:s.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(R.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}const Lf=ec(-1),Vf=ec(1);function Bf(n,e=null){return function(t,s){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:r},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(r,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(s){let i=t.tr;for(let r=0;r<t.selection.ranges.length;r++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[r];i.setBlockType(l,a,n,e)}s(i.scrollIntoView())}return!0}}function Hf(n,e,t,s){for(let o=0;o<e.length;o++){let{$from:i,$to:r}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,r.pos,(a,c)=>{if(l||!s)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ft(n,e=null,t){let s=t!==!1;return function(o,i){let{empty:r,$cursor:l,ranges:a}=o.selection;if(r&&!l||!Hf(o.doc,a,n,s))return!1;if(i)if(l)n.isInSet(o.storedMarks||l.marks())?i(o.tr.removeStoredMark(n)):i(o.tr.addStoredMark(n.create(e)));else{let c,d=o.tr;c=!a.some(u=>o.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<a.length;u++){let{$from:h,$to:f}=a[u];if(!c)d.removeMark(h.pos,f.pos,n);else{let p=h.pos,m=f.pos,g=h.nodeAfter,b=f.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,y=b&&b.isText?/\s*$/.exec(b.text)[0].length:0;p+C<m&&(p+=C,m-=y),d.addMark(p,m,n.create(e))}}i(d.scrollIntoView())}return!0}}function Ln(...n){return function(e,t,s){for(let o=0;o<n.length;o++)if(n[o](e,t,s))return!0;return!1}}let ho=Ln(ja,Af,Ef),Pr=Ln(ja,Nf,Pf);const Be={Enter:Ln(If,Rf,Za,Df),"Mod-Enter":Ua,Backspace:ho,"Mod-Backspace":ho,"Shift-Backspace":ho,Delete:Pr,"Mod-Delete":Pr,"Mod-a":Xa},tc={"Ctrl-h":Be.Backspace,"Alt-Backspace":Be["Mod-Backspace"],"Ctrl-d":Be.Delete,"Ctrl-Alt-Backspace":Be["Mod-Delete"],"Alt-Delete":Be["Mod-Delete"],"Alt-d":Be["Mod-Delete"],"Ctrl-a":Lf,"Ctrl-e":Vf};for(let n in Be)tc[n]=Be[n];const $f=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Ff=$f?tc:Be;var Os=200,G=function(){};G.prototype.append=function(e){return e.length?(e=G.from(e),!this.length&&e||e.length<Os&&this.leafAppend(e)||this.length<Os&&e.leafPrepend(this)||this.appendInner(e)):this};G.prototype.prepend=function(e){return e.length?G.from(e).append(this):this};G.prototype.appendInner=function(e){return new Wf(this,e)};G.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?G.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};G.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};G.prototype.forEach=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length),t<=s?this.forEachInner(e,t,s,0):this.forEachInvertedInner(e,t,s,0)};G.prototype.map=function(e,t,s){t===void 0&&(t=0),s===void 0&&(s=this.length);var o=[];return this.forEach(function(i,r){return o.push(e(i,r))},t,s),o};G.from=function(e){return e instanceof G?e:e&&e.length?new nc(e):G.empty};var nc=function(n){function e(s){n.call(this),this.values=s}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,r,l){for(var a=i;a<r;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,r,l){for(var a=i-1;a>=r;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Os)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Os)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(G);G.empty=new nc([]);var Wf=function(n){function e(t,s){n.call(this),this.left=t,this.right=s,this.length=t.length+s.length,this.depth=Math.max(t.depth,s.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(s){return s<this.left.length?this.left.get(s):this.right.get(s-this.left.length)},e.prototype.forEachInner=function(s,o,i,r){var l=this.left.length;if(o<l&&this.left.forEachInner(s,o,Math.min(i,l),r)===!1||i>l&&this.right.forEachInner(s,Math.max(o-l,0),Math.min(this.length,i)-l,r+l)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,r){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(s,o-l,Math.max(i,l)-l,r+l)===!1||i<l&&this.left.forEachInvertedInner(s,Math.min(o,l),i,r)===!1)return!1},e.prototype.sliceInner=function(s,o){if(s==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(s,o):s>=i?this.right.slice(s-i,o-i):this.left.slice(s,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(s){var o=this.right.leafAppend(s);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(s){var o=this.left.leafPrepend(s);if(o)return new e(o,this.right)},e.prototype.appendInner=function(s){return this.left.depth>=Math.max(this.right.depth,s.depth)+1?new e(this.left,new e(this.right,s)):new e(this,s)},e}(G);const _f=500;class xe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let s=this.items.length;for(;;s--)if(this.items.get(s-1).selection){--s;break}let o,i;t&&(o=this.remapping(s,this.items.length),i=o.maps.length);let r=e.tr,l,a,c=[],d=[];return this.items.forEach((u,h)=>{if(!u.step){o||(o=this.remapping(s,h+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new Ae(u.map));let f=u.step.map(o.slice(i)),p;f&&r.maybeStep(f).doc&&(p=r.mapping.maps[r.mapping.maps.length-1],c.push(new Ae(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else r.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new xe(this.items.slice(0,s).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:r,selection:l}}addTransform(e,t,s,o){let i=[],r=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),h=new Ae(e.mapping.maps[d],u,t),f;(f=a&&a.merge(h))&&(h=f,d?i.pop():l=l.slice(0,l.length-1)),i.push(h),t&&(r++,t=void 0),o||(a=h)}let c=r-s.depth;return c>Gf&&(l=qf(l,c),r-=c),new xe(l.append(i),r)}remapping(e,t){let s=new Ut;return this.items.forEach((o,i)=>{let r=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?s.maps.length-o.mirrorOffset:void 0;s.appendMap(o.map,r)},e,t),s}addMaps(e){return this.eventCount==0?this:new xe(this.items.append(e.map(t=>new Ae(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let s=[],o=Math.max(0,this.items.length-t),i=e.mapping,r=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},o);let a=t;this.items.forEach(h=>{let f=i.getMirror(--a);if(f==null)return;r=Math.min(r,f);let p=i.maps[f];if(h.step){let m=e.steps[f].invert(e.docs[f]),g=h.selection&&h.selection.map(i.slice(a+1,f));g&&l++,s.push(new Ae(p,m,g))}else s.push(new Ae(p))},o);let c=[];for(let h=t;h<r;h++)c.push(new Ae(i.maps[h]));let d=this.items.slice(0,o).append(c).append(s),u=new xe(d,l);return u.emptyItemCount()>_f&&(u=u.compress(this.items.length-s.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),s=t.maps.length,o=[],i=0;return this.items.forEach((r,l)=>{if(l>=e)o.push(r),r.selection&&i++;else if(r.step){let a=r.step.map(t.slice(s)),c=a&&a.getMap();if(s--,c&&t.appendMap(c,s),a){let d=r.selection&&r.selection.map(t.slice(s));d&&i++;let u=new Ae(c.invert(),a,d),h,f=o.length-1;(h=o.length&&o[f].merge(u))?o[f]=h:o.push(u)}}else r.map&&s--},this.items.length,0),new xe(G.from(o.reverse()),i)}}xe.empty=new xe(G.empty,0);function qf(n,e){let t;return n.forEach((s,o)=>{if(s.selection&&e--==0)return t=o,!1}),n.slice(t)}class Ae{constructor(e,t,s,o){this.map=e,this.step=t,this.selection=s,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ae(t.getMap().invert(),t,this.selection)}}}class je{constructor(e,t,s,o,i){this.done=e,this.undone=t,this.prevRanges=s,this.prevTime=o,this.prevComposition=i}}const Gf=20;function jf(n,e,t,s){let o=t.getMeta(xt),i;if(o)return o.historyState;t.getMeta(Uf)&&(n=new je(n.done,n.undone,null,0,-1));let r=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(r&&r.getMeta(xt))return r.getMeta(xt).redo?new je(n.done.addTransform(t,void 0,s,fs(e)),n.undone,Ir(t.mapping.maps),n.prevTime,n.prevComposition):new je(n.done,n.undone.addTransform(t,void 0,s,fs(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(r&&r.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!r&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-s.newGroupDelay||!Kf(t,n.prevRanges)),c=r?fo(n.prevRanges,t.mapping):Ir(t.mapping.maps);return new je(n.done.addTransform(t,a?e.selection.getBookmark():void 0,s,fs(e)),xe.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new je(n.done.rebased(t,i),n.undone.rebased(t,i),fo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new je(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),fo(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Kf(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((s,o)=>{for(let i=0;i<e.length;i+=2)s<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function Ir(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((s,o,i,r)=>e.push(i,r));return e}function fo(n,e){if(!n)return null;let t=[];for(let s=0;s<n.length;s+=2){let o=e.map(n[s],1),i=e.map(n[s+1],-1);o<=i&&t.push(o,i)}return t}function Jf(n,e,t){let s=fs(e),o=xt.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,s);if(!i)return null;let r=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,e.selection.getBookmark(),o,s),a=new je(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(r).setMeta(xt,{redo:t,historyState:a})}let po=!1,Rr=null;function fs(n){let e=n.plugins;if(Rr!=e){po=!1,Rr=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){po=!0;break}}return po}const xt=new Wn("history"),Uf=new Wn("closeHistory");function Zf(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Fn({key:xt,state:{init(){return new je(xe.empty,xe.empty,null,0,-1)},apply(e,t,s){return jf(t,s,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let s=t.inputType,o=s=="historyUndo"?oc:s=="historyRedo"?jo:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function sc(n,e){return(t,s)=>{let o=xt.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(s){let i=Jf(o,t,n);i&&s(e?i.scrollIntoView():i)}return!0}}const oc=sc(!1,!0),jo=sc(!0,!0);var it={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:"'"},Ns={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yf=typeof navigator<"u"&&/Mac/.test(navigator.platform),Xf=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var J=0;J<10;J++)it[48+J]=it[96+J]=String(J);for(var J=1;J<=24;J++)it[J+111]="F"+J;for(var J=65;J<=90;J++)it[J]=String.fromCharCode(J+32),Ns[J]=String.fromCharCode(J);for(var mo in it)Ns.hasOwnProperty(mo)||(Ns[mo]=it[mo]);function Qf(n){var e=Yf&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Xf&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ns:it)[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 ep=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function tp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let s,o,i,r;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))r=!0;else if(/^a(lt)?$/i.test(a))s=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))ep?r=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return s&&(t="Alt-"+t),o&&(t="Ctrl-"+t),r&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function np(n){let e=Object.create(null);for(let t in n)e[tp(t)]=n[t];return e}function go(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function yo(n){return new Fn({props:{handleKeyDown:ic(n)}})}function ic(n){let e=np(n);return function(t,s){let o=Qf(s),i,r=e[go(o,s)];if(r&&r(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(s.shiftKey){let l=e[go(o,s,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((s.shiftKey||s.altKey||s.metaKey||o.charCodeAt(0)>127)&&(i=it[s.keyCode])&&i!=o){let l=e[go(i,s)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}function Dr(n,e=null){return function(t,s){let{$from:o,$to:i}=t.selection,r=o.blockRange(i),l=!1,a=r;if(!r)return!1;if(r.depth>=2&&o.node(r.depth-1).type.compatibleContent(n)&&r.startIndex==0){if(o.index(r.depth-1)==0)return!1;let d=t.doc.resolve(r.start-2);a=new Ts(d,d,r.depth),r.endIndex<r.parent.childCount&&(r=new Ts(o,t.doc.resolve(i.end(r.depth)),r.depth)),l=!0}let c=za(a,n,e,r);return c?(s&&s(sp(t.tr,r,c,l,n).scrollIntoView()),!0):!1}}function sp(n,e,t,s,o){let i=k.empty;for(let d=t.length-1;d>=0;d--)i=k.from(t[d].type.create(t[d].attrs,i));n.step(new Z(e.start-(s?2:0),e.end,e.start,e.end,new M(i,0,0),t.length,!0));let r=0;for(let d=0;d<t.length;d++)t[d].type==o&&(r=d+1);let l=t.length-r,a=e.start+t.length-(s?2:0),c=e.parent;for(let d=e.startIndex,u=e.endIndex,h=!0;d<u;d++,h=!1)!h&&Zt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(d).nodeSize;return n}function op(n,e){return function(t,s){let{$from:o,$to:i,node:r}=t.selection;if(r&&r.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(s){let u=k.empty,h=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-h;b>=o.depth-3;b--)u=k.from(o.node(b).copy(u));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;u=u.append(k.from(n.createAndFill()));let p=o.before(o.depth-(h-1)),m=t.tr.replace(p,o.after(-f),new M(u,4-h,0)),g=-1;m.doc.nodesBetween(p,m.doc.content.size,(b,C)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=C+1)}),g>-1&&m.setSelection(I.near(m.doc.resolve(g))),s(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),d=a?[null,{type:a}]:void 0;return Zt(c.doc,o.pos,2,d)?(s&&s(c.split(o.pos,2,d).scrollIntoView()),!0):!1}}function Ko(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,r=>r.childCount>0&&r.firstChild.type==n);return i?t?s.node(i.depth-1).type==n?ip(e,t,n,i):rp(e,t,i):!0:!1}}function ip(n,e,t,s){let o=n.tr,i=s.end,r=s.$to.end(s.depth);i<r&&(o.step(new Z(i-1,r,i,r,new M(k.from(t.create(null,s.parent.copy())),1,0),1,!0)),s=new Ts(o.doc.resolve(s.$from.pos),o.doc.resolve(r),s.depth));const l=_s(s);if(l==null)return!1;o.lift(s,l);let a=o.mapping.map(i,-1)-1;return qs(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function rp(n,e,t){let s=n.tr,o=t.parent;for(let f=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)f-=o.child(p).nodeSize,s.delete(f-1,f+1);let i=s.doc.resolve(t.start),r=i.nodeAfter;if(s.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,r.content.append(a?k.empty:k.from(o))))return!1;let u=i.pos,h=u+r.nodeSize;return s.step(new Z(u-(l?1:0),h+(a?1:0),u+1,h-1,new M((l?k.empty:k.from(o.copy(k.empty))).append(a?k.empty:k.from(o.copy(k.empty))),l?0:1,a?0:1),l?0:1)),e(s.scrollIntoView()),!0}function lp(n){return function(e,t){let{$from:s,$to:o}=e.selection,i=s.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let r=i.startIndex;if(r==0)return!1;let l=i.parent,a=l.child(r-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=k.from(c?n.create():null),u=new M(k.from(n.create(null,k.from(l.type.create(null,d)))),c?3:1,0),h=i.start,f=i.end;t(e.tr.step(new Z(h-(c?3:1),f,h,f,u,1,!0)).scrollIntoView())}return!0}}const U=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Vn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Jo=null;const Ve=function(n,e,t){let s=Jo||(Jo=document.createRange());return s.setEnd(n,t??n.nodeValue.length),s.setStart(n,e||0),s},ap=function(){Jo=null},Ot=function(n,e,t,s){return t&&(zr(n,e,t,s,-1)||zr(n,e,t,s,1))},cp=/^(img|br|input|textarea|hr)$/i;function zr(n,e,t,s,o){for(;;){if(n==t&&e==s)return!0;if(e==(o<0?0:ge(n))){let i=n.parentNode;if(!i||i.nodeType!=1||_n(n)||cp.test(n.nodeName)||n.contentEditable=="false")return!1;e=U(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?ge(n):0}else return!1}}function ge(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function dp(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ge(n)}else if(n.parentNode&&!_n(n))e=U(n),n=n.parentNode;else return null}}function up(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!_n(n))e=U(n)+1,n=n.parentNode;else return null}}function hp(n,e,t){for(let s=e==0,o=e==ge(n);s||o;){if(n==t)return!0;let i=U(n);if(n=n.parentNode,!n)return!1;s=s&&i==0,o=o&&i==ge(n)}}function _n(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const js=function(n){return n.focusNode&&Ot(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function pt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function fp(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function pp(n,e,t){if(n.caretPositionFromPoint)try{let s=n.caretPositionFromPoint(e,t);if(s)return{node:s.offsetNode,offset:Math.min(ge(s.offsetNode),s.offset)}}catch{}if(n.caretRangeFromPoint){let s=n.caretRangeFromPoint(e,t);if(s)return{node:s.startContainer,offset:Math.min(ge(s.startContainer),s.startOffset)}}}const Ne=typeof navigator<"u"?navigator:null,Lr=typeof document<"u"?document:null,lt=Ne&&Ne.userAgent||"",Uo=/Edge\/(\d+)/.exec(lt),rc=/MSIE \d/.exec(lt),Zo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(lt),ce=!!(rc||Zo||Uo),nt=rc?document.documentMode:Zo?+Zo[1]:Uo?+Uo[1]:0,Te=!ce&&/gecko\/(\d+)/i.test(lt);Te&&+(/Firefox\/(\d+)/.exec(lt)||[0,0])[1];const Yo=!ce&&/Chrome\/(\d+)/.exec(lt),Q=!!Yo,lc=Yo?+Yo[1]:0,oe=!ce&&!!Ne&&/Apple Computer/.test(Ne.vendor),rn=oe&&(/Mobile\/\w+/.test(lt)||!!Ne&&Ne.maxTouchPoints>2),me=rn||(Ne?/Mac/.test(Ne.platform):!1),mp=Ne?/Win/.test(Ne.platform):!1,Ce=/Android \d/.test(lt),qn=!!Lr&&"webkitFontSmoothing"in Lr.documentElement.style,gp=qn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function yp(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 Re(n,e){return typeof n=="number"?n:n[e]}function bp(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,s=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*s}}function Vr(n,e,t){let s=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let r=t||n.dom;r;r=Vn(r)){if(r.nodeType!=1)continue;let l=r,a=l==i.body,c=a?yp(i):bp(l),d=0,u=0;if(e.top<c.top+Re(s,"top")?u=-(c.top-e.top+Re(o,"top")):e.bottom>c.bottom-Re(s,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Re(o,"top")-c.top:e.bottom-c.bottom+Re(o,"bottom")),e.left<c.left+Re(s,"left")?d=-(c.left-e.left+Re(o,"left")):e.right>c.right-Re(s,"right")&&(d=e.right-c.right+Re(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,f=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let p=l.scrollLeft-h,m=l.scrollTop-f;e={left:e.left-p,top:e.top-m,right:e.right-p,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(r).position))break}}function vp(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),s,o;for(let i=(e.left+e.right)/2,r=t+1;r<Math.min(innerHeight,e.bottom);r+=5){let l=n.root.elementFromPoint(i,r);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){s=l,o=a.top;break}}return{refDOM:s,refTop:o,stack:ac(n.dom)}}function ac(n){let e=[],t=n.ownerDocument;for(let s=n;s&&(e.push({dom:s,top:s.scrollTop,left:s.scrollLeft}),n!=t);s=Vn(s));return e}function wp({refDOM:n,refTop:e,stack:t}){let s=n?n.getBoundingClientRect().top:0;cc(t,s==0?0:s-e)}function cc(n,e){for(let t=0;t<n.length;t++){let{dom:s,top:o,left:i}=n[t];s.scrollTop!=o+e&&(s.scrollTop=o+e),s.scrollLeft!=i&&(s.scrollLeft=i)}}let Bt=null;function Sp(n){if(n.setActive)return n.setActive();if(Bt)return n.focus(Bt);let e=ac(n);n.focus(Bt==null?{get preventScroll(){return Bt={preventScroll:!0},!0}}:void 0),Bt||(Bt=!1,cc(e,0))}function dc(n,e){let t,s=2e8,o,i=0,r=e.top,l=e.top,a,c;for(let d=n.firstChild,u=0;d;d=d.nextSibling,u++){let h;if(d.nodeType==1)h=d.getClientRects();else if(d.nodeType==3)h=Ve(d).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=r&&p.bottom>=l){r=Math.max(p.bottom,r),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(m<s){t=d,s=m,o=m&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&m&&(i=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,s=0),t&&t.nodeType==3?Cp(t,o):!t||s&&t.nodeType==1?{node:n,offset:i}:dc(t,o)}function Cp(n,e){let t=n.nodeValue.length,s=document.createRange();for(let o=0;o<t;o++){s.setEnd(n,o+1),s.setStart(n,o);let i=Ge(s,1);if(i.top!=i.bottom&&xi(e,i))return{node:n,offset:o+(e.left>=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function xi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function xp(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function kp(n,e,t){let{node:s,offset:o}=dc(e,t),i=-1;if(s.nodeType==1&&!s.firstChild){let r=s.getBoundingClientRect();i=r.left!=r.right&&t.left>(r.left+r.right)/2?1:-1}return n.docView.posFromDOM(s,o,i)}function Tp(n,e,t,s){let o=-1;for(let i=e,r=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!r&&a.left>s.left||a.top>s.top?o=l.posBefore:(!r&&a.right<s.left||a.bottom<s.top)&&(o=l.posAfter),r=!0),!l.contentDOM&&o<0&&!l.node.isText)return(l.node.isBlock?s.top<(a.top+a.bottom)/2:s.left<(a.left+a.right)/2)?l.posBefore:l.posAfter}i=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function uc(n,e,t){let s=n.childNodes.length;if(s&&t.top<t.bottom)for(let o=Math.max(0,Math.min(s-1,Math.floor(s*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let r=n.childNodes[i];if(r.nodeType==1){let l=r.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(xi(e,c))return uc(r,e,c)}}if((i=(i+1)%s)==o)break}return n}function Mp(n,e){let t=n.dom.ownerDocument,s,o=0,i=pp(t,e.left,e.top);i&&({node:s,offset:o}=i);let r=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!r||!n.dom.contains(r.nodeType!=1?r.parentNode:r)){let c=n.dom.getBoundingClientRect();if(!xi(e,c)||(r=uc(n.dom,e,c),!r))return null}if(oe)for(let c=r;s&&c;c=Vn(c))c.draggable&&(s=void 0);if(r=xp(r,e),s){if(Te&&s.nodeType==1&&(o=Math.min(o,s.childNodes.length),o<s.childNodes.length)){let d=s.childNodes[o],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&o++}let c;qn&&o&&s.nodeType==1&&(c=s.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,s==n.dom&&o==s.childNodes.length-1&&s.lastChild.nodeType==1&&e.top>s.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||s.nodeType!=1||s.childNodes[o-1].nodeName!="BR")&&(l=Tp(n,s,o,e))}l==null&&(l=kp(n,r,e));let a=n.docView.nearestDesc(r,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Br(n){return n.top<n.bottom||n.left<n.right}function Ge(n,e){let t=n.getClientRects();if(t.length){let s=t[e<0?0:t.length-1];if(Br(s))return s}return Array.prototype.find.call(t,Br)||n.getBoundingClientRect()}const Ap=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function hc(n,e,t){let{node:s,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),r=qn||Te;if(s.nodeType==3)if(r&&(Ap.test(s.nodeValue)||(t<0?!o:o==s.nodeValue.length))){let a=Ge(Ve(s,o,o),t);if(Te&&o&&/\s/.test(s.nodeValue[o-1])&&o<s.nodeValue.length){let c=Ge(Ve(s,o-1,o-1),-1);if(c.top==a.top){let d=Ge(Ve(s,o,o+1),-1);if(d.top!=a.top)return hn(d,d.left<c.left)}}return a}else{let a=o,c=o,d=t<0?1:-1;return t<0&&!o?(c++,d=-1):t>=0&&o==s.nodeValue.length?(a--,d=1):t<0?a--:c++,hn(Ge(Ve(s,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1];if(a.nodeType==1)return bo(a.getBoundingClientRect(),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];if(a.nodeType==1)return bo(a.getBoundingClientRect(),!0)}return bo(s.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==ge(s))){let a=s.childNodes[o-1],c=a.nodeType==3?Ve(a,ge(a)-(r?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return hn(Ge(c,1),!1)}if(i==null&&o<ge(s)){let a=s.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ve(a,0,r?0:1):a.nodeType==1?a:null:null;if(c)return hn(Ge(c,-1),!0)}return hn(Ge(s.nodeType==3?Ve(s):s,-t),t>=0)}function hn(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 bo(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 fc(n,e,t){let s=n.state,o=n.root.activeElement;s!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{s!=e&&n.updateState(s),o!=n.dom&&o&&o.focus()}}function Ep(n,e,t){let s=e.selection,o=t=="up"?s.$from:s.$to;return fc(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let r=hc(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ve(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 Op=/[\u0590-\u08ac]/;function Np(n,e,t){let{$head:s}=e.selection;if(!s.parent.isTextblock)return!1;let o=s.parentOffset,i=!o,r=o==s.parent.content.size,l=n.domSelection();return l?!Op.test(s.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:r:fc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",t,"character");let f=s.depth?n.docView.domAfterPos(s.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),g}):s.pos==s.start()||s.pos==s.end()}let Hr=null,$r=null,Fr=!1;function Pp(n,e,t){return Hr==e&&$r==t?Fr:(Hr=e,$r=t,Fr=t=="up"||t=="down"?Ep(n,e,t):Np(n,e,t))}const ye=0,Wr=1,yt=2,Pe=3;class Gn{constructor(e,t,s,o){this.parent=e,this.children=t,this.dom=s,this.contentDOM=o,this.dirty=ye,s.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,s){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,s=this.posAtStart;;t++){let o=this.children[t];if(o==e)return s;s+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,s){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(s<0){let i,r;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(r)+r.size:this.posAtStart}else{let i,r;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((r=i.pmViewDesc)&&r.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(r):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>U(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??s>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let s=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),r;if(i&&(!t||i.node))if(s&&(r=i.nodeDOM)&&!(r.nodeType==1?r.contains(e.nodeType==1?e:e.parentNode):r==e))s=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let s=t;s;s=s.parent)if(s==this)return t}posFromDOM(e,t,s){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,s)}return-1}descAt(e){for(let t=0,s=0;t<this.children.length;t++){let o=this.children[t],i=s+o.size;if(s==e&&i!=s){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<i)return o.descAt(e-s-o.border);s=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let s=0,o=0;for(let i=0;s<this.children.length;s++){let r=this.children[s],l=i+r.size;if(l>e||r instanceof mc){o=e-i;break}i=l}if(o)return this.children[s].domFromPos(o-this.children[s].border,t);for(let i;s&&!(i=this.children[s-1]).size&&i instanceof pc&&i.side>=0;s--);if(t<=0){let i,r=!0;for(;i=s?this.children[s-1]:null,!(!i||i.dom.parentNode==this.contentDOM);s--,r=!1);return i&&t&&r&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?U(i.dom)+1:0}}else{let i,r=!0;for(;i=s<this.children.length?this.children[s]:null,!(!i||i.dom.parentNode==this.contentDOM);s++,r=!1);return i&&r&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?U(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,s=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,i=-1;for(let r=s,l=0;;l++){let a=this.children[l],c=r+a.size;if(o==-1&&e<=c){let d=r+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=r;for(let u=l;u>0;u--){let h=this.children[u-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=U(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){i=U(u.dom);break}t+=u.size}i==-1&&(i=this.contentDOM.childNodes.length);break}r=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:s}=this.domFromPos(e,0);if(t.nodeType!=1||s==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[s]}setSelection(e,t,s,o=!1){let i=Math.min(e,t),r=Math.max(e,t);for(let f=0,p=0;f<this.children.length;f++){let m=this.children[f],g=p+m.size;if(i>p&&r<g)return m.setSelection(e-p-m.border,t-p-m.border,s,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=s.root.getSelection(),d=s.domSelectionRange(),u=!1;if((Te||oe)&&e==t){let{node:f,offset:p}=l;if(f.nodeType==3){if(u=!!(p&&f.nodeValue[p-1]==`
|
|
196
|
+
`),u&&p==f.nodeValue.length)for(let m=f,g;m;m=m.parentNode){if(g=m.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:U(g)+1});break}let b=m.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let m=f.childNodes[p-1];u=m&&(m.nodeName=="BR"||m.contentEditable=="false")}}if(Te&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let f=d.focusNode.childNodes[d.focusOffset];f&&f.contentEditable=="false"&&(o=!0)}if(!(o||u&&oe)&&Ot(l.node,l.offset,d.anchorNode,d.anchorOffset)&&Ot(a.node,a.offset,d.focusNode,d.focusOffset))return;let h=!1;if((c.extend||e==t)&&!u){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>t){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let s=0,o=0;o<this.children.length;o++){let i=this.children[o],r=s+i.size;if(s==r?e<=r&&t>=s:e<r&&t>s){let l=s+i.border,a=r-i.border;if(e>=l&&t<=a){this.dirty=e==s||t==r?yt:Wr,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Pe:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?yt:Pe}s=r}this.dirty=yt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let s=e==1?yt:Wr;t.dirty<s&&(t.dirty=s)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class pc extends Gn{constructor(e,t,s,o){let i,r=t.type.toDOM;if(typeof r=="function"&&(r=r(s,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(r.nodeType!=1){let l=document.createElement("span");l.appendChild(r),r=l}r.contentEditable="false",r.classList.add("ProseMirror-widget")}super(e,[],r,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==ye&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Ip extends Gn{constructor(e,t,s,o){super(e,[],t,null),this.textDOM=s,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Nt extends Gn{constructor(e,t,s,o,i){super(e,[],s,o),this.mark=t,this.spec=i}static create(e,t,s,o){let i=o.nodeViews[t.type.name],r=i&&i(t,o,s);return(!r||!r.dom)&&(r=Rt.renderSpec(document,t.type.spec.toDOM(t,s),null,t.attrs)),new Nt(e,t,r.dom,r.contentDOM||r.dom,r)}parseRule(){return this.dirty&Pe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let s=this.parent;for(;!s.node;)s=s.parent;s.dirty<this.dirty&&(s.dirty=this.dirty),this.dirty=ye}}slice(e,t,s){let o=Nt.create(this.parent,this.mark,!0,s),i=this.children,r=this.size;t<r&&(i=Qo(i,t,r,s)),e>0&&(i=Qo(i,0,e,s));for(let l=0;l<i.length;l++)i[l].parent=o;return o.children=i,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class st extends Gn{constructor(e,t,s,o,i,r,l,a,c){super(e,[],i,r),this.node=t,this.outerDeco=s,this.innerDeco=o,this.nodeDOM=l}static create(e,t,s,o,i,r){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)},s,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Rt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let h=d;return d=bc(d,s,t),c?a=new Rp(e,t,s,o,d,u||null,h,c,i,r+1):t.isText?new Ks(e,t,s,o,d,h,i):new st(e,t,s,o,d,u||null,h,i,r+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let s=this.children[t];if(this.dom.contains(s.dom.parentNode)){e.contentElement=s.dom.parentNode;break}}e.contentElement||(e.getContent=()=>k.empty)}return e}matchesNode(e,t,s){return this.dirty==ye&&e.eq(this.node)&&Ps(t,this.outerDeco)&&s.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let s=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,r=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new zp(this,r&&r.node,e);Bp(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,s,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?V.none:this.node.child(d).marks,s,e),a.placeWidget(c,e,o)},(c,d,u,h)=>{a.syncToMarks(c.marks,s,e);let f;a.findNodeMatch(c,d,u,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(f=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(c,d,u,f,e)||a.updateNextNode(c,d,u,e,h,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],s,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==yt)&&(r&&this.protectLocalComposition(e,r),gc(this.contentDOM,this.children,e),rn&&Hp(this.dom))}localCompositionInfo(e,t){let{from:s,to:o}=e.state.selection;if(!(e.state.selection instanceof R)||s<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let r=i.nodeValue,l=$p(this.node.content,r,s-t,o-t);return l<0?null:{node:i,pos:l,text:r}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:s,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let r=new Ip(this,i,t,o);e.input.compositionNodes.push(r),this.children=Qo(this.children,s,s+o.length,e,r)}update(e,t,s,o){return this.dirty==Pe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,s,o),!0)}updateInner(e,t,s,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=s,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=ye}updateOuterDeco(e){if(Ps(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,s=this.dom;this.dom=yc(this.dom,this.nodeDOM,Xo(this.outerDeco,this.node,t),Xo(e,this.node,t)),this.dom!=s&&(s.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function _r(n,e,t,s,o){bc(s,e,n);let i=new st(void 0,n,e,t,s,s,s,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Ks extends st{constructor(e,t,s,o,i,r,l){super(e,t,s,o,i,null,r,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,s,o){return this.dirty==Pe||this.dirty!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=ye,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,s){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,s)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,s){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new Ks(this.parent,o,this.outerDeco,this.innerDeco,i,i,s)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Pe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class mc extends Gn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Rp extends st{constructor(e,t,s,o,i,r,l,a,c,d){super(e,t,s,o,i,r,l,c,d),this.spec=a}update(e,t,s,o){if(this.dirty==Pe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,s);return i&&this.updateInner(e,t,s,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,s,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,s,o){this.spec.setSelection?this.spec.setSelection(e,t,s.root):super.setSelection(e,t,s,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function gc(n,e,t){let s=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let r=e[i],l=r.dom;if(l.parentNode==n){for(;l!=s;)s=qr(s),o=!0;s=s.nextSibling}else o=!0,n.insertBefore(l,s);if(r instanceof Nt){let a=s?s.previousSibling:n.lastChild;gc(r.contentDOM,r.children,t),s=a?a.nextSibling:n.firstChild}}for(;s;)s=qr(s),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const Tn=function(n){n&&(this.nodeName=n)};Tn.prototype=Object.create(null);const bt=[new Tn];function Xo(n,e,t){if(n.length==0)return bt;let s=t?bt[0]:new Tn,o=[s];for(let i=0;i<n.length;i++){let r=n[i].type.attrs;if(r){r.nodeName&&o.push(s=new Tn(r.nodeName));for(let l in r){let a=r[l];a!=null&&(t&&o.length==1&&o.push(s=new Tn(e.isInline?"span":"div")),l=="class"?s.class=(s.class?s.class+" ":"")+a:l=="style"?s.style=(s.style?s.style+";":"")+a:l!="nodeName"&&(s[l]=a))}}}return o}function yc(n,e,t,s){if(t==bt&&s==bt)return e;let o=e;for(let i=0;i<s.length;i++){let r=s[i],l=t[i];if(i){let a;l&&l.nodeName==r.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==r.nodeName||(a=document.createElement(r.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=bt[0]),o=a}Dp(o,l||bt[0],r)}return o}function Dp(n,e,t){for(let s in e)s!="class"&&s!="style"&&s!="nodeName"&&!(s in t)&&n.removeAttribute(s);for(let s in t)s!="class"&&s!="style"&&s!="nodeName"&&t[s]!=e[s]&&n.setAttribute(s,t[s]);if(e.class!=t.class){let s=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<s.length;i++)o.indexOf(s[i])==-1&&n.classList.remove(s[i]);for(let i=0;i<o.length;i++)s.indexOf(o[i])==-1&&n.classList.add(o[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let s=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=s.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function bc(n,e,t){return yc(n,n,bt,Xo(e,t,n.nodeType!=1))}function Ps(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 qr(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class zp{constructor(e,t,s){this.lock=t,this.view=s,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Lp(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let s=e;s<t;s++)this.top.children[s].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,s){let o=0,i=this.stack.length>>1,r=Math.min(i,e.length);for(;o<r&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=ye,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=Nt.create(this.top,e[i],t,s);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,s,o){let i=-1,r;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,s))i=this.top.children.indexOf(r,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,s)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,s,o,i){let r=this.top.children[o];return r.dirty==Pe&&r.dom==r.contentDOM&&(r.dirty=yt),r.update(e,t,s,i)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let s=e.pmViewDesc;if(s){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==s)return o}return-1}e=t}}updateNextNode(e,t,s,o,i,r){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof st){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let d=a.dom,u,h=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Pe&&Ps(t,a.outerDeco));if(!h&&a.update(e,t,s,o))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(u=this.recreateWrapper(a,e,t,s,o,r)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=yt,u.updateChildren(o,r+1),u.dirty=ye),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,s,o,i,r){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ps(s,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=st.create(this.top,t,s,o,i,r);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,s,o,i){let r=st.create(this.top,e,t,s,o,i);r.contentDOM&&r.updateChildren(o,i+1),this.top.children.splice(this.index++,0,r),this.changed=!0}placeWidget(e,t,s){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let i=new pc(this.top,e,t,s);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Nt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ks)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((oe||Q)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let s=document.createElement(e);e=="IMG"&&(s.className="ProseMirror-separator",s.alt=""),e=="BR"&&(s.className="ProseMirror-trailingBreak");let o=new mc(this.top,[],s,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Lp(n,e){let t=e,s=t.children.length,o=n.childCount,i=new Map,r=[];e:for(;o>0;){let l;for(;;)if(s){let c=t.children[s-1];if(c instanceof Nt)t=c,s=c.children.length;else{l=c,s--;break}}else{if(t==e)break e;s=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),r.push(l)}}return{index:o,matched:i,matches:r.reverse()}}function Vp(n,e){return n.type.side-e.type.side}function Bp(n,e,t,s){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let d=n.child(c);s(d,o,e.forChild(i,d),c),i+=d.nodeSize}return}let r=0,l=[],a=null;for(let c=0;;){let d,u;for(;r<o.length&&o[r].to==i;){let g=o[r++];g.widget&&(d?(u||(u=[d])).push(g):d=g)}if(d)if(u){u.sort(Vp);for(let g=0;g<u.length;g++)t(u[g],c,!!a)}else t(d,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<n.childCount)f=c,h=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;r<o.length&&o[r].from<=i&&o[r].to>i;)l.push(o[r++]);let p=i+h.nodeSize;if(h.isText){let g=p;r<o.length&&o[r].from<g&&(g=o[r].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<p&&(a=h.cut(g-i),h=h.cut(0,g-i),p=g,f=-1)}else for(;r<o.length&&o[r].to<p;)r++;let m=h.isInline&&!h.isLeaf?l.filter(g=>!g.inline):l.slice();s(h,m,e.forChild(i,h),f),i=p}}function Hp(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 $p(n,e,t,s){for(let o=0,i=0;o<n.childCount&&i<=s;){let r=n.child(o++),l=i;if(i+=r.nodeSize,!r.isText)continue;let a=r.text;for(;o<n.childCount;){let c=n.child(o++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=s&&a.slice(s-e.length-l,s-l)==e)return s-e.length;let c=l<s?a.lastIndexOf(e,s-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==s&&a.length>=s+e.length-l&&a.slice(s-l,s-l+e.length)==e)return s}}return-1}function Qo(n,e,t,s,o){let i=[];for(let r=0,l=0;r<n.length;r++){let a=n[r],c=l,d=l+=a.size;c>=t||d<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,s)),o&&(i.push(o),o=void 0),d>t&&i.push(a.slice(t-c,a.size,s)))}return i}function ki(n,e=null){let t=n.domSelectionRange(),s=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,r=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(r<0)return null;let l=s.resolve(r),a,c;if(js(t)){for(a=r;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&N.isSelectable(u)&&o.parent&&!(u.isInline&&hp(t.focusNode,t.focusOffset,o.dom))){let h=o.posBefore;c=new N(r==h?l:s.resolve(h))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=r,h=r;for(let f=0;f<t.rangeCount;f++){let p=t.getRangeAt(f);u=Math.min(u,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,r]=h==n.state.selection.anchor?[h,u]:[u,h],l=s.resolve(r)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=s.resolve(a);if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=Ti(n,d,l,u)}return c}function vc(n){return n.editable?n.hasFocus():Sc(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function $e(n,e=!1){let t=n.state.selection;if(wc(n,t),!!vc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Q){let s=n.domSelectionRange(),o=n.domObserver.currentSelection;if(s.anchorNode&&o.anchorNode&&Ot(s.anchorNode,s.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Wp(n);else{let{anchor:s,head:o}=t,i,r;Gr&&!(t instanceof R)&&(t.$from.parent.inlineContent||(i=jr(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(r=jr(n,t.to))),n.docView.setSelection(s,o,n,e),Gr&&(i&&Kr(i),r&&Kr(r)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Fp(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Gr=oe||Q&&lc<63;function jr(n,e){let{node:t,offset:s}=n.docView.domFromPos(e,0),o=s<t.childNodes.length?t.childNodes[s]:null,i=s?t.childNodes[s-1]:null;if(oe&&o&&o.contentEditable=="false")return vo(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return vo(o);if(i)return vo(i)}}function vo(n){return n.contentEditable="true",oe&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Kr(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Fp(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),s=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=s||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!vc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Wp(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let s=n.cursorWrapper.dom,o=s.nodeName=="IMG";o?t.setStart(s.parentNode,U(s)+1):t.setStart(s,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ce&&nt<=11&&(s.disabled=!0,s.disabled=!1)}function wc(n,e){if(e instanceof N){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Jr(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Jr(n)}function Jr(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ti(n,e,t,s){return n.someProp("createSelectionBetween",o=>o(n,e,t))||R.between(e,t,s)}function Ur(n){return n.editable&&!n.hasFocus()?!1:Sc(n)}function Sc(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 _p(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Ot(e.node,e.offset,t.anchorNode,t.anchorOffset)}function ei(n,e){let{$anchor:t,$head:s}=n.selection,o=e>0?t.max(s):t.min(s),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&I.findFrom(i,e)}function Ke(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Zr(n,e,t){let s=n.state.selection;if(s instanceof R)if(t.indexOf("s")>-1){let{$head:o}=s,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let r=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Ke(n,new R(s.$anchor,r))}else if(s.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=ei(n.state,e);return o&&o instanceof N?Ke(n,o):!1}else if(!(me&&t.indexOf("m")>-1)){let o=s.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,r;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(r=n.docView.descAt(l))&&!r.contentDOM?N.isSelectable(i)?Ke(n,new N(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):qn?Ke(n,new R(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(s instanceof N&&s.node.isInline)return Ke(n,new R(e>0?s.$to:s.$from));{let o=ei(n.state,e);return o?Ke(n,o):!1}}}function Is(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Mn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ht(n,e){return e<0?qp(n):Gp(n)}function qp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o,i,r=!1;for(Te&&t.nodeType==1&&s<Is(t)&&Mn(t.childNodes[s],-1)&&(r=!0);;)if(s>0){if(t.nodeType!=1)break;{let l=t.childNodes[s-1];if(Mn(l,-1))o=t,i=--s;else if(l.nodeType==3)t=l,s=t.nodeValue.length;else break}}else{if(Cc(t))break;{let l=t.previousSibling;for(;l&&Mn(l,-1);)o=t.parentNode,i=U(l),l=l.previousSibling;if(l)t=l,s=Is(t);else{if(t=t.parentNode,t==n.dom)break;s=0}}}r?ti(n,t,s):o&&ti(n,o,i)}function Gp(n){let e=n.domSelectionRange(),t=e.focusNode,s=e.focusOffset;if(!t)return;let o=Is(t),i,r;for(;;)if(s<o){if(t.nodeType!=1)break;let l=t.childNodes[s];if(Mn(l,1))i=t,r=++s;else break}else{if(Cc(t))break;{let l=t.nextSibling;for(;l&&Mn(l,1);)i=l.parentNode,r=U(l)+1,l=l.nextSibling;if(l)t=l,s=0,o=Is(t);else{if(t=t.parentNode,t==n.dom)break;s=o=0}}}i&&ti(n,i,r)}function Cc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function jp(n,e){for(;n&&e==n.childNodes.length&&!_n(n);)e=U(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 Kp(n,e){for(;n&&!e&&!_n(n);)e=U(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 ti(n,e,t){if(e.nodeType!=3){let i,r;(r=jp(e,t))?(e=r,t=0):(i=Kp(e,t))&&(e=i,t=i.nodeValue.length)}let s=n.domSelection();if(!s)return;if(js(s)){let i=document.createRange();i.setEnd(e,t),i.setStart(e,t),s.removeAllRanges(),s.addRange(i)}else s.extend&&s.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&$e(n)},50)}function Yr(n,e){let t=n.state.doc.resolve(e);if(!(Q||mp)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left<o.left?"ltr":"rtl"}if(e<t.end()){let i=n.coordsAtPos(e+1),r=(i.top+i.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(i.left-o.left)>1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Xr(n,e,t){let s=n.state.selection;if(s instanceof R&&!s.empty||t.indexOf("s")>-1||me&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=s;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let r=ei(n.state,e);if(r&&r instanceof N)return Ke(n,r)}if(!o.parent.inlineContent){let r=e<0?o:i,l=s instanceof fe?I.near(r,e):I.findFrom(r,e);return l?Ke(n,l):!1}return!1}function Qr(n,e){if(!(n.state.selection instanceof R))return!0;let{$head:t,$anchor:s,empty:o}=n.state.selection;if(!t.sameParent(s))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let r=n.state.tr;return e<0?r.delete(t.pos-i.nodeSize,t.pos):r.delete(t.pos,t.pos+i.nodeSize),n.dispatch(r),!0}return!1}function el(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Jp(n){if(!oe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let s=e.firstChild;el(n,s,"true"),setTimeout(()=>el(n,s,"false"),20)}return!1}function Up(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Zp(n,e){let t=e.keyCode,s=Up(e);if(t==8||me&&t==72&&s=="c")return Qr(n,-1)||Ht(n,-1);if(t==46&&!e.shiftKey||me&&t==68&&s=="c")return Qr(n,1)||Ht(n,1);if(t==13||t==27)return!0;if(t==37||me&&t==66&&s=="c"){let o=t==37?Yr(n,n.state.selection.from)=="ltr"?-1:1:-1;return Zr(n,o,s)||Ht(n,o)}else if(t==39||me&&t==70&&s=="c"){let o=t==39?Yr(n,n.state.selection.from)=="ltr"?1:-1:1;return Zr(n,o,s)||Ht(n,o)}else{if(t==38||me&&t==80&&s=="c")return Xr(n,-1,s)||Ht(n,-1);if(t==40||me&&t==78&&s=="c")return Jp(n)||Xr(n,1,s)||Ht(n,1);if(s==(me?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function xc(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:s,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&s.childCount==1&&s.firstChild.childCount==1;){o--,i--;let f=s.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),s=f.content}let r=n.someProp("clipboardSerializer")||Rt.fromSchema(n.state.schema),l=Oc(),a=l.createElement("div");a.appendChild(r.serializeFragment(s,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=Ec[c.nodeName.toLowerCase()]);){for(let f=d.length-1;f>=0;f--){let p=l.createElement(d[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let h=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
|
|
197
197
|
|
|
198
|
-
`);return{dom:a,text:
|
|
199
|
-
`))),0,0):M.empty;let h=n.someProp("clipboardTextParser",u=>u(e,o,s,n));if(h)l=h;else{let u=o.marks(),{schema:f}=n.state,p=It.fromSchema(f);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,u)))})}}else n.someProp("transformPastedHTML",h=>{t=h(t,n)}),r=_p(t),_n&&qp(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let h=+d[3];h>0;h--){let u=r.firstChild;for(;u&&u.nodeType!=1;)u=u.nextSibling;if(!u)break;r=u}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||en.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(u){return u.nodeName=="BR"&&!u.nextSibling&&u.parentNode&&!$p.test(u.parentNode.nodeName)?{ignore:!0}:null}})),d)l=Gp(Yr(l,+d[1],+d[2]),d[4]);else if(l=M.maxOpen(Fp(l.content,o),!0),l.openStart||l.openEnd){let h=0,u=0;for(let f=l.content.firstChild;h<l.openStart&&!f.type.spec.isolating;h++,f=f.firstChild);for(let f=l.content.lastChild;u<l.openEnd&&!f.type.spec.isolating;u++,f=f.lastChild);l=Yr(l,h,u)}return n.someProp("transformPasted",h=>{l=h(l,n)}),l}const $p=/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;function Fp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=o.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&wc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Sc(r[r.length-1],i.length));let d=vc(l,a);r.push(d),o=o.matchType(d.type),i=a}}),r)return k.from(r)}return n}function vc(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,k.from(n));return n}function wc(n,e,t,s,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=wc(n,e,t,s.lastChild,o+1);if(i)return s.copy(s.content.replaceChild(s.childCount-1,i));if(s.contentMatchAt(s.childCount).matchType(o==n.length-1?t.type:n[o+1]))return s.copy(s.content.append(k.from(vc(t,n,o+1))))}}function Sc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Sc(n.lastChild,e-1)),s=n.contentMatchAt(n.childCount).fillBefore(k.empty,!0);return n.copy(t.append(s))}function Xo(n,e,t,s,o,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),o<s-1&&(l=Xo(l,e,t,s,o+1,i)),o>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function Yr(n,e,t){return e<n.openStart&&(n=new M(Xo(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(Xo(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Cc={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 Xr=null;function xc(){return Xr||(Xr=document.implementation.createHTMLDocument("title"))}let bo=null;function Wp(n){let e=window.trustedTypes;return e?(bo||(bo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),bo.createHTML(n)):n}function _p(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=xc().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(n),o;if((o=s&&Cc[s[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Wp(n),o)for(let i=0;i<o.length;i++)t=t.querySelector(o[i])||t;return t}function qp(n){let e=n.querySelectorAll(Q?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let s=e[t];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),s)}}function Gp(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:r}=n;for(let l=s.length-2;l>=0;l-=2){let a=t.nodes[s[l]];if(!a||a.hasRequiredAttrs())break;o=k.from(a.create(s[l+1],o)),i++,r++}return new M(o,i,r)}const se={},oe={},jp={touchstart:!0,touchmove:!0};class Kp{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Jp(n){for(let e in se){let t=se[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{Zp(n,s)&&!Ci(n,s)&&(n.editable||!(s.type in oe))&&t(n,s)},jp[e]?{passive:!0}:void 0)}ne&&n.dom.addEventListener("input",()=>null),Qo(n)}function et(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Up(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Qo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>Ci(n,s))})}function Ci(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function Zp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Yp(n,e){!Ci(n,e)&&se[e.type]&&(n.editable||!(e.type in oe))&&se[e.type](n,e)}oe.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Tc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ce&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),on&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",o=>o(n,ft(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||Hp(n,t)?t.preventDefault():et(n,"key")};oe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};oe.keypress=(n,e)=>{let t=e;if(Tc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||me&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof R)||!s.$from.sameParent(s.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,s.$from.pos,s.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function js(n){return{left:n.clientX,top:n.clientY}}function Xp(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function xi(n,e,t,s,o){if(s==-1)return!1;let i=n.state.doc.resolve(s);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),o,!0):l(n,t,i.node(r),i.before(r),o,!1)))return!0;return!1}function Yt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function Qp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&N.isSelectable(s)?(Yt(n,new N(t)),!0):!1}function em(n,e){if(e==-1)return!1;let t=n.state.selection,s,o;t instanceof N&&(s=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(N.isSelectable(l)){s&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(r);break}}return o!=null?(Yt(n,N.create(n.state.doc,o)),!0):!1}function tm(n,e,t,s,o){return xi(n,"handleClickOn",e,t,s)||n.someProp("handleClick",i=>i(n,e,s))||(o?em(n,t):Qp(n,t))}function nm(n,e,t,s){return xi(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",o=>o(n,e,s))}function sm(n,e,t,s){return xi(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",o=>o(n,e,s))||om(n,t,s)}function om(n,e,t){if(t.button!=0)return!1;let s=n.state.doc;if(e==-1)return s.inlineContent?(Yt(n,R.create(s,0,s.content.size)),!0):!1;let o=s.resolve(e);for(let i=o.depth+1;i>0;i--){let r=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(r.inlineContent)Yt(n,R.create(s,l+1,l+1+r.content.size));else if(N.isSelectable(r))Yt(n,N.create(s,l));else continue;return!0}}function ki(n){return Ps(n)}const kc=me?"metaKey":"ctrlKey";se.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=ki(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&Xp(t,n.input.lastClick)&&!t[kc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(js(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new im(n,r,t,!!s)):(i=="doubleClick"?nm:sm)(n,r.pos,r.inside,t)?t.preventDefault():et(n,"pointer"))};class im{constructor(e,t,s,o){this.view=e,this.pos=t,this.event=s,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[kc],this.allowDefault=s.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=o?null:s.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Te&&!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)),et(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>$e(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(js(e))),this.updateAllowDefault(e),this.allowDefault||!t?et(this.view,"pointer"):tm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ne&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Yt(this.view,I.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):et(this.view,"pointer")}move(e){this.updateAllowDefault(e),et(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)}}se.touchstart=n=>{n.input.lastTouch=Date.now(),ki(n),et(n,"pointer")};se.touchmove=n=>{n.input.lastTouch=Date.now(),et(n,"pointer")};se.contextmenu=n=>ki(n);function Tc(n,e){return n.composing?!0:ne&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rm=Ce?5e3:-1;oe.compositionstart=oe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Ps(n,!0),n.markCursor=null;else if(Ps(n,!e.selection.empty),Te&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let o=s.focusNode,i=s.focusOffset;o&&o.nodeType==1&&i!=0;){let r=i<0?o.lastChild:o.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,i=-1}}n.input.composing=!0}Mc(n,rm)};oe.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++,Mc(n,20))};function Mc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Ps(n),e))}function Ac(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=am());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Qf(e.focusNode,e.focusOffset),s=ep(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let o=s.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||s==i)return i;if(!o||!o.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return s}}return t||s}function am(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Ps(n,e=!1){if(!(Ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ac(n),e||n.docView&&n.docView.dirty){let t=wi(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function cm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Ln=ce&&tt<15||on&&ip<604;se.copy=oe.cut=(n,e)=>{let t=e,s=n.state.selection,o=t.type=="cut";if(s.empty)return;let i=Ln?null:t.clipboardData,r=s.content(),{dom:l,text:a}=yc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):cm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function hm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?Bn(n,s.value,null,o,e):Bn(n,s.textContent,s.innerHTML,o,e)},50)}function Bn(n,e,t,s,o){let i=bc(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||M.empty)))return!0;if(!i)return!1;let r=dm(i),l=r?n.state.tr.replaceSelectionWith(r,s):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ec(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," "):""}oe.paste=(n,e)=>{let t=e;if(n.composing&&!Ce)return;let s=Ln?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&Bn(n,Ec(s),s.getData("text/html"),o,t)?t.preventDefault():hm(n,t)};class Oc{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const Nc=me?"altKey":"ctrlKey";se.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(js(t)),r;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof N?o.to-1:o.to))){if(s&&s.mightDrag)r=N.create(n.state.doc,s.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let h=n.docView.nearestDesc(t.target,!0);h&&h.node.type.spec.draggable&&h!=n.docView&&(r=N.create(n.state.doc,h.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=yc(n,l);(!t.dataTransfer.files.length||!Q||tc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Ln?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Ln||t.dataTransfer.setData("text/plain",c),n.dragging=new Oc(d,!t[Nc],r)};se.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};oe.dragover=oe.dragenter=(n,e)=>e.preventDefault();oe.drop=(n,e)=>{let t=e,s=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(js(t));if(!o)return;let i=n.state.doc.resolve(o.pos),r=s&&s.slice;r?n.someProp("transformPasted",p=>{r=p(r,n)}):r=bc(n,Ec(t.dataTransfer),Ln?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(s&&!t[Nc]);if(n.someProp("handleDrop",p=>p(n,t,r||M.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?of(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=s;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,u=c.doc;if(h?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&N.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new N(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>p=C),c.setSelection(Si(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};se.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&$e(n)},20))};se.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)};se.beforeinput=(n,e)=>{if(Q&&Ce&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,ft(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in oe)se[n]=oe[n];function Hn(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 Is{constructor(e,t){this.toDOM=e,this.spec=t||xt,this.side=this.spec.side||0}map(e,t,s,o){let{pos:i,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new ae(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Is&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Hn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class st{constructor(e,t){this.attrs=e,this.spec=t||xt}map(e,t,s,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-s,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-s;return i>=r?null:new ae(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof st&&Hn(this.attrs,e.attrs)&&Hn(this.spec,e.spec)}static is(e){return e.type instanceof st}destroy(){}}class Ti{constructor(e,t){this.attrs=e,this.spec=t||xt}map(e,t,s,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=i.pos?null:new ae(i.pos-s,r.pos-s,this)}valid(e,t){let{index:s,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(s)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof Ti&&Hn(this.attrs,e.attrs)&&Hn(this.spec,e.spec)}destroy(){}}class ae{constructor(e,t,s){this.from=e,this.to=t,this.type=s}copy(e,t){return new ae(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,s){return this.type.map(e,this,t,s)}static widget(e,t,s){return new ae(e,e,new Is(t,s))}static inline(e,t,s,o){return new ae(e,t,new st(s,o))}static node(e,t,s,o){return new ae(e,t,new Ti(s,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof st}get widget(){return this.type instanceof Is}}const Ft=[],xt={};class H{constructor(e,t){this.local=e.length?e:Ft,this.children=t.length?t:Ft}static create(e,t){return t.length?Rs(t,e,0,xt):Y}find(e,t,s){let o=[];return this.findInner(e??0,t??1e9,o,0,s),o}findInner(e,t,s,o,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&s.push(l.copy(l.from+o,l.to+o))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,s,o+l,i)}}map(e,t,s){return this==Y||e.maps.length==0?this:this.mapInner(e,t,0,0,s||xt)}mapInner(e,t,s,o,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,s,o);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?um(this.children,r||[],e,t,s,o,i):r?new H(r.sort(kt),Ft):Y}add(e,t){return t.length?this==Y?H.create(e,t):this.addInner(e,t,0):this}addInner(e,t,s){let o,i=0;e.forEach((l,a)=>{let c=a+s,d;if(d=Ic(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,Rs(d,l,c+1,xt)),i+=3}});let r=Pc(i?Rc(t):t,-s);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new H(r.length?this.local.concat(r).sort(kt):this.local,o||this.children)}remove(e){return e.length==0||this==Y?this:this.removeInner(e,0)}removeInner(e,t){let s=this.children,o=this.local;for(let i=0;i<s.length;i+=3){let r,l=s[i]+t,a=s[i+1]+t;for(let d=0,h;d<e.length;d++)(h=e[d])&&h.from>l&&h.to<a&&(e[d]=null,(r||(r=[])).push(h));if(!r)continue;s==this.children&&(s=this.children.slice());let c=s[i+2].removeInner(r,l+1);c!=Y?s[i+2]=c:(s.splice(i,3),i-=3)}if(o.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<o.length;l++)o[l].eq(r,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return s==this.children&&o==this.local?this:o.length||s.length?new H(o,s):Y}forChild(e,t){if(this==Y)return this;if(t.isLeaf)return H.empty;let s,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(s=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof st){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new H(o.sort(kt),Ft);return s?new Ue([l,s]):l}return s||Y}eq(e){if(this==e)return!0;if(!(e instanceof H)||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 Mi(this.localsInner(e))}localsInner(e){if(this==Y)return Ft;if(e.inlineContent||!this.local.some(st.is))return this.local;let t=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof st||t.push(this.local[s]);return t}forEachSet(e){e(this)}}H.empty=new H([],[]);H.removeOverlap=Mi;const Y=H.empty;class Ue{constructor(e){this.members=e}map(e,t){const s=this.members.map(o=>o.map(e,t,xt));return Ue.from(s)}forChild(e,t){if(t.isLeaf)return H.empty;let s=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Y&&(i instanceof Ue?s=s.concat(i.members):s.push(i))}return Ue.from(s)}eq(e){if(!(e instanceof Ue)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,s=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{s&&(t=t.slice(),s=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Mi(s?t:t.sort(kt)):Ft}static from(e){switch(e.length){case 0:return Y;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof H)?e:e.reduce((t,s)=>t.concat(s instanceof H?s:s.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function um(n,e,t,s,o,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let h=0;t.maps[c].forEach((u,f,p,m)=>{let g=m-p-(f-u);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||u>C+d-h)continue;let y=l[b]+d-h;f>=y?l[b+1]=u<=y?-2:-1:u>=d&&g&&(l[b]+=g,l[b+1]+=g)}h+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),h=d-o;if(h<0||h>=s.content.size){a=!0;continue}let u=t.map(n[c+1]+i,-1),f=u-o,{index:p,offset:m}=s.content.findIndex(h),g=s.maybeChild(p);if(g&&m==h&&m+g.nodeSize==f){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=Y?(l[c]=h,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=fm(l,n,e,t,o,i,r),d=Rs(c,s,0,r);e=d.local;for(let h=0;h<l.length;h+=3)l[h+1]<0&&(l.splice(h,3),h-=3);for(let h=0,u=0;h<d.children.length;h+=3){let f=d.children[h];for(;u<l.length&&l[u]<f;)u+=3;l.splice(u,0,d.children[h],d.children[h+1],d.children[h+2])}}return new H(e.sort(kt),l)}function Pc(n,e){if(!e||!n.length)return n;let t=[];for(let s=0;s<n.length;s++){let o=n[s];t.push(new ae(o.from+e,o.to+e,o.type))}return t}function fm(n,e,t,s,o,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let h=a.local[d].map(s,o,c);h?t.push(h):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Ic(n,e,t){if(e.isLeaf)return null;let s=t+e.nodeSize,o=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<s&&((o||(o=[])).push(r),n[i]=null);return o}function Rc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Rs(n,e,t,s){let o=[],i=!1;e.forEach((l,a)=>{let c=Ic(n,l,a+t);if(c){i=!0;let d=Rs(c,l,t+a+1,s);d!=Y&&o.push(a,a+l.nodeSize,d)}});let r=Pc(i?Rc(n):n,-t).sort(kt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(s.onRemove&&s.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new H(r,o):Y}function kt(n,e){return n.from-e.from||n.to-e.to}function Mi(n){let e=n;for(let t=0;t<e.length-1;t++){let s=e[t];if(s.from!=s.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==s.from){i.to!=s.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,s.to),Qr(e,o+1,i.copy(s.to,i.to)));continue}else{i.from<s.to&&(e==n&&(e=n.slice()),e[t]=s.copy(s.from,i.from),Qr(e,o,s.copy(i.from,s.to)));break}}}return e}function Qr(n,e,t){for(;e<n.length&&kt(t,n[e])>0;)e++;n.splice(e,0,t)}function vo(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=Y&&e.push(s)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Ue.from(e)}const pm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mm=ce&&tt<=11;class gm{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class ym{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new gm,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let o=0;o<s.length;o++)this.queue.push(s[o]);ce&&tt<=11&&s.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),mm&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,pm)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Gr(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(ce&&tt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Et(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let i=e.focusNode;i;i=Vn(i))t.add(i);for(let i=e.anchorNode;i;i=Vn(i))if(t.has(i)){s=i;break}let o=s&&this.view.docView.nearestDesc(s);if(o&&o.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let s=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&Gr(e)&&!this.ignoreSelectionChange(s),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let h=this.registerMutation(t[d],a);h&&(i=i<0?h.from:Math.min(h.from,i),r=r<0?h.to:Math.max(h.to,r),h.typeOver&&(l=!0))}if(Te&&a.length){let d=a.filter(h=>h.nodeName=="BR");if(d.length==2){let[h,u]=d;h.parentNode&&h.parentNode.parentNode==u.parentNode?u.remove():h.remove()}else{let{focusNode:h}=this.currentSelection;for(let u of d){let f=u.parentNode;f&&f.nodeName=="LI"&&(!h||wm(e,h)!=f)&&u.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&qs(s)&&(c=wi(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(s),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,r),bm(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||$e(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let h=e.addedNodes[d];t.push(h),h.nodeType==3&&(this.lastChangedTextNode=h)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let o=e.previousSibling,i=e.nextSibling;if(ce&&tt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:h,nextSibling:u}=e.addedNodes[d];(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h),(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u)}let r=o&&o.parentNode==e.target?U(o)+1:0,l=s.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?U(i):e.target.childNodes.length,c=s.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let el=new WeakMap,tl=!1;function bm(n){if(!el.has(n)&&(el.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Te,tl)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."),tl=!0}}function nl(n,e){let t=e.startContainer,s=e.startOffset,o=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Et(r.node,r.offset,o,i)&&([t,s,o,i]=[o,i,t,s]),{anchorNode:t,anchorOffset:s,focusNode:o,focusOffset:i}}function vm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return nl(n,o)}let t;function s(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",s,!0),t?nl(n,t):null}function wm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let s=n.docView.nearestDesc(t,!0);if(s&&s.node.isBlock)return t}return null}function Sm(n,e,t){let{node:s,fromOffset:o,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],qs(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Q&&n.input.lastKeyCode===8)for(let g=i;g>o;g--){let b=s.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let h=n.state.doc,u=n.someProp("domParser")||en.fromSchema(n.state.schema),f=h.resolve(r),p=null,m=u.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Cm,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+r,head:b+r}}return{doc:m,sel:p,from:r,to:l}}function Cm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ne&&/^(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||ne&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const xm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function km(n,e,t,s,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=wi(n,T);if(A&&!n.state.selection.eq(A)){if(Q&&Ce&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,ft(13,"Enter"))))return;let P=n.state.tr.setSelection(A);T=="pointer"?P.setMeta("pointer",!0):T=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Sm(n,e,t),d=n.state.doc,h=d.slice(c.from,c.to),u,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(u=n.state.selection.to,f="end"):(u=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=Am(h.content,c.doc.content,c.from,u,f);if(p&&n.input.domChangeCount++,(on&&n.input.lastIOSEnter>Date.now()-225||Ce)&&o.some(T=>T.nodeType==1&&!xm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(s&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=sl(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let A=n.state.tr.setSelection(T);i&&A.setMeta("composition",i),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof R&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ce&&tt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,y;if((on&&n.input.lastIOSEnter>Date.now()-225&&(!C||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=I.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,ft(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Mm(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,ft(8,"Backspace")))){Ce&&Q&&n.domObserver.suppressSelectionUpdates();return}Q&&Ce&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),Ce&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,ft(13,"Enter"))})},20));let v=p.start,w=p.endA,S,x,E;if(C){if(m.pos==g.pos)ce&&tt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(E=Tm(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))S=n.state.tr,E.type=="add"?S.addMark(v,w,E.mark):S.removeMark(v,w,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",A=>A(n,v,w,T)))return;S=n.state.tr.insertText(T,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=sl(n,S.doc,c.sel);T&&!(Q&&Ce&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==v||T.head==S.mapping.map(w)-1)||ce&&T.empty&&T.head==v)&&S.setSelection(T)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function sl(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Si(n,e.resolve(t.anchor),e.resolve(t.head))}function Tm(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,o=t,i=s,r,l,a;for(let d=0;d<s.length;d++)o=s[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(n))return{mark:l,type:r}}function Mm(n,e,t,s,o){if(t-e<=o.pos-s.pos||wo(s,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!s.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(wo(i,!0,!0));return!r.parent.isTextblock||r.pos>t||wo(r,!0,!1)<t?!1:s.parent.content.cut(s.parentOffset).eq(r.parent.content)}function wo(n,e,t){let s=n.depth,o=e?n.end():n.pos;for(;s>0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,o++,e=!1;if(t){let i=n.node(s).maybeChild(n.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Am(n,e,t,s,o){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(r,l));s-=r+a-i}if(r<i&&n.size<e.size){let a=s<=i&&s>=r?i-s:0;i-=a,i&&i<e.size&&ol(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=s<=i&&s>=l?i-s:0;i-=a,i&&i<n.size&&ol(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function ol(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Em{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Kp,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(cl),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=ll(this),rl(this),this.nodeViews=al(this),this.docView=Hr(this.state.doc,il(this),vo(this),this.dom,this),this.domObserver=new ym(this,(s,o,i,r)=>km(this,s,o,i,r)),this.domObserver.start(),Jp(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Qo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(cl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let o=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Ac(this),r=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=al(this);Nm(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Qo(this),this.editable=ll(this),rl(this);let a=vo(this),c=il(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",h=i||!this.docView.matchesNode(e.doc,c,a);(h||!e.selection.eq(o.selection))&&(r=!0);let u=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&ap(this);if(r){this.domObserver.stop();let f=h&&(ce||Q)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Om(o.selection,e.selection);if(h){let p=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Hr(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ip(this))?$e(this,f):(pc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((s=this.dragging)===null||s===void 0)&&s.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():u&&cp(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof N){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Rr(this,t.getBoundingClientRect(),e)}else Rr(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let s=this.directPlugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let s=this.state.plugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let s=this.pluginViews[t];s.update&&s.update(this,e)}}updateDraggedNode(e,t){let s=e.node,o=-1;if(this.state.doc.nodeAt(s.from)==s.node)o=s.from;else{let i=s.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==s.node&&(o=i)}this.dragging=new Oc(e.slice,e.move,o<0?void 0:N.create(this.state.doc,o))}someProp(e,t){let s=this._props&&this._props[e],o;if(s!=null&&(o=t?t(s):s))return o;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ce){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&dp(this.dom),$e(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mp(this,e)}coordsAtPos(e,t=1){return 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,s=-1){let o=this.docView.posFromDOM(e,t,s);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return wp(this,t||this.state,e)}pasteHTML(e,t){return Bn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Bn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Up(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Yf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yp(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ne&&this.root.nodeType===11&&np(this.dom.ownerDocument)==this.dom&&vm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function il(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[ae.node(0,n.state.doc.content.size,e)]}function rl(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:ae.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ll(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Om(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function al(n){let e=Object.create(null);function t(s){for(let o in s)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=s[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Nm(n,e){let t=0,s=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)s++;return t!=s}function cl(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 ei,ti;if(typeof WeakMap<"u"){let n=new WeakMap;ei=e=>n.get(e),ti=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;ei=s=>{for(let o=0;o<n.length;o+=2)if(n[o]==s)return n[o+1]},ti=(s,o)=>(t==10&&(t=0),n[t++]=s,n[t++]=o)}var F=class{constructor(n,e,t,s){this.width=n,this.height=e,this.map=t,this.problems=s}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const s=e%this.width,o=e/this.width|0;let i=s+1,r=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:s,top:o,right:i,bottom:r}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:s,right:o,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?s==0:o==this.width)?null:this.map[i*this.width+(t<0?s-1:o)]:(t<0?i==0:r==this.height)?null:this.map[s+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:s,top:o,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(o,a),right:Math.max(s,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let s=n.top;s<n.bottom;s++)for(let o=n.left;o<n.right;o++){const i=s*this.width+o,r=this.map[i];t[r]||(t[r]=!0,!(o==n.left&&o&&this.map[i-1]==r||s==n.top&&s&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let s=0,o=0;;s++){const i=o+t.child(s).nodeSize;if(s==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<o;)r++;return r==l?i-1:this.map[r]}o=i}}static get(n){return ei(n)||ti(n,Pm(n))}};function Pm(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Im(n),t=n.childCount,s=[];let o=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)s[c]=0;for(let c=0,d=0;c<t;c++){const h=n.child(c);d++;for(let p=0;;p++){for(;o<s.length&&s[o]!=0;)o++;if(p==h.childCount)break;const m=h.child(p),{colspan:g,rowspan:b,colwidth:C}=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=o+y*e;for(let w=0;w<g;w++){s[v+w]==0?s[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%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]++}}}o+=g,d+=m.nodeSize}const u=(c+1)*e;let f=0;for(;o<u;)s[o++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}const l=new F(e,t,s,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&Rm(l,r,n),l}function Im(n){let e=-1,t=!1;for(let s=0;s<n.childCount;s++){const o=n.child(s);let i=0;if(t)for(let r=0;r<s;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>s&&(i+=c.attrs.colspan)}}for(let r=0;r<o.childCount;r++){const l=o.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Rm(n,e,t){n.problems||(n.problems=[]);const s={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(s[i])continue;s[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,h=e[d*2];h!=null&&(!a.colwidth||a.colwidth[c]!=h)&&((l||(l=Dm(a)))[c]=h)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Dm(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function dl(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),s=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:s&&s.length==o?s:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function hl(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const s in e){const o=e[s].setDOMAttr;o&&o(n.attrs[s],t)}return t}function zm(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const s in e)t[s]={default:e[s].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:s=>dl(s,e)}],toDOM(s){return["td",hl(s,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:s=>dl(s,e)}],toDOM(s){return["th",hl(s,e),0]}}}}function Ie(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const s=n.nodes[t],o=s.spec.tableRole;o&&(e[o]=s)}}return e}var Ze=new Fn("selectingCells");function Gn(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 Ks(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 Ai(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=Gn(e.$head)||Vm(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Vm(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ni(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Lm(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ei(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Dc(n,e,t){const s=n.node(-1),o=F.get(s),i=n.start(-1),r=o.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function rn(n,e,t=1){const s={...n,colspan:n.colspan-t};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,t),s.colwidth.some(o=>o>0)||(s.colwidth=null)),s}var G=class Ve extends I{constructor(e,t=e){const s=e.node(-1),o=F.get(s),i=e.start(-1),r=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const h=s.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const u=i+d+1;return new La(l.resolve(u),l.resolve(u+h.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const s=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(ni(s)&&ni(o)&&Ei(s,o)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?Ve.rowSelection(s,o):i&&this.isColSelection()?Ve.colSelection(s,o):new Ve(s,o)}return R.between(s,o)}content(){const e=this.$anchorCell.node(-1),t=F.get(e),s=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},r=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,h=o.left;h<o.right;h++,d++){const u=t.map[d];if(i[u])continue;i[u]=!0;const f=t.findCell(u);let p=e.nodeAt(u);if(!p)throw RangeError(`No cell with offset ${u} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=rn(b,0,m)),g>0&&(b=rn(b,b.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<o.top||f.bottom>o.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}r.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new M(k.from(l),1,1)}replace(e,t=M.empty){const s=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:l,$to:a}=o[r],c=e.mapping.slice(s);e.replace(c.map(l.pos),c.map(a.pos),r?M.empty:t)}const i=I.findFrom(e.doc.resolve(e.mapping.slice(s).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new M(k.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),s=F.get(t),o=this.$anchorCell.start(-1),i=s.cellsInRect(s.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),o+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const s=e.node(-1),o=F.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+o.map[r.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),r.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+r.right-1]))),new Ve(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=F.get(e),s=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-s),i=t.colCount(this.$headCell.pos-s);if(Math.min(o,i)>0)return!1;const r=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof Ve&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const s=e.node(-1),o=F.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+o.map[r.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),r.right<o.width&&(e=a.resolve(i+o.map[o.width*(r.top+1)-1]))),new Ve(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Ve(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){return new Ve(e.resolve(t),e.resolve(s))}getBookmark(){return new Bm(this.$anchorCell.pos,this.$headCell.pos)}};G.prototype.visible=!1;I.jsonID("cell",G);var Bm=class zc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new zc(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),s=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&s.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&s.index()<s.parent.childCount&&Ei(t,s)?new G(t,s):I.near(s,1)}};function Hm(n){if(!(n.selection instanceof G))return null;const e=[];return n.selection.forEachCell((t,s)=>{e.push(ae.node(s,s+t.nodeSize,{class:"selectedCell"}))}),H.create(n.doc,e)}function $m({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,s=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,s--);return t==s&&/row|table/.test(n.node(o).type.spec.tableRole)}function Fm({$from:n,$to:e}){let t,s;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return t!==s&&e.parentOffset===0}function Wm(n,e,t){const s=(e||n).selection,o=(e||n).doc;let i,r;if(s instanceof N&&(r=s.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=G.create(o,s.from);else if(r=="row"){const l=o.resolve(s.from+1);i=G.rowSelection(l,l)}else if(!t){const l=F.get(s.node),a=s.from+1,c=a+l.map[l.width*l.height-1];i=G.create(o,a+1,c)}}else s instanceof R&&$m(s)?i=R.create(o,s.from):s instanceof R&&Fm(s)&&(i=R.create(o,s.$from.start(),s.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var _m=new Fn("fix-tables");function Vc(n,e,t,s){const o=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(o,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}s(a,t),l<o&&n.child(l).sameMarkup(a)?Vc(n.child(l),a,t+1,s):a.nodesBetween(0,a.content.size,s,t+1),t+=a.nodeSize}}function qm(n,e){let t;const s=(o,i)=>{o.type.spec.tableRole=="table"&&(t=Gm(n,o,i,t))};return e?e.doc!=n.doc&&Vc(e.doc,n.doc,0,s):n.doc.descendants(s),t}function Gm(n,e,t,s){const o=F.get(e);if(!o.problems)return s;s||(s=n.tr);const i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const h=d.attrs;for(let u=0;u<h.rowspan;u++)i[c.row+u]+=c.n;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,rn(h,h.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),h=c+d.nodeSize,u=i[a];if(u>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<u;g++){const b=Ie(n.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:h-1;s.insert(s.mapping.map(m),p)}c=h}return s.setMeta(_m,{fixTables:!0})}function Lc(n){const e=n.selection,t=Ai(n),s=t.node(-1),o=t.start(-1),i=F.get(s);return{...e instanceof G?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:s}}function jm(n){return function(e,t){if(!Ks(e))return!1;if(t){const s=Ie(e.schema),o=Lc(e),i=e.tr,r=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=r.map(a=>o.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==s.header_cell&&i.setNodeMarkup(o.tableStart+r[a],s.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(o.tableStart+r[a],s.header_cell,l[a].attrs);t(i)}return!0}}function ul(n,e,t){const s=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<s.length;o++){const i=e.table.nodeAt(s[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function Oi(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jm(n):function(t,s){if(!Ks(t))return!1;if(s){const o=Ie(t.schema),i=Lc(t),r=t.tr,l=ul("row",i,o),a=ul("column",i,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,h=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?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(h).forEach(f=>{const p=f+i.tableStart,m=r.doc.nodeAt(p);m&&r.setNodeMarkup(p,u,m.attrs)}),s(r)}return!0}}Oi("row",{useDeprecatedLogic:!0});Oi("column",{useDeprecatedLogic:!0});Oi("cell",{useDeprecatedLogic:!0});function Km(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let s=n.index(-1)-1,o=n.before();s>=0;s--){const i=n.node(-1).child(s),r=i.lastChild;if(r)return o-1-r.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let s=n.indexAfter(-1),o=n.after();s<t.childCount;s++){const i=t.child(s);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function fl(n){return function(e,t){if(!Ks(e))return!1;const s=Km(Ai(e),n);if(s==null)return!1;if(t){const o=e.doc.resolve(s);t(e.tr.setSelection(R.between(o,Lm(o))).scrollIntoView())}return!0}}function ss(n,e){const t=n.selection;if(!(t instanceof G))return!1;if(e){const s=n.tr,o=Ie(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(o)||s.replace(s.mapping.map(r+1),s.mapping.map(r+i.nodeSize-1),new M(o,0,0))}),s.docChanged&&e(s)}return!0}function Jm(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:s}=n;for(;e.childCount==1&&(t>0&&s>0||e.child(0).type.spec.tableRole=="table");)t--,s--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,r=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),h=a<e.childCount-1?0:Math.max(0,s-1);(d||h)&&(c=si(Ie(r).row,new M(c,d,h)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||s?si(Ie(r).row,new M(e,t,s)).content:e);else return null;return Um(r,l)}function Um(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let s=0;for(let o=0;o<t.length;o++)s=Math.max(s,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(k.empty),t[o]<s){const i=Ie(n).cell.createAndFill(),r=[];for(let l=t[o];l<s;l++)r.push(i);e[o]=e[o].append(k.from(r))}return{height:e.length,width:s,rows:e}}function si(n,e){const t=n.createAndFill();return new Va(t).replace(0,t.content.size,e).doc}function Zm({width:n,height:e,rows:t},s,o){if(n!=s){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,h=0;d<s;h++){let u=a.child(h%a.childCount);d+u.attrs.colspan>s&&(u=u.type.createChecked(rn(u.attrs,u.attrs.colspan,d+u.attrs.colspan-s),u.content)),c.push(u),d+=u.attrs.colspan;for(let f=1;f<u.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+u.attrs.colspan}r.push(k.from(c))}t=r,n=s}if(e!=o){const i=[];for(let r=0,l=0;r<o;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let h=c.child(d);r+h.attrs.rowspan>o&&(h=h.type.create({...h.attrs,rowspan:Math.max(1,o-h.attrs.rowspan)},h.content)),a.push(h)}i.push(k.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function Ym(n,e,t,s,o,i,r){const l=n.doc.type.schema,a=Ie(l);let c,d;if(o>e.width)for(let h=0,u=0;h<e.height;h++){const f=t.child(h);u+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(r).map(u-1+s),p)}if(i>e.height){const h=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;h.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const u=a.row.create(null,k.from(h)),f=[];for(let p=e.height;p<i;p++)f.push(u);n.insert(n.mapping.slice(r).map(s+t.nodeSize-2),f)}return!!(c||d)}function pl(n,e,t,s,o,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const d=r*e.width+c,h=e.map[d];if(e.map[d-e.width]==h){a=!0;const u=t.nodeAt(h),{top:f,left:p}=e.findCell(h);n.setNodeMarkup(n.mapping.slice(l).map(h+s),null,{...u.attrs,rowspan:r-f}),n.insert(n.mapping.slice(l).map(e.positionAt(r,p,t)),u.type.createAndFill({...u.attrs,rowspan:f+u.attrs.rowspan-r})),c+=u.attrs.colspan-1}}return a}function ml(n,e,t,s,o,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const d=c*e.width+r,h=e.map[d];if(e.map[d-1]==h){a=!0;const u=t.nodeAt(h),f=e.colCount(h),p=n.mapping.slice(l).map(h+s);n.setNodeMarkup(p,null,rn(u.attrs,r-f,u.attrs.colspan-(r-f))),n.insert(p+u.nodeSize,u.type.createAndFill(rn(u.attrs,0,r-f))),c+=u.attrs.rowspan-1}}return a}function gl(n,e,t,s,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=F.get(i);const{top:l,left:a}=s,c=a+o.width,d=l+o.height,h=n.tr;let u=0;function f(){if(i=t?h.doc.nodeAt(t-1):h.doc,!i)throw new Error("No table found");r=F.get(i),u=h.mapping.maps.length}Ym(h,r,i,t,c,d,u)&&f(),pl(h,r,i,t,a,c,l,u)&&f(),pl(h,r,i,t,a,c,d,u)&&f(),ml(h,r,i,t,l,d,a,u)&&f(),ml(h,r,i,t,l,d,c,u)&&f();for(let p=l;p<d;p++){const m=r.positionAt(p,a,i),g=r.positionAt(p,c,i);h.replace(h.mapping.slice(u).map(m+t),h.mapping.slice(u).map(g+t),new M(o.rows[p-l],0,0))}f(),h.setSelection(new G(h.doc.resolve(t+r.positionAt(l,a,i)),h.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(h)}var Xm=Qa({ArrowLeft:is("horiz",-1),ArrowRight:is("horiz",1),ArrowUp:is("vert",-1),ArrowDown:is("vert",1),"Shift-ArrowLeft":rs("horiz",-1),"Shift-ArrowRight":rs("horiz",1),"Shift-ArrowUp":rs("vert",-1),"Shift-ArrowDown":rs("vert",1),Backspace:ss,"Mod-Backspace":ss,Delete:ss,"Mod-Delete":ss});function fs(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function is(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof G)return fs(t,s,I.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=Bc(o,n,e);if(r==null)return!1;if(n=="horiz")return fs(t,s,I.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=Dc(l,n,e);let c;return a?c=I.near(a,1):e<0?c=I.near(t.doc.resolve(l.before(-1)),-1):c=I.near(t.doc.resolve(l.after(-1)),1),fs(t,s,c)}}}function rs(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;let r;if(i instanceof G)r=i;else{const a=Bc(o,n,e);if(a==null)return!1;r=new G(t.doc.resolve(a))}const l=Dc(r.$headCell,n,e);return l?fs(t,s,new G(r.$anchorCell,l)):!1}}function Qm(n,e){const t=n.state.doc,s=Gn(t.resolve(e));return s?(n.dispatch(n.state.tr.setSelection(new G(s))),!0):!1}function eg(n,e,t){if(!Ks(n.state))return!1;let s=Jm(t);const o=n.state.selection;if(o instanceof G){s||(s={width:1,height:1,rows:[k.from(si(Ie(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),r=o.$anchorCell.start(-1),l=F.get(i).rectBetween(o.$anchorCell.pos-r,o.$headCell.pos-r);return s=Zm(s,l.right-l.left,l.bottom-l.top),gl(n.state,n.dispatch,r,l,s),!0}else if(s){const i=Ai(n.state),r=i.start(-1);return gl(n.state,n.dispatch,r,F.get(i.node(-1)).findCell(i.pos-r),s),!0}else return!1}function tg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const s=yl(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof G)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(o=Gn(n.state.selection.$anchor))!=null&&((t=So(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!s)return;function i(a,c){let d=So(n,c);const h=Ze.getState(n.state)==null;if(!d||!Ei(a,d))if(h)d=a;else return;const u=new G(a,d);if(h||!n.state.selection.eq(u)){const f=n.state.tr.setSelection(u);h&&f.setMeta(Ze,a.pos),n.dispatch(f)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),Ze.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ze,-1))}function l(a){const c=a,d=Ze.getState(n.state);let h;if(d!=null)h=n.state.doc.resolve(d);else if(yl(n,c.target)!=s&&(h=So(n,e),!h))return r();h&&i(h,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function Bc(n,e,t){if(!(n.state.selection instanceof R))return null;const{$head:s}=n.state.selection;for(let o=s.depth-1;o>=0;o--){const i=s.node(o);if((t<0?s.index(o):s.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=s.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function yl(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function So(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}var ng=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),oi(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,oi(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function oi(n,e,t,s,o,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let h=0,u=0;h<d.childCount;h++){const{colspan:f,colwidth:p}=d.child(h).attrs;for(let m=0;m<f;m++,u++){const g=o==u?i:p&&p[m],b=g?g+"px":"";if(l+=g||s,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const h=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=h}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ue=new Fn("tableColumnResizing");function sg({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:s=ng,lastColumnResizable:o=!0}={}){const i=new $n({key:ue,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,h=Ie(l.schema).table.name;return s&&d&&(d[h]=(u,f)=>new s(u,t,f)),new og(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=ue.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{ig(r,l,n,o)},mouseleave:r=>{rg(r)},mousedown:(r,l)=>{lg(r,l,e,t)}},decorations:r=>{const l=ue.getState(r);if(l&&l.activeHandle>-1)return ug(r,l.activeHandle)},nodeViews:{}}});return i}var og=class ps{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,s=e.getMeta(ue);if(s&&s.setHandle!=null)return new ps(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new ps(t.activeHandle,s.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return ni(e.doc.resolve(o))||(o=-1),new ps(o,t.dragging)}return t}};function ig(n,e,t,s){const o=ue.getState(n.state);if(o&&!o.dragging){const i=cg(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=bl(n,e,"left",t):a-e.clientX<=t&&(r=bl(n,e,"right",t))}if(r!=o.activeHandle){if(!s&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=F.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Hc(n,r)}}}function rg(n){const e=ue.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Hc(n,-1)}function lg(n,e,t,s){var o;const i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,r=ue.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=ag(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(ue,{setDragging:{startX:e.clientX,startWidth:a}}));function c(h){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const u=ue.getState(n.state);u!=null&&u.dragging&&(dg(n,u.activeHandle,vl(u.dragging,h,t)),n.dispatch(n.state.tr.setMeta(ue,{setDragging:null})))}function d(h){if(!h.which)return c(h);const u=ue.getState(n.state);if(u&&u.dragging){const f=vl(u.dragging,h,t);wl(n,u.activeHandle,f,s)}}return wl(n,r.activeHandle,a,s),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function ag(n,e,{colspan:t,colwidth:s}){const o=s&&s[s.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(s)for(let c=0;c<t;c++)s[c]&&(l-=s[c],a--);return l/a}function cg(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function bl(n,e,t,s){const o=t=="right"?-s:s,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=Gn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=F.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 vl(n,e,t){const s=e.clientX-n.startX;return Math.max(t,n.startWidth+s)}function Hc(n,e){n.dispatch(n.state.tr.setMeta(ue,{setHandle:e}))}function dg(n,e,t){const s=n.state.doc.resolve(e),o=s.node(-1),i=F.get(o),r=s.start(-1),l=i.colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const h=i.map[d],u=o.nodeAt(h).attrs,f=u.colspan==1?0:l-i.colCount(h);if(u.colwidth&&u.colwidth[f]==t)continue;const p=u.colwidth?u.colwidth.slice():hg(u.colspan);p[f]=t,a.setNodeMarkup(r+h,null,{...u,colwidth:p})}a.docChanged&&n.dispatch(a)}function wl(n,e,t,s){const o=n.state.doc.resolve(e),i=o.node(-1),r=o.start(-1),l=F.get(i).colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&oi(i,a.firstChild,a,s,l,t)}function hg(n){return Array(n).fill(0)}function ug(n,e){var t;const s=[],o=n.doc.resolve(e),i=o.node(-1);if(!i)return H.empty;const r=F.get(i),l=o.start(-1),a=r.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const h=r.map[d],u=l+h+i.nodeAt(h).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=ue.getState(n))!=null&&t.dragging&&s.push(ae.node(l+h,l+h+i.nodeAt(h).nodeSize,{class:"column-resize-dragging"})),s.push(ae.widget(u,f))}}return H.create(n.doc,s)}function fg({allowTableNodeSelection:n=!1}={}){return new $n({key:Ze,state:{init(){return null},apply(e,t){const s=e.getMeta(Ze);if(s!=null)return s==-1?null:s;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:Hm,handleDOMEvents:{mousedown:tg},createSelectionBetween(e){return Ze.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Qm,handleKeyDown:Xm,handlePaste:eg},appendTransaction(e,t,s){return Wm(s,qm(s,t),n)}})}const Mn=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Sl="data-gs-mrk-fs",Cl="data-gs-ib",Ds="data-gs-ifrg",We="attrs",$c={[We]:{default:"{}"}},De={[We]:{default:{}}},Fc=n=>({[We]:JSON.stringify(Mn(n))}),ze=n=>({attrs:Mn(n)}),un=n=>e=>[n,e.attrs.attrs,0],Je=n=>n.attrs[We]?JSON.parse(n.attrs[We]):{},pg={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Ds}]`,getAttrs:ze}],toDOM:()=>["span",{[Ds]:""},0]},div:{group:"block",content:"inline*",attrs:De,parseDOM:[{tag:"div",getAttrs:ze}],toDOM:un("div")},paragraph:{group:"block",content:"inline*",attrs:De,parseDOM:[{tag:"p",getAttrs:ze}],toDOM:un("p")},orderedList:{group:"block",content:"listItem+",attrs:De,parseDOM:[{tag:"ol",getAttrs:ze}],toDOM:un("ol")},bulletList:{group:"block",content:"listItem+",attrs:De,parseDOM:[{tag:"ul",getAttrs:ze}],toDOM:un("ul")},listItem:{content:"block*",group:"block",attrs:De,parseDOM:[{tag:"li",getAttrs:ze}],toDOM:un("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:De,parseDOM:[{tag:"pre",getAttrs:ze}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:De,parseDOM:[{tag:"img[src]",getAttrs:ze}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Cl}]`}],toDOM(){return["br",{[Cl]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:De,parseDOM:[{tag:"br",getAttrs:ze}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:Mn(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...zm({tableGroup:"block",cellContent:"block+",cellAttributes:{[We]:{default:De[We].default,getFromDOM:Mn,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:Mn(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},fn=(n,e)=>({attrs:$c,parseDOM:n.map(t=>({tag:t,getAttrs:Fc})),toDOM:e}),mg={strong:fn(["strong","b"],n=>["b",Je(n)]),link:fn(["a"],n=>["a",Je(n),0]),em:fn(["em","i"],n=>["em",Je(n)]),underline:fn(["u"],n=>["u",Je(n),0]),strikethrough:fn(["s"],n=>["s",Je(n),0]),font_size:{attrs:{...$c,size:{default:null}},parseDOM:[{tag:`span[${Sl}]`,getAttrs:n=>({...Fc(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Je(n),[Sl]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},xl=new Ru({nodes:pg,marks:mg}),Js=new WeakMap,Ni=new WeakMap,gg=(n,e)=>{Js.set(n,e),Ni.set(e,n)},yg=(n,e)=>{Js.delete(n),Ni.delete(e)},Co=n=>Js.get(n),bg=n=>Ni.get(n),kl=n=>{var t;const e=bg(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},vg=n=>n.dispatchEvent(new CustomEvent("input"));function wg(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Ds)){if(t.getAttribute("style")){t.removeAttribute(Ds);return}const s=t.parentElement;if(s){for(;t.firstChild;)s.insertBefore(t.firstChild,t);s.removeChild(t)}}else Array.from(t.children).forEach(s=>e(s))};e(n)}function Sg(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,h={})=>{d.trigger("focus",h.event)},a=(d,h)=>{s(d)&&o(d)&&!r(d)&&l(d,h)},c=(d,h)=>{if(s(d)&&!o(d)&&i(d)){const u=d.parents().find(f=>f.isInstanceOf("text"));u&&(l(u,h),setTimeout(()=>n.select(u),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Cg=(n,e)=>{const t=xg(n);return t&&Ig(t)?kg(n,e):t?Ga(()=>({type:n.schema.nodes.div}))(n,e):!1};function xg(n){const e=n.selection.$from;if(e.node(e.depth).type===n.schema.nodes.inlineFragment){const t=e.depth-1;return e.node(t)}return e.node(e.depth)}function kg(n,e){const{selection:t,schema:s,tr:o}=n;o.split(t.from,1);const i=t.from+1,r=o.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",h=s.text(d),u=s.nodes.div.create(l,a?h:[],[]);return o.replaceRangeWith(i,i+c+2,u),o.setSelection(R.create(o.doc,i+1)),e==null||e(o.scrollIntoView()),!0}function Tg(n,e,t){const{state:s,dispatch:o}=n,{selection:i,tr:r}=s,l=(a,c,d)=>{const h={};return a.split(";").forEach(u=>{const[f,p]=u.split(":").map(m=>m.trim());f&&(h[f]=p)}),h[c]=d,Object.entries(h).map(([u,f])=>`${u}: ${f}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,h;if(a.type===s.schema.nodes.image){const u=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}else if(a.type.isBlock){const u=l(((h=a.attrs.attrs)==null?void 0:h.style)||"","text-align",e);Wc(a)?r.setBlockType(i.from,void 0,s.schema.nodes.div,{attrs:{style:u}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:u}})}});else{const a=s.doc.resolve(i.from),c=a.start(a.depth),d=s.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const h=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:h})}}r.docChanged&&o(r.scrollIntoView())}const pn=(n,e)=>{const{from:t,to:s}=n.selection;let o=!1;return n.doc.nodesBetween(t,s,i=>{if(o)return!1;i.marks.some(r=>r.type===e)&&(o=!0)}),o};function Mg(n,e,t="_blank"){const{state:s,dispatch:o}=n,{schema:i,selection:r,tr:l}=s,a=i.marks.link;try{const c=a.create({[We]:JSON.stringify({href:e,target:t})});l.addMark(r.from,r.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function Ag(n,e){const{state:t,dispatch:s}=n,{selection:o,tr:i}=t;if(o.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(o.from,o.to,r.create({size:e})),s(i.scrollIntoView())}const bt=(n,e)=>{const{doc:t,selection:s}=n.state,o=t.resolve(s.from);for(let i=o.depth;i>0;i--){const r=o.node(i);if(e(r))return{pos:i>0?o.before(i):0,start:o.start(i),depth:i,node:r}}},Eg=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,s])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${s}`.trim(),e),{});function Og(...n){return(e,t)=>{const s=r=>{e=e.apply(r),t==null||t(r)},o=n.pop();return n.reduce((r,l)=>r||l(e,s),!1)&&o!==void 0&&o(e,t)}}const Ng=(n,e)=>{const{state:t,dispatch:s}=n;if(e!=null&&e.event){const{event:o}=e,i=n.posAtCoords({left:o.clientX,top:o.clientY});i!=null&&i.pos&&s(t.tr.setSelection(R.create(t.doc,i.pos)))}else ja(t,s);setTimeout(()=>setTimeout(()=>n.focus()))},ii=n=>n.isBlock,Wc=n=>n.type.name==="inlineFragment",Pg=n=>ii(n)&&!Wc(n),_c=n=>n.type.name==="bulletList",qc=n=>n.type.name==="orderedList",Ig=n=>n.type.name==="heading",Rg=n=>_c(n)||qc(n),Tl=(n,e)=>{var i,r;const t=(i=bt(n,l=>l.type===e))==null?void 0:i.node,s=n.state.schema.nodes.listItem;let o;return t?o=_o(s):(r=bt(n,Rg))!=null&&r.node?o=Og(_o(s),Nr(e)):o=Nr(e),o(n.state,n.dispatch)},Gc=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(s=>s.type.name===e)},Dg=n=>{var r;const{view:e,prop:t,editor:s,propCSS:o}=n,i=(r=bt(e,Pg))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=Eg(l.style);if(t in a)return a[t]||"";if(l.id){const c=s.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},zg=n=>{const{view:e,prop:t,markName:s,editor:o,propCSS:i}=n,r=Gc(e,s);if(r){const l=r.attrs;if(l[t])return l[t];if(l[We]){const a=Je(r).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},jc=(n,e)=>{const{dispatch:t}=n,{nodes:s,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:i,doc:r}=n.state;return r.textBetween(i.from,i.to," ")},replace:(i,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(i));r.select&&(c=c.setSelection(R.create(c.doc,a,a+i.length))),t==null||t(c)}},bold:{toggle:()=>ut(o.strong)(n.state,t),isActive:()=>pn(n.state,o.strong)},italic:{toggle:()=>ut(o.em)(n.state,t),isActive:()=>pn(n.state,o.em)},underline:{toggle:()=>ut(o.underline)(n.state,t),isActive:()=>pn(n.state,o.underline)},strikethrough:{toggle:()=>ut(o.strikethrough)(n.state,t),isActive:()=>pn(n.state,o.strikethrough)},link:{get:()=>{const i=kl(n);if(i!=null&&i.is("link"))return i.getAttributes();{const r=Gc(n,"link");return r?Je(r):{}}},toggle:()=>ut(o.link)(n.state,t),isActive:()=>pn(n.state,o.link),create:i=>{const r=kl(n);r!=null&&r.is("link")?(r.addAttributes({href:i.url,target:i.target}),n.focus()):Mg(n,i.url,i.target)}},alignText:{get:()=>Dg({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:i=>Tg(n,i.value,!0)},fontSize:{get:()=>zg({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:i=>Ag(n,i.value)},image:{open(){const i="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),h={id:i,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:u=>{const f={alt:d,src:u.asset.getSrc()};l(r.tr.replaceSelectionWith(s.image.createAndFill({attrs:f})))}}};e.runCommand(j.layoutToggle,h)}},heading:{get:()=>{var r;const i=(r=bt(n,ii))==null?void 0:r.node;return`${(i==null?void 0:i.attrs.level)||""}`},set:({value:i})=>{var a;const{state:r}=n,l=(a=bt(n,ii))==null?void 0:a.node;Af(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:i?parseInt(i,10):0})(r,t)}},listBullet:{isActive:()=>{var i;return!!((i=bt(n,_c))!=null&&i.node)},toggle:()=>Tl(n,s.bulletList)},listOrdered:{isActive:()=>{var i;return!!((i=bt(n,qc))!=null&&i.node)},toggle:()=>Tl(n,s.orderedList)}}},Se="rte:selectionchange",pe={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Vg=(n,e)=>{var a;const{editor:t,el:s}=n,o=Js.get(s),i=jc(o,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:pe.bold,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:pe.italic,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:pe.underline,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:pe.strikethrough,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:pe.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:pe.link,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:h,y:u,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(j.layoutRemove,{id:m}),b=i.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:h,y:u,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const v=new FormData(y.currentTarget);i.link.create({url:v.get("url"),target:v.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:v})=>v({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:v})=>v({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(j.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:pe.alignTextLeft},{id:"center",icon:pe.alignTextCenter},{id:"right",icon:pe.alignTextRight},{id:"justify",icon:pe.alignTextJustify}],editorEvents:{[Se]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:pe.listBullet,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:pe.listOrdered,size:"s",type:"button",editorEvents:{[Se]:({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:{[Se]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[Se]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),o.focus()}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.alignText,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:o},items:l}))||l};class Lg{constructor(e,t,s){this.editor=s,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:s}=this;jc(s,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class lt{constructor(e,t,s={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Bg(t):t,this.undoable=s.undoable!==!1,this.inCode=s.inCode||!1}}function Bg(n){return function(e,t,s,o){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),s+=r;let l=s-o;l>0&&(i=t[0].slice(r-l,r)+i,s=o)}return e.tr.insertText(i,s,o)}}const Hg=500;function $g({rules:n}){let e=new $n({state:{init(){return null},apply(t,s){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:s)}},props:{handleTextInput(t,s,o,i){return Ml(t,s,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:s}=t.state.selection;s&&Ml(t,s.pos,s.pos,"",n,e)})}}},isInputRules:!0});return e}function Ml(n,e,t,s,o,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Hg),l.parentOffset,null,"")+s;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let h=d.match.exec(a),u=h&&d.handler(r,h,e-(h[0].length-s.length),t);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:e,to:t,text:s}),n.dispatch(u),!0}return!1}const Fg=new lt(/--$/,"—"),Wg=new lt(/\.\.\.$/,"…"),_g=new lt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),qg=new lt(/"$/,"”"),Gg=new lt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),jg=new lt(/'$/,"’"),Kg=[_g,qg,Gg,jg];function Pi(n,e,t=null,s){return new lt(n,(o,i,r,l)=>{let a=t instanceof Function?t(i):t,c=o.tr.delete(r,l),d=c.doc.resolve(r),h=d.blockRange(),u=h&&Oa(h,e,a);if(!u)return null;c.wrap(h,u);let f=c.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&Ws(c.doc,r-1)&&(!s||s(i,f))&&c.join(r-1),c})}function Kc(n,e,t=null){return new lt(n,(s,o,i,r)=>{let l=s.doc.resolve(i),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?s.tr.delete(i,r).setBlockType(i,i,e,a):null})}function Jg(n){return Pi(/^\s*>\s$/,n)}function Ug(n){return Pi(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function Zg(n){return Pi(/^\s*([-+*])\s$/,n)}function Yg(n){return Kc(/^```$/,n)}function Xg(n,e){return Kc(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function Qg(n){const e=Kg.concat(Wg,Fg);let t;return(t=n.nodes.blockquote)&&e.push(Jg(t)),(t=n.nodes.orderedList)&&e.push(Ug(t)),(t=n.nodes.bulletList)&&e.push(Zg(t)),(t=n.nodes.codeBlock)&&e.push(Yg(t)),(t=n.nodes.heading)&&e.push(Xg(t,6)),$g({rules:e})}const e1="rteProseMirror",t1=function(n,e={}){const t={plugins:r=>r.plugins,...e},s=(r,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:xl}))||xl,{nodes:c,marks:d}=a,h=en.fromSchema(a).parse(r),u=qt.create({doc:h,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[sg(),fg(),Qg(a),Hf(),mo({Tab:fl(1),"Shift-Tab":fl(-1)}),mo({Enter:zn(qa,Kf(c.listItem),Cg),"Shift-Enter":zn(_a,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":Xa,"Mod-y":Wo,"Mod-Shift-z":Wo,"Mod-b":ut(d.strong),"Mod-i":ut(d.em),"Shift-Tab":_o(c.listItem),Tab:Zf(c.listItem)}),mo(Nf)]})}),f=new Em({mount:r},{state:u,dispatchTransaction(g){var w;const{state:b}=f,C=b.apply(g),y=!b.doc.eq(C.doc);f.updateState(C);const v=!b.selection.eq(C.selection);y&&(vg(((w=l==null?void 0:l.view)==null?void 0:w.el)||r),f.focus()),(v||y)&&n.trigger(Se)}});return r.__rteView=f,f.setProps({nodeViews:{image(g){return new Lg(g,f,n)}}}),f},o=r=>Vg(r,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(r,l,a){const c=Co(r);if(c)return c;const d=s(r,a);return gg(r,d),Ng(d,a),d},disable(r){const l=Co(r);if(l)return yg(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=Co(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),h=It.fromSchema(a).serializeFragment(c.content);return h.childNodes.forEach(u=>{u.nodeType===Node.ELEMENT_NODE&&u.innerHTML===""&&(u.innerHTML="<br/>")}),d.appendChild(h),wg(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const i=Sg(n,t);re({editor:n,licenseKey:t.licenseKey,plan:W.free,pluginName:e1,cleanup:()=>{n.RichTextEditor.customRte=void 0,i()}})},n1=ie(t1),s1="canvasEmptyState",o1=function(n,e={}){const t=new WeakMap,s=new WeakMap,o=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):Ls(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),o.delete(y)},h=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=o.get(y);if(v&&w)d(y);else if(!v&&!w){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:T=>{s.set(x,T),o.set(y,!0);const A=x.getChildrenContainer();A==null||A.appendChild(T)},unmount:()=>c(x)});t.set(x,()=>{E==null||E();const T=s.get(x);T==null||T.remove()})})}}finally{i.delete(y)}},u=y=>{o.has(y)&&d(y)},f=({model:y})=>{h(y.getComponent())},p=n.Components.events,m=`${p.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=p.removed;n.on(m,h),n.on(g,h),n.on(C,u),n.on(b,f),re({editor:n,licenseKey:l.licenseKey,plan:W.startup,pluginName:s1,cleanup:()=>{n.off(m,h),n.off(g,h),n.off(C,u),n.off(b,f)}})},i1=ie(o1),Al="canvasFullSize",r1=function(n,e={}){const{Canvas:t,Commands:s,Devices:o}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:r,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:h,frameTransition:u}=i,f=`${d}px`,p=t.events,m=`${s.events.stopCommand}core:preview`,g=t.getConfig(),b=`${Al}:disable`,C=o.getAll().map(v=>({...v.attributes}));g.scrollableCanvas=!0,o.getAll().map(v=>{!v.get("width")&&v.set("width",`${c}px`),!v.get("height")&&v.set("height","auto"),!v.get("minHeight")&&v.set("minHeight",f)});const y=v=>{const w="data-gs-plg-full-size",S=document.querySelector(`style[${w}]`);if(v&&S)return S.remove();const x=S||document.createElement("style"),E=t.getZoomMultiplier();x.setAttribute(w,"true"),x.innerHTML=`
|
|
200
|
-
.gjs-frame-wrapper { transition: width ${
|
|
198
|
+
`);return{dom:a,text:h,slice:e}}function kc(n,e,t,s,o){let i=o.parent.type.spec.code,r,l;if(!t&&!e)return null;let a=e&&(s||i||!t);if(a){if(n.someProp("transformPastedText",h=>{e=h(e,i||s,n)}),i)return e?new M(k.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
199
|
+
`))),0,0):M.empty;let u=n.someProp("clipboardTextParser",h=>h(e,o,s,n));if(u)l=u;else{let h=o.marks(),{schema:f}=n.state,p=Rt.fromSchema(f);r=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=r.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(f.text(m,h)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),r=em(t),qn&&tm(r);let c=r&&r.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let h=r.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;r=h}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||tn.fromSchema(n.state.schema)).parseSlice(r,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Yp.test(h.parentNode.nodeName)?{ignore:!0}:null}})),d)l=nm(tl(l,+d[1],+d[2]),d[4]);else if(l=M.maxOpen(Xp(l.content,o),!0),l.openStart||l.openEnd){let u=0,h=0;for(let f=l.content.firstChild;u<l.openStart&&!f.type.spec.isolating;u++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=tl(l,u,h)}return n.someProp("transformPasted",u=>{l=u(l,n)}),l}const Yp=/^(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 Xp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,r=[];if(n.forEach(l=>{if(!r)return;let a=o.findWrapping(l.type),c;if(!a)return r=null;if(c=r.length&&i.length&&Mc(a,i,l,r[r.length-1],0))r[r.length-1]=c;else{r.length&&(r[r.length-1]=Ac(r[r.length-1],i.length));let d=Tc(l,a);r.push(d),o=o.matchType(d.type),i=a}}),r)return k.from(r)}return n}function Tc(n,e,t=0){for(let s=e.length-1;s>=t;s--)n=e[s].create(null,k.from(n));return n}function Mc(n,e,t,s,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Mc(n,e,t,s.lastChild,o+1);if(i)return s.copy(s.content.replaceChild(s.childCount-1,i));if(s.contentMatchAt(s.childCount).matchType(o==n.length-1?t.type:n[o+1]))return s.copy(s.content.append(k.from(Tc(t,n,o+1))))}}function Ac(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ac(n.lastChild,e-1)),s=n.contentMatchAt(n.childCount).fillBefore(k.empty,!0);return n.copy(t.append(s))}function ni(n,e,t,s,o,i){let r=e<0?n.firstChild:n.lastChild,l=r.content;return n.childCount>1&&(i=0),o<s-1&&(l=ni(l,e,t,s,o+1,i)),o>=t&&(l=e<0?r.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(r.contentMatchAt(r.childCount).fillBefore(k.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,r.copy(l))}function tl(n,e,t){return e<n.openStart&&(n=new M(ni(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(ni(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Ec={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 nl=null;function Oc(){return nl||(nl=document.implementation.createHTMLDocument("title"))}let wo=null;function Qp(n){let e=window.trustedTypes;return e?(wo||(wo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),wo.createHTML(n)):n}function em(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Oc().createElement("div"),s=/<([a-z][^>\s]+)/i.exec(n),o;if((o=s&&Ec[s[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"</"+i+">").reverse().join("")),t.innerHTML=Qp(n),o)for(let i=0;i<o.length;i++)t=t.querySelector(o[i])||t;return t}function tm(n){let e=n.querySelectorAll(Q?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let s=e[t];s.childNodes.length==1&&s.textContent==" "&&s.parentNode&&s.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),s)}}function nm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,s;try{s=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:r}=n;for(let l=s.length-2;l>=0;l-=2){let a=t.nodes[s[l]];if(!a||a.hasRequiredAttrs())break;o=k.from(a.create(s[l+1],o)),i++,r++}return new M(o,i,r)}const ie={},re={},sm={touchstart:!0,touchmove:!0};class om{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 im(n){for(let e in ie){let t=ie[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=s=>{lm(n,s)&&!Mi(n,s)&&(n.editable||!(s.type in re))&&t(n,s)},sm[e]?{passive:!0}:void 0)}oe&&n.dom.addEventListener("input",()=>null),si(n)}function tt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function rm(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 si(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=s=>Mi(n,s))})}function Mi(n,e){return n.someProp("handleDOMEvents",t=>{let s=t[e.type];return s?s(n,e)||e.defaultPrevented:!1})}function lm(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 am(n,e){!Mi(n,e)&&ie[e.type]&&(n.editable||!(e.type in re))&&ie[e.type](n,e)}re.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Pc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Ce&&Q&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),rn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let s=Date.now();n.input.lastIOSEnter=s,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==s&&(n.someProp("handleKeyDown",o=>o(n,pt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",s=>s(n,t))||Zp(n,t)?t.preventDefault():tt(n,"key")};re.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};re.keypress=(n,e)=>{let t=e;if(Pc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||me&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let s=n.state.selection;if(!(s instanceof R)||!s.$from.sameParent(s.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,s.$from.pos,s.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Js(n){return{left:n.clientX,top:n.clientY}}function cm(n,e){let t=e.x-n.clientX,s=e.y-n.clientY;return t*t+s*s<100}function Ai(n,e,t,s,o){if(s==-1)return!1;let i=n.state.doc.resolve(s);for(let r=i.depth+1;r>0;r--)if(n.someProp(e,l=>r>i.depth?l(n,t,i.nodeAfter,i.before(r),o,!0):l(n,t,i.node(r),i.before(r),o,!1)))return!0;return!1}function Xt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let s=n.state.tr.setSelection(e);s.setMeta("pointer",!0),n.dispatch(s)}function dm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),s=t.nodeAfter;return s&&s.isAtom&&N.isSelectable(s)?(Xt(n,new N(t)),!0):!1}function um(n,e){if(e==-1)return!1;let t=n.state.selection,s,o;t instanceof N&&(s=t.node);let i=n.state.doc.resolve(e);for(let r=i.depth+1;r>0;r--){let l=r>i.depth?i.nodeAfter:i.node(r);if(N.isSelectable(l)){s&&t.$from.depth>0&&r>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(r);break}}return o!=null?(Xt(n,N.create(n.state.doc,o)),!0):!1}function hm(n,e,t,s,o){return Ai(n,"handleClickOn",e,t,s)||n.someProp("handleClick",i=>i(n,e,s))||(o?um(n,t):dm(n,t))}function fm(n,e,t,s){return Ai(n,"handleDoubleClickOn",e,t,s)||n.someProp("handleDoubleClick",o=>o(n,e,s))}function pm(n,e,t,s){return Ai(n,"handleTripleClickOn",e,t,s)||n.someProp("handleTripleClick",o=>o(n,e,s))||mm(n,t,s)}function mm(n,e,t){if(t.button!=0)return!1;let s=n.state.doc;if(e==-1)return s.inlineContent?(Xt(n,R.create(s,0,s.content.size)),!0):!1;let o=s.resolve(e);for(let i=o.depth+1;i>0;i--){let r=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(r.inlineContent)Xt(n,R.create(s,l+1,l+1+r.content.size));else if(N.isSelectable(r))Xt(n,N.create(s,l));else continue;return!0}}function Ei(n){return Rs(n)}const Nc=me?"metaKey":"ctrlKey";ie.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let s=Ei(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&cm(t,n.input.lastClick)&&!t[Nc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let r=n.posAtCoords(Js(t));r&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new gm(n,r,t,!!s)):(i=="doubleClick"?fm:pm)(n,r.pos,r.inside,t)?t.preventDefault():tt(n,"pointer"))};class gm{constructor(e,t,s,o){this.view=e,this.pos=t,this.event=s,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!s[Nc],this.allowDefault=s.shiftKey;let i,r;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),r=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,r=d.depth?d.before():0}const l=o?null:s.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(s.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof N&&c.from<=r&&c.to>r)&&(this.mightDrag={node:i,pos:r,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Te&&!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)),tt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>$e(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Js(e))),this.updateAllowDefault(e),this.allowDefault||!t?tt(this.view,"pointer"):hm(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||oe&&this.mightDrag&&!this.mightDrag.node.isAtom||Q&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Xt(this.view,I.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):tt(this.view,"pointer")}move(e){this.updateAllowDefault(e),tt(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)}}ie.touchstart=n=>{n.input.lastTouch=Date.now(),Ei(n),tt(n,"pointer")};ie.touchmove=n=>{n.input.lastTouch=Date.now(),tt(n,"pointer")};ie.contextmenu=n=>Ei(n);function Pc(n,e){return n.composing?!0:oe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ym=Ce?5e3:-1;re.compositionstart=re.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof R&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(s=>s.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rs(n,!0),n.markCursor=null;else if(Rs(n,!e.selection.empty),Te&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let s=n.domSelectionRange();for(let o=s.focusNode,i=s.focusOffset;o&&o.nodeType==1&&i!=0;){let r=i<0?o.lastChild:o.childNodes[i-1];if(!r)break;if(r.nodeType==3){let l=n.domSelection();l&&l.collapse(r,r.nodeValue.length);break}else o=r,i=-1}}n.input.composing=!0}Ic(n,ym)};re.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++,Ic(n,20))};function Ic(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rs(n),e))}function Rc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=vm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function bm(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=dp(e.focusNode,e.focusOffset),s=up(e.focusNode,e.focusOffset);if(t&&s&&t!=s){let o=s.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||s==i)return i;if(!o||!o.isText(s.nodeValue))return s;if(n.input.compositionNode==s){let r=t.pmViewDesc;if(!(!r||!r.isText(t.nodeValue)))return s}}return t||s}function vm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rs(n,e=!1){if(!(Ce&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Rc(n),e||n.docView&&n.docView.dirty){let t=ki(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 wm(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let s=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),s.removeAllRanges(),s.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Bn=ce&&nt<15||rn&&gp<604;ie.copy=re.cut=(n,e)=>{let t=e,s=n.state.selection,o=t.type=="cut";if(s.empty)return;let i=Bn?null:t.clipboardData,r=s.content(),{dom:l,text:a}=xc(n,r);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):wm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Sm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Cm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,s=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(s.contentEditable="true"),s.style.cssText="position: fixed; left: -10000px; top: 10px",s.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),s.parentNode&&s.parentNode.removeChild(s),t?Hn(n,s.value,null,o,e):Hn(n,s.textContent,s.innerHTML,o,e)},50)}function Hn(n,e,t,s,o){let i=kc(n,e,t,s,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||M.empty)))return!0;if(!i)return!1;let r=Sm(i),l=r?n.state.tr.replaceSelectionWith(r,s):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Dc(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," "):""}re.paste=(n,e)=>{let t=e;if(n.composing&&!Ce)return;let s=Bn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;s&&Hn(n,Dc(s),s.getData("text/html"),o,t)?t.preventDefault():Cm(n,t)};class zc{constructor(e,t,s){this.slice=e,this.move=t,this.node=s}}const Lc=me?"altKey":"ctrlKey";ie.dragstart=(n,e)=>{let t=e,s=n.input.mouseDown;if(s&&s.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Js(t)),r;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof N?o.to-1:o.to))){if(s&&s.mightDrag)r=N.create(n.state.doc,s.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(r=N.create(n.state.doc,u.posBefore))}}let l=(r||n.state.selection).content(),{dom:a,text:c,slice:d}=xc(n,l);(!t.dataTransfer.files.length||!Q||lc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Bn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Bn||t.dataTransfer.setData("text/plain",c),n.dragging=new zc(d,!t[Lc],r)};ie.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};re.dragover=re.dragenter=(n,e)=>e.preventDefault();re.drop=(n,e)=>{let t=e,s=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Js(t));if(!o)return;let i=n.state.doc.resolve(o.pos),r=s&&s.slice;r?n.someProp("transformPasted",p=>{r=p(r,n)}):r=kc(n,Dc(t.dataTransfer),Bn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(s&&!t[Lc]);if(n.someProp("handleDrop",p=>p(n,t,r||M.empty,l))){t.preventDefault();return}if(!r)return;t.preventDefault();let a=r?gf(n.state.doc,i.pos,r):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=s;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=r.openStart==0&&r.openEnd==0&&r.content.childCount==1,h=c.doc;if(u?c.replaceRangeWith(d,d,r.content.firstChild):c.replaceRange(d,d,r),c.doc.eq(h))return;let f=c.doc.resolve(d);if(u&&N.isSelectable(r.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(r.content.firstChild))c.setSelection(new N(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,b,C)=>p=C),c.setSelection(Ti(n,f,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ie.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&$e(n)},20))};ie.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)};ie.beforeinput=(n,e)=>{if(Q&&Ce&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:s}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=s||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,pt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in re)ie[n]=re[n];function $n(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 Ds{constructor(e,t){this.toDOM=e,this.spec=t||kt,this.side=this.spec.side||0}map(e,t,s,o){let{pos:i,deleted:r}=e.mapResult(t.from+o,this.side<0?-1:1);return r?null:new ae(i-s,i-s,this)}valid(){return!0}eq(e){return this==e||e instanceof Ds&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$n(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class ot{constructor(e,t){this.attrs=e,this.spec=t||kt}map(e,t,s,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-s,r=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-s;return i>=r?null:new ae(i,r,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ot&&$n(this.attrs,e.attrs)&&$n(this.spec,e.spec)}static is(e){return e.type instanceof ot}destroy(){}}class Oi{constructor(e,t){this.attrs=e,this.spec=t||kt}map(e,t,s,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let r=e.mapResult(t.to+o,-1);return r.deleted||r.pos<=i.pos?null:new ae(i.pos-s,r.pos-s,this)}valid(e,t){let{index:s,offset:o}=e.content.findIndex(t.from),i;return o==t.from&&!(i=e.child(s)).isText&&o+i.nodeSize==t.to}eq(e){return this==e||e instanceof Oi&&$n(this.attrs,e.attrs)&&$n(this.spec,e.spec)}destroy(){}}class ae{constructor(e,t,s){this.from=e,this.to=t,this.type=s}copy(e,t){return new ae(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,s){return this.type.map(e,this,t,s)}static widget(e,t,s){return new ae(e,e,new Ds(t,s))}static inline(e,t,s,o){return new ae(e,t,new ot(s,o))}static node(e,t,s,o){return new ae(e,t,new Oi(s,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof ot}get widget(){return this.type instanceof Ds}}const Wt=[],kt={};class ${constructor(e,t){this.local=e.length?e:Wt,this.children=t.length?t:Wt}static create(e,t){return t.length?zs(t,e,0,kt):Y}find(e,t,s){let o=[];return this.findInner(e??0,t??1e9,o,0,s),o}findInner(e,t,s,o,i){for(let r=0;r<this.local.length;r++){let l=this.local[r];l.from<=t&&l.to>=e&&(!i||i(l.spec))&&s.push(l.copy(l.from+o,l.to+o))}for(let r=0;r<this.children.length;r+=3)if(this.children[r]<t&&this.children[r+1]>e){let l=this.children[r]+1;this.children[r+2].findInner(e-l,t-l,s,o+l,i)}}map(e,t,s){return this==Y||e.maps.length==0?this:this.mapInner(e,t,0,0,s||kt)}mapInner(e,t,s,o,i){let r;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,s,o);a&&a.type.valid(t,a)?(r||(r=[])).push(a):i.onRemove&&i.onRemove(this.local[l].spec)}return this.children.length?xm(this.children,r||[],e,t,s,o,i):r?new $(r.sort(Tt),Wt):Y}add(e,t){return t.length?this==Y?$.create(e,t):this.addInner(e,t,0):this}addInner(e,t,s){let o,i=0;e.forEach((l,a)=>{let c=a+s,d;if(d=Bc(t,l,c)){for(o||(o=this.children.slice());i<o.length&&o[i]<a;)i+=3;o[i]==a?o[i+2]=o[i+2].addInner(l,d,c+1):o.splice(i,0,a,a+l.nodeSize,zs(d,l,c+1,kt)),i+=3}});let r=Vc(i?Hc(t):t,-s);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||r.splice(l--,1);return new $(r.length?this.local.concat(r).sort(Tt):this.local,o||this.children)}remove(e){return e.length==0||this==Y?this:this.removeInner(e,0)}removeInner(e,t){let s=this.children,o=this.local;for(let i=0;i<s.length;i+=3){let r,l=s[i]+t,a=s[i+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(r||(r=[])).push(u));if(!r)continue;s==this.children&&(s=this.children.slice());let c=s[i+2].removeInner(r,l+1);c!=Y?s[i+2]=c:(s.splice(i,3),i-=3)}if(o.length){for(let i=0,r;i<e.length;i++)if(r=e[i])for(let l=0;l<o.length;l++)o[l].eq(r,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return s==this.children&&o==this.local?this:o.length||s.length?new $(o,s):Y}forChild(e,t){if(this==Y)return this;if(t.isLeaf)return $.empty;let s,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(s=this.children[l+2]);break}let i=e+1,r=i+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<r&&a.to>i&&a.type instanceof ot){let c=Math.max(i,a.from)-i,d=Math.min(r,a.to)-i;c<d&&(o||(o=[])).push(a.copy(c,d))}}if(o){let l=new $(o.sort(Tt),Wt);return s?new Ue([l,s]):l}return s||Y}eq(e){if(this==e)return!0;if(!(e instanceof $)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ni(this.localsInner(e))}localsInner(e){if(this==Y)return Wt;if(e.inlineContent||!this.local.some(ot.is))return this.local;let t=[];for(let s=0;s<this.local.length;s++)this.local[s].type instanceof ot||t.push(this.local[s]);return t}forEachSet(e){e(this)}}$.empty=new $([],[]);$.removeOverlap=Ni;const Y=$.empty;class Ue{constructor(e){this.members=e}map(e,t){const s=this.members.map(o=>o.map(e,t,kt));return Ue.from(s)}forChild(e,t){if(t.isLeaf)return $.empty;let s=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=Y&&(i instanceof Ue?s=s.concat(i.members):s.push(i))}return Ue.from(s)}eq(e){if(!(e instanceof Ue)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,s=!0;for(let o=0;o<this.members.length;o++){let i=this.members[o].localsInner(e);if(i.length)if(!t)t=i;else{s&&(t=t.slice(),s=!1);for(let r=0;r<i.length;r++)t.push(i[r])}}return t?Ni(s?t:t.sort(Tt)):Wt}static from(e){switch(e.length){case 0:return Y;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof $)?e:e.reduce((t,s)=>t.concat(s instanceof $?s:s.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function xm(n,e,t,s,o,i,r){let l=n.slice();for(let c=0,d=i;c<t.maps.length;c++){let u=0;t.maps[c].forEach((h,f,p,m)=>{let g=m-p-(f-h);for(let b=0;b<l.length;b+=3){let C=l[b+1];if(C<0||h>C+d-u)continue;let y=l[b]+d-u;f>=y?l[b+1]=h<=y?-2:-1:h>=d&&g&&(l[b]+=g,l[b+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(n[c]+i),u=d-o;if(u<0||u>=s.content.size){a=!0;continue}let h=t.map(n[c+1]+i,-1),f=h-o,{index:p,offset:m}=s.content.findIndex(u),g=s.maybeChild(p);if(g&&m==u&&m+g.nodeSize==f){let b=l[c+2].mapInner(t,g,d+1,n[c]+i+1,r);b!=Y?(l[c]=u,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=km(l,n,e,t,o,i,r),d=zs(c,s,0,r);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,h=0;u<d.children.length;u+=3){let f=d.children[u];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,d.children[u],d.children[u+1],d.children[u+2])}}return new $(e.sort(Tt),l)}function Vc(n,e){if(!e||!n.length)return n;let t=[];for(let s=0;s<n.length;s++){let o=n[s];t.push(new ae(o.from+e,o.to+e,o.type))}return t}function km(n,e,t,s,o,i,r){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(s,o,c);u?t.push(u):r.onRemove&&r.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+i+1);return t}function Bc(n,e,t){if(e.isLeaf)return null;let s=t+e.nodeSize,o=null;for(let i=0,r;i<n.length;i++)(r=n[i])&&r.from>t&&r.to<s&&((o||(o=[])).push(r),n[i]=null);return o}function Hc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function zs(n,e,t,s){let o=[],i=!1;e.forEach((l,a)=>{let c=Bc(n,l,a+t);if(c){i=!0;let d=zs(c,l,t+a+1,s);d!=Y&&o.push(a,a+l.nodeSize,d)}});let r=Vc(i?Hc(n):n,-t).sort(Tt);for(let l=0;l<r.length;l++)r[l].type.valid(e,r[l])||(s.onRemove&&s.onRemove(r[l].spec),r.splice(l--,1));return r.length||o.length?new $(r,o):Y}function Tt(n,e){return n.from-e.from||n.to-e.to}function Ni(n){let e=n;for(let t=0;t<e.length-1;t++){let s=e[t];if(s.from!=s.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==s.from){i.to!=s.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,s.to),sl(e,o+1,i.copy(s.to,i.to)));continue}else{i.from<s.to&&(e==n&&(e=n.slice()),e[t]=s.copy(s.from,i.from),sl(e,o,s.copy(i.from,s.to)));break}}}return e}function sl(n,e,t){for(;e<n.length&&Tt(t,n[e])>0;)e++;n.splice(e,0,t)}function So(n){let e=[];return n.someProp("decorations",t=>{let s=t(n.state);s&&s!=Y&&e.push(s)}),n.cursorWrapper&&e.push($.create(n.state.doc,[n.cursorWrapper.deco])),Ue.from(e)}const Tm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Mm=ce&&nt<=11;class Am{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 Em{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Am,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(s=>{for(let o=0;o<s.length;o++)this.queue.push(s[o]);ce&&nt<=11&&s.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Mm&&(this.onCharData=s=>{this.queue.push({target:s.target,type:"characterData",oldValue:s.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Tm)),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(Ur(this.view)){if(this.suppressingSelectionUpdates)return $e(this.view);if(ce&&nt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ot(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,s;for(let i=e.focusNode;i;i=Vn(i))t.add(i);for(let i=e.anchorNode;i;i=Vn(i))if(t.has(i)){s=i;break}let o=s&&this.view.docView.nearestDesc(s);if(o&&o.ignoreMutation({type:"selection",target:s.nodeType==3?s.parentNode:s}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let s=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(s)&&Ur(e)&&!this.ignoreSelectionChange(s),i=-1,r=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(i=i<0?u.from:Math.min(u.from,i),r=r<0?u.to:Math.max(u.to,r),u.typeOver&&(l=!0))}if(Te&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,h]=d;u.parentNode&&u.parentNode.parentNode==h.parentNode?h.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let h of d){let f=h.parentNode;f&&f.nodeName=="LI"&&(!u||Pm(e,u)!=f)&&h.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&js(s)&&(c=ki(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,$e(e),this.currentSelection.set(s),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,r),Om(e)),this.handleDOMChange(i,r,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(s)||$e(e),this.currentSelection.set(s))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let s=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(s==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!s||s.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(s.contentDOM&&s.contentDOM!=s.dom&&!s.contentDOM.contains(e.target))return{from:s.posBefore,to:s.posAfter};let o=e.previousSibling,i=e.nextSibling;if(ce&&nt<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:h}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(o=u),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(i=h)}let r=o&&o.parentNode==e.target?U(o)+1:0,l=s.localPosFromDOM(e.target,r,-1),a=i&&i.parentNode==e.target?U(i):e.target.childNodes.length,c=s.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:s.posAtStart-s.border,to:s.posAtEnd+s.border}:(this.lastChangedTextNode=e.target,{from:s.posAtStart,to:s.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let ol=new WeakMap,il=!1;function Om(n){if(!ol.has(n)&&(ol.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Te,il)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."),il=!0}}function rl(n,e){let t=e.startContainer,s=e.startOffset,o=e.endContainer,i=e.endOffset,r=n.domAtPos(n.state.selection.anchor);return Ot(r.node,r.offset,o,i)&&([t,s,o,i]=[o,i,t,s]),{anchorNode:t,anchorOffset:s,focusNode:o,focusOffset:i}}function Nm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return rl(n,o)}let t;function s(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",s,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",s,!0),t?rl(n,t):null}function Pm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let s=n.docView.nearestDesc(t,!0);if(s&&s.node.isBlock)return t}return null}function Im(n,e,t){let{node:s,fromOffset:o,toOffset:i,from:r,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,d=a.anchorNode;if(d&&n.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],js(a)||c.push({node:a.focusNode,offset:a.focusOffset})),Q&&n.input.lastKeyCode===8)for(let g=i;g>o;g--){let b=s.childNodes[g-1],C=b.pmViewDesc;if(b.nodeName=="BR"&&!C){i=g;break}if(!C||C.size)break}let u=n.state.doc,h=n.someProp("domParser")||tn.fromSchema(n.state.schema),f=u.resolve(r),p=null,m=h.parse(s,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Rm,context:f});if(c&&c[0].pos!=null){let g=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=g),p={anchor:g+r,head:b+r}}return{doc:m,sel:p,from:r,to:l}}function Rm(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(oe&&/^(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||oe&&/^(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 Dm=/^(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 zm(n,e,t,s,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,A=ki(n,T);if(A&&!n.state.selection.eq(A)){if(Q&&Ce&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",D=>D(n,pt(13,"Enter"))))return;let P=n.state.tr.setSelection(A);T=="pointer"?P.setMeta("pointer",!0):T=="key"&&P.scrollIntoView(),i&&P.setMeta("composition",i),n.dispatch(P)}return}let r=n.state.doc.resolve(e),l=r.sharedDepth(t);e=r.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Im(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),h,f;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(h=n.state.selection.to,f="end"):(h=n.state.selection.from,f="start"),n.input.lastKeyCode=null;let p=Bm(u.content,c.doc.content,c.from,h,f);if(p&&n.input.domChangeCount++,(rn&&n.input.lastIOSEnter>Date.now()-225||Ce)&&o.some(T=>T.nodeType==1&&!Dm.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,pt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(s&&a instanceof R&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=ll(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let A=n.state.tr.setSelection(T);i&&A.setMeta("composition",i),n.dispatch(A)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof R&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ce&&nt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),b=d.resolve(p.start),C=m.sameParent(g)&&m.parent.inlineContent&&b.end()>=p.endA,y;if((rn&&n.input.lastIOSEnter>Date.now()-225&&(!C||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!C&&m.pos<c.doc.content.size&&!m.sameParent(g)&&(y=I.findFrom(c.doc.resolve(m.pos+1),1,!0))&&y.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,pt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Vm(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",T=>T(n,pt(8,"Backspace")))){Ce&&Q&&n.domObserver.suppressSelectionUpdates();return}Q&&Ce&&p.endB==p.start&&(n.input.lastAndroidDelete=Date.now()),Ce&&!C&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,pt(13,"Enter"))})},20));let v=p.start,w=p.endA,S,x,E;if(C){if(m.pos==g.pos)ce&&nt<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>$e(n),20)),S=n.state.tr.delete(v,w),x=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(E=Lm(m.parent.content.cut(m.parentOffset,g.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start()))))S=n.state.tr,E.type=="add"?S.addMark(v,w,E.mark):S.removeMark(v,w,E.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",A=>A(n,v,w,T)))return;S=n.state.tr.insertText(T,v,w)}}if(S||(S=n.state.tr.replace(v,w,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=ll(n,S.doc,c.sel);T&&!(Q&&Ce&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastAndroidDelete<Date.now()-100)&&(T.head==v||T.head==S.mapping.map(w)-1)||ce&&T.empty&&T.head==v)&&S.setSelection(T)}x&&S.ensureMarks(x),i&&S.setMeta("composition",i),n.dispatch(S.scrollIntoView())}function ll(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Ti(n,e.resolve(t.anchor),e.resolve(t.head))}function Lm(n,e){let t=n.firstChild.marks,s=e.firstChild.marks,o=t,i=s,r,l,a;for(let d=0;d<s.length;d++)o=s[d].removeFromSet(o);for(let d=0;d<t.length;d++)i=t[d].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],r="add",a=d=>d.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],r="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(k.from(c).eq(n))return{mark:l,type:r}}function Vm(n,e,t,s,o){if(t-e<=o.pos-s.pos||Co(s,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!s.parent.isTextblock){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let r=n.resolve(Co(i,!0,!0));return!r.parent.isTextblock||r.pos>t||Co(r,!0,!1)<t?!1:s.parent.content.cut(s.parentOffset).eq(r.parent.content)}function Co(n,e,t){let s=n.depth,o=e?n.end():n.pos;for(;s>0&&(e||n.indexAfter(s)==n.node(s).childCount);)s--,o++,e=!1;if(t){let i=n.node(s).maybeChild(n.indexAfter(s));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Bm(n,e,t,s,o){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:r,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(r,l));s-=r+a-i}if(r<i&&n.size<e.size){let a=s<=i&&s>=r?i-s:0;i-=a,i&&i<e.size&&al(e.textBetween(i-1,i+1))&&(i+=a?1:-1),l=i+(l-r),r=i}else if(l<i){let a=s<=i&&s>=l?i-s:0;i-=a,i&&i<n.size&&al(n.textBetween(i-1,i+1))&&(i+=a?1:-1),r=i+(r-l),l=i}return{start:i,endA:r,endB:l}}function al(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 Hm{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 om,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(fl),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=ul(this),dl(this),this.nodeViews=hl(this),this.docView=_r(this.state.doc,cl(this),So(this),this.dom,this),this.domObserver=new Em(this,(s,o,i,r)=>zm(this,s,o,i,r)),this.domObserver.start(),im(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&&si(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(fl),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let s in this._props)t[s]=this._props[s];t.state=this.state;for(let s in e)t[s]=e[s];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var s;let o=this.state,i=!1,r=!1;e.storedMarks&&this.composing&&(Rc(this),r=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=hl(this);Fm(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&si(this),this.editable=ul(this),dl(this);let a=So(this),c=cl(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(r=!0);let h=d=="preserve"&&r&&this.dom.style.overflowAnchor==null&&vp(this);if(r){this.domObserver.stop();let f=u&&(ce||Q)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&$m(o.selection,e.selection);if(u){let p=Q?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=bm(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=_r(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_p(this))?$e(this,f):(wc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((s=this.dragging)===null||s===void 0)&&s.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():h&&wp(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof N){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Vr(this,t.getBoundingClientRect(),e)}else Vr(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let s=this.directPlugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let s=this.state.plugins[t];s.spec.view&&this.pluginViews.push(s.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let s=this.pluginViews[t];s.update&&s.update(this,e)}}updateDraggedNode(e,t){let s=e.node,o=-1;if(this.state.doc.nodeAt(s.from)==s.node)o=s.from;else{let i=s.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==s.node&&(o=i)}this.dragging=new zc(e.slice,e.move,o<0?void 0:N.create(this.state.doc,o))}someProp(e,t){let s=this._props&&this._props[e],o;if(s!=null&&(o=t?t(s):s))return o;for(let r=0;r<this.directPlugins.length;r++){let l=this.directPlugins[r].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let r=0;r<i.length;r++){let l=i[r].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ce){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&&Sp(this.dom),$e(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Mp(this,e)}coordsAtPos(e,t=1){return hc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,s=-1){let o=this.docView.posFromDOM(e,t,s);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Pp(this,t||this.state,e)}pasteHTML(e,t){return Hn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Hn(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(rm(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],So(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ap())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return am(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?oe&&this.root.nodeType===11&&fp(this.dom.ownerDocument)==this.dom&&Nm(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function cl(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let s in t)s=="class"?e.class+=" "+t[s]:s=="style"?e.style=(e.style?e.style+";":"")+t[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(t[s]))}),e.translate||(e.translate="no"),[ae.node(0,n.state.doc.content.size,e)]}function dl(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:ae.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ul(n){return!n.someProp("editable",e=>e(n.state)===!1)}function $m(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 hl(n){let e=Object.create(null);function t(s){for(let o in s)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=s[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Fm(n,e){let t=0,s=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)s++;return t!=s}function fl(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 oi,ii;if(typeof WeakMap<"u"){let n=new WeakMap;oi=e=>n.get(e),ii=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;oi=s=>{for(let o=0;o<n.length;o+=2)if(n[o]==s)return n[o+1]},ii=(s,o)=>(t==10&&(t=0),n[t++]=s,n[t++]=o)}var _=class{constructor(n,e,t,s){this.width=n,this.height=e,this.map=t,this.problems=s}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const s=e%this.width,o=e/this.width|0;let i=s+1,r=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;r<this.height&&this.map[e+this.width*l]==t;l++)r++;return{left:s,top:o,right:i,bottom:r}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:s,right:o,top:i,bottom:r}=this.findCell(n);return e=="horiz"?(t<0?s==0:o==this.width)?null:this.map[i*this.width+(t<0?s-1:o)]:(t<0?i==0:r==this.height)?null:this.map[s+this.width*(t<0?i-1:r)]}rectBetween(n,e){const{left:t,right:s,top:o,bottom:i}=this.findCell(n),{left:r,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,r),top:Math.min(o,a),right:Math.max(s,l),bottom:Math.max(i,c)}}cellsInRect(n){const e=[],t={};for(let s=n.top;s<n.bottom;s++)for(let o=n.left;o<n.right;o++){const i=s*this.width+o,r=this.map[i];t[r]||(t[r]=!0,!(o==n.left&&o&&this.map[i-1]==r||s==n.top&&s&&this.map[i-this.width]==r)&&e.push(r))}return e}positionAt(n,e,t){for(let s=0,o=0;;s++){const i=o+t.child(s).nodeSize;if(s==n){let r=e+n*this.width;const l=(n+1)*this.width;for(;r<l&&this.map[r]<o;)r++;return r==l?i-1:this.map[r]}o=i}}static get(n){return oi(n)||ii(n,Wm(n))}};function Wm(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=_m(n),t=n.childCount,s=[];let o=0,i=null;const r=[];for(let c=0,d=e*t;c<d;c++)s[c]=0;for(let c=0,d=0;c<t;c++){const u=n.child(c);d++;for(let p=0;;p++){for(;o<s.length&&s[o]!=0;)o++;if(p==u.childCount)break;const m=u.child(p),{colspan:g,rowspan:b,colwidth:C}=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=o+y*e;for(let w=0;w<g;w++){s[v+w]==0?s[v+w]=d:(i||(i=[])).push({type:"collision",row:c,pos:d,n:g-w});const S=C&&C[w];if(S){const x=(v+w)%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]++}}}o+=g,d+=m.nodeSize}const h=(c+1)*e;let f=0;for(;o<h;)s[o++]==0&&f++;f&&(i||(i=[])).push({type:"missing",row:c,n:f}),d++}const l=new _(e,t,s,i);let a=!1;for(let c=0;!a&&c<r.length;c+=2)r[c]!=null&&r[c+1]<t&&(a=!0);return a&&qm(l,r,n),l}function _m(n){let e=-1,t=!1;for(let s=0;s<n.childCount;s++){const o=n.child(s);let i=0;if(t)for(let r=0;r<s;r++){const l=n.child(r);for(let a=0;a<l.childCount;a++){const c=l.child(a);r+c.attrs.rowspan>s&&(i+=c.attrs.colspan)}}for(let r=0;r<o.childCount;r++){const l=o.child(r);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function qm(n,e,t){n.problems||(n.problems=[]);const s={};for(let o=0;o<n.map.length;o++){const i=n.map[o];if(s[i])continue;s[i]=!0;const r=t.nodeAt(i);if(!r)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=r.attrs;for(let c=0;c<a.colspan;c++){const d=(o+c)%n.width,u=e[d*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=Gm(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function Gm(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function pl(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),s=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(r=>Number(r)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:s&&s.length==o?s:null};for(const r in e){const l=e[r].getFromDOM,a=l&&l(n);a!=null&&(i[r]=a)}return i}function ml(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const s in e){const o=e[s].setDOMAttr;o&&o(n.attrs[s],t)}return t}function jm(n){const e=n.cellAttributes||{},t={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const s in e)t[s]={default:e[s].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:s=>pl(s,e)}],toDOM(s){return["td",ml(s,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:s=>pl(s,e)}],toDOM(s){return["th",ml(s,e),0]}}}}function Ie(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const s=n.nodes[t],o=s.spec.tableRole;o&&(e[o]=s)}}return e}var Ze=new Wn("selectingCells");function jn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Us(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 Pi(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=jn(e.$head)||Km(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Km(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const s=e.type.spec.tableRole;if(s=="cell"||s=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ri(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Jm(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ii(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function $c(n,e,t){const s=n.node(-1),o=_.get(s),i=n.start(-1),r=o.nextCell(n.pos-i,e,t);return r==null?null:n.node(0).resolve(i+r)}function ln(n,e,t=1){const s={...n,colspan:n.colspan-t};return s.colwidth&&(s.colwidth=s.colwidth.slice(),s.colwidth.splice(e,t),s.colwidth.some(o=>o>0)||(s.colwidth=null)),s}var j=class Le extends I{constructor(e,t=e){const s=e.node(-1),o=_.get(s),i=e.start(-1),r=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(r).filter(d=>d!=t.pos-i);a.unshift(t.pos-i);const c=a.map(d=>{const u=s.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);const h=i+d+1;return new _a(l.resolve(h),l.resolve(h+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const s=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(ri(s)&&ri(o)&&Ii(s,o)){const i=this.$anchorCell.node(-1)!=s.node(-1);return i&&this.isRowSelection()?Le.rowSelection(s,o):i&&this.isColSelection()?Le.colSelection(s,o):new Le(s,o)}return R.between(s,o)}content(){const e=this.$anchorCell.node(-1),t=_.get(e),s=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s),i={},r=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let d=a*t.width+o.left,u=o.left;u<o.right;u++,d++){const h=t.map[d];if(i[h])continue;i[h]=!0;const f=t.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const m=o.left-f.left,g=f.right-o.right;if(m>0||g>0){let b=p.attrs;if(m>0&&(b=ln(b,0,m)),g>0&&(b=ln(b,b.colspan-g,g)),f.left<o.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<o.top||f.bottom>o.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,o.bottom)-Math.max(f.top,o.top)};f.top<o.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}r.push(e.child(a).copy(k.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:r;return new M(k.from(l),1,1)}replace(e,t=M.empty){const s=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:l,$to:a}=o[r],c=e.mapping.slice(s);e.replace(c.map(l.pos),c.map(a.pos),r?M.empty:t)}const i=I.findFrom(e.doc.resolve(e.mapping.slice(s).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new M(k.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),s=_.get(t),o=this.$anchorCell.start(-1),i=s.cellsInRect(s.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let r=0;r<i.length;r++)e(t.nodeAt(i[r]),o+i[r])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const s=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(s,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const s=e.node(-1),o=_.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.top<=l.top?(r.top>0&&(e=a.resolve(i+o.map[r.left])),l.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+o.map[l.left])),r.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+r.right-1]))),new Le(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=_.get(e),s=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-s),i=t.colCount(this.$headCell.pos-s);if(Math.min(o,i)>0)return!1;const r=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(r,l)==t.width}eq(e){return e instanceof Le&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const s=e.node(-1),o=_.get(s),i=e.start(-1),r=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return r.left<=l.left?(r.left>0&&(e=a.resolve(i+o.map[r.top*o.width])),l.right<o.width&&(t=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+o.map[l.top*o.width])),r.right<o.width&&(e=a.resolve(i+o.map[o.width*(r.top+1)-1]))),new Le(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new Le(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,s=t){return new Le(e.resolve(t),e.resolve(s))}getBookmark(){return new Um(this.$anchorCell.pos,this.$headCell.pos)}};j.prototype.visible=!1;I.jsonID("cell",j);var Um=class Fc{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Fc(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),s=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&s.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&s.index()<s.parent.childCount&&Ii(t,s)?new j(t,s):I.near(s,1)}};function Zm(n){if(!(n.selection instanceof j))return null;const e=[];return n.selection.forEachCell((t,s)=>{e.push(ae.node(s,s+t.nodeSize,{class:"selectedCell"}))}),$.create(n.doc,e)}function Ym({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,s=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,s--);return t==s&&/row|table/.test(n.node(o).type.spec.tableRole)}function Xm({$from:n,$to:e}){let t,s;for(let o=n.depth;o>0;o--){const i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){const i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){s=i;break}}return t!==s&&e.parentOffset===0}function Qm(n,e,t){const s=(e||n).selection,o=(e||n).doc;let i,r;if(s instanceof N&&(r=s.node.type.spec.tableRole)){if(r=="cell"||r=="header_cell")i=j.create(o,s.from);else if(r=="row"){const l=o.resolve(s.from+1);i=j.rowSelection(l,l)}else if(!t){const l=_.get(s.node),a=s.from+1,c=a+l.map[l.width*l.height-1];i=j.create(o,a+1,c)}}else s instanceof R&&Ym(s)?i=R.create(o,s.from):s instanceof R&&Xm(s)&&(i=R.create(o,s.$from.start(),s.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var eg=new Wn("fix-tables");function Wc(n,e,t,s){const o=n.childCount,i=e.childCount;e:for(let r=0,l=0;r<i;r++){const a=e.child(r);for(let c=l,d=Math.min(o,r+3);c<d;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}s(a,t),l<o&&n.child(l).sameMarkup(a)?Wc(n.child(l),a,t+1,s):a.nodesBetween(0,a.content.size,s,t+1),t+=a.nodeSize}}function tg(n,e){let t;const s=(o,i)=>{o.type.spec.tableRole=="table"&&(t=ng(n,o,i,t))};return e?e.doc!=n.doc&&Wc(e.doc,n.doc,0,s):n.doc.descendants(s),t}function ng(n,e,t,s){const o=_.get(e);if(!o.problems)return s;s||(s=n.tr);const i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const d=e.nodeAt(c.pos);if(!d)continue;const u=d.attrs;for(let h=0;h<u.rowspan;h++)i[c.row+h]+=c.n;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,ln(u,u.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const d=e.nodeAt(c.pos);if(!d)continue;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,{...d.attrs,rowspan:d.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const d=e.nodeAt(c.pos);if(!d)continue;s.setNodeMarkup(s.mapping.map(t+1+c.pos),null,{...d.attrs,colwidth:c.colwidth})}}let r,l;for(let a=0;a<i.length;a++)i[a]&&(r==null&&(r=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const d=e.child(a),u=c+d.nodeSize,h=i[a];if(h>0){let f="cell";d.firstChild&&(f=d.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<h;g++){const b=Ie(n.schema)[f].createAndFill();b&&p.push(b)}const m=(a==0||r==a-1)&&l==a?c+1:u-1;s.insert(s.mapping.map(m),p)}c=u}return s.setMeta(eg,{fixTables:!0})}function _c(n){const e=n.selection,t=Pi(n),s=t.node(-1),o=t.start(-1),i=_.get(s);return{...e instanceof j?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:s}}function sg(n){return function(e,t){if(!Us(e))return!1;if(t){const s=Ie(e.schema),o=_c(e),i=e.tr,r=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=r.map(a=>o.table.nodeAt(a));for(let a=0;a<r.length;a++)l[a].type==s.header_cell&&i.setNodeMarkup(o.tableStart+r[a],s.cell,l[a].attrs);if(i.steps.length==0)for(let a=0;a<r.length;a++)i.setNodeMarkup(o.tableStart+r[a],s.header_cell,l[a].attrs);t(i)}return!0}}function gl(n,e,t){const s=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<s.length;o++){const i=e.table.nodeAt(s[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function Ri(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?sg(n):function(t,s){if(!Us(t))return!1;if(s){const o=Ie(t.schema),i=_c(t),r=t.tr,l=gl("row",i,o),a=gl("column",i,o),d=(n==="column"?l:n==="row"?a:!1)?1:0,u=n=="column"?{left:0,top:d,right:1,bottom:i.map.height}:n=="row"?{left:d,top:0,right:i.map.width,bottom:1}:i,h=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{const p=f+i.tableStart,m=r.doc.nodeAt(p);m&&r.setNodeMarkup(p,h,m.attrs)}),s(r)}return!0}}Ri("row",{useDeprecatedLogic:!0});Ri("column",{useDeprecatedLogic:!0});Ri("cell",{useDeprecatedLogic:!0});function og(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let s=n.index(-1)-1,o=n.before();s>=0;s--){const i=n.node(-1).child(s),r=i.lastChild;if(r)return o-1-r.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let s=n.indexAfter(-1),o=n.after();s<t.childCount;s++){const i=t.child(s);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function yl(n){return function(e,t){if(!Us(e))return!1;const s=og(Pi(e),n);if(s==null)return!1;if(t){const o=e.doc.resolve(s);t(e.tr.setSelection(R.between(o,Jm(o))).scrollIntoView())}return!0}}function is(n,e){const t=n.selection;if(!(t instanceof j))return!1;if(e){const s=n.tr,o=Ie(n.schema).cell.createAndFill().content;t.forEachCell((i,r)=>{i.content.eq(o)||s.replace(s.mapping.map(r+1),s.mapping.map(r+i.nodeSize-1),new M(o,0,0))}),s.docChanged&&e(s)}return!0}function ig(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:s}=n;for(;e.childCount==1&&(t>0&&s>0||e.child(0).type.spec.tableRole=="table");)t--,s--,e=e.child(0).content;const o=e.child(0),i=o.type.spec.tableRole,r=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const d=a?0:Math.max(0,t-1),u=a<e.childCount-1?0:Math.max(0,s-1);(d||u)&&(c=li(Ie(r).row,new M(c,d,u)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||s?li(Ie(r).row,new M(e,t,s)).content:e);else return null;return rg(r,l)}function rg(n,e){const t=[];for(let o=0;o<e.length;o++){const i=e[o];for(let r=i.childCount-1;r>=0;r--){const{rowspan:l,colspan:a}=i.child(r).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let s=0;for(let o=0;o<t.length;o++)s=Math.max(s,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(k.empty),t[o]<s){const i=Ie(n).cell.createAndFill(),r=[];for(let l=t[o];l<s;l++)r.push(i);e[o]=e[o].append(k.from(r))}return{height:e.length,width:s,rows:e}}function li(n,e){const t=n.createAndFill();return new Wa(t).replace(0,t.content.size,e).doc}function lg({width:n,height:e,rows:t},s,o){if(n!=s){const i=[],r=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let d=i[l]||0,u=0;d<s;u++){let h=a.child(u%a.childCount);d+h.attrs.colspan>s&&(h=h.type.createChecked(ln(h.attrs,h.attrs.colspan,d+h.attrs.colspan-s),h.content)),c.push(h),d+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)i[l+f]=(i[l+f]||0)+h.attrs.colspan}r.push(k.from(c))}t=r,n=s}if(e!=o){const i=[];for(let r=0,l=0;r<o;r++,l++){const a=[],c=t[l%e];for(let d=0;d<c.childCount;d++){let u=c.child(d);r+u.attrs.rowspan>o&&(u=u.type.create({...u.attrs,rowspan:Math.max(1,o-u.attrs.rowspan)},u.content)),a.push(u)}i.push(k.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function ag(n,e,t,s,o,i,r){const l=n.doc.type.schema,a=Ie(l);let c,d;if(o>e.width)for(let u=0,h=0;u<e.height;u++){const f=t.child(u);h+=f.nodeSize;const p=[];let m;f.lastChild==null||f.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=d||(d=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(r).map(h-1+s),p)}if(i>e.height){const u=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,k.from(u)),f=[];for(let p=e.height;p<i;p++)f.push(h);n.insert(n.mapping.slice(r).map(s+t.nodeSize-2),f)}return!!(c||d)}function bl(n,e,t,s,o,i,r,l){if(r==0||r==e.height)return!1;let a=!1;for(let c=o;c<i;c++){const d=r*e.width+c,u=e.map[d];if(e.map[d-e.width]==u){a=!0;const h=t.nodeAt(u),{top:f,left:p}=e.findCell(u);n.setNodeMarkup(n.mapping.slice(l).map(u+s),null,{...h.attrs,rowspan:r-f}),n.insert(n.mapping.slice(l).map(e.positionAt(r,p,t)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-r})),c+=h.attrs.colspan-1}}return a}function vl(n,e,t,s,o,i,r,l){if(r==0||r==e.width)return!1;let a=!1;for(let c=o;c<i;c++){const d=c*e.width+r,u=e.map[d];if(e.map[d-1]==u){a=!0;const h=t.nodeAt(u),f=e.colCount(u),p=n.mapping.slice(l).map(u+s);n.setNodeMarkup(p,null,ln(h.attrs,r-f,h.attrs.colspan-(r-f))),n.insert(p+h.nodeSize,h.type.createAndFill(ln(h.attrs,0,r-f))),c+=h.attrs.rowspan-1}}return a}function wl(n,e,t,s,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let r=_.get(i);const{top:l,left:a}=s,c=a+o.width,d=l+o.height,u=n.tr;let h=0;function f(){if(i=t?u.doc.nodeAt(t-1):u.doc,!i)throw new Error("No table found");r=_.get(i),h=u.mapping.maps.length}ag(u,r,i,t,c,d,h)&&f(),bl(u,r,i,t,a,c,l,h)&&f(),bl(u,r,i,t,a,c,d,h)&&f(),vl(u,r,i,t,l,d,a,h)&&f(),vl(u,r,i,t,l,d,c,h)&&f();for(let p=l;p<d;p++){const m=r.positionAt(p,a,i),g=r.positionAt(p,c,i);u.replace(u.mapping.slice(h).map(m+t),u.mapping.slice(h).map(g+t),new M(o.rows[p-l],0,0))}f(),u.setSelection(new j(u.doc.resolve(t+r.positionAt(l,a,i)),u.doc.resolve(t+r.positionAt(d-1,c-1,i)))),e(u)}var cg=ic({ArrowLeft:rs("horiz",-1),ArrowRight:rs("horiz",1),ArrowUp:rs("vert",-1),ArrowDown:rs("vert",1),"Shift-ArrowLeft":ls("horiz",-1),"Shift-ArrowRight":ls("horiz",1),"Shift-ArrowUp":ls("vert",-1),"Shift-ArrowDown":ls("vert",1),Backspace:is,"Mod-Backspace":is,Delete:is,"Mod-Delete":is});function ps(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function rs(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;if(i instanceof j)return ps(t,s,I.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;const r=qc(o,n,e);if(r==null)return!1;if(n=="horiz")return ps(t,s,I.near(t.doc.resolve(i.head+e),e));{const l=t.doc.resolve(r),a=$c(l,n,e);let c;return a?c=I.near(a,1):e<0?c=I.near(t.doc.resolve(l.before(-1)),-1):c=I.near(t.doc.resolve(l.after(-1)),1),ps(t,s,c)}}}function ls(n,e){return(t,s,o)=>{if(!o)return!1;const i=t.selection;let r;if(i instanceof j)r=i;else{const a=qc(o,n,e);if(a==null)return!1;r=new j(t.doc.resolve(a))}const l=$c(r.$headCell,n,e);return l?ps(t,s,new j(r.$anchorCell,l)):!1}}function dg(n,e){const t=n.state.doc,s=jn(t.resolve(e));return s?(n.dispatch(n.state.tr.setSelection(new j(s))),!0):!1}function ug(n,e,t){if(!Us(n.state))return!1;let s=ig(t);const o=n.state.selection;if(o instanceof j){s||(s={width:1,height:1,rows:[k.from(li(Ie(n.state.schema).cell,t))]});const i=o.$anchorCell.node(-1),r=o.$anchorCell.start(-1),l=_.get(i).rectBetween(o.$anchorCell.pos-r,o.$headCell.pos-r);return s=lg(s,l.right-l.left,l.bottom-l.top),wl(n.state,n.dispatch,r,l,s),!0}else if(s){const i=Pi(n.state),r=i.start(-1);return wl(n.state,n.dispatch,r,_.get(i.node(-1)).findCell(i.pos-r),s),!0}else return!1}function hg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const s=Sl(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof j)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&s&&(o=jn(n.state.selection.$anchor))!=null&&((t=xo(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!s)return;function i(a,c){let d=xo(n,c);const u=Ze.getState(n.state)==null;if(!d||!Ii(a,d))if(u)d=a;else return;const h=new j(a,d);if(u||!n.state.selection.eq(h)){const f=n.state.tr.setSelection(h);u&&f.setMeta(Ze,a.pos),n.dispatch(f)}}function r(){n.root.removeEventListener("mouseup",r),n.root.removeEventListener("dragstart",r),n.root.removeEventListener("mousemove",l),Ze.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ze,-1))}function l(a){const c=a,d=Ze.getState(n.state);let u;if(d!=null)u=n.state.doc.resolve(d);else if(Sl(n,c.target)!=s&&(u=xo(n,e),!u))return r();u&&i(u,c)}n.root.addEventListener("mouseup",r),n.root.addEventListener("dragstart",r),n.root.addEventListener("mousemove",l)}function qc(n,e,t){if(!(n.state.selection instanceof R))return null;const{$head:s}=n.state.selection;for(let o=s.depth-1;o>=0;o--){const i=s.node(o);if((t<0?s.index(o):s.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=s.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Sl(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xo(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?jn(n.state.doc.resolve(t.pos)):null}var fg=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")),ai(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,ai(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function ai(n,e,t,s,o,i){var r;let l=0,a=!0,c=e.firstChild;const d=n.firstChild;if(d){for(let u=0,h=0;u<d.childCount;u++){const{colspan:f,colwidth:p}=d.child(u).attrs;for(let m=0;m<f;m++,h++){const g=o==h?i:p&&p[m],b=g?g+"px":"";if(l+=g||s,g||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const C=document.createElement("col");C.style.width=b,e.appendChild(C)}}}for(;c;){const u=c.nextSibling;(r=c.parentNode)==null||r.removeChild(c),c=u}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var he=new Wn("tableColumnResizing");function pg({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:s=fg,lastColumnResizable:o=!0}={}){const i=new Fn({key:he,state:{init(r,l){var a,c;const d=(c=(a=i.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,u=Ie(l.schema).table.name;return s&&d&&(d[u]=(h,f)=>new s(h,t,f)),new mg(-1,!1)},apply(r,l){return l.apply(r)}},props:{attributes:r=>{const l=he.getState(r);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(r,l)=>{gg(r,l,n,o)},mouseleave:r=>{yg(r)},mousedown:(r,l)=>{bg(r,l,e,t)}},decorations:r=>{const l=he.getState(r);if(l&&l.activeHandle>-1)return xg(r,l.activeHandle)},nodeViews:{}}});return i}var mg=class ms{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,s=e.getMeta(he);if(s&&s.setHandle!=null)return new ms(s.setHandle,!1);if(s&&s.setDragging!==void 0)return new ms(t.activeHandle,s.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return ri(e.doc.resolve(o))||(o=-1),new ms(o,t.dragging)}return t}};function gg(n,e,t,s){const o=he.getState(n.state);if(o&&!o.dragging){const i=wg(e.target);let r=-1;if(i){const{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?r=Cl(n,e,"left",t):a-e.clientX<=t&&(r=Cl(n,e,"right",t))}if(r!=o.activeHandle){if(!s&&r!==-1){const l=n.state.doc.resolve(r),a=l.node(-1),c=_.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Gc(n,r)}}}function yg(n){const e=he.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Gc(n,-1)}function bg(n,e,t,s){var o;const i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,r=he.getState(n.state);if(!r||r.activeHandle==-1||r.dragging)return!1;const l=n.state.doc.nodeAt(r.activeHandle),a=vg(n,r.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(he,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const h=he.getState(n.state);h!=null&&h.dragging&&(Sg(n,h.activeHandle,xl(h.dragging,u,t)),n.dispatch(n.state.tr.setMeta(he,{setDragging:null})))}function d(u){if(!u.which)return c(u);const h=he.getState(n.state);if(h&&h.dragging){const f=xl(h.dragging,u,t);kl(n,h.activeHandle,f,s)}}return kl(n,r.activeHandle,a,s),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function vg(n,e,{colspan:t,colwidth:s}){const o=s&&s[s.length-1];if(o)return o;const i=n.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,a=t;if(s)for(let c=0;c<t;c++)s[c]&&(l-=s[c],a--);return l/a}function wg(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Cl(n,e,t,s){const o=t=="right"?-s:s,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;const{pos:r}=i,l=jn(n.state.doc.resolve(r));if(!l)return-1;if(t=="right")return l.pos;const a=_.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 xl(n,e,t){const s=e.clientX-n.startX;return Math.max(t,n.startWidth+s)}function Gc(n,e){n.dispatch(n.state.tr.setMeta(he,{setHandle:e}))}function Sg(n,e,t){const s=n.state.doc.resolve(e),o=s.node(-1),i=_.get(o),r=s.start(-1),l=i.colCount(s.pos-r)+s.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){const d=c*i.width+l;if(c&&i.map[d]==i.map[d-i.width])continue;const u=i.map[d],h=o.nodeAt(u).attrs,f=h.colspan==1?0:l-i.colCount(u);if(h.colwidth&&h.colwidth[f]==t)continue;const p=h.colwidth?h.colwidth.slice():Cg(h.colspan);p[f]=t,a.setNodeMarkup(r+u,null,{...h,colwidth:p})}a.docChanged&&n.dispatch(a)}function kl(n,e,t,s){const o=n.state.doc.resolve(e),i=o.node(-1),r=o.start(-1),l=_.get(i).colCount(o.pos-r)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&ai(i,a.firstChild,a,s,l,t)}function Cg(n){return Array(n).fill(0)}function xg(n,e){var t;const s=[],o=n.doc.resolve(e),i=o.node(-1);if(!i)return $.empty;const r=_.get(i),l=o.start(-1),a=r.colCount(o.pos-l)+o.nodeAfter.attrs.colspan-1;for(let c=0;c<r.height;c++){const d=a+c*r.width;if((a==r.width-1||r.map[d]!=r.map[d+1])&&(c==0||r.map[d]!=r.map[d-r.width])){const u=r.map[d],h=l+u+i.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(t=he.getState(n))!=null&&t.dragging&&s.push(ae.node(l+u,l+u+i.nodeAt(u).nodeSize,{class:"column-resize-dragging"})),s.push(ae.widget(h,f))}}return $.create(n.doc,s)}function kg({allowTableNodeSelection:n=!1}={}){return new Fn({key:Ze,state:{init(){return null},apply(e,t){const s=e.getMeta(Ze);if(s!=null)return s==-1?null:s;if(t==null||!e.docChanged)return t;const{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:Zm,handleDOMEvents:{mousedown:hg},createSelectionBetween(e){return Ze.getState(e.state)!=null?e.state.selection:null},handleTripleClick:dg,handleKeyDown:cg,handlePaste:ug},appendTransaction(e,t,s){return Qm(s,tg(s,t),n)}})}const An=n=>{const e=Object.fromEntries(Array.from(n.attributes).map(t=>[t.name,t.value]));return delete e.draggable,e},Tl="data-gs-mrk-fs",Ml="data-gs-ib",Ls="data-gs-ifrg",We="attrs",jc={[We]:{default:"{}"}},De={[We]:{default:{}}},Kc=n=>({[We]:JSON.stringify(An(n))}),ze=n=>({attrs:An(n)}),fn=n=>e=>[n,e.attrs.attrs,0],Je=n=>n.attrs[We]?JSON.parse(n.attrs[We]):{},Tg={doc:{content:"block+"},text:{group:"inline",inline:!0},inlineFragment:{group:"block",content:"inline*",isTextBlock:!0,parseDOM:[{tag:`span[${Ls}]`,getAttrs:ze}],toDOM:()=>["span",{[Ls]:""},0]},div:{group:"block",content:"inline*",attrs:De,parseDOM:[{tag:"div",getAttrs:ze}],toDOM:fn("div")},paragraph:{group:"block",content:"inline*",attrs:De,parseDOM:[{tag:"p",getAttrs:ze}],toDOM:fn("p")},orderedList:{group:"block",content:"listItem+",attrs:De,parseDOM:[{tag:"ol",getAttrs:ze}],toDOM:fn("ol")},bulletList:{group:"block",content:"listItem+",attrs:De,parseDOM:[{tag:"ul",getAttrs:ze}],toDOM:fn("ul")},listItem:{content:"block*",group:"block",attrs:De,parseDOM:[{tag:"li",getAttrs:ze}],toDOM:fn("li"),defining:!0},codeBlock:{group:"block",content:"text*",marks:"",attrs:De,parseDOM:[{tag:"pre",getAttrs:ze}],toDOM:n=>["pre",n.attrs.attrs,["code",0]]},image:{inline:!0,group:"inline",selectable:!0,attrs:De,parseDOM:[{tag:"img[src]",getAttrs:ze}],toDOM:n=>["img",n.attrs.attrs]},inlineBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:`br[${Ml}]`}],toDOM(){return["br",{[Ml]:""}]}},hardBreak:{inline:!1,group:"block",selectable:!1,attrs:De,parseDOM:[{tag:"br",getAttrs:ze}],toDOM:n=>["br",{...n.attrs.attrs}]},heading:{group:"block",content:"inline*",attrs:{level:{default:1},attrs:{default:{}}},defining:!0,parseDOM:Array.from({length:6},(n,e)=>({tag:`h${e+1}`,getAttrs:t=>({level:e+1,attrs:An(t)})})),toDOM({attrs:n}){const{level:e}=n;return[e?`h${e}`:"div",n.attrs,0]}},...jm({tableGroup:"block",cellContent:"block+",cellAttributes:{[We]:{default:De[We].default,getFromDOM:An,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:An(n)}),priority:0}],toDOM(n){const{tagName:e,attrs:t}=n.attrs;return[e,t,0]}}},pn=(n,e)=>({attrs:jc,parseDOM:n.map(t=>({tag:t,getAttrs:Kc})),toDOM:e}),Mg={strong:pn(["strong","b"],n=>["b",Je(n)]),link:pn(["a"],n=>["a",Je(n),0]),em:pn(["em","i"],n=>["em",Je(n)]),underline:pn(["u"],n=>["u",Je(n),0]),strikethrough:pn(["s"],n=>["s",Je(n),0]),font_size:{attrs:{...jc,size:{default:null}},parseDOM:[{tag:`span[${Tl}]`,getAttrs:n=>({...Kc(n),size:n.style.fontSize})}],toDOM(n){const{size:e}=n.attrs,t={...Je(n),[Tl]:!0};return e&&(t.style=`font-size: ${e}`),["span",t,0]}}},Al=new qh({nodes:Tg,marks:Mg}),Zs=new WeakMap,Di=new WeakMap,Ag=(n,e)=>{Zs.set(n,e),Di.set(e,n)},Eg=(n,e)=>{Zs.delete(n),Di.delete(e)},ko=n=>Zs.get(n),Og=n=>Di.get(n),El=n=>{var t;const e=Og(n);return(t=e==null?void 0:e.__gjsv)==null?void 0:t.model},Ng=n=>n.dispatchEvent(new CustomEvent("input"));function Pg(n){const e=t=>{if(t.tagName==="SPAN"&&t.hasAttribute(Ls)){if(t.getAttribute("style")){t.removeAttribute(Ls);return}const s=t.parentElement;if(s){for(;t.firstChild;)s.insertBefore(t.firstChild,t);s.removeChild(t)}}else Array.from(t.children).forEach(s=>e(s))};e(n)}function Ig(n,e={}){if(!e.enableOnClick)return()=>{};const t=n.Components.events,s=d=>n.getSelectedAll().includes(d),o=d=>d.isInstanceOf("text")&&!d.isChildOf("text"),i=d=>d.isChildOf("text"),r=d=>n.getEditing()===d,l=(d,u={})=>{d.trigger("focus",u.event)},a=(d,u)=>{s(d)&&o(d)&&!r(d)&&l(d,u)},c=(d,u)=>{if(s(d)&&!o(d)&&i(d)){const h=d.parents().find(f=>f.isInstanceOf("text"));h&&(l(h,u),setTimeout(()=>n.select(h),0))}};return n.on(t.select,a),n.on(t.selectBefore,c),()=>{n.off(t.select,a),n.off(t.selectBefore,c)}}const Rg=(n,e)=>{const t=Dg(n);return t&&_g(t)?zg(n,e):t?Ya(()=>({type:n.schema.nodes.div}))(n,e):!1};function Dg(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 zg(n,e){const{selection:t,schema:s,tr:o}=n;o.split(t.from,1);const i=t.from+1,r=o.doc.nodeAt(i),l={...r.attrs.attrs,id:void 0},a=r.textContent.length>0,c=r.textContent.length||0,d=r.textContent||" ",u=s.text(d),h=s.nodes.div.create(l,a?u:[],[]);return o.replaceRangeWith(i,i+c+2,h),o.setSelection(R.create(o.doc,i+1)),e==null||e(o.scrollIntoView()),!0}function Lg(n,e,t){const{state:s,dispatch:o}=n,{selection:i,tr:r}=s,l=(a,c,d)=>{const u={};return a.split(";").forEach(h=>{const[f,p]=h.split(":").map(m=>m.trim());f&&(u[f]=p)}),u[c]=d,Object.entries(u).map(([h,f])=>`${h}: ${f}`).join("; ")};if(!i.empty||t)r.doc.nodesBetween(i.from,i.to,(a,c)=>{var d,u;if(a.type===s.schema.nodes.image){const h=l(((d=a.attrs.attrs)==null?void 0:d.style)||"","float",e);r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}else if(a.type.isBlock){const h=l(((u=a.attrs.attrs)==null?void 0:u.style)||"","text-align",e);Jc(a)?r.setBlockType(i.from,void 0,s.schema.nodes.div,{attrs:{style:h}}):r.setNodeMarkup(c,void 0,{...a.attrs,attrs:{...a.attrs.attrs,style:h}})}});else{const a=s.doc.resolve(i.from),c=a.start(a.depth),d=s.doc.nodeAt(c);if(d!=null&&d.type.isBlock){const u=l(d.attrs.style||"","text-align",e);r.setNodeMarkup(c,void 0,{...d.attrs,style:u})}}r.docChanged&&o(r.scrollIntoView())}const mn=(n,e)=>{const{from:t,to:s}=n.selection;let o=!1;return n.doc.nodesBetween(t,s,i=>{if(o)return!1;i.marks.some(r=>r.type===e)&&(o=!0)}),o};function Vg(n,e,t="_blank"){const{state:s,dispatch:o}=n,{schema:i,selection:r,tr:l}=s,a=i.marks.link;try{const c=a.create({[We]:JSON.stringify({href:e,target:t})});l.addMark(r.from,r.to,c),o(l.scrollIntoView())}catch(c){console.error("Error applying link mark:",c)}}function Bg(n,e){const{state:t,dispatch:s}=n,{selection:o,tr:i}=t;if(o.empty)return;const r=t.schema.marks.font_size;if(!r){console.error("Font size mark is not defined in the schema.");return}i.addMark(o.from,o.to,r.create({size:e})),s(i.scrollIntoView())}const vt=(n,e)=>{const{doc:t,selection:s}=n.state,o=t.resolve(s.from);for(let i=o.depth;i>0;i--){const r=o.node(i);if(e(r))return{pos:i>0?o.before(i):0,start:o.start(i),depth:i,node:r}}},Hg=n=>(n||"").split(";").map(e=>e.split(":")).reduce((e,[t,s])=>(t=t.replace(/-./g,o=>o.toUpperCase()[1]).trim(),e[t]=`${s}`.trim(),e),{});function $g(...n){return(e,t)=>{const s=r=>{e=e.apply(r),t==null||t(r)},o=n.pop();return n.reduce((r,l)=>r||l(e,s),!1)&&o!==void 0&&o(e,t)}}const Fg=(n,e)=>{const{state:t,dispatch:s}=n;if(e!=null&&e.event){const{event:o}=e,i=n.posAtCoords({left:o.clientX,top:o.clientY});i!=null&&i.pos&&s(t.tr.setSelection(R.create(t.doc,i.pos)))}else Xa(t,s);setTimeout(()=>setTimeout(()=>n.focus()))},ci=n=>n.isBlock,Jc=n=>n.type.name==="inlineFragment",Wg=n=>ci(n)&&!Jc(n),Uc=n=>n.type.name==="bulletList",Zc=n=>n.type.name==="orderedList",_g=n=>n.type.name==="heading",qg=n=>Uc(n)||Zc(n),Ol=(n,e)=>{var i,r;const t=(i=vt(n,l=>l.type===e))==null?void 0:i.node,s=n.state.schema.nodes.listItem;let o;return t?o=Ko(s):(r=vt(n,qg))!=null&&r.node?o=$g(Ko(s),Dr(e)):o=Dr(e),o(n.state,n.dispatch)},Yc=(n,e)=>{const{selection:t}=n.state;return[...t.$from.marks(),...t.$to.marks()].find(s=>s.type.name===e)},Gg=n=>{var r;const{view:e,prop:t,editor:s,propCSS:o}=n,i=(r=vt(e,Wg))==null?void 0:r.node;if(i){const l=i.attrs.attrs||{},a=Hg(l.style);if(t in a)return a[t]||"";if(l.id){const c=s.Components.getById(l.id);return((c==null?void 0:c.getStyle())||{})[o]||""}}return""},jg=n=>{const{view:e,prop:t,markName:s,editor:o,propCSS:i}=n,r=Yc(e,s);if(r){const l=r.attrs;if(l[t])return l[t];if(l[We]){const a=Je(r).id;if(a){const c=o.Components.getById(a);return((c==null?void 0:c.getStyle())||{})[i]||""}}}return""},Xc=(n,e)=>{const{dispatch:t}=n,{nodes:s,marks:o}=n.state.schema;return{text:{selected:()=>{const{selection:i,doc:r}=n.state;return r.textBetween(i.from,i.to," ")},replace:(i,r={})=>{const{state:l}=n,{from:a}=l.selection;let c=l.tr.replaceSelectionWith(l.schema.text(i));r.select&&(c=c.setSelection(R.create(c.doc,a,a+i.length))),t==null||t(c)}},bold:{toggle:()=>ft(o.strong)(n.state,t),isActive:()=>mn(n.state,o.strong)},italic:{toggle:()=>ft(o.em)(n.state,t),isActive:()=>mn(n.state,o.em)},underline:{toggle:()=>ft(o.underline)(n.state,t),isActive:()=>mn(n.state,o.underline)},strikethrough:{toggle:()=>ft(o.strikethrough)(n.state,t),isActive:()=>mn(n.state,o.strikethrough)},link:{get:()=>{const i=El(n);if(i!=null&&i.is("link"))return i.getAttributes();{const r=Yc(n,"link");return r?Je(r):{}}},toggle:()=>ft(o.link)(n.state,t),isActive:()=>mn(n.state,o.link),create:i=>{const r=El(n);r!=null&&r.is("link")?(r.addAttributes({href:i.url,target:i.target}),n.focus()):Vg(n,i.url,i.target)}},alignText:{get:()=>Gg({view:n,editor:e,prop:"textAlign",propCSS:"text-align"}),set:i=>Lg(n,i.value,!0)},fontSize:{get:()=>jg({view:n,editor:e,markName:"font_size",prop:"size",propCSS:"font-size"}),set:i=>Bg(n,i.value)},image:{open(){const i="assetLayout",{state:r,dispatch:l}=n,{selection:a,doc:c}=r,d=c.textBetween(a.from,a.to," "),u={id:i,disablePropagation:!0,placer:{type:"dialog",title:"Select image",size:"l"},header:!1,layout:{type:"panelAssets",onSelect:h=>{const f={alt:d,src:h.asset.getSrc()};l(r.tr.replaceSelectionWith(s.image.createAndFill({attrs:f})))}}};e.runCommand(B.layoutToggle,u)}},heading:{get:()=>{var r;const i=(r=vt(n,ci))==null?void 0:r.node;return`${(i==null?void 0:i.attrs.level)||""}`},set:({value:i})=>{var a;const{state:r}=n,l=(a=vt(n,ci))==null?void 0:a.node;Bf(r.schema.nodes.heading,{attrs:l==null?void 0:l.attrs.attrs,level:i?parseInt(i,10):0})(r,t)}},listBullet:{isActive:()=>{var i;return!!((i=vt(n,Uc))!=null&&i.node)},toggle:()=>Ol(n,s.bulletList)},listOrdered:{isActive:()=>{var i;return!!((i=vt(n,Zc))!=null&&i.node)},toggle:()=>Ol(n,s.orderedList)}}},Se="rte:selectionchange",pe={bold:'<svg viewBox="0 0 24 24"><path d="M13.5,15.5H10V12.5H13.5A1.5,1.5 0 0,1 15,14A1.5,1.5 0 0,1 13.5,15.5M10,6.5H13A1.5,1.5 0 0,1 14.5,8A1.5,1.5 0 0,1 13,9.5H10M15.6,10.79C16.57,10.11 17.25,9 17.25,8C17.25,5.74 15.5,4 13.25,4H7V18H14.04C16.14,18 17.75,16.3 17.75,14.21C17.75,12.69 16.89,11.39 15.6,10.79Z" /></svg>',italic:'<svg viewBox="0 0 24 24"><path d="M10,4V7H12.21L8.79,15H6V18H14V15H11.79L15.21,7H18V4H10Z" /></svg>',underline:'<svg viewBox="0 0 24 24"><path d="M5,21H19V19H5V21M12,17A6,6 0 0,0 18,11V3H15.5V11A3.5,3.5 0 0,1 12,14.5A3.5,3.5 0 0,1 8.5,11V3H6V11A6,6 0 0,0 12,17Z" /></svg>',strikethrough:'<svg viewBox="0 0 24 24"><path d="M7.2 9.8c-1.2-2.3.5-5 2.9-5.5 3.1-1 7.6.4 7.5 4.2h-3l-.1-.8c-.2-.6-.6-.9-1.2-1.1-.8-.3-2.1-.2-2.8.3C9 8.2 10.4 9.5 12 10H7.4l-.2-.2M21 13v-2H3v2h9.6l.6.2c.6.3 1.1.5 1.3 1.1.1.4.2.9 0 1.3-.2.5-.6.7-1.1.9-1.8.5-4-.2-3.9-2.4h-3c-.1 2.6 2.1 4.4 4.5 4.7 3.8.8 8.3-1.6 6.3-5.9l3.7.1Z"/></svg>',link:'<svg viewBox="0 0 24 24"><path d="M3.9,12C3.9,10.29 5.29,8.9 7,8.9H11V7H7A5,5 0 0,0 2,12A5,5 0 0,0 7,17H11V15.1H7C5.29,15.1 3.9,13.71 3.9,12M8,13H16V11H8V13M17,7H13V8.9H17C18.71,8.9 20.1,10.29 20.1,12C20.1,13.71 18.71,15.1 17,15.1H13V17H17A5,5 0 0,0 22,12A5,5 0 0,0 17,7Z" /></svg>',image:'<svg viewBox="0 0 24 24"><path d="M19,19H5V5H19M19,3H5A2,2 0 0,0 3,5V19A2,2 0 0,0 5,21H19A2,2 0 0,0 21,19V5A2,2 0 0,0 19,3M13.96,12.29L11.21,15.83L9.25,13.47L6.5,17H17.5L13.96,12.29Z"></path></svg>',listBullet:'<svg viewBox="0 0 24 24"><path d="M7 5h14v2H7V5m0 8v-2h14v2H7M4 4.5A1.5 1.5 0 0 1 5.5 6 1.5 1.5 0 0 1 4 7.5 1.5 1.5 0 0 1 2.5 6 1.5 1.5 0 0 1 4 4.5m0 6A1.5 1.5 0 0 1 5.5 12 1.5 1.5 0 0 1 4 13.5 1.5 1.5 0 0 1 2.5 12 1.5 1.5 0 0 1 4 10.5M7 19v-2h14v2H7m-3-2.5A1.5 1.5 0 0 1 5.5 18 1.5 1.5 0 0 1 4 19.5 1.5 1.5 0 0 1 2.5 18 1.5 1.5 0 0 1 4 16.5Z"/></svg>',listOrdered:'<svg viewBox="0 0 24 24"><path d="M7 13v-2h14v2H7m0 6v-2h14v2H7M7 7V5h14v2H7M3 8V5H2V4h2v4H3m-1 9v-1h3v4H2v-1h2v-.5H3v-1h1V17H2m2.3-7a.8.8 0 0 1 .7.8c0 .1 0 .3-.2.5L3 13h2v1H2v-1l2-2H2v-1h2.3Z"/></svg>',alignTextLeft:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H15V9H3V7M3,11H21V13H3V11M3,15H15V17H3V15M3,19H21V21H3V19Z" /></svg>',alignTextCenter:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M7,7H17V9H7V7M3,11H21V13H3V11M7,15H17V17H7V15M3,19H21V21H3V19Z" /></svg>',alignTextRight:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M9,7H21V9H9V7M3,11H21V13H3V11M9,15H21V17H9V15M3,19H21V21H3V19Z" /></svg>',alignTextJustify:'<svg viewBox="0 0 24 24"><path d="M3,3H21V5H3V3M3,7H21V9H3V7M3,11H21V13H3V11M3,15H21V17H3V15M3,19H21V21H3V19Z" /></svg>'},Kg=(n,e)=>{var a;const{editor:t,el:s}=n,o=Zs.get(s),i=Xc(o,t),r={separator:{type:"column",style:{borderRightWidth:"1px",borderRightStyle:"solid",alignSelf:"stretch",margin:3}},bold:{id:"bold",icon:pe.bold,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.bold.isActive()})}},onClick:({setState:c})=>{i.bold.toggle(),c({active:i.bold.isActive()})}},italic:{id:"italic",icon:pe.italic,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.italic.isActive()})}},onClick:({setState:c})=>{i.italic.toggle(),c({active:i.italic.isActive()})}},underline:{id:"underline",icon:pe.underline,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.underline.isActive()})}},onClick:({setState:c})=>{i.underline.toggle(),c({active:i.underline.isActive()})}},strikethrough:{id:"strikethrough",icon:pe.strikethrough,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.strikethrough.isActive()})}},onClick:({setState:c})=>{i.strikethrough.toggle(),c({active:i.strikethrough.isActive()})}},image:{id:"image",icon:pe.image,size:"s",type:"button",onClick:()=>i.image.open()},link:{id:"link",icon:pe.link,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.link.isActive(),disabled:o.state.selection.empty})}},onClick:({event:c})=>{const d=c.currentTarget||c.target,{x:u,y:h,width:f,height:p}=d.getBoundingClientRect(),m="linkLayout",g=()=>t.runCommand(B.layoutRemove,{id:m}),b=i.link.get(),C={id:m,style:{width:240},disablePropagation:!0,placer:{type:"popover",closeOnClickAway:!0,x:u,y:h,w:f,h:p},header:{label:"Link"},layout:{type:"column",as:"form",style:{padding:"0 10px 15px",gap:10},onSubmit:y=>{y.preventDefault();const v=new FormData(y.currentTarget);i.link.create({url:v.get("url"),target:v.get("target")}),g()},children:[{type:"inputField",name:"url",label:"URL",placeholder:"eg. https://google.com",required:!0,value:(b==null?void 0:b.href)||"",onChange:({value:y,setState:v})=>v({value:y})},{type:"selectField",name:"target",label:"Open link in",emptyState:"Current window",value:(b==null?void 0:b.target)||"",options:[{id:"",label:"Current window"},{id:"_blank",label:"New window"}],onChange:({value:y,setState:v})=>v({value:y})},{type:"row",style:{gap:10,justifyContent:"end"},children:[i.link.isActive()&&{type:"button",label:"Clear",buttonType:"button",onClick:()=>{i.link.toggle(),g()}},{type:"button",variant:"primary",label:"Submit",buttonType:"submit"}]}]}};t.runCommand(B.layoutToggle,C)}},alignText:{id:"alignText",type:"buttonGroupField",size:"s",value:"",options:[{id:"left",icon:pe.alignTextLeft},{id:"center",icon:pe.alignTextCenter},{id:"right",icon:pe.alignTextRight},{id:"justify",icon:pe.alignTextJustify}],editorEvents:{[Se]:({setState:c})=>{c({value:i.alignText.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.alignText.set({value:c})}},listBullet:{id:"listBullet",icon:pe.listBullet,size:"s",type:"button",editorEvents:{[Se]:({setState:c})=>{c({active:i.listBullet.isActive()})}},onClick:({setState:c})=>{i.listBullet.toggle(),c({active:i.listBullet.isActive()})}},listOrdered:{id:"listOrdered",icon:pe.listOrdered,size:"s",type:"button",editorEvents:{[Se]:({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:{[Se]:({setState:c})=>{c({value:i.heading.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.heading.set({value:c}),o.focus()}},fontSize:{id:"fontSize",type:"selectField",size:"s",value:"",emptyState:"Font size",options:[{id:"8pt",label:"8pt"},{id:"10pt",label:"10pt"},{id:"12pt",label:"12pt"},{id:"14pt",label:"14pt"},{id:"18pt",label:"18pt"},{id:"24pt",label:"24pt"},{id:"36pt",label:"36pt"}],editorEvents:{[Se]:({setState:c})=>{c({value:i.fontSize.get()})}},onChange:({value:c,setState:d})=>{d({value:c}),i.fontSize.set({value:c}),o.focus()}}},l=[r.bold,r.italic,r.underline,r.strikethrough,r.image,r.link,r.listBullet,r.listOrdered,r.alignText,r.heading,r.fontSize];return((a=e.toolbar)==null?void 0:a.call(e,{...n,commands:i,layouts:r,proseMirror:{view:o},items:l}))||l};class Jg{constructor(e,t,s){this.editor=s,this.node=e,this.dom=document.createElement("img"),this.view=t,Object.keys(e.attrs.attrs).forEach(o=>{this.dom.setAttribute(o,e.attrs.attrs[o])}),this.dom.addEventListener("dblclick",o=>this.handleDoubleClick(o))}handleDoubleClick(e){const{editor:t,view:s}=this;Xc(s,t).image.open(),e.preventDefault()}update(e){return e.type!==this.node.type?!1:(this.node=e,Object.keys(e.attrs.attrs).forEach(t=>{this.dom.setAttribute(t,e.attrs.attrs[t])}),!0)}selectNode(){this.dom.style.outline="2px solid #ffca6f"}deselectNode(){this.dom.style.outline=""}}class at{constructor(e,t,s={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Ug(t):t,this.undoable=s.undoable!==!1,this.inCode=s.inCode||!1}}function Ug(n){return function(e,t,s,o){let i=n;if(t[1]){let r=t[0].lastIndexOf(t[1]);i+=t[0].slice(r+t[1].length),s+=r;let l=s-o;l>0&&(i=t[0].slice(r-l,r)+i,s=o)}return e.tr.insertText(i,s,o)}}const Zg=500;function Yg({rules:n}){let e=new Fn({state:{init(){return null},apply(t,s){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:s)}},props:{handleTextInput(t,s,o,i){return Nl(t,s,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:s}=t.state.selection;s&&Nl(t,s.pos,s.pos,"",n,e)})}}},isInputRules:!0});return e}function Nl(n,e,t,s,o,i){if(n.composing)return!1;let r=n.state,l=r.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Zg),l.parentOffset,null,"")+s;for(let c=0;c<o.length;c++){let d=o[c];if(l.parent.type.spec.code){if(!d.inCode)continue}else if(d.inCode==="only")continue;let u=d.match.exec(a),h=u&&d.handler(r,u,e-(u[0].length-s.length),t);if(h)return d.undoable&&h.setMeta(i,{transform:h,from:e,to:t,text:s}),n.dispatch(h),!0}return!1}const Xg=new at(/--$/,"—"),Qg=new at(/\.\.\.$/,"…"),e1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“"),t1=new at(/"$/,"”"),n1=new at(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘"),s1=new at(/'$/,"’"),o1=[e1,t1,n1,s1];function zi(n,e,t=null,s){return new at(n,(o,i,r,l)=>{let a=t instanceof Function?t(i):t,c=o.tr.delete(r,l),d=c.doc.resolve(r),u=d.blockRange(),h=u&&za(u,e,a);if(!h)return null;c.wrap(u,h);let f=c.doc.resolve(r-1).nodeBefore;return f&&f.type==e&&qs(c.doc,r-1)&&(!s||s(i,f))&&c.join(r-1),c})}function Qc(n,e,t=null){return new at(n,(s,o,i,r)=>{let l=s.doc.resolve(i),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?s.tr.delete(i,r).setBlockType(i,i,e,a):null})}function i1(n){return zi(/^\s*>\s$/,n)}function r1(n){return zi(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function l1(n){return zi(/^\s*([-+*])\s$/,n)}function a1(n){return Qc(/^```$/,n)}function c1(n,e){return Qc(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function d1(n){const e=o1.concat(Qg,Xg);let t;return(t=n.nodes.blockquote)&&e.push(i1(t)),(t=n.nodes.orderedList)&&e.push(r1(t)),(t=n.nodes.bulletList)&&e.push(l1(t)),(t=n.nodes.codeBlock)&&e.push(a1(t)),(t=n.nodes.heading)&&e.push(c1(t,6)),Yg({rules:e})}const u1="rteProseMirror",h1=function(n,e={}){const t={plugins:r=>r.plugins,...e},s=(r,l)=>{var p,m;const a=((p=t.schema)==null?void 0:p.call(t,{editor:n,schema:Al}))||Al,{nodes:c,marks:d}=a,u=tn.fromSchema(a).parse(r),h=Gt.create({doc:u,schema:a,plugins:(m=t.plugins)==null?void 0:m.call(t,{editor:n,plugins:[pg(),kg(),d1(a),Zf(),yo({Tab:yl(1),"Shift-Tab":yl(-1)}),yo({Enter:Ln(Za,op(c.listItem),Rg),"Shift-Enter":Ln(Ua,(g,b)=>(b&&b(g.tr.replaceSelectionWith(c.inlineBreak.create()).scrollIntoView()),!0)),"Mod-z":oc,"Mod-y":jo,"Mod-Shift-z":jo,"Mod-b":ft(d.strong),"Mod-i":ft(d.em),"Shift-Tab":Ko(c.listItem),Tab:lp(c.listItem)}),yo(Ff)]})}),f=new Hm({mount:r},{state:h,dispatchTransaction(g){var w;const{state:b}=f,C=b.apply(g),y=!b.doc.eq(C.doc);f.updateState(C);const v=!b.selection.eq(C.selection);y&&(Ng(((w=l==null?void 0:l.view)==null?void 0:w.el)||r),f.focus()),(v||y)&&n.trigger(Se)}});return r.__rteView=f,f.setProps({nodeViews:{image(g){return new Jg(g,f,n)}}}),f},o=r=>Kg(r,t);n.setCustomRte({toolbar:o,parseContent:!0,async enable(r,l,a){const c=ko(r);if(c)return c;const d=s(r,a);return Ag(r,d),Fg(d,a),d},disable(r){const l=ko(r);if(l)return Eg(r,l),l.destroy(),{forceSync:!0}},getContent(r){const l=ko(r);if(l){const{schema:a,doc:c}=l.state,d=document.createElement("div"),u=Rt.fromSchema(a).serializeFragment(c.content);return u.childNodes.forEach(h=>{h.nodeType===Node.ELEMENT_NODE&&h.innerHTML===""&&(h.innerHTML="<br/>")}),d.appendChild(u),Pg(d),r.classList.remove("ProseMirror-focused"),d.innerHTML}return r.innerHTML}});const i=Ig(n,t);te({editor:n,licenseKey:t.licenseKey,plan:F.free,pluginName:u1,cleanup:()=>{n.RichTextEditor.customRte=void 0,i()}})},f1=ee(h1),p1="canvasEmptyState",m1=function(n,e={}){const t=new WeakMap,s=new WeakMap,o=new WeakMap,i=new Set,r=new WeakMap,l={emptyStates:[],...e},a=(y,v)=>{let w=!1;const{isValid:S}=v;return Array.isArray(S)?w=S.some(x=>y.is(x)):Hs(S)?w=S({component:y,editor:n}):w=y.is(S),w},c=y=>{const v=t.get(y);t.delete(y),v==null||v()},d=y=>{y.views.forEach(v=>c(v)),o.delete(y)},u=y=>{if(!(!y||i.has(y)))try{i.add(y);const v=y.components().length>0,w=o.get(y);if(v&&w)d(y);else if(!v&&!w){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:T=>{s.set(x,T),o.set(y,!0);const A=x.getChildrenContainer();A==null||A.appendChild(T)},unmount:()=>c(x)});t.set(x,()=>{E==null||E();const T=s.get(x);T==null||T.remove()})})}}finally{i.delete(y)}},h=y=>{o.has(y)&&d(y)},f=({model:y})=>{u(y.getComponent())},p=n.Components.events,m=`${p.update}:components`,g="component:mount",b=n.Canvas.events.frameLoadBody,C=p.removed;n.on(m,u),n.on(g,u),n.on(C,h),n.on(b,f),te({editor:n,licenseKey:l.licenseKey,plan:F.startup,pluginName:p1,cleanup:()=>{n.off(m,u),n.off(g,u),n.off(C,h),n.off(b,f)}})},g1=ee(m1),Pl="canvasFullSize",y1=function(n,e={}){const{Canvas:t,Commands:s,Devices:o}=n,i={deviceMaxWidth:1200,deviceMinHeigth:500,canvasOffsetY:30,canvasOffsetX:50,canvasTransition:.3,frameBorderRadius:5,frameTransition:.3,...e},{canvasOffsetY:r,canvasOffsetX:l,canvasTransition:a,deviceMaxWidth:c,deviceMinHeigth:d,frameBorderRadius:u,frameTransition:h}=i,f=`${d}px`,p=t.events,m=`${s.events.stopCommand}core:preview`,g=t.getConfig(),b=`${Pl}:disable`,C=o.getAll().map(v=>({...v.attributes}));g.scrollableCanvas=!0,o.getAll().map(v=>{!v.get("width")&&v.set("width",`${c}px`),!v.get("height")&&v.set("height","auto"),!v.get("minHeight")&&v.set("minHeight",f)});const y=v=>{const w="data-gs-plg-full-size",S=document.querySelector(`style[${w}]`);if(v&&S)return S.remove();const x=S||document.createElement("style"),E=t.getZoomMultiplier();x.setAttribute(w,"true"),x.innerHTML=`
|
|
200
|
+
.gjs-frame-wrapper { transition: width ${h}s !important; }
|
|
201
201
|
.gjs-frame-wrapper__bottom { height: ${r*E}px }
|
|
202
|
-
.gjs-frame { border-radius: ${
|
|
203
|
-
`,!S&&document.body.appendChild(x)};n.on(p.frameLoadHead,v=>{if(!g.scrollableCanvas)return;const{window:w}=v,S=w.document,x=S.head,E="data-gs-plg-wrapper-style",T=x.querySelector(`style[${E}]`)||S.createElement("style");T.setAttribute(E,"true"),T.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${f}; }`,!x.contains(T)&&x.appendChild(T)}),n.onReady(()=>{const v=t.getSpotsEl(),w=t.getElement(),S=t.getFramesEl(),x=a*1e3,E=w.style;E.overflowX="hidden",S.style.transition=`transform ${a}s`;const T={x:l,y:r};y();const A=()=>v.style.display="none",P=()=>v.style.display="",D=ai(()=>{t.fitViewport({zoom:we=>we>100?100:we,ignoreHeight:!0,gap:T}),y(),setTimeout(()=>{var we,Me;n.em.destroyed||((Me=(we=n.getSelected())==null?void 0:we.getEl())==null||Me.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),P())},x)},100),V=new ResizeObserver(()=>{A(),D()});V.observe(w.parentElement);const B=()=>{A(),D()},be=(we={})=>{we.options&&we.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:T})},ve=()=>{E.overflowX="hidden",E.overflowY="auto"},at=()=>{V.disconnect(),D.clear()};n.on(o.events.select,B),n.on(p.zoom,be),n.on(m,ve),n.on(n.events.destroy,at),D(),s.add(b,()=>{o.devices.reset(C),g.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),E.overflowY="hidden",y(!0),n.off(o.events.select,B),n.off(p.zoom,be),n.off(m,ve),at(),s.run("studio:canvasReload")})}),re({editor:n,licenseKey:i.licenseKey,plan:W.startup,pluginName:Al,cleanup:()=>{n.runCommand(b)}})},l1=ie(r1),a1=n=>{const e={};for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?s=s.map(o=>o.toString()).join(","):s=s.toString(),e[t]=s)}return new URLSearchParams(e)},c1=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:s="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=a1(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[s])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),h={...c,...d};h.part?h.part.includes("snippet")||h.part.push("snippet"):h.part=["snippet"];const f=await(await fetch(o(h))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(r),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{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}}]})}},d1={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},h1="youtubeAssetProvider",u1=function(n,e){var c;const{skipVideoComponent:t,i18n:s={}}=e,o=c1(e);n.runCommand(j.assetProviderAdd,{provider:o});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:o.id,providers:[],types:[],select:h=>{n.Assets.close(),d.set({videoId:h.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...h]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...h]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,h=d.get("provider")||"";h!=null&&h.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:d1,...s}),re({editor:n,licenseKey:e.licenseKey,plan:W.startup,pluginName:h1,cleanup:()=>{n.runCommand(j.assetProviderRemove,{id:o.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})},f1=ie(u1),p1=n=>{const{family:e,menu:t,axes:s}=n,o=!!s,i=Object.assign({},...n.variants.map(r=>{var d,h;let l,a;if(o){const u=s.find(f=>f.tag==="wght");if(u){const{start:f,end:p}=u;l=`${f} ${p}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((h=r.match(/[a-zA-Z]+/))==null?void 0:h[0])==="italic"?"italic":void 0,{[r]:{family:e,source:n.files[r],variant:r,options:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`assetManagerMenu-${e}`,source:t,variant:"menu"},variants:i}},m1=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:p1(n),needsLoading:!0}}),g1=n=>{if(n.customData.needsLoading){n.customData.needsLoading=!1;const{font:e}=n.customData,{family:t,source:s,options:o}=e.menuVariant,i=new FontFace(t,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let mn;const y1=n=>{const e=[];for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?e.push(...s.map(o=>[t,o.toString()])):(s=s.toString(),e.push([t,s])))}return new URLSearchParams(e)},b1=n=>{const{apiKey:e,searchParams:t}=n,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=y1(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(mn)return mn;const o={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...o,...i},a=await(await fetch(s(r))).json();return(c=a.items)!=null&&c.length?(mn=a.items.map(m1),mn):[]},itemLayout:o=>{const i=mn.find(r=>r.id===o.assetProps.id);return g1(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},v1={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},w1="googleFontsAssetProvider",S1=function(n,e){const{i18n:t={}}=e,s=b1(e);n.runCommand(j.assetProviderAdd,{provider:s}),n.I18n.addMessages({en:v1,...t}),re({editor:n,licenseKey:e.licenseKey,plan:W.startup,pluginName:w1,cleanup:()=>{n.runCommand(j.assetProviderRemove,{id:s.id})}})},C1=ie(S1);exports.accordionComponent=$h;exports.canvasEmptyState=i1;exports.canvasFullSize=l1;exports.dialogComponent=cd;exports.flexComponent=lu;exports.fsLightboxComponent=rh;exports.googleFontsAssetProvider=C1;exports.iconifyComponent=kd;exports.lightGalleryComponent=gh;exports.listPagesComponent=nh;exports.rteProseMirror=n1;exports.rteTinyMce=gu;exports.swiperComponent=Ph;exports.tableComponent=Ud;exports.youtubeAssetProvider=f1;
|
|
202
|
+
.gjs-frame { border-radius: ${u}px }
|
|
203
|
+
`,!S&&document.body.appendChild(x)};n.on(p.frameLoadHead,v=>{if(!g.scrollableCanvas)return;const{window:w}=v,S=w.document,x=S.head,E="data-gs-plg-wrapper-style",T=x.querySelector(`style[${E}]`)||S.createElement("style");T.setAttribute(E,"true"),T.innerHTML=`[data-gjs-type="wrapper"] { min-height: ${f}; }`,!x.contains(T)&&x.appendChild(T)}),n.onReady(()=>{const v=t.getSpotsEl(),w=t.getElement(),S=t.getFramesEl(),x=a*1e3,E=w.style;E.overflowX="hidden",S.style.transition=`transform ${a}s`;const T={x:l,y:r};y();const A=()=>v.style.display="none",P=()=>v.style.display="",D=hi(()=>{t.fitViewport({zoom:we=>we>100?100:we,ignoreHeight:!0,gap:T}),y(),setTimeout(()=>{var we,Me;n.em.destroyed||((Me=(we=n.getSelected())==null?void 0:we.getEl())==null||Me.scrollIntoView({block:"nearest"}),n.refresh({tools:!0}),P())},x)},100),L=new ResizeObserver(()=>{A(),D()});L.observe(w.parentElement);const H=()=>{A(),D()},be=(we={})=>{we.options&&we.options.from!=="fitViewport"&&t.fitViewport({zoom:t.getZoom(),ignoreHeight:!0,gap:T})},ve=()=>{E.overflowX="hidden",E.overflowY="auto"},ct=()=>{L.disconnect(),D.clear()};n.on(o.events.select,H),n.on(p.zoom,be),n.on(m,ve),n.on(n.events.destroy,ct),D(),s.add(b,()=>{o.devices.reset(C),g.scrollableCanvas=!1,t.getModel().updateDevice(),t.setZoom(100),t.setCoords(0,0),E.overflowY="hidden",y(!0),n.off(o.events.select,H),n.off(p.zoom,be),n.off(m,ve),ct(),s.run("studio:canvasReload")})}),te({editor:n,licenseKey:i.licenseKey,plan:F.startup,pluginName:Pl,cleanup:()=>{n.runCommand(b)}})},b1=ee(y1);var Ye=(n=>(n.panelBlocks="panelBlocks",n.panelPagesLayers="panelPagesLayers",n.panelGlobalStyles="panelGlobalStyles",n.panelSidebarTabs="panelSidebarTabs",n.panelAssets="panelAssets",n))(Ye||{});const ed="sidebarButtonsTarget",gs=n=>{const{id:e,icon:t,label:s,tooltip:o,className:i,skipSelfClose:r,removeLayouts:l,layoutComponent:a,layoutCommand:c}=n,d=e;return{id:td(e),type:"button",icon:t,tooltip:s||o,className:i,editorEvents:{[`${Ll.layoutToggleId}${d}`]:({fromEvent:u,setState:h,editor:f})=>{h({active:u.isOpen}),setTimeout(()=>f.refresh({tools:!0}),20)}},onClick:({editor:u,state:h})=>{if(h.active&&r)return;const f=(c==null?void 0:c.placer)||{type:"static",layoutId:ed},p={...f,skipCleanup:f.type==="static"},m=l||Object.keys(Ye).filter(b=>b!==d);nd(u,{removeLayouts:m,layout:{placer:p}});const g={id:d,placer:f,header:(c==null?void 0:c.header)??{label:s,close:!r},layout:a,style:{width:250,height:"100%",borderRightWidth:1,...c==null?void 0:c.style}};u.runCommand(B.layoutToggle,g)}}},td=n=>`button__${n}`,nd=(n,e={})=>{(e.removeLayouts||Object.keys(Ye)).forEach(s=>n.runCommand(B.layoutRemove,{id:s,layout:e.layout}))},To=(n,e,t)=>{const s=n.map(o=>{const i=gs(o);return t!=null&&t.sidebarButton?t.sidebarButton({id:o.id,breakpoint:e,buttonProps:i,sidebarButtonProps:o,createSidebarButton:r=>gs({...o,...r})}):i}).filter(Boolean);return t!=null&&t.sidebarButtons?t==null?void 0:t.sidebarButtons({breakpoint:e,sidebarButtons:s,createSidebarButton:o=>gs({...o})}):s},Mo=(n,e,t,s)=>{var o;return((o=s==null?void 0:s.rootLayout)==null?void 0:o.call(s,{breakpoint:t,sidebarButtons:e,rootLayout:n,createSidebarButton:i=>gs({...i})}))??n},sd=n=>{const e=(n==null?void 0:n.breakpointTablet)??1024,t=(n==null?void 0:n.breakpointMobile)??768,s={},o=[{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:d,editor:u})=>{var p;const h=u.getSelected(),f={type:"image",src:d.src};if(h!=null&&h.is("image"))return h.set("src",d.src);if(h&&u.Components.canMove(h,f)){const m=h.append(f)[0];m&&u.select(m)}else if(!h){const m=(p=u.getWrapper())==null?void 0:p.append(f)[0];m&&u.select(m)}}}}],i=[...o,{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"}}],r={id:ed,type:"column",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:[]}}};if(e){const d=To(i,e,n);s[e]=Mo({type:"row",style:{height:"100%"},children:[{...l,children:d},r,a]},d,e,n)}if(t){const d=i.map(h=>({...h,layoutCommand:{placer:{type:"absolute",position:"left"},style:{height:"calc(100% - 40px)"}}})),u=To(d,t,n);s[t]=Mo({type:"column",style:{height:"100%"},children:[{type:"sidebarTop",leftContainer:{buttons:[]}},{type:"canvas"},{type:"sidebarBottom",style:{padding:"0 5px",alignItems:"center",gap:10,minHeight:39},children:u}]},u,t,n)}const c=To(o,0,n);return{default:Mo({type:"row",style:{height:"100%"},children:[{...l,children:c},r,a,{type:"sidebarRight"}]},c,0,n),responsive:s}},Il="layoutSidebarButtons",v1=function(n,e={}){const{Commands:t}=n,s=t.events,o={...e};(()=>{if(n.runCommand(B.layoutConfigGet)||o.skipLayoutConfig===!0)return;const l=sd(o);n.runCommand(B.layoutConfigSet,{...l})})(),t.add(`${Il}:toggleButton`,(r,l,a={})=>{const c=document.getElementById(td(a.id));c==null||c.click()}),n.on(`${s.runCommand}core:preview`,()=>{nd(n)}),te({editor:n,licenseKey:o.licenseKey,plan:F.startup,pluginName:Il,cleanup:()=>{n.runCommand(B.layoutConfigSet)}})},od=ee(v1);od.createLayoutConfig=n=>sd(n);const w1=n=>{const e={};for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?s=s.map(o=>o.toString()).join(","):s=s.toString(),e[t]=s)}return new URLSearchParams(e)},S1=n=>{const{apiKey:e,searchParams:t,thumbnailQuality:s="high"}=n,o=(l={})=>{const c="https://www.googleapis.com/youtube/v3/search",d=w1(l);return`${c}?${d}`},i=l=>{var a,c,d;return((a=l[s])==null?void 0:a.url)||((c=l.high)==null?void 0:c.url)||((d=l.medium)==null?void 0:d.url)||l.default.url},r=l=>{const a=i(l.snippet.thumbnails);return{id:l.id.videoId,src:`https://www.youtube.com/watch?v=${l.id.videoId}`,name:l.snippet.title,customData:{thumbnailUrl:a,videoItem:l}}};return{id:"youtube",types:["youtube-video"],label:({editor:l})=>l.I18n.t("youtubeAssetProvider.providerLabel"),search:{reloadOnInput:!0,debounceMs:1e3},async onLoad({searchValue:l,pageCustomData:a}){var m;const c={maxResults:25,q:l,pageToken:a==null?void 0:a.token,type:["video"],key:e},d=t==null?void 0:t({searchValue:l}),u={...c,...d};u.part?u.part.includes("snippet")||u.part.push("snippet"):u.part=["snippet"];const f=await(await fetch(o(u))).json();return(m=f.items)!=null&&m.length?{items:f.items.map(r),nextPageCustomData:{token:f.nextPageToken},isLastPage:!f.nextPageToken}:{items:[],isLastPage:!0}},itemLayout:({assetProps:l,onSelect:a})=>({type:"column",onClick:()=>a(l),htmlAttrs:{title:l.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"custom",render:()=>{var c;return`<img src="${(c=l.customData)==null?void 0:c.thumbnailUrl}" alt="${l.name}" style="width: 100%; height: 100px; object-fit: cover">`}},{type:"text",content:l.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",paddingLeft:8,paddingRight:8}}]})}},C1={youtubeAssetProvider:{searchBtn:"Search on YouTube",modalTitle:"Select YouTube Video",providerLabel:"YouTube Videos"}},x1="youtubeAssetProvider",k1=function(n,e){var c;const{skipVideoComponent:t,i18n:s={}}=e,o=S1(e);n.runCommand(B.assetProviderAdd,{provider:o});const i="search-on-youtube",r="video",l=(c=n.Components.getType(r))==null?void 0:c.model.prototype,a=d=>{n.Assets.open({modalTitle:n.I18n.t("youtubeAssetProvider.modalTitle"),providerId:o.id,providers:[],types:[],select:u=>{n.Assets.close(),d.set({videoId:u.attributes.id})},content:{header:{addUrl:!1,upload:!1}}})};!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){const[d,...u]=l.getYoutubeTraits.apply(this);return[d,{id:i,type:"button",label:n.I18n.t("youtubeAssetProvider.searchBtn"),command:()=>a(this)},...u]}},view:{events:()=>({dblclick:"onActive"}),onActive(){const{model:d}=this,u=d.get("provider")||"";u!=null&&u.startsWith("yt")&&a(d)}}}),n.I18n.addMessages({en:C1,...s}),te({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:x1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:o.id}),!t&&l&&n.Components.addType(r,{model:{getYoutubeTraits(){return l.getYoutubeTraits.apply(this).filter(d=>d.id!==i)}}})}})},T1=ee(k1),M1=n=>{const{family:e,menu:t,axes:s}=n,o=!!s,i=Object.assign({},...n.variants.map(r=>{var d,u;let l,a;if(o){const h=s.find(f=>f.tag==="wght");if(h){const{start:f,end:p}=h;l=`${f} ${p}`}}return l||(l=((d=r.match(/\d+/))==null?void 0:d[0])??"400"),a=((u=r.match(/[a-zA-Z]+/))==null?void 0:u[0])==="italic"?"italic":void 0,{[r]:{family:e,source:n.files[r],variant:r,options:{style:a,weight:l}}}}));return{family:e,menuVariant:{family:`assetManagerMenu-${e}`,source:t,variant:"menu"},variants:i}},A1=n=>({id:`${n.family}/${n.version}`,type:"font",src:n.menu,name:n.family,customData:{font:M1(n),needsLoading:!0}}),E1=n=>{if(n.customData.needsLoading){n.customData.needsLoading=!1;const{font:e}=n.customData,{family:t,source:s,options:o}=e.menuVariant,i=new FontFace(t,`url("${s}")`,o);document.fonts.add(i),i.load().catch(()=>{})}};let gn;const O1=n=>{const e=[];for(const t of Object.keys(n)){let s=n[t];s&&(Array.isArray(s)?e.push(...s.map(o=>[t,o.toString()])):(s=s.toString(),e.push([t,s])))}return new URLSearchParams(e)},N1=n=>{const{apiKey:e,searchParams:t}=n,s=(o={})=>{const i="https://www.googleapis.com/webfonts/v1/webfonts",r=O1(o);return`${i}?${r}`};return{id:"google-fonts",types:["font"],label:({editor:o})=>o.I18n.t("googleFontsAssetProvider.providerLabel"),search:{reloadOnInput:!1},async onLoad(){var c;if(gn)return gn;const o={key:e,sort:"alpha",subset:"latin",capability:["WOFF2","VF"]},i=t==null?void 0:t(),r={...o,...i},a=await(await fetch(s(r))).json();return(c=a.items)!=null&&c.length?(gn=a.items.map(A1),gn):[]},itemLayout:o=>{const i=gn.find(r=>r.id===o.assetProps.id);return E1(i),{type:"column",onClick:()=>o.onSelect(i),htmlAttrs:{title:i.name},style:{borderWidth:"1px",borderRadius:8,overflow:"hidden",cursor:"pointer"},children:[{type:"text",content:i.name,style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:i.customData.font.menuVariant.family,fontSize:"24px",paddingLeft:"8px",paddingRight:"8px"}}]}}}},P1={googleFontsAssetProvider:{searchBtn:"Search on Google Fonts",modalTitle:"Select Font",providerLabel:"Google Fonts"}},I1="googleFontsAssetProvider",R1=function(n,e){const{i18n:t={}}=e,s=N1(e);n.runCommand(B.assetProviderAdd,{provider:s}),n.I18n.addMessages({en:P1,...t}),te({editor:n,licenseKey:e.licenseKey,plan:F.startup,pluginName:I1,cleanup:()=>{n.runCommand(B.assetProviderRemove,{id:s.id})}})},D1=ee(R1);exports.accordionComponent=Yu;exports.canvasEmptyState=g1;exports.canvasFullSize=b1;exports.dialogComponent=wd;exports.flexComponent=bh;exports.fsLightboxComponent=yu;exports.googleFontsAssetProvider=D1;exports.iconifyComponent=zd;exports.layoutSidebarButtons=od;exports.lightGalleryComponent=Au;exports.listPagesComponent=fu;exports.rteProseMirror=f1;exports.rteTinyMce=Ah;exports.swiperComponent=Wu;exports.tableComponent=ru;exports.youtubeAssetProvider=T1;
|