@novaprose/tinymce-compat 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -6
- package/dist/index.d.ts +20 -6
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/novaprose.css +187 -31
- package/dist/tinymce-chunks/advlist-7a360f16.js +2 -0
- package/dist/tinymce-chunks/advlist-7a360f16.js.map +7 -0
- package/dist/tinymce-chunks/autolink-7e2e7be2.js +2 -0
- package/dist/tinymce-chunks/autolink-7e2e7be2.js.map +7 -0
- package/dist/tinymce-chunks/autoresize-d6c9537b.js +2 -0
- package/dist/tinymce-chunks/autoresize-d6c9537b.js.map +7 -0
- package/dist/tinymce-chunks/autosave-4fd46720.js +2 -0
- package/dist/tinymce-chunks/autosave-4fd46720.js.map +7 -0
- package/dist/tinymce-chunks/charmap-4b14307a.js +2 -0
- package/dist/tinymce-chunks/charmap-4b14307a.js.map +7 -0
- package/dist/tinymce-chunks/comments-panel-37cba890.js +2 -0
- package/dist/tinymce-chunks/comments-panel-37cba890.js.map +7 -0
- package/dist/tinymce-chunks/directionality-60dba768.js +2 -0
- package/dist/tinymce-chunks/directionality-60dba768.js.map +7 -0
- package/dist/tinymce-chunks/emoticons-7e6da0b6.js +2 -0
- package/dist/tinymce-chunks/emoticons-7e6da0b6.js.map +7 -0
- package/dist/tinymce-chunks/form-dialog-9cde0ef7.js +2 -0
- package/dist/tinymce-chunks/form-dialog-9cde0ef7.js.map +7 -0
- package/dist/tinymce-chunks/insertdatetime-e0dbcf63.js +2 -0
- package/dist/tinymce-chunks/insertdatetime-e0dbcf63.js.map +7 -0
- package/dist/tinymce-chunks/nonbreaking-49bdb0d2.js +2 -0
- package/dist/tinymce-chunks/nonbreaking-49bdb0d2.js.map +7 -0
- package/dist/tinymce-chunks/paste-office-a38659d6.js +3 -0
- package/dist/tinymce-chunks/paste-office-a38659d6.js.map +7 -0
- package/dist/tinymce-chunks/quickbars-d937e10a.js +2 -0
- package/dist/tinymce-chunks/quickbars-d937e10a.js.map +7 -0
- package/dist/tinymce-chunks/revisionhistory-d6306426.js +2 -0
- package/dist/tinymce-chunks/revisionhistory-d6306426.js.map +7 -0
- package/dist/tinymce-chunks/table-80284f6f.js +2 -0
- package/dist/tinymce-chunks/table-80284f6f.js.map +7 -0
- package/dist/tinymce-chunks/visualblocks-58c88e5d.js +2 -0
- package/dist/tinymce-chunks/visualblocks-58c88e5d.js.map +7 -0
- package/dist/tinymce.global.js +23 -23
- package/dist/tinymce.global.js.map +7 -1
- package/package.json +11 -6
package/dist/tinymce.global.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";(()=>{var mm=Object.defineProperty;var P=(n,e)=>()=>(n&&(e=n(n=0)),e);var He=(n,e)=>{for(var t in e)mm(n,t,{get:e[t],enumerable:!0})};function se(n,e){Ai.set(n,e)}function Ti(n){return Ai.has(n)}function Ql(n){return typeof n=="function"}function Zl(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=Ai.get(o);i?Ql(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else Ql(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function Ni(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let u of l.requires??[]){if(e.has(u))continue;let d=t.get(u);if(!d)return o.push(`Plugin "${l.name}" requires "${u}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(d,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function ea(n){let e=await n();return"default"in e&&e.default?e.default:e}var Ai,Hr=P(()=>{"use strict";Ai=new Map});var L,M,j=P(()=>{"use strict";L=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,M={undo:L('<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />'),redo:L('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:L('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:L('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:L('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:L('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:L('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:L('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" />'),superscript:L('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" />'),bulletList:L('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:L('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" />'),indent:L('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:L('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:L('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:L('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:L('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:L('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:L('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:L('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:L('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:L('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:L('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:L('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:L('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:L('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:L('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:L('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:L('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:L('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:L('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:L('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:L('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:L('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:L('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:L('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:L('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:L('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:L('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:L('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:L('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:L('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:L('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:L('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:L('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:L('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:L('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:L('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:L('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:L('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:L('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:L('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:L('<path d="m18 15-6-6-6 6" />'),search:L('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:L('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:L('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:L('<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />'),sourceCode:L('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:L('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:L('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:L('<path d="M20 6 9 17l-5-5" />'),close:L('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:L('<path d="m6 9 6 6 6-6" />'),more:L('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:L('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:L('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:L('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),upload:L('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:L('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:L('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:L('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:L('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:L('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:L('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:L('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),anchor:L('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:L('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:L('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:L('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:L('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:L('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:L('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:L('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),nonBreaking:L('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:L('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),history:L('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:L('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:L('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:L('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:L('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:L('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />')}});function ye(n){this.content=n}var Li,ta=P(()=>{"use strict";ye.prototype={constructor:ye,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 r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new ye(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 ye(t)},addToStart:function(n,e){return new ye([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new ye(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new ye(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=ye.from(n),n.size?new ye(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=ye.from(n),n.size?new ye(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=ye.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}};ye.from=function(n){if(n instanceof ye)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new ye(e)};Li=ye});function pa(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&ga(s.charCodeAt(a-1))&&ma(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=pa(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function ha(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,f=u.length;for(;d>0&&f>0&&c[d-1]==u[f-1];)d--,f--,t--,r--;return d&&f&&d<c.length&&ga(c.charCodeAt(d-1))&&ma(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=ha(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function ma(n){return n>=56320&&n<57344}function ga(n){return n>=55296&&n<56320}function zr(n,e){return Oi.index=n,Oi.offset=e,Oi}function _r(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 r=0;r<n.length;r++)if(!_r(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!_r(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}function ba(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(ba(i.content,e-o-1,t-o-1)))}function ya(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=ya(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function gm(n,e,t){if(t.openStart>n.depth)throw new xt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new xt("Inconsistent open depths");return va(n,e,t,0)}function va(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=va(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Ft(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=bm(t,n);return Ft(i,wa(n,s,l,e,r))}else return Ft(i,Vr(n,e,r))}function ka(n,e){if(!e.type.compatibleContent(n.type))throw new xt("Cannot join "+e.type.name+" onto "+n.type.name)}function Di(n,e,t){let r=n.node(t);return ka(r,e.node(t)),r}function zt(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 qn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(zt(n.nodeAfter,r),i++));for(let l=i;l<s;l++)zt(o.child(l),r);e&&e.depth==t&&e.textOffset&&zt(e.nodeBefore,r)}function Ft(n,e){if(!n.type.validContent(e))throw new xt("Invalid content for node "+n.type.name);return n.copy(e)}function wa(n,e,t,r,o){let i=n.depth>o&&Di(n,e,o+1),s=r.depth>o&&Di(t,r,o+1),l=[];return qn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(ka(i,s),zt(Ft(i,wa(n,e,t,r,o+1)),l)):(i&&zt(Ft(i,Vr(n,e,o+1)),l),qn(e,t,o,l),s&&zt(Ft(s,Vr(t,r,o+1)),l)),qn(r,null,o,l),new A(l)}function Vr(n,e,t){let r=[];if(qn(null,n,t,r),n.depth>t){let o=Di(n,e,t+1);zt(Ft(o,Vr(n,e,t+1)),r)}return qn(e,null,t,r),new A(r)}function bm(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(A.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}function xa(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function oa(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}function Sa(n){let e=[];do e.push(km(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function km(n){let e=[];do e.push(wm(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function wm(n){let e=Mm(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=xm(n,e);else break;return e}function ia(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function xm(n,e){let t=ia(n),r=t;return n.eat(",")&&(n.next!="}"?r=ia(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Sm(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Mm(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=Sm(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 Cm(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ma(n,e){return e-n}function sa(n,e){let t=[];return r(e),t.sort(Ma);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function Em(n){let e=Object.create(null);return t(sa(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);sa(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new _t(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ma);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function Am(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ca(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ea(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function Aa(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Bi(n,r,e[r]);return t}function Tm(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}function la(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=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(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Nm(n){return n.tag!=null}function Lm(n){return n.style!=null}function aa(n,e,t){return e!=null?(e?Kn:0)|(e==="full"?Hi:0):n&&n.whitespace=="pre"?Kn|Hi:t&~Wn}function Dm(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Na.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Rm(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ca(n){let e={};for(let t in n)e[t]=n[t];return e}function ua(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}function da(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Fr(n){return n.document||window.document}function Pm(n){let e=fa.get(n);return e===void 0&&fa.set(n,e=Im(n)),e}function Im(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function $r(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Pm(r))&&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 s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let f=d.indexOf(" ");f>0?a.setAttributeNS(d.slice(0,f),d.slice(f+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let f=e[d];if(f===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof f=="string")a.appendChild(n.createTextNode(f));else{let{dom:p,contentDOM:h}=$r(n,f,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var A,Oi,W,xt,O,qr,Ri,ym,na,$t,vm,De,ra,Pi,_t,Ii,lt,Bi,Un,jn,St,Ta,Om,Na,Kn,Hi,Wn,fn,Wr,je,fa,de=P(()=>{"use strict";ta();A=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return pa(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return ha(this,e,t,r)}findIndex(e){if(e==0)return zr(0,e);if(e==this.size)return zr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?zr(t+1,i):zr(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=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 n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};A.empty=new A([],0);Oi={index:0,offset:0};W=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!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;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||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&&_r(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 r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};W.none=[];xt=class extends Error{},O=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=ya(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(ba(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 n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(A.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};O.empty=new O(A.empty,0,0);qr=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):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 r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return W.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new $t(this,e,r);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 r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=na.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else na.set(e,r=new Ri);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%ym,o}},Ri=class{constructor(){this.elts=[],this.i=0}},ym=12,na=new WeakMap,$t=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}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)}},vm=Object.create(null),De=class n{constructor(e,t,r,o=W.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||A.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,r,o=0){this.content.nodesBetween(e,t,r,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,r,o){return this.content.textBetween(e,t,r,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,r){return this.type==e&&_r(this.attrs,t||e.defaultAttrs||vm)&&W.sameSet(this.marks,r||W.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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,r=!1){if(e==t)return O.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new O(c,o.depth-s,i.depth-s)}replace(e,t,r){return gm(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return qr.resolveCached(this,e)}resolveNoCache(e){return qr.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.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()+")"),xa(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,r=A.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),oa(this.type.attrs,this.attrs,"node",this.type.name);let e=W.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];oa(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!W.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 r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let o=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};De.prototype.text=void 0;ra=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),Pi=class n extends De{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):xa(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return ra(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(ra(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}};_t=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ii(e,t);if(r.next==null)return n.empty;let o=Sa(r);r.next&&r.err("Unexpected trailing text");let i=Em(Cm(o));return Am(i,r),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,r=e.childCount){let o=this;for(let i=t;o&&i<r;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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.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(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
2
|
-
`)}};_t.empty=new _t(!0);Ii=class{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+"')")}};lt=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Aa(e,r.attrs),this.defaultAttrs=Ca(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==_t.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ea(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new De(this,this.computeAttrs(e),A.from(t),W.setFrom(r))}createChecked(e=null,t,r){return t=A.from(t),this.checkContent(t),new De(this,this.computeAttrs(e),t,W.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=A.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(A.empty,!0);return i?new De(this,e,t.append(i),W.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).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){}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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:W.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};Bi=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Tm(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Un=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Aa(e,o.attrs),this.excluded=null;let i=Ca(this.attrs);this.instance=i?new W(this,i):null}create(e=null){return!e&&this.instance?this.instance:new W(this,Ea(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}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]}excludes(e){return this.excluded.indexOf(e)>-1}},jn=class{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=Li.from(e.nodes),t.marks=Li.from(e.marks||{}),this.nodes=lt.compile(this.spec.nodes,this),this.marks=Un.compile(this.spec.marks,this);let r=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],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=_t.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?la(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:la(this,s.split(" "))}this.nodeFromJSON=o=>De.fromJSON(this,o),this.markFromJSON=o=>W.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof lt){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,r,o)}text(e,t){let r=this.nodes.text;return new Pi(r,r.defaultAttrs,e,W.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};St=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(Nm(o))this.tags.push(o);else if(Lm(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.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 r=new Wr(this,t,!1);return r.addAll(e,W.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Wr(this,t,!0);return r.addAll(e,W.none,t.from,t.to),O.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Rm(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ca(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=ca(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Ta={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},Om={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Na={ol:!0,ul:!0},Kn=1,Hi=2,Wn=4;fn=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=W.none,this.match=i||(s&Wn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Kn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.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=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.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&&!Ta.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Wr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=aa(null,t.preserveWhitespace,0)|(r?Wn:0);o?i=new fn(o.type,o.attrs,W.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new fn(null,null,W.none,!0,null,s):i=new fn(e.schema.topNodeType,null,W.none,!0,null,s),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 r=e.nodeValue,o=this.top,i=o.options&Hi?"full":this.localPreserveWS||(o.options&Kn)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Na.hasOwnProperty(s)&&this.parser.normalizeLists&&Dm(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Om.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ta.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
4
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));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,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=W.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):ua(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=aa(e,i,s.options);s.options&Wn&&s.content.length==0&&(l|=Wn);let a=W.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):ua(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new fn(e,t,a,o,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=Kn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){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)&(r?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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};je=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Fr(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.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<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return Fr(t).createTextNode(e.text);let{dom:r,contentDOM:o}=$r(Fr(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 r}serializeNode(e,t={}){let r=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(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&$r(Fr(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:$r(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=da(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return da(e.marks)}};fa=new WeakMap});function Bm(n,e){return n+e*Ia}function La(n){return n&Pa}function Hm(n){return(n-(n&Pa))/Ia}function Vi(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Vi(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return A.fromArray(r)}function jr(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}function $i(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function zm(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);jr(Vt,c,u,r,o)}}),o.forEach(i=>n.step(i))}function Fm(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Un){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let p=0;p<o.length;p++){let h=o[p];h.step==i-1&&d.eq(o[p].style)&&(f=h)}f?(f.to=c,f.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Mt(s.from,s.to,s.style)))}function qi(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new ve(l,u,O.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new Mt(l,u,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,h;for(;f=p.exec(c.text);)h||(h=new O(A.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ve(l+f.index,l+f.index+f[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);n.replace(l,l,new O(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function $m(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function qt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!$m(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function _m(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=A.empty,d=0;for(let h=i,m=!1;h>t;h--)m||r.index(h)>0?(m=!0,u=A.from(r.node(h).copy(u)),d++):a--;let f=A.empty,p=0;for(let h=i,m=!1;h>t;h--)m||o.after(h+1)<o.end(h)?(m=!0,f=A.from(o.node(h).copy(f)),p++):c++;n.step(new he(a,c,s,l,new O(u.append(f),d,p),u.size-d,!0))}function gn(n,e,t=null,r=n){let o=Vm(n,e),i=o&&qm(r,e);return i?o.map(Oa).concat({type:e,attrs:t}).concat(i.map(Oa)):null}function Oa(n){return{type:n,attrs:null}}function Vm(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function qm(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Wm(n,e,t){let r=A.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=A.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new he(o,i,o,i,new O(r,0,0),t.length,!0))}function Um(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&jm(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&$a(n,s,l,i),qi(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return n.step(new he(d,f,d+1,f-1,new O(A.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Fa(n,s,l,i),!1}})}function Fa(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function $a(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function jm(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Km(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new he(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new O(A.from(s),0,0),1,!0))}function Ct(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(f,d.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(p))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function Jm(n,e,t=1,r){let o=n.doc.resolve(e),i=A.empty,s=A.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=A.from(o.node(l).copy(i));let u=r&&r[c];s=A.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new ve(e,e,new O(i.append(s),t,t),!0))}function Wt(n,e){let t=n.resolve(e),r=t.index();return Xm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function Gm(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function Xm(n,e){return!!(n&&e&&!n.isLeaf&&Gm(n,e))}function Ym(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);$a(n,u.node(),u.before(),l)}s.inlineContent&&qi(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ve(c,a.map(e+t,-1),O.empty,!0)),r===!0){let u=n.doc.resolve(c);Fa(n,u.node(),u.before(),n.steps.length)}return n}function Qm(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function Gr(n,e,t){let r=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 s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(i==1)d=u.canReplace(c,c,o);else{let f=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function Xr(n,e,t=e,r=O.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return _a(o,i,r)?new ve(e,t,r):new _i(o,i,r).fit()}function _a(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}function Jn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Jn(n.firstChild.content,e-1,t)))}function Gn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Gn(n.lastChild.content,e-1,t)))}function Da(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Va(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Va(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),n.copy(r)}function Fi(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!Zm(t,i.content,s)?l:null}function Zm(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function eg(n){return n.spec.defining||n.spec.definingForContent}function Ra(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function tg(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(_a(o,i,r))return n.step(new ve(e,t,r));let s=Wa(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let f=o.depth,p=o.pos-1;f>0;f--,p--){let h=o.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==p&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=r.openStart;for(let f=r.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==r.openStart)break;f=h.content}for(let f=u-1;f>=0;f--){let p=c[f],h=eg(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(h||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+u+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m<s.length;m++){let g=s[(m+a)%s.length],b=!0;g<0&&(b=!1,g=-g);let x=o.node(g-1),w=o.index(g-1);if(x.canReplaceWith(w,w,h.type,h.marks))return n.replace(o.before(g),b?i.after(g):t,new O(qa(r.content,0,r.openStart,p),p,r.openEnd))}}let d=n.steps.length;for(let f=s.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let p=s[f];p<0||(e=o.before(p),t=i.after(p))}}function qa(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(qa(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return n}function ng(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Qm(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new O(A.from(r),0,0))}function rg(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=Wa(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function Wa(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;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}var Pa,Ia,Ba,Ha,Ur,za,Xn,at,Yn,zi,le,pe,Vt,Mt,Qn,Zn,pn,ve,he,_i,Kr,Jr,hn,mn,Ye=P(()=>{"use strict";de();Pa=65535,Ia=Math.pow(2,16);Ba=1,Ha=2,Ur=4,za=8,Xn=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&za)>0}get deletedBefore(){return(this.delInfo&(Ba|Ur))>0}get deletedAfter(){return(this.delInfo&(Ha|Ur))>0}get deletedAcross(){return(this.delInfo&Ur)>0}},at=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=La(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Hm(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,p=a+o+(f<0?0:u);if(r)return p;let h=e==(t<0?a:d)?null:Bm(l/3,e-a),m=0;return c&&(m|=e==a?Ha:e==d?Ba:Ur,(t<0?e!=a:e!=d)&&(m|=za)),new Xn(p,m,h)}o+=u-c}return r?e+o:new Xn(e+o,0,null)}touches(e,t){let r=0,o=La(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};at.empty=new at([]);Yn=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}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.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.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 r?e:new Xn(e,o,null)}},zi=Object.create(null),le=class{getMap(){return at.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=zi[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in zi)throw new RangeError("Duplicate use of step JSON ID "+e);return zi[e]=t,t.prototype.jsonID=e,t}},pe=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof xt)return n.fail(i.message);throw i}}};Vt=class n extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new O(Vi(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!W.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);jr(Mt,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||jr(n,s,l,a,t)}}}),t.length==1?t[0]:new Qn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};le.jsonID("addMark",Vt);Mt=class n extends le{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new O(Vi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&jr(Vt,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new Qn(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};le.jsonID("removeMark",Mt);Qn=class n extends le{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new pe(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>le.fromJSON(e,r)))}};le.jsonID("markSet",Qn);Zn=class n extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new O(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new pn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};le.jsonID("addNodeMark",Zn);pn=class n extends le{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new O(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Zn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};le.jsonID("removeNodeMark",pn);ve=class n extends le{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&$i(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new at([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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?O.empty:new O(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(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?O.empty:new O(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(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 n(t.from,t.to,O.fromJSON(e,t.slice),!!t.structure)}};ve.MAP_BIAS=1;le.jsonID("replace",ve);he=class n extends le{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&($i(e,this.from,this.gapFrom)||$i(e,this.gapTo,this.to)))return pe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return pe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?pe.fromReplace(e,this.from,this.to,r):pe.fail("Content does not fit in gap")}getMap(){return new at([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 n(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),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.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 n(t.from,t.to,t.gapFrom,t.gapTo,O.fromJSON(e,t.slice),t.insert,!!t.structure)}};le.jsonID("replaceAround",he);_i=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=A.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=A.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,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new O(i,s,l);return e>-1?new he(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ve(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Da(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(A.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return Ra(e,-1)<=t?!1:(this.unplaced.size>1&&Ra(e,1)>r&&r++,this.unplaced=new O(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Da(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new O(Jn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new O(Jn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,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 s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(Va(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Gn(this.placed,t,A.from(u)),this.frontier[t].match=d,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=u[u.length-1];g&&m<p;m++)this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),g=g.lastChild;this.unplaced=h?e==0?O.empty:new O(Jn(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new O(Jn(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Fi(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:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Fi(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Fi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,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=Gn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Gn(this.placed,this.depth,A.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(A.empty,!0);t.childCount&&(this.placed=Gn(this.placed,this.frontier.length,t))}};Kr=class n extends le{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return pe.fromReplace(e,this.pos,this.pos+1,new O(A.from(o),0,t.isLeaf?0:1))}getMap(){return at.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};le.jsonID("attr",Kr);Jr=class n extends le{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 r=e.type.create(t,e.content,e.marks);return pe.ok(r)}getMap(){return at.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};le.jsonID("docAttr",Jr);hn=class extends Error{};hn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};hn.prototype=Object.create(Error.prototype);hn.prototype.constructor=hn;hn.prototype.name="TransformError";mn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Yn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new hn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=O.empty){let o=Xr(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new O(A.from(r),0,0))}delete(e,t){return this.replace(e,t,O.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return tg(this,e,t,r),this}replaceRangeWith(e,t,r){return ng(this,e,t,r),this}deleteRange(e,t){return rg(this,e,t),this}lift(e,t){return _m(this,e,t),this}join(e,t=1){return Ym(this,e,t),this}wrap(e,t){return Wm(this,e,t),this}setBlockType(e,t=e,r,o=null){return Um(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Km(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Kr(e,t,r)),this}setDocAttribute(e,t){return this.step(new Jr(e,t)),this}addNodeMark(e,t){return this.step(new Zn(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof W)t.isInSet(r.marks)&&this.step(new pn(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new pn(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return Jm(this,e,t,r),this}addMark(e,t,r){return zm(this,e,t,r),this}removeMark(e,t,r){return Fm(this,e,t,r),this}clearIncompatible(e,t,r){return qi(this,e,t,r),this}}});function ja(n){!Ua&&!n.parent.inlineContent&&(Ua=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}function bn(n,e,t,r,o,i=!1){if(e.inlineContent)return H.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&B.isSelectable(l))return B.create(n,t-(o<0?l.nodeSize:0))}else{let a=bn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function Ka(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof ve||o instanceof he))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(F.near(n.doc.resolve(s),t))}function Xa(n,e){return!e||!n?n:n.bind(e)}function Ya(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Ya(o,e,{})),t[r]=o}return t}function Qa(n){return n in Ui?n+"$"+ ++Ui[n]:(Ui[n]=0,n+"$")}var Wi,F,Et,Ua,H,Qr,B,ji,me,og,Ja,Yr,Ga,Ki,Ut,ig,er,yn,_,Ui,J,K=P(()=>{"use strict";de();Ye();Wi=Object.create(null),F=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Et(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=O.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?O.empty:t),l==0&&Ka(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Ka(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new H(e):bn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?bn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):bn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new me(e.node(0))}static atStart(e){return bn(e,e,0,0,1)||new me(e)}static atEnd(e){return bn(e,e,e.content.size,e.childCount,-1)||new me(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Wi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Wi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Wi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return H.between(this.$anchor,this.$head).getBookmark()}};F.prototype.visible=!0;Et=class{constructor(e,t){this.$from=e,this.$to=t}},Ua=!1;H=class n extends F{constructor(e,t=e){ja(e),ja(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return F.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=O.empty){if(super.replace(e,t),t==O.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=F.findFrom(t,r,!0)||F.findFrom(t,-r,!0);if(i)t=i.$head;else return F.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(F.findFrom(e,-r,!0)||F.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};F.jsonID("text",H);Qr=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return H.between(e.resolve(this.anchor),e.resolve(this.head))}},B=class n extends F{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?F.near(i):new n(i)}content(){return new O(A.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 ji(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}};B.prototype.visible=!1;F.jsonID("node",B);ji=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Qr(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&B.isSelectable(r)?new B(t):F.near(t)}},me=class n extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=O.empty){if(t==O.empty){e.delete(0,e.doc.content.size);let r=F.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return og}};F.jsonID("all",me);og={map(){return this},resolve(n){return new me(n)}};Ja=1,Yr=2,Ga=4,Ki=class extends mn{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|Ja)&~Yr,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ja)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Yr,this}ensureMarks(e){return W.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&Yr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Yr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||W.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(F.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|=Ga,this}get scrolledIntoView(){return(this.updated&Ga)>0}};Ut=class{constructor(e,t,r){this.name=e,this.init=Xa(t.init,r),this.apply=Xa(t.apply,r)}},ig=[new Ut("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ut("selection",{init(n,e){return n.selection||F.atStart(e.doc)},apply(n){return n.selection}}),new Ut("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ut("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],er=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ig.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ut(r.key,r.spec.state,r))})}},yn=class n{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];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],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Ki(this)}static create(e){let t=new er(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new er(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[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(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new er(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=De.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=F.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};_=class{constructor(e){this.spec=e,this.props={},e.props&&Ya(e.props,this,this.props),this.key=e.key?e.key.key:Qa("plugin")}getState(e){return e[this.key]}},Ui=Object.create(null);J=class{constructor(e="key"){this.key=Qa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}});function v(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function X(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}function Ce(n="nova"){return Za+=1,`${n}-${Za}`}function Qe(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():t;if(sg){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var Za,sg,Ji,Z=P(()=>{"use strict";Za=0;sg=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);Ji='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'});function ec(n){let e=Ce("nova-dialog-title"),t=v("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=v("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=v("button",{type:"button",className:"nova-button"},n.cancelLabel),i=v("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},X(M.close)),s=v("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},v("header",{className:"nova-dialog-header"},v("h2",{id:e},n.title),i),v("div",{className:"nova-dialog-body"},n.body,t),v("footer",{className:"nova-dialog-footer"},o,r)),l=v("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),document.removeEventListener("focusin",f,!0),n.onClose?.(),n.returnFocus?.())},u=h=>{t.hidden=!h,t.textContent=h??""},d=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),u(null),d(!0);try{let m=n.onSubmit?await n.onSubmit():!0;typeof m=="string"?u(m):m!==!1&&c()}finally{a||d(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape")h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let m=[...s.querySelectorAll(Ji)].filter(x=>!x.hidden),g=m[0],b=m[m.length-1];if(!g||!b)return;h.shiftKey&&document.activeElement===g?(h.preventDefault(),b.focus()):!h.shiftKey&&document.activeElement===b&&(h.preventDefault(),g.focus())}});let f=h=>{s.contains(h.target)||(s.querySelector(Ji)??s).focus()};return document.addEventListener("focusin",f,!0),(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ce(n){let e=Ce("nova-field"),t=n.hint?`${e}-hint`:void 0,r=v("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,required:n.required??!1,autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:v("div",{className:"nova-field"},v("label",{for:e,className:"nova-label"},n.label),r,n.hint?v("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function tc(n,e=!1){let t=Ce("nova-check"),r=v("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:v("div",{className:"nova-field nova-field-inline"},r,v("label",{for:t},n)),input:r}}function tr(n){let e=Ce("nova-field"),t=v("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>v("option",{value:o.value},o.label)));return t.value=n.value,{el:v("div",{className:"nova-field"},v("label",{for:e,className:"nova-label"},n.label),t),select:t}}var At=P(()=>{"use strict";Z();j()});function V(n,e){let t=(n.options.language??"en").toLowerCase();return e[t]??e[t.split("-")[0]]??e.en}function vn(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function Zr(n){let e=v("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=v("div",{className:"nova-symbols-list"}),r=v("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,u])=>u.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(v("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>v("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},v("div",{className:"nova-symbols-title"},a.title),v("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>v("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(document.activeElement);if(l<0)return;let a=Math.max(1,s.filter(d=>d.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a};if(!(i.key in c))return;i.preventDefault();let u=l+c[i.key];u<0?e.focus():s[Math.min(s.length-1,u)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function eo(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var ke=P(()=>{"use strict";Z()});function Sn(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}function ut(n,e,t){let r=Zi||(Zi=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function ag(){Zi=null}function no(n,e,t,r){return t&&(ic(n,e,t,r,-1)||ic(n,e,t,r,1))}function ic(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:xe(n))){let s=n.parentNode;if(!s||!$(s)||ro(n)||oc.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ee(n)+(o<0?0:1),n=s}else if($(n)){let s=n.childNodes[e+(o<0?-1:0)];if($(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(ro(s)||oc.test(s.nodeName))return!1;n=s,e=o<0?xe(n):0}}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function $(n){return n.nodeType==1}function ge(n){return n.nodeType==3}function Mn(n,e){return e?n.contains($(e)?e:e.parentNode):!1}function Hc(n,e){for(;;){if(ge(n)&&e)return n;if($(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=xe(n)}else if(n.parentNode&&!ro(n,!0))e=Ee(n),n=n.parentNode;else return null}}function zc(n,e){for(;;){if(ge(n)&&e<n.nodeValue.length)return n;if($(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!ro(n,!0))e=Ee(n)+1,n=n.parentNode;else return null}}function cg(n,e,t){for(let r=e==0,o=e==xe(n);r||o;){if(n==t)return!0;let i=Ee(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==xe(n)}}function ro(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function po(n){return n.focusNode&&no(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function Fc(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function ug(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function dg(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function fg(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(xe(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(xe(r.startContainer),r.startOffset)}}}function hg(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 ct(n,e){return typeof n=="number"?n:n[e]}function mg(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function lc(n,e,t){if(!ts(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!$(s)){s=Sn(s);continue}let l=s==i.body,a=l?hg(i):mg(s),c=0,u=0;if(e.top<a.top+ct(r,"top")?u=-(a.top-e.top+ct(o,"top")):e.bottom>a.bottom-ct(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+ct(o,"top")-a.top:e.bottom-a.bottom+ct(o,"bottom")),e.left<a.left+ct(r,"left")?c=-(a.left-e.left+ct(o,"left")):e.right>a.right-ct(r,"right")&&(c=e.right-a.right+ct(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let f=s.scrollLeft,p=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-f,m=s.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:Sn(s)}}function gg(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Vc(n.dom)}}function Vc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=Sn(r));return e}function bg({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;qc(t,r==0?0:r-e)}function qc(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}function Wc(n){if(n.setActive)return n.setActive();if(kn)return n.focus(kn);let e=Vc(n);n.focus(kn==null?{get preventScroll(){return kn={preventScroll:!0},!0}}:void 0),kn||(kn=!1,qc(e,0))}function Uc(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let f;if($(u))f=u.getClientRects();else if(ge(u))f=ut(u).getClientRects();else continue;for(let p=0;p<f.length;p++){let h=f[p];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(m<r){t=u,r=m,o=m&&ge(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,$(u)&&m&&(i=d+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&ge(t)?yg(t,o):!t||r?{node:n,offset:i}:Uc(t,o)}function yg(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=Tt(r,1);if(s.top!=s.bottom&&gs(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function gs(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function vg(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function kg(n,e,t){let{node:r,offset:o}=Uc(e,t),i=-1;if($(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function wg(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if($(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.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 jc(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if($(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(gs(e,c))return jc(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function xg(n,e){let t=n.dom.ownerDocument,r,o=0,i=fg(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!gs(e,c)||(s=jc(n.dom,e,c),!s))return null}if(Te)for(let c=s;r&&c;c=Sn(c))c.draggable&&(r=void 0);if(s=vg(s,e),r){if(Ke&&$(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;ho&&o&&$(r)&&$(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&$(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!$(r)||r.childNodes[o-1].nodeName!="BR")&&(l=wg(n,r,o,e))}l==null&&(l=kg(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ts(n){return n.top<n.bottom||n.left<n.right}function Tt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(ts(r))return r}return Array.prototype.find.call(t,ts)||n.getBoundingClientRect()}function Kc(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=ho||Ke;if(ge(r))if(s&&(Sg.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=Tt(ut(r,o,o),t);if(Ke&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=Tt(ut(r,o-1,o-1),-1);if(c.top==a.top){let u=Tt(ut(r,o,o+1),-1);if(u.top!=a.top)return nr(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,nr(Tt(ut(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==xe(r))){let a=r.childNodes[o-1];if($(a))return Gi(a.getBoundingClientRect(),!1)}if(i==null&&o<xe(r)){let a=r.childNodes[o];if($(a))return Gi(a.getBoundingClientRect(),!0)}return Gi(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==xe(r))){let a=r.childNodes[o-1],c=ge(a)?ut(a,xe(a)-(s?0:1)):$(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return nr(Tt(c,1),!1)}if(i==null&&o<xe(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?ge(a)?ut(a,0,s?0:1):$(a)?a:null:null;if(c)return nr(Tt(c,-1),!0)}return nr(Tt(ge(r)?ut(r):r,-t),t>=0)}function nr(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 Gi(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 Jc(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Mg(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Jc(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 s=Kc(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if($(l))a=l.getClientRects();else if(ge(l))a=ut(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}function Eg(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!Cg.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:Jc(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:d,focusOffset:f}=n.domSel.readRange(),p=d&&!Mn(u,d)||a.focusNode==d&&a.focusOffset==f;return Fc(l,a),c!=null&&(l.caretBidiLevel=c),p}):r.pos==r.start()||r.pos==r.end()}function Ag(n,e,t){return ac==e&&cc==t?uc:(ac=e,cc=t,uc=t=="up"||t=="down"?Mg(n,e,t):Eg(n,e,t))}function dc(n,e,t,r,o,i){i?bs(r,r,lr(i,n,!1),lr(e,n,!1)):Xc(r,e,n);let s=new Dt(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}function Gc(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=fc(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof Kt){let a=r?r.previousSibling:n.lastChild;Gc(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=fc(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}function lr(n,e,t){if(n.length==0)return jt;let r=t?jt[0]:new or,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new or(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new or(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function bs(n,e,t,r){if(t==jt&&r==jt)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=jt[0]),o=a}Tg(o,l||jt[0],s)}return o}function Tg(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.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 r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Xc(n,e,t){return bs(n,n,jt,lr(e,t,!$(n)))}function lo(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function fc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}function Ng(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let u=t.children[r-1];if(u instanceof Kt)o.push(r-1),t=u,r=u.children.length;else{a=u,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function Lg(n,e){return n.type.side-e.type.side}function Og(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let g=o[s++];g.widget&&(u?(d||(d=[u])).push(g):u=g)}if(u)if(d){d.sort(Lg);for(let g=0;g<d.length;g++)t(d[g],c,!!a)}else t(u,c,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(c<n.childCount)p=c,f=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=i&&l.splice(g--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+f.nodeSize;if(f.isText){let g=h;s<o.length&&o[s].from<g&&(g=o[s].from);for(let b=0;b<l.length;b++)l[b].to<g&&(g=l[b].to);g<h&&(a=f.cut(g-i),f=f.cut(0,g-i),h=g,p=-1)}else for(;s<o.length&&o[s].to<h;)s++;let m=f.isInline&&!f.isLeaf?l.filter(g=>!g.inline):l.slice();r(f,m,e.forChild(i,f),p),i=h}}function Dg(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 Rg(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.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>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function is(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&F.findFrom(i,e)}function Nt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function pc(n,e,t){let r=n.state.selection;if(r instanceof H)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return Nt(n,new H(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=ss(n.state,e);return o&&o instanceof B?Nt(n,o):!1}else if(!qe||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?B.isSelectable(i)?Nt(n,new B(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):Nt(n,new H(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof B&&r.node.isInline)return Nt(n,new H(e>0?r.$to:r.$from));{let o=ss(n.state,e);return o?Nt(n,o):!1}}}function ir(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):$(n)&&n.contentEditable=="false"}function wn(n,e){return e<0?Pg(n):Ig(n)}function Pg(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ke&&$(t)&&r<xe(t)&&ir(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!$(t))break;let l=t.childNodes[r-1];if(ir(l,-1))o=t,i=--r;else if(ge(l))t=l,r=t.nodeValue.length;else break}else{if(Yc(t))break;{let l=t.previousSibling;for(;l&&ir(l,-1);)o=t.parentNode,i=Ee(l),l=l.previousSibling;if(l)t=l,r=xe(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?ls(n,t,r):o&&ls(n,o,i)}function Ig(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=xe(t),i,s;for(;;)if(r<o){if(!$(t))break;let l=t.childNodes[r];if(ir(l,1))i=t,s=++r;else break}else{if(Yc(t))break;{let l=t.nextSibling;for(;l&&ir(l,1);)i=l.parentNode,s=Ee(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=xe(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&ls(n,i,s)}function Yc(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function ls(n,e,t){if(!ge(e)){let s,l;(l=zc(e,t))?(e=l,t=0):(s=Hc(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;po(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function hc(n,e){let t=n.state.doc.resolve(e);if(!(Ae||_c)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function mc(n,e,t){let r=n.state.selection;if(r instanceof H&&!r.empty||t.indexOf("s")>-1||qe&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=ss(n.state,e);if(s&&s instanceof B)return Nt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof me?F.near(s,e):F.findFrom(s,e);return l?Nt(n,l):!1}return!1}function gc(n,e){if(!(n.state.selection instanceof H))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))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 s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function bc(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function Bg(n){if(!Te||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&$(e)&&t==0&&e.firstChild&&$(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;bc(n,r,"true"),setTimeout(()=>bc(n,r,"false"),20)}return!1}function Hg(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zg(n,e){let t=e.keyCode,r=Hg(e);if(t==8||qe&&t==72&&r=="c")return gc(n,-1)||wn(n,-1);if(t==46&&!e.shiftKey||qe&&t==68&&r=="c")return gc(n,1)||wn(n,1);if(t==13||t==27)return!0;if(t==37||qe&&t==66&&r=="c"){let o=t==37?hc(n,n.state.selection.from)=="ltr"?-1:1:-1;return pc(n,o,r)||wn(n,o)}else if(t==39||qe&&t==70&&r=="c"){let o=t==39?hc(n,n.state.selection.from)=="ltr"?1:-1:1;return pc(n,o,r)||wn(n,o)}else{if(t==38||qe&&t==80&&r=="c")return mc(n,-1,r)||wn(n,-1);if(t==40||qe&&t==78&&r=="c")return Bg(n)||mc(n,1,r)||wn(n,1);if(r==(qe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ys(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||je.fromSchema(n.state.schema),l=ru(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&$(c)&&(u=nu[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}c=a.firstChild}c&&$(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
1
|
+
var __novaChunkBase=typeof document!=="undefined"&&(document.currentScript&&document.currentScript.src||document.baseURI)||"";function __novaChunk(p){return new URL(p,__novaChunkBase).href}
|
|
2
|
+
(()=>{var Sf=Object.create;var Er=Object.defineProperty;var wf=Object.getOwnPropertyDescriptor;var Ef=Object.getOwnPropertyNames;var Cf=Object.getPrototypeOf,Af=Object.prototype.hasOwnProperty;var Tf=(n,e,t)=>e in n?Er(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var me=(n=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(n,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):n)(function(n){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var Z=(n,e)=>{for(var t in e)Er(n,t,{get:e[t],enumerable:!0})},Nf=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ef(e))!Af.call(n,o)&&o!==t&&Er(n,o,{get:()=>e[o],enumerable:!(r=wf(e,o))||r.enumerable});return n};var ge=(n,e,t)=>(t=n!=null?Sf(Cf(n)):{},Nf(e||!n||!n.__esModule?Er(t,"default",{value:n,enumerable:!0}):t,n));var E=(n,e,t)=>Tf(n,typeof e!="symbol"?e+"":e,t);var pi={};Z(pi,{definePlugin:()=>Sa,isPluginRegistered:()=>Cr,loadPlugin:()=>di,orderPlugins:()=>Ar,registerPlugin:()=>U,resolveEntries:()=>ui});function Sa(n){return n}var ci=new Map;function U(n,e){ci.set(n,e)}function Cr(n){return ci.has(n)}function xa(n){return typeof n=="function"}function ui(n){let e=[],t=[],r=[];for(let o of n)if(typeof o=="string"){let i=ci.get(o);i?xa(i)?t.push(i):e.push(i):r.push(`Plugin "${o}" is not registered`)}else xa(o)?t.push(o):e.push(o);return{plugins:e,loaders:t,errors:r}}function Ar(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),r=[],o=[],i=new Map,s=(l,a)=>{let c=i.get(l.name);if(c==="done")return!0;if(c==="failed")return!1;if(c==="visiting")return o.push(`Plugin dependency cycle: ${[...a,l.name].join(" \u2192 ")}`),!1;i.set(l.name,"visiting");for(let u of l.requires??[]){if(e.has(u))continue;let d=t.get(u);if(!d)return o.push(`Plugin "${l.name}" requires "${u}", which is not loaded`),i.set(l.name,"failed"),!1;if(!s(d,[...a,l.name]))return i.set(l.name,"failed"),!1}return i.set(l.name,"done"),r.push(l),!0};for(let l of n)s(l,[]);return{ordered:r,errors:o}}async function di(n){let e=await n();return"default"in e&&e.default?e.default:e}var fi={};Z(fi,{icons:()=>S});var T=n=>`<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${n}</svg>`,S={undo:T('<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />'),redo:T('<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'),bold:T('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:T('<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'),underline:T('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:T('<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'),code:T('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:T('<path d="m4 5 8 8" /><path d="m12 5-8 8" /><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" />'),superscript:T('<path d="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" />'),bulletList:T('<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'),orderedList:T('<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" />'),indent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:T('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:T('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:T('<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'),alignLeft:T('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:T('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:T('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:T('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:T('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:T('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'),unlink:T('<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'),image:T('<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'),clearFormatting:T('<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'),formatMore:T('<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'),imageLeft:T('<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'),imageCenter:T('<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'),imageRight:T('<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'),resize:T('<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'),altText:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),imageCaption:T('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:T('<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'),paragraph:T('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'),h3:T('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'),pasteText:T('<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'),table:T('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:T('<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'),rowAfter:T('<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'),rowDelete:T('<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'),colBefore:T('<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'),colAfter:T('<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'),colDelete:T('<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'),merge:T('<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),split:T('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:T('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:T('<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'),tableProps:T('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:T('<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'),tableDelete:T('<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'),chevronUp:T('<path d="m18 15-6-6-6 6" />'),search:T('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:T('<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'),fullscreenExit:T('<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'),preview:T('<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />'),sourceCode:T('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:T('<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'),print:T('<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'),check:T('<path d="M20 6 9 17l-5-5" />'),close:T('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:T('<path d="m6 9 6 6 6-6" />'),more:T('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:T('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:T('<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'),lineHeight:T('<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'),upload:T('<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'),externalLink:T('<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'),copy:T('<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'),edit:T('<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'),resizeHandle:T('<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'),browse:T('<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'),mergeTags:T('<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'),resizeHandleBoth:T('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),anchor:T('<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'),save:T('<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'),charmap:T('<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'),commentAdd:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'),comments:T('<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'),emoji:T('<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'),dateTime:T('<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'),media:T('<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'),nonBreaking:T('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:T('<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'),sidebar:T('<rect x="3" y="4" width="18" height="16" rx="2" /><path d="M15 4v16" />'),history:T('<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'),suggest:T('<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'),review:T('<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'),visualBlocks:T('<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'),ltr:T('<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'),rtl:T('<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />')};var Ri={};Z(Ri,{AllSelection:()=>se,EditorState:()=>Vn,NodeSelection:()=>P,Plugin:()=>z,PluginKey:()=>K,Selection:()=>F,SelectionRange:()=>Bt,TextSelection:()=>I,Transaction:()=>Fr});var xi={};Z(xi,{ContentMatch:()=>ht,DOMParser:()=>Qe,DOMSerializer:()=>Le,Fragment:()=>A,Mark:()=>_,MarkType:()=>Yt,Node:()=>Ae,NodeRange:()=>ft,NodeType:()=>qe,ReplaceError:()=>Xe,ResolvedPos:()=>Dn,Schema:()=>Xt,Slice:()=>D});function be(n){this.content=n}be.prototype={constructor:be,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 r=t&&t!=n?this.remove(t):this,o=r.find(n),i=r.content.slice();return o==-1?i.push(t||n,e):(i[o+1]=e,t&&(i[o]=t)),new be(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 be(t)},addToStart:function(n,e){return new be([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new be(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),i=r.find(n);return o.splice(i==-1?o.length:i,0,e,t),new be(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=be.from(n),n.size?new be(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=be.from(n),n.size?new be(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=be.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}};be.from=function(n){if(n instanceof be)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new be(e)};var hi=be;function Ia(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){let s=o.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&Fa(s.charCodeAt(a-1))&&Ba(s.charCodeAt(a))&&t--,t}if(o.content.size||i.content.size){let s=Ia(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Ha(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=s.text,u=l.text,d=c.length,p=u.length;for(;d>0&&p>0&&c[d-1]==u[p-1];)d--,p--,t--,r--;return d&&p&&d<c.length&&Fa(c.charCodeAt(d-1))&&Ba(c.charCodeAt(d))&&(t++,r++),{a:t,b:r}}if(s.content.size||l.content.size){let c=Ha(s.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}function Ba(n){return n>=56320&&n<57344}function Fa(n){return n>=55296&&n<56320}var A=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&r(a,o+l,i||null,s)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);i<e.content.length;i++)o.push(e.content[i]);return new n(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;a>e&&((s<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(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,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Ia(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return Ha(this,e,t,r)}findIndex(e){if(e==0)return Tr(0,e);if(e==this.size)return Tr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,r=0;;t++){let o=this.child(t),i=r+o.nodeSize;if(i>=e)return i==e?Tr(t+1,i):Tr(t,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return n.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;o<e.length;o++){let i=e[o];r+=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 n(t||e,r)}static from(e){if(!e)return n.empty;if(e instanceof n)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new n([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}};A.empty=new A([],0);var mi={index:0,offset:0};function Tr(n,e){return mi.index=n,mi.offset=e,mi}function Dr(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 r=0;r<n.length;r++)if(!Dr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!Dr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}var _=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!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;!r&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||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&&Dr(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 r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};_.none=[];var Xe=class extends Error{},D=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=_a(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(za(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 n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(A.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};D.empty=new D(A.empty,0,0);function za(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(za(i.content,e-o-1,t-o-1)))}function _a(n,e,t,r,o,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=_a(a.content,e-l-1,t,s==0?r-1:0,s==n.childCount-1?o-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function Of(n,e,t){if(t.openStart>n.depth)throw new Xe("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new Xe("Inconsistent open depths");return $a(n,e,t,0)}function $a(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let s=$a(n,e,t,r+1);return i.copy(i.content.replaceChild(o,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let s=n.parent,l=s.content;return Lt(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Df(t,n);return Lt(i,qa(n,s,l,e,r))}else return Lt(i,Lr(n,e,r))}function Va(n,e){if(!e.type.compatibleContent(n.type))throw new Xe("Cannot join "+e.type.name+" onto "+n.type.name)}function gi(n,e,t){let r=n.node(t);return Va(r,e.node(t)),r}function Dt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Nn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Dt(n.nodeAfter,r),i++));for(let l=i;l<s;l++)Dt(o.child(l),r);e&&e.depth==t&&e.textOffset&&Dt(e.nodeBefore,r)}function Lt(n,e){if(!n.type.validContent(e))throw new Xe("Invalid content for node "+n.type.name);return n.copy(e)}function qa(n,e,t,r,o){let i=n.depth>o&&gi(n,e,o+1),s=r.depth>o&&gi(t,r,o+1),l=[];return Nn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(Va(i,s),Dt(Lt(i,qa(n,e,t,r,o+1)),l)):(i&&Dt(Lt(i,Lr(n,e,o+1)),l),Nn(e,t,o,l),s&&Dt(Lt(s,Lr(t,r,o+1)),l)),Nn(r,null,o,l),new A(l)}function Lr(n,e,t){let r=[];if(Nn(null,n,t,r),n.depth>t){let o=gi(n,e,t+1);Dt(Lt(o,Lr(n,e,t+1)),r)}return Nn(e,null,t,r),new A(r)}function Df(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(A.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var Dn=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,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 r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):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 r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)o+=r.child(i).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return _.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let i=r.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!o||!i[s].isInSet(o.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!o||!r[i].isInSet(o.marks))&&(r=r[i--].removeFromSet(r));return r}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 r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new ft(this,e,r);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 r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=wa.get(e);if(r)for(let i=0;i<r.elts.length;i++){let s=r.elts[i];if(s.pos==t)return s}else wa.set(e,r=new bi);let o=r.elts[r.i]=n.resolve(e,t);return r.i=(r.i+1)%Lf,o}},bi=class{constructor(){this.elts=[],this.i=0}},Lf=12,wa=new WeakMap,ft=class{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}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)}},Rf=Object.create(null),Ae=class n{constructor(e,t,r,o=_.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||A.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,r,o=0){this.content.nodesBetween(e,t,r,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,r,o){return this.content.textBetween(e,t,r,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,r){return this.type==e&&Dr(this.attrs,t||e.defaultAttrs||Rf)&&_.sameSet(this.marks,r||_.none)}copy(e=null){return e==this.content?this:new n(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new n(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,r=!1){if(e==t)return D.empty;let o=this.resolve(e),i=this.resolve(t),s=r?0:o.sharedDepth(t),l=o.start(s),c=o.node(s).content.cut(o.pos-l,i.pos-l);return new D(c,o.depth-s,i.depth-s)}replace(e,t,r){return Of(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Dn.resolveCached(this,e)}resolveNoCache(e){return Dn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,i=>(r.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,r=A.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<i;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let i=this.contentMatchAt(e).matchType(r),s=i&&i.matchFragment(this.content,t);return s?s.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),Ca(this.type.attrs,this.attrs,"node",this.type.name);let e=_.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];Ca(r.type.attrs,r.attrs,"mark",r.type.name),e=r.addToSet(e)}if(!_.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=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,r)}let o=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,o,r)}};Ae.prototype.text=void 0;var Ea=(()=>{let{stack:n}=new Error("/");if(!n||!/\n\s*at\s/.test(n))return t=>t;let e=Object.create(null);return t=>(e[t],t)})(),yi=class n extends Ae{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}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 Ea(this.text.slice(e,t))}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(Ea(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}function Ca(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${r}`);for(let o in n)n[o].validate&&n[o].validate(e[o])}var ht=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new vi(e,t);if(r.next==null)return n.empty;let o=ja(r);r.next&&r.err("Unexpected trailing text");let i=_f(zf(o));return $f(i,r),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,r=e.childCount){let o=this;for(let i=t;o&&i<r;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 r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function i(s,l){let a=s.matchFragment(e,r);if(a&&(!t||a.validEnd))return A.from(l.map(c=>c.createAndFill()));for(let c=0;c<s.next.length;c++){let{type:u,next:d}=s.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(d)==-1){o.push(d);let p=i(d,l.concat(u));if(p)return p}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),i=o.match;if(i.matchType(e)){let s=[];for(let l=o;l.type;l=l.via)s.push(l.type);return s.reverse()}for(let s=0;s<i.next.length;s++){let{type:l,next:a}=i.next[s];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.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(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s<r.next.length;s++)i+=(s?", ":"")+r.next[s].type.name+"->"+e.indexOf(r.next[s].next);return i}).join(`
|
|
3
|
+
`)}};ht.empty=new ht(!0);var vi=class{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 ja(n){let e=[];do e.push(Pf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Pf(n){let e=[];do e.push(If(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function If(n){let e=Ff(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=Hf(n,e);else break;return e}function Aa(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Hf(n,e){let t=Aa(n),r=t;return n.eat(",")&&(n.next!="}"?r=Aa(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Bf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Ff(n){if(n.eat("(")){let e=ja(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=Bf(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 zf(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();o(i(s.expr,a),u),a=u}if(s.max==-1)o(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();r(a,u),o(i(s.expr,a),u),a=u}return[r(a)]}else{if(s.type=="name")return[r(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Ka(n,e){return e-n}function Ta(n,e){let t=[];return r(e),t.sort(Ka);function r(o){let i=n[o];if(i.length==1&&!i[0].term)return r(i[0].to);t.push(o);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&r(a)}}}function _f(n){let e=Object.create(null);return t(Ta(n,0));function t(r){let o=[];r.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Ta(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[r.join(",")]=new ht(r.indexOf(n.length-1)>-1);for(let s=0;s<o.length;s++){let l=o[s][1].sort(Ka);i.next.push({type:o[s][0],next:e[l.join(",")]||t(l)})}return i}}function $f(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],i=!o.validEnd,s=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),r.indexOf(c)==-1&&r.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ua(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ja(n,e){let t=Object.create(null);for(let r in n){let o=n[r],i=e&&e[r];if(i===void 0)if(o.hasDefault)i=o.default;else throw new RangeError("No value supplied for attribute "+r);else o.validate&&o.validate(i);t[r]=i}return t}function Ga(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ki(n,r,e[r]);return t}var qe=class n{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ga(e,r.attrs),this.defaultAttrs=Ua(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==ht.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:Ja(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ae(this,this.computeAttrs(e),A.from(t),_.setFrom(r))}createChecked(e=null,t,r){return t=A.from(t),this.checkContent(t),new Ae(this,this.computeAttrs(e),t,_.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=A.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(A.empty,!0);return i?new Ae(this,e,t.append(i),_.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).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){}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 r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:_.none:e}static compile(e,t){let r=Object.create(null);e.forEach((i,s)=>r[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Vf(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var ki=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Vf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},Yt=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Ga(e,o.attrs),this.excluded=null;let i=Ua(this.attrs);this.instance=i?new _(this,i):null}create(e=null){return!e&&this.instance?this.instance:new _(this,Ja(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}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]}excludes(e){return this.excluded.indexOf(e)>-1}},Xt=class{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=hi.from(e.nodes),t.marks=hi.from(e.marks||{}),this.nodes=qe.compile(this.spec.nodes,this),this.marks=Yt.compile(this.spec.marks,this);let r=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],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=ht.parse(s,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?Na(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Na(this,s.split(" "))}this.nodeFromJSON=o=>Ae.fromJSON(this,o),this.markFromJSON=o=>_.fromJSON(this,o),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof qe){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,r,o)}text(e,t){let r=this.nodes.text;return new yi(r,r.defaultAttrs,e,_.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Na(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],i=n.marks[o],s=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(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function qf(n){return n.tag!=null}function Wf(n){return n.style!=null}var Qe=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(qf(o))this.tags.push(o);else if(Wf(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.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 r=new Rr(this,t,!1);return r.addAll(e,_.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Rr(this,t,!0);return r.addAll(e,_.none,t.from,t.to),D.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let i=this.tags[o];if(Uf(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||t.matchesContext(i.context))){if(i.getAttrs){let s=i.getAttrs(e);if(s===!1)continue;i.attrs=s||void 0}return i}}}matchStyle(e,t,r,o){for(let i=o?this.styles.indexOf(o)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!r.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s<t.length;s++){let l=t[s];if((l.priority==null?50:l.priority)<i)break}t.splice(s,0,o)}for(let o in e.marks){let i=e.marks[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Da(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Da(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Ya={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},jf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xa={ol:!0,ul:!0},Ln=1,Mi=2,On=4;function Oa(n,e,t){return e!=null?(e?Ln:0)|(e==="full"?Mi:0):n&&n.whitespace=="pre"?Ln|Mi:t&~On}var Gt=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=_.none,this.match=i||(s&On?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(A.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Ln)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.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=A.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(A.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&&!Ya.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Rr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Oa(null,t.preserveWhitespace,0)|(r?On:0);o?i=new Gt(o.type,o.attrs,_.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Gt(null,null,_.none,!0,null,s):i=new Gt(e.schema.topNodeType,null,_.none,!0,null,s),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 r=e.nodeValue,o=this.top,i=o.options&Mi?"full":this.localPreserveWS||(o.options&Ln)>0,{schema:s}=this.parser;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
|
|
4
|
+
`);else if(s.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(s.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(s.text(l[a]),t,!/\S/.test(l[a]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let l=o.content[o.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(s.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Xa.hasOwnProperty(s)&&this.parser.normalizeLists&&Kf(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:jf.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ya.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let d=a&&a.skip?t:this.readStyles(e,t);d&&this.addAll(e,d),c&&this.sync(i),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
5
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let i=this.parser.matchedStyles[o],s=r.getPropertyValue(i);if(s)for(let l=void 0;;){let a=this.parser.matchStyle(i,s,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));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,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,r){let o,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,i=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(i);for(let s=0;s<o.length;s++)t=this.enterInner(o[s],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=_.none;for(let l of o.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):La(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let i=this.findPlace(e.create(t),r,!1);return i&&(i=this.enterInner(e,t,r,!0,o)),i}enterInner(e,t,r,o=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Oa(e,i,s.options);s.options&On&&s.content.length==0&&(l|=On);let a=_.none;return r=r.filter(c=>(s.type?s.type.allowsMarkType(c.type):La(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Gt(e,t,a,o,null,l)),this.open++,r}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;this.localPreserveWS&&(this.nodes[t].options|=Ln)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].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,r){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)&(r?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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Kf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xa.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Uf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Da(n){let e={};for(let t in n)e[t]=n[t];return e}function La(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||i.indexOf(u)<0&&s(u))return!0}};if(s(o.contentMatch))return!0}}var Le=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Nr(t).createDocumentFragment());let o=r,i=[];return e.forEach(s=>{if(i.length||s.marks.length){let l=0,a=0;for(;l<i.length&&a<s.marks.length;){let c=s.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<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(s,t))}),r}serializeNodeInner(e,t){if(e.isText)return Nr(t).createTextNode(e.text);let{dom:r,contentDOM:o}=Or(Nr(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 r}serializeNode(e,t={}){let r=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(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Or(Nr(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return typeof t=="string"?{dom:e.createTextNode(t)}:Or(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ra(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ra(e.marks)}};function Ra(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Nr(n){return n.document||window.document}var Pa=new WeakMap;function Jf(n){let e=Pa.get(n);return e===void 0&&Pa.set(n,e=Gf(n)),e}function Gf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Or(n,e,t,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let o=e[0],i;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=Jf(r))&&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 s=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let p=d.indexOf(" ");p>0?a.setAttributeNS(d.slice(0,p),d.slice(p+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let p=e[d];if(p===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else if(typeof p=="string")a.appendChild(n.createTextNode(p));else{let{dom:f,contentDOM:h}=Or(n,p,t,r);if(a.appendChild(f),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var Ni={};Z(Ni,{AddMarkStep:()=>mt,AddNodeMarkStep:()=>en,AttrStep:()=>Hn,DocAttrStep:()=>Bn,MapResult:()=>Qt,Mapping:()=>Zt,RemoveMarkStep:()=>Ze,RemoveNodeMarkStep:()=>Rt,ReplaceAroundStep:()=>ie,ReplaceStep:()=>ue,Step:()=>J,StepMap:()=>We,StepResult:()=>oe,Transform:()=>Fn,TransformError:()=>Pt,canJoin:()=>bt,canSplit:()=>et,dropPoint:()=>zn,findWrapping:()=>It,insertPoint:()=>dc,joinPoint:()=>uc,liftTarget:()=>gt,replaceStep:()=>_n});var nc=65535,rc=Math.pow(2,16);function Yf(n,e){return n+e*rc}function Qa(n){return n&nc}function Xf(n){return(n-(n&nc))/rc}var oc=1,ic=2,Pr=4,sc=8,Qt=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&sc)>0}get deletedBefore(){return(this.delInfo&(oc|Pr))>0}get deletedAfter(){return(this.delInfo&(ic|Pr))>0}get deletedAcross(){return(this.delInfo&Pr)>0}},We=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Qa(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Xf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+i],u=this.ranges[l+s],d=a+c;if(e<=d){let p=c?e==a?-1:e==d?1:t:t,f=a+o+(p<0?0:u);if(r)return f;let h=e==(t<0?a:d)?null:Yf(l/3,e-a),g=0;return c&&(g|=e==a?ic:e==d?oc:Pr,(t<0?e!=a:e!=d)&&(g|=sc)),new Qt(f,g,h)}o+=u-c}return r?e+o:new Qt(e+o,0,null)}touches(e,t){let r=0,o=Qa(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o<this.ranges.length;o+=3){let s=this.ranges[o],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),i+=u-c}}invert(){return new n(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?n.empty:new n(e<0?[0,-e,0]:[0,0,e])}};We.empty=new We([]);var Zt=class n{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new n(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=e.from,r=this._maps.length;t<e.to;t++){let o=e.getMirror(t);o!=null&&(o=o<t&&o>=e.from?r+(o-e.from):void 0),this.appendMap(e._maps[t],o)}}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.to-1,r=this._maps.length+e._maps.length;t>=e.from;t--){let o=e.getMirror(t);o!=null&&(o=o>t&&o<e.to?r-(o-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),o)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let i=this.from;i<this.to;i++){let s=this._maps[i],l=s.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 r?e:new Qt(e,o,null)}},Si=Object.create(null),J=class{getMap(){return We.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Si[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Si)throw new RangeError("Duplicate use of step JSON ID "+e);return Si[e]=t,t.prototype.jsonID=e,t}},oe=class n{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new n(e,null)}static fail(e){return new n(null,e)}static fromReplace(e,t,r,o){try{return n.ok(e.replace(t,r,o))}catch(i){if(i instanceof Xe)return n.fail(i.message);throw i}}};function Ai(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let i=n.child(o);i.content.size&&(i=i.copy(Ai(i.content,e,i))),i.isInline&&(i=e(i,t,o)),r.push(i)}return A.fromArray(r)}var mt=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),i=new D(Ai(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{if(r.isInline&&r.isAtom){let i=this.mark.addToSet(r.marks);if(!_.sameSet(i,r.marks)){let s=Math.max(this.from,o),l=Math.min(this.to,o+r.nodeSize);Ir(Ze,s,l,this.mark,t);for(let a of r.marks)a.isInSet(i)||Ir(n,s,l,a,t)}}}),t.length==1?t[0]:new In(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("addMark",mt);var Ze=class n extends J{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new D(Ai(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(r,o)=>{r.isInline&&r.isAtom&&this.mark.isInSet(r.marks)&&Ir(mt,Math.max(this.from,o),Math.min(this.to,o+r.nodeSize),this.mark,t)}),t.length==1?t[0]:new In(t)}map(e){let t=e.map(this.from,1),r=e.map(this.to,-1);return t>=r?null:new n(t,r,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(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 n(t.from,t.to,e.markFromJSON(t.mark))}};J.jsonID("removeMark",Ze);function Ir(n,e,t,r,o){let i=o.length?o[o.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(r)?o[o.length-1]=new n(i.from,t,r):o.push(new n(e,t,r))}var In=class n extends J{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let r=t.apply(e);if(!r.doc)return r;e=r.doc}return new oe(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let r of this.steps){let o=r.map(e);o&&t.push(o)}return t.length?new n(t):null}toJSON(){return{stepType:"markSet",steps:this.steps.map(e=>e.toJSON())}}static fromJSON(e,t){if(!Array.isArray(t.steps)||!t.steps.every(r=>r.stepType=="addMark"||r.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(r=>J.fromJSON(e,r)))}};J.jsonID("markSet",In);var en=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new n(this.pos,t.marks[o]);return new n(this.pos,this.mark)}}return new Rt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("addNodeMark",en);var Rt=class n extends J{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new en(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new n(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 n(t.pos,e.markFromJSON(t.mark))}};J.jsonID("removeNodeMark",Rt);var ue=class n extends J{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&Ei(e,this.from,this.to)?oe.fail("Structure replace would overwrite content"):oe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new We([this.from,this.to-this.from,this.slice.size])}invert(e){return new n(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),r=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return r.deletedAcross&&t.deletedAcross?null:new n(r.pos,Math.max(r.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof n)||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?D.empty:new D(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new n(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?D.empty:new D(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new n(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 n(t.from,t.to,D.fromJSON(e,t.slice),!!t.structure)}};ue.MAP_BIAS=1;J.jsonID("replace",ue);var ie=class n extends J{constructor(e,t,r,o,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Ei(e,this.from,this.gapFrom)||Ei(e,this.gapTo,this.to)))return oe.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return oe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?oe.fromReplace(e,this.from,this.to,r):oe.fail("Content does not fit in gap")}getMap(){return new We([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 n(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),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||i>r.pos||o>i?null:new n(t.pos,r.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 n(t.from,t.to,t.gapFrom,t.gapTo,D.fromJSON(e,t.slice),t.insert,!!t.structure)}};J.jsonID("replaceAround",ie);function Ei(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Qf(n,e,t,r){let o=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!r.isInSet(a)&&l.type.allowsMarkType(r.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);Ir(mt,c,u,r,o)}}),o.forEach(i=>n.step(i))}function Zf(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(r instanceof Yt){let c=s.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],p;for(let f=0;f<o.length;f++){let h=o[f];h.step==i-1&&d.eq(o[f].style)&&(p=h)}p?(p.to=c,p.step=i):o.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),o.forEach(s=>n.step(new Ze(s.from,s.to,s.style)))}function Ti(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<i.childCount;a++){let c=i.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)s.push(new ue(l,u,D.empty));else{r=d;for(let p=0;p<c.marks.length;p++)t.allowsMarkType(c.marks[p].type)||n.step(new Ze(l,u,c.marks[p]));if(o&&c.isText&&t.whitespace!="pre"){let p,f=/\r?\n|\r/g,h;for(;p=f.exec(c.text);)h||(h=new D(A.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ue(l+p.index,l+p.index+p[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(A.empty,!0);n.replace(l,l,new D(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function eh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function gt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth,o=0,i=0;;--r){let s=n.$from.node(r),l=n.$from.index(r)+o,a=n.$to.indexAfter(r)-i;if(r<n.depth&&s.canReplace(l,a,t))return r;if(r==0||s.type.spec.isolating||!eh(s,l,a))break;l&&(o=1),a<s.childCount&&(i=1)}return null}function th(n,e,t){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),l=o.after(i+1),a=s,c=l,u=A.empty,d=0;for(let h=i,g=!1;h>t;h--)g||r.index(h)>0?(g=!0,u=A.from(r.node(h).copy(u)),d++):a--;let p=A.empty,f=0;for(let h=i,g=!1;h>t;h--)g||o.after(h+1)<o.end(h)?(g=!0,p=A.from(o.node(h).copy(p)),f++):c++;n.step(new ie(a,c,s,l,new D(u.append(p),d,f),u.size-d,!0))}function It(n,e,t=null,r=n){let o=nh(n,e),i=o&&rh(r,e);return i?o.map(Za).concat({type:e,attrs:t}).concat(i.map(Za)):null}function Za(n){return{type:n,attrs:null}}function nh(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(r,o,s)?i:null}function rh(n,e){let{parent:t,startIndex:r,endIndex:o}=n,i=t.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function oh(n,e,t){let r=A.empty;for(let s=t.length-1;s>=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=A.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new ie(o,i,o,i,new D(r,0,0),t.length,!0))}function ih(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&sh(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?c=!1:!f&&h&&(c=!0)}c===!1&&ac(n,s,l,i),Ti(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let u=n.mapping.slice(i),d=u.map(l,1),p=u.map(l+s.nodeSize,1);return n.step(new ie(d,p,d+1,p-1,new D(A.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&lc(n,s,l,i),!1}})}function lc(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ac(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
6
|
+
`))}})}function sh(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function lh(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ie(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new D(A.from(s),0,0),1,!0))}function et(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=r&&r[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let g=r&&r[u]||d;if(!d.canReplace(p+1,d.childCount)||!g.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function ah(n,e,t=1,r){let o=n.doc.resolve(e),i=A.empty,s=A.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=A.from(o.node(l).copy(i));let u=r&&r[c];s=A.from(u?u.type.create(u.attrs,s):o.node(l).copy(s))}n.step(new ue(e,e,new D(i.append(s),t,t),!0))}function bt(n,e){let t=n.resolve(e),r=t.index();return cc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function ch(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let i=e.child(o),s=i.type==r?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function cc(n,e){return!!(n&&e&&!n.isLeaf&&ch(n,e))}function uc(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let i,s,l=r.index(o);if(o==r.depth?(i=r.nodeBefore,s=r.nodeAfter):t>0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&cc(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function uh(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(o);u&&!d?r=!1:!u&&d&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);ac(n,u.node(),u.before(),l)}s.inlineContent&&Ti(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ue(c,a.map(e+t,-1),D.empty,!0)),r===!0){let u=n.doc.resolve(c);lc(n,u.node(),u.before(),n.steps.length)}return n}function dc(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i<r.node(o).childCount)return null}return null}function zn(n,e,t){let r=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 s=r.depth;s>=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=r.index(s)+(l>0?1:0),u=r.node(s),d=!1;if(i==1)d=u.canReplace(c,c,o);else{let p=u.contentMatchAt(c).findWrapping(o.firstChild.type);d=p&&u.canReplaceWith(c,c,p[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}}return null}function _n(n,e,t=e,r=D.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return pc(o,i,r)?new ue(e,t,r):new Ci(o,i,r).fit()}function pc(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var Ci=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=A.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=A.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,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new D(i,s,l);return e>-1?new ie(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new ue(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let i=t.firstChild;if(t.childCount>1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=ec(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(A.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced;return tc(e,-1)<=t?!1:(this.unplaced.size>1&&tc(e,1)>r&&r++,this.unplaced=new D(e,t+1,r),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=ec(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new D(Rn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new D(Rn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let g=0;g<i.length;g++)this.openFrontierNode(i[g]);let s=this.unplaced,l=r?r.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:p}=this.frontier[t];if(o){for(let g=0;g<o.childCount;g++)u.push(o.child(g));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let g=l.child(c),m=d.matchType(g.type);if(!m)break;c++,(c>1||a==0||g.content.size)&&(d=m,u.push(fc(g.mark(p.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let h=c==l.childCount;h||(f=-1),this.placed=Pn(this.placed,t,A.from(u)),this.frontier[t].match=d,h&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=u[u.length-1];m&&g<f;g++)this.frontier.push({type:m.type,match:m.contentMatchAt(m.childCount)}),m=m.lastChild;this.unplaced=h?e==0?D.empty:new D(Rn(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new D(Rn(s.content,e,c),e,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wi(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:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=wi(e,t,o,r,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=wi(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,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=Pn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Pn(this.placed,this.depth,A.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(A.empty,!0);t.childCount&&(this.placed=Pn(this.placed,this.frontier.length,t))}};function Rn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Rn(n.firstChild.content,e-1,t)))}function Pn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Pn(n.lastChild.content,e-1,t)))}function ec(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function fc(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,fc(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(A.empty,!0)))),n.copy(r)}function wi(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!dh(t,i.content,s)?l:null}function dh(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ph(n){return n.spec.defining||n.spec.definingForContent}function tc(n,e){for(let t=0;;t++){let r=e<0?n.firstChild:n.lastChild;if(!r||r.isAtom)return t;n=r.content}}function fh(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),i=n.doc.resolve(t);if(pc(o,i,r))return n.step(new ue(e,t,r));let s=mc(o,i);s[s.length-1]==0&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let p=o.depth,f=o.pos-1;p>0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?l=p:o.before(p)==f&&s.splice(1,0,-p)}let a=s.indexOf(l),c=[],u=r.openStart;for(let p=r.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==r.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=ph(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(l)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=r.openStart;p>=0;p--){let f=(p+u+1)%(r.openStart+1),h=c[f];if(h)for(let g=0;g<s.length;g++){let m=s[(g+a)%s.length],b=!0;m<0&&(b=!1,m=-m);let k=o.node(m-1),y=o.index(m-1);if(k.canReplaceWith(y,y,h.type,h.marks))return n.replace(o.before(m),b?i.after(m):t,new D(hc(r.content,0,r.openStart,f),f,r.openEnd))}}let d=n.steps.length;for(let p=s.length-1;p>=0&&(n.replace(e,t,r),!(n.steps.length>d));p--){let f=s[p];f<0||(e=o.before(f),t=i.after(f))}}function hc(n,e,t,r,o){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(hc(i.content,e+1,t,r,i)))}if(e>r){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return n}function hh(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=dc(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new D(A.from(r),0,0))}function mh(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&r.parentOffset==0&&o.parentOffset==0){let s=r.sharedDepth(t),l=!1;for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=r.depth;a>0&&e==r.start(a);a--)e=r.before(a);for(let a=o.depth;a>0&&t==o.start(a);a--)t=o.before(a);r=n.doc.resolve(e),o=n.doc.resolve(t)}}let i=mc(r,o);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function mc(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;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}var Hn=class n extends J{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return oe.fromReplace(e,this.pos,this.pos+1,new D(A.from(o),0,t.isLeaf?0:1))}getMap(){return We.empty}invert(e){return new n(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 n(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 n(t.pos,t.attr,t.value)}};J.jsonID("attr",Hn);var Bn=class n extends J{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 r=e.type.create(t,e.content,e.marks);return oe.ok(r)}getMap(){return We.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};J.jsonID("docAttr",Bn);var Pt=class extends Error{};Pt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Pt.prototype=Object.create(Error.prototype);Pt.prototype.constructor=Pt;Pt.prototype.name="TransformError";var Fn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Zt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Pt(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}changedRange(){let e=1e9,t=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let o=this.mapping.maps[r];r&&(e=o.map(e,1),t=o.map(t,-1)),o.forEach((i,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=D.empty){let o=_n(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new D(A.from(r),0,0))}delete(e,t){return this.replace(e,t,D.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return fh(this,e,t,r),this}replaceRangeWith(e,t,r){return hh(this,e,t,r),this}deleteRange(e,t){return mh(this,e,t),this}lift(e,t){return th(this,e,t),this}join(e,t=1){return uh(this,e,t),this}wrap(e,t){return oh(this,e,t),this}setBlockType(e,t=e,r,o=null){return ih(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return lh(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Hn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Bn(e,t)),this}addNodeMark(e,t){return this.step(new en(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof _)t.isInSet(r.marks)&&this.step(new Rt(e,t));else{let o=r.marks,i,s=[];for(;i=t.isInSet(o);)s.push(new Rt(e,i)),o=i.removeFromSet(o);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,r){return ah(this,e,t,r),this}addMark(e,t,r){return Qf(this,e,t,r),this}removeMark(e,t,r){return Zf(this,e,t,r),this}clearIncompatible(e,t,r){return Ti(this,e,t,r),this}};var Oi=Object.create(null),F=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Bt(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=D.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(i);e.replaceRange(u.map(a.pos),u.map(c.pos),l?D.empty:t),l==0&&yc(e,i,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){let{$from:s,$to:l}=o[i],a=e.mapping.slice(r),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),yc(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new I(e):tn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let i=e.depth-1;i>=0;i--){let s=t<0?tn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):tn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new se(e.node(0))}static atStart(e){return tn(e,e,0,0,1)||new se(e)}static atEnd(e){return tn(e,e,e.content.size,e.childCount,-1)||new se(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Oi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Oi)throw new RangeError("Duplicate use of selection JSON ID "+e);return Oi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return I.between(this.$anchor,this.$head).getBookmark()}};F.prototype.visible=!0;var Bt=class{constructor(e,t){this.$from=e,this.$to=t}},gc=!1;function bc(n){!gc&&!n.parent.inlineContent&&(gc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var I=class n extends F{constructor(e,t=e){bc(e),bc(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return F.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=D.empty){if(super.replace(e,t),t==D.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Br(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=F.findFrom(t,r,!0)||F.findFrom(t,-r,!0);if(i)t=i.$head;else return F.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(F.findFrom(e,-r,!0)||F.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new n(e,t)}};F.jsonID("text",I);var Br=class n{constructor(e,t){this.anchor=e,this.head=t}map(e){return new n(e.map(this.anchor),e.map(this.head))}resolve(e){return I.between(e.resolve(this.anchor),e.resolve(this.head))}},P=class n extends F{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),i=e.resolve(o);return r?F.near(i):new n(i)}content(){return new D(A.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 Li(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}};P.prototype.visible=!1;F.jsonID("node",P);var Li=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Br(r,r):new n(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&P.isSelectable(r)?new P(t):F.near(t)}},se=class n extends F{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=D.empty){if(t==D.empty){e.delete(0,e.doc.content.size);let r=F.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new n(e)}map(e){return new n(e)}eq(e){return e instanceof n}getBookmark(){return gh}};F.jsonID("all",se);var gh={map(){return this},resolve(n){return new se(n)}};function tn(n,e,t,r,o,i=!1){if(e.inlineContent)return I.create(n,t);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&P.isSelectable(l))return P.create(n,t-(o<0?l.nodeSize:0))}else{let a=tn(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function yc(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof ue||o instanceof ie))return;let i=n.mapping.maps[r],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(F.near(n.doc.resolve(s),t))}var vc=1,Hr=2,kc=4,Fr=class extends Fn{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|vc)&~Hr,this.storedMarks=null,this}get selectionSet(){return(this.updated&vc)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Hr,this}ensureMarks(e){return _.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Hr)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Hr,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||_.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(F.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|=kc,this}get scrolledIntoView(){return(this.updated&kc)>0}};function Mc(n,e){return!e||!n?n:n.bind(e)}var Ht=class{constructor(e,t,r){this.name=e,this.init=Mc(t.init,r),this.apply=Mc(t.apply,r)}},bh=[new Ht("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Ht("selection",{init(n,e){return n.selection||F.atStart(e.doc)},apply(n){return n.selection}}),new Ht("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Ht("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],$n=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bh.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Ht(r.key,r.spec.state,r))})}},Vn=class n{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 r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];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],r=this.applyInner(e),o=null;for(;;){let i=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=o?o[s].n:0,c=o?o[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let d=0;d<this.config.plugins.length;d++)o.push(d<s?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),i=!0}o&&(o[s]={state:r,n:t.length})}}if(!i)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let i=r[o];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new Fr(this)}static create(e){let t=new $n(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new n(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new $n(this.schema,e.plugins),r=t.fields,o=new n(t);for(let i=0;i<r.length;i++){let s=r[i].name;o[s]=this.hasOwnProperty(s)?this[s]:r[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(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new $n(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Ae.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=F.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function xc(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=xc(o,e,{})),t[r]=o}return t}var z=class{constructor(e){this.spec=e,this.props={},e.props&&xc(e.props,this,this.props),this.key=e.key?e.key.key:Sc("plugin")}getState(e){return e[this.key]}},Di=Object.create(null);function Sc(n){return n in Di?n+"$"+ ++Di[n]:(Di[n]=0,n+"$")}var K=class{constructor(e="key"){this.key=Sc(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Ii={};Z(Ii,{FOCUSABLE:()=>nn,activeElement:()=>j,eventTarget:()=>Pi,formatShortcut:()=>tt,h:()=>M,icon:()=>V,isMac:()=>Ec,isRtl:()=>rn,listenDocument:()=>yt,logicalKey:()=>Me,uniqueId:()=>Te});function M(n,e={},...t){let r=document.createElement(n);for(let[o,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?r.addEventListener(o.replace(/^on/,"").toLowerCase(),i):o==="className"?r.className=String(i):r.setAttribute(o,i===!0?"":String(i)));for(let o of t.flat())o==null||o===!1||r.append(o);return r}function V(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}var wc=0;function Te(n="nova"){return wc+=1,`${n}-${wc}`}var Ec=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function tt(n){let e=n.split("-"),t=e.pop(),r=t.length===1?t.toUpperCase():t;if(Ec){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+r}let o={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>o[i]??i),r].join("+")}var nn='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function j(n){let e=n.getRootNode(),t=("activeElement"in e?e.activeElement:null)??document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}function Pi(n){return n.composedPath?.()[0]??n.target}function yt(n,e,t){let r=n.getRootNode(),o=typeof ShadowRoot<"u"&&r instanceof ShadowRoot?r:null,i=l=>{o&&l.composedPath().includes(o.host)||t(l,Pi(l))},s=l=>t(l,Pi(l));return document.addEventListener(e,i,!0),o?.addEventListener(e,s,!0),()=>{document.removeEventListener(e,i,!0),o?.removeEventListener(e,s,!0)}}function rn(n){return n.closest("[dir]")?.getAttribute("dir")?.toLowerCase()==="rtl"}function Me(n,e){return n.key!=="ArrowLeft"&&n.key!=="ArrowRight"||!rn(e)?n.key:n.key==="ArrowLeft"?"ArrowRight":"ArrowLeft"}function Cc(n){let e=Te("nova-dialog-title"),t=M("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),r=M("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),o=M("button",{type:"button",className:"nova-button"},n.cancelLabel),i=M("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},V(S.close)),s=M("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},M("header",{className:"nova-dialog-header"},M("h2",{id:e},n.title),i),M("div",{className:"nova-dialog-body"},n.body,t),M("footer",{className:"nova-dialog-footer"},o,r)),l=M("div",{className:"nova-dialog-backdrop"},s);n.host.append(l);let a=!1,c=()=>{a||(a=!0,l.remove(),p(),n.onClose?.(),n.returnFocus?.())},u=h=>{t.hidden=!h,t.textContent=h??""},d=h=>{r.disabled=h,s.setAttribute("aria-busy",String(h))};s.addEventListener("submit",async h=>{h.preventDefault(),u(null),d(!0);try{let g=n.onSubmit?await n.onSubmit():!0;typeof g=="string"?u(g):g!==!1&&c()}finally{a||d(!1)}}),o.addEventListener("click",c),i.addEventListener("click",c),l.addEventListener("mousedown",h=>{h.target===l&&c()}),s.addEventListener("keydown",h=>{if(h.key==="Escape")h.preventDefault(),h.stopPropagation(),c();else if(h.key==="Tab"){let g=[...s.querySelectorAll(nn)].filter(k=>!k.hidden),m=g[0],b=g[g.length-1];if(!m||!b)return;h.shiftKey&&j(s)===m?(h.preventDefault(),b.focus()):!h.shiftKey&&j(s)===b&&(h.preventDefault(),m.focus())}});let p=yt(s,"focusin",(h,g)=>{s.contains(g)||(s.querySelector(nn)??s).focus()});return(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?r:o)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ee(n){let e=Te("nova-field"),t=n.hint?`${e}-hint`:void 0,r=M("input",{id:e,type:n.type??"text",className:"nova-input",value:n.value??"",placeholder:n.placeholder,required:n.required??!1,autocomplete:n.autocomplete??"off",spellcheck:"false","aria-describedby":t});return r.value=n.value??"",{el:M("div",{className:"nova-field"},M("label",{for:e,className:"nova-label"},n.label),r,n.hint?M("p",{id:t,className:"nova-hint"},n.hint):null),input:r}}function Ac(n,e=!1){let t=Te("nova-check"),r=M("input",{id:t,type:"checkbox",className:"nova-checkbox"});return r.checked=e,{el:M("div",{className:"nova-field nova-field-inline"},r,M("label",{for:t},n)),input:r}}function qn(n){let e=Te("nova-field"),t=M("select",{id:e,className:"nova-input nova-select"},...n.options.map(o=>M("option",{value:o.value},o.label)));return t.value=n.value,{el:M("div",{className:"nova-field"},M("label",{for:e,className:"nova-label"},n.label),t),select:t}}var Fi={};Z(Fi,{insertText:()=>vh,openSymbolDialog:()=>Mh,pickLabels:()=>le,symbolPanel:()=>kh});var Ft={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","dialog.required":"This field is required","dialog.invalid":"Check the format","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.retry":"Retry","image.retrying":"Connection problem \u2014 retrying the upload\u2026","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","image.caption":"Caption","image.captionPlaceholder":"Add a caption\u2026","status.words":"{count} words","status.resize":"Resize editor","dialog.browse":"Browse",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"};var zr={},_r={en:Ft},Tc=new Set,Oc={};function yh(n){let e={};for(let[t,r]of Object.entries(n))typeof r=="string"?e[t]=r:r.forEach((o,i)=>e[`${t}.${i}`]=o);return e}function Hi(n,e){let t=n.toLowerCase();zr[t]={...zr[t],...e},_r[t]={...Ft,..._r[t],...e}}function Dc(n,e){let t={};for(let[r,o]of Object.entries(e))o&&(t[r]=yh(o));Oc[n]=t}var Nc=(n,e)=>e?n.replace(/\{(\w+)\}/g,(t,r)=>String(e[r]??`{${r}}`)):n;function Bi(n="en",e={}){let t=n.toLowerCase(),r=t.split("-")[0],o=_r[t]??_r[r]??Ft;o===Ft&&r!=="en"&&!Tc.has(r)&&(Tc.add(r),console.warn(`[nova] language "${n}" is not registered, using English. import pack from '@novaprose/core/i18n/${r}'; registerLanguage('${r}', pack);`));let i={...Ft,...o,...e},s={...zr[r],...zr[t]},l=e;return(a,c)=>{let u=i[a];if(u!==void 0)return Nc(u,c);let d=a.indexOf("."),p=d>0?Oc[a.slice(0,d)]:void 0,f=a.slice(d+1),h=l[a]??s[a]??p?.[t]?.[f]??p?.[r]?.[f]??p?.en?.[f]??a;return Nc(h,c)}}function le(n,e,t){Dc(e,t);let r={};for(let[o,i]of Object.entries(t.en))r[o]=typeof i=="string"?n.ui.t(`${e}.${o}`):i.map((s,l)=>n.ui.t(`${e}.${o}.${l}`));return r}function vh(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}function kh(n){let e=M("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=M("div",{className:"nova-symbols-list"}),r=M("div",{className:`nova-symbols ${n.className}`},e,t),o=i=>{let s=i.trim().toLowerCase(),l=n.groups.map(a=>({title:a.title,items:s?a.items.filter(([c,u])=>u.includes(s)||c===s):a.items})).filter(a=>a.items.length);if(!l.length){t.replaceChildren(M("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>M("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},M("div",{className:"nova-symbols-title"},a.title),M("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>M("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>o(e.value)),e.addEventListener("keydown",i=>{i.key==="ArrowDown"?(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.focus()):i.key==="Enter"&&(i.preventDefault(),t.querySelector(".nova-symbols-cell")?.click())}),t.addEventListener("keydown",i=>{let s=[...t.querySelectorAll(".nova-symbols-cell")],l=s.indexOf(j(t));if(l<0)return;let a=Math.max(1,s.filter(p=>p.offsetTop===s[0].offsetTop).length),c={ArrowRight:1,ArrowLeft:-1,ArrowDown:a,ArrowUp:-a},u=Me(i,t);if(!(u in c))return;i.preventDefault();let d=l+c[u];d<0?e.focus():s[Math.min(s.length-1,d)]?.focus()}),o(""),queueMicrotask(()=>e.focus()),r}function Mh(n,e,t){let r=null,o=t(()=>r?.close());r=n.ui.openDialog({title:e,body:o,cancelLabel:n.ui.t("dialog.close")})}var Lc=S.anchor,xh={en:{title:"Anchor",id:"ID",hint:"Letters, digits, \u201C-\u201D, \u201C_\u201D, \u201C.\u201D; must start with a letter. Link to it with #ID.",invalid:"Use letters, digits, \u201C-\u201D, \u201C_\u201D or \u201C.\u201D, starting with a letter",save:"Save"}},$r=/^[A-Za-z][\w.-]{0,63}$/,Rc={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return $r.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return $r.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:$r.test(n.attrs.id)?n.attrs.id:null}]}},setup(n){let e=le(n,"anchor",xh),t=()=>{let{selection:o}=n.view.state;return o instanceof P&&o.node.type.name==="anchor"?o:null},r=()=>{let o=t(),i=ee({label:e.id,hint:e.hint,value:o?.node.attrs.id??""});n.ui.openDialog({title:e.title,body:M("div",{className:"nova-form"},i.el),submitLabel:e.save,onSubmit:()=>{let s=i.input.value.trim();if(!$r.test(s))return e.invalid;let{state:l,dispatch:a}=n.view,c=n.schema.nodes.anchor,u=t();return a(u?l.tr.setNodeMarkup(u.from,void 0,{id:s}):l.tr.replaceSelectionWith(c.create({id:s}),!1).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("anchor",{icon:Lc,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("anchor",{text:e.title,icon:Lc,onAction:r})}};var hs={};Z(hs,{Decoration:()=>ae,DecorationSet:()=>G,EditorView:()=>fn,__endComposition:()=>Jm,__parseFromClipboard:()=>Um});var xe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};function an(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}var qi=null;function rt(n,e,t){let r=qi||(qi=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r}function Sh(){qi=null}function Vr(n,e,t,r){return t&&(Ic(n,e,t,r,-1)||Ic(n,e,t,r,1))}var Pc=/^(img|br|input|textarea|hr)$/i;function Ic(n,e,t,r,o){for(var i;;){if(n==t&&e==r)return!0;if(e==(o<0?0:ve(n))){let s=n.parentNode;if(!s||!H(s)||qr(n)||Pc.test(n.nodeName)||n.contentEditable=="false")return!1;e=xe(n)+(o<0?0:1),n=s}else if(H(n)){let s=n.childNodes[e+(o<0?-1:0)];if(H(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=o;else return!1;else{if(qr(s)||Pc.test(s.nodeName))return!1;n=s,e=o<0?ve(n):0}}else return!1}}function ve(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function H(n){return n.nodeType==1}function de(n){return n.nodeType==3}function cn(n,e){return e?n.contains(H(e)?e:e.parentNode):!1}function fu(n,e){for(;;){if(de(n)&&e)return n;if(H(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=ve(n)}else if(n.parentNode&&!qr(n,!0))e=xe(n),n=n.parentNode;else return null}}function hu(n,e){for(;;){if(de(n)&&e<n.nodeValue.length)return n;if(H(n)&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!qr(n,!0))e=xe(n)+1,n=n.parentNode;else return null}}function wh(n,e,t){for(let r=e==0,o=e==ve(n);r||o;){if(n==t)return!0;let i=xe(n);if(n=n.parentNode,!n)return!1;r=r&&i==0,o=o&&i==ve(n)}}function qr(n,e=!1){let t;for(let r=n;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function Qr(n){return n.focusNode&&Vr(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function mu(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function Eh(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Ch(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function Ah(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(ve(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(ve(r.startContainer),r.startOffset)}}}var je=typeof navigator<"u"?navigator:null,Hc=typeof document<"u"?document:null,un=je&&je.userAgent||"",Ie=/gecko\/(\d+)/i.test(un)&&!/edge?\//i.test(un);Ie&&+(/Firefox\/(\d+)/.exec(un)||[0,0])[1];var Wi=/Chrome\/(\d+)/.exec(un),Se=!!Wi,gu=Wi?+Wi[1]:0,we=!!je&&/Apple Computer/.test(je.vendor),dn=we&&(/Mobile\/\w+/.test(un)||!!je&&je.maxTouchPoints>2),Re=dn||(je?/Mac/.test(je.platform):!1),bu=je?/Win/.test(je.platform):!1,ot=/Android \d/.test(un),Zr=!!Hc&&"webkitFontSmoothing"in Hc.documentElement.style,Th=Zr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nh(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 nt(n,e){return typeof n=="number"?n:n[e]}function Oh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Bc(n,e,t){if(!ji(e)&&e.left==0)return;let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!H(s)){s=an(s);continue}let l=s==i.body,a=l?Nh(i):Oh(s),c=0,u=0;if(e.top<a.top+nt(r,"top")?u=-(a.top-e.top+nt(o,"top")):e.bottom>a.bottom-nt(r,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+nt(o,"top")-a.top:e.bottom-a.bottom+nt(o,"bottom")),e.left<a.left+nt(r,"left")?c=-(a.left-e.left+nt(o,"left")):e.right>a.right-nt(r,"right")&&(c=e.right-a.right+nt(o,"right")),c||u)if(l)i.defaultView.scrollBy(c,u);else{let p=s.scrollLeft,f=s.scrollTop;u&&(s.scrollTop+=u),c&&(s.scrollLeft+=c);let h=s.scrollLeft-p,g=s.scrollTop-f;e={left:e.left-h,top:e.top-g,right:e.right-h,bottom:e.bottom-g}}let d=l?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s=d=="absolute"?s.offsetParent:an(s)}}function Dh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=n.root.elementFromPoint(i,s);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:yu(n.dom)}}function yu(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=an(r));return e}function Lh({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;vu(t,r==0?0:r-e)}function vu(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:i}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}var on=null;function ku(n){if(n.setActive)return n.setActive();if(on)return n.focus(on);let e=yu(n);n.focus(on==null?{get preventScroll(){return on={preventScroll:!0},!0}}:void 0),on||(on=!1,vu(e,0))}function Mu(n,e){let t,r=2e8,o,i=0,s=e.top,l=e.top,a,c;for(let u=n.firstChild,d=0;u;u=u.nextSibling,d++){let p;if(H(u))p=u.getClientRects();else if(de(u))p=rt(u).getClientRects();else continue;for(let f=0;f<p.length;f++){let h=p[f];if(h.top<=s&&h.bottom>=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let g=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(g<r){t=u,r=g,o=g&&de(t)?{left:h.right<e.left?h.right:h.left,top:e.top}:e,H(u)&&g&&(i=d+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=d+1)}}return!t&&a&&(t=a,o=c,r=0),t&&de(t)?Rh(t,o):!t||r?{node:n,offset:i}:Mu(t,o)}function Rh(n,e){let t=n.nodeValue.length,r=document.createRange(),o;for(let i=0;i<t;i++){r.setEnd(n,i+1),r.setStart(n,i);let s=vt(r,1);if(s.top!=s.bottom&&ss(e,s)){o={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return r.detach(),o||{node:n,offset:0}}function ss(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Ph(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Ih(n,e,t){let{node:r,offset:o}=Mu(e,t),i=-1;if(H(r)&&!r.firstChild){let s=r.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function Hh(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(H(l.dom)&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),s=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.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 xu(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),i=o;;){let s=n.childNodes[i];if(H(s)){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ss(e,c))return xu(s,e,c)}}if((i=(i+1)%r)==o)break}return n}function Bh(n,e){let t=n.dom.ownerDocument,r,o=0,i=Ah(t,e.left,e.top);i&&({node:r,offset:o}=i);let s=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!s||!n.dom.contains(s)){let c=n.dom.getBoundingClientRect();if(!ss(e,c)||(s=xu(n.dom,e,c),!s))return null}if(we)for(let c=s;r&&c;c=an(c))c.draggable&&(r=void 0);if(s=Ph(s,e),r){if(Ie&&H(r)&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&o++}let c;Zr&&o&&H(r)&&H(c=r.childNodes[o-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&H(r.lastChild)&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||!H(r)||r.childNodes[o-1].nodeName!="BR")&&(l=Hh(n,r,o,e))}l==null&&(l=Ih(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function ji(n){return n.top<n.bottom||n.left<n.right}function vt(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(ji(r))return r}return Array.prototype.find.call(t,ji)||n.getBoundingClientRect()}var Fh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Su(n,e,t){let{node:r,offset:o,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=Zr||Ie;if(de(r))if(s&&(Fh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=vt(rt(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=vt(rt(r,o-1,o-1),-1);if(c.top==a.top){let u=vt(rt(r,o,o+1),-1);if(u.top!=a.top)return Wn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,Wn(vt(rt(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==ve(r))){let a=r.childNodes[o-1];if(H(a))return zi(a.getBoundingClientRect(),!1)}if(i==null&&o<ve(r)){let a=r.childNodes[o];if(H(a))return zi(a.getBoundingClientRect(),!0)}return zi(r.getBoundingClientRect(),t>=0)}if(i==null&&o&&(t<0||o==ve(r))){let a=r.childNodes[o-1],c=de(a)?rt(a,ve(a)-(s?0:1)):H(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Wn(vt(c,1),!1)}if(i==null&&o<ve(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?de(a)?rt(a,0,s?0:1):H(a)?a:null:null;if(c)return Wn(vt(c,-1),!0)}return Wn(vt(de(r)?rt(r):r,-t),t>=0)}function Wn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function zi(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 wu(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function zh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return wu(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 s=Su(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(H(l))a=l.getClientRects();else if(de(l))a=rt(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}var _h=/[\u0590-\u08ac]/;function $h(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!_h.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:wu(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:d,focusOffset:p}=n.domSel.readRange(),f=d&&!cn(u,d)||a.focusNode==d&&a.focusOffset==p;return mu(l,a),c!=null&&(l.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var Fc=null,zc=null,_c=!1;function Vh(n,e,t){return Fc==e&&zc==t?_c:(Fc=e,zc=t,_c=t=="up"||t=="down"?zh(n,e,t):$h(n,e,t))}var qt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=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,r){if(this.contentDOM&&cn(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}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??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(H(s)?cn(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof jr||i instanceof Wr&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?xe(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?xe(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=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 s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=xe(p.dom)+1;break}e-=p.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=xe(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=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:r}=this.domFromPos(e,0);if(!H(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Wr=class extends qt{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=H(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Ki=class extends qt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,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}},_t=class n extends qt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Le.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=Ji(i,t,s,r)),e>0&&(i=Ji(i,0,e,r));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()}},St=class n extends qt{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!de(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=Le.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let p=u;return u=Cu(u,r,t),c?a=new Kr(e,t,r,o,u,d||null,p,c):t.isText?new Jn(e,t,r,o,u,p):new n(e,t,r,o,u,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>H(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>A.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&Ur(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ui(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Kh(this.node,this.innerDeco,(d,p,f)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,p):d.type.side>=0&&!f&&a.syncToMarks(p==this.node.childCount?_.none:this.node.child(p).marks,r,e,p),a.placeWidget(d,e,o)},(d,p,f,h)=>{a.syncToMarks(d.marks,r,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(d,p,f,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,p,f,g,e,o)||a.updateNextNode(d,p,f,e,h,o)||a.addNode(d,p,f,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),Eu(this.contentDOM,this.children,e),dn&&Uh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof I)||r<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 s=i.nodeValue,l=Jh(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,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 s=new Ki(this,i,t,o);e.input.compositionNodes.push(s),this.children=Ji(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(Ur(e,this.outerDeco))return;let t=!H(this.nodeDOM),r=this.dom;this.dom=ls(this.dom,this.nodeDOM,Gn(this.outerDeco,this.node,t),Gn(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){H(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function $c(n,e,t,r,o,i){i?ls(r,r,Gn(i,n,!1),Gn(e,n,!1)):Cu(r,e,n);let s=new St(void 0,n,e,t,r,r,r);return s.contentDOM&&s.updateChildren(o,0),s}var Jn=class n extends St{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||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.damage=0,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},jr=class extends qt{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Kr=class extends St{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}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 Eu(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=r;)r=Vc(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(s instanceof _t){let a=r?r.previousSibling:n.lastChild;Eu(s.contentDOM,s.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Vc(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}var Kn=function(n){n&&(this.nodeName=n)};Kn.prototype=Object.create(null);var zt=[new Kn];function Gn(n,e,t){if(n.length==0)return zt;let r=t?zt[0]:new Kn,o=[r];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&o.push(r=new Kn(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&o.length==1&&o.push(r=new Kn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function ls(n,e,t,r){if(t==zt&&r==zt)return e;let o=e;for(let i=0;i<r.length;i++){let s=r[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=zt[0]),o=a}qh(o,l||zt[0],s)}return o}function qh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.remove(r[i]);for(let i=0;i<o.length;i++)r.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 r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Cu(n,e,t){return ls(n,n,zt,Gn(e,t,!H(n)))}function Ur(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 Vc(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}var Ui=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Wh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof _t&&!(u.damage&4)&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=_t.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){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 u=a.dom,d,p=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&Ur(t,a.outerDeco));if(!p&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!p&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ur(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=St.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=St.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){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 Wr(this.top,e,t,r);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 _t;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Jn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((we||Se)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new jr(this.top,[],r,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||H(e)&&e.contains(this.lock.parentNode))}};function Wh(n,e){let t=e,r=t.children.length,o=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(r){let u=t.children[r-1];if(u instanceof _t)o.push(r-1),t=u,r=u.children.length;else{a=u,r--;break}}else{if(t==e)break e;r=o.pop(),t=t.parent}let c=a.node;if(c){if(c!=n.child(i-1))break;--i,s.set(a,i),l.push(a)}}return{index:i,matched:s,matches:l.reverse()}}function jh(n,e){return n.type.side-e.type.side}function Kh(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<o.length&&o[s].to==i;){let m=o[s++];m.widget&&(u?(d||(d=[u])).push(m):u=m)}if(u)if(d){d.sort(jh);for(let m=0;m<d.length;m++)t(d[m],c,!!a)}else t(u,c,!!a);let p,f;if(a)f=-1,p=a,a=null;else if(c<n.childCount)f=c,p=n.child(c++);else break;for(let m=0;m<l.length;m++)l[m].to<=i&&l.splice(m--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let m=h;s<o.length&&o[s].from<m&&(m=o[s].from);for(let b=0;b<l.length;b++)l[b].to<m&&(m=l[b].to);m<h&&(a=p.cut(m-i),p=p.cut(0,m-i),h=m,f=-1)}else for(;s<o.length&&o[s].to<h;)s++;let g=p.isInline&&!p.isLeaf?l.filter(m=>!m.inline):l.slice();r(p,g,e.forChild(i,p),f),i=h}}function Uh(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 Jh(n,e,t,r){for(let o=0,i=0;o<n.childCount&&i<=r;){let s=n.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.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>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Ji(n,e,t,r,o){let i=[];for(let s=0,l=0;s<n.length;s++){let a=n[s],c=l,u=l+=a.size;c>=t||u<=e?i.push(a):(c<e&&i.push(a.slice(0,e-c,r)),o&&(i.push(o),o=void 0),u>t&&i.push(a.slice(t-c,a.size,r)))}return i}function Gi(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&F.findFrom(i,e)}function kt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function qc(n,e,t){let r=n.state.selection;if(r instanceof I)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return kt(n,new I(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Gi(n.state,e);return o&&o instanceof P?kt(n,o):!1}else if(!Re||t.indexOf("m")<0){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?P.isSelectable(i)?kt(n,new P(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):kt(n,new I(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(r instanceof P&&r.node.isInline)return kt(n,new I(e>0?r.$to:r.$from));{let o=Gi(n.state,e);return o?kt(n,o):!1}}}function Un(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):H(n)&&n.contentEditable=="false"}function sn(n,e){return e<0?Gh(n):Yh(n)}function Gh(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Ie&&H(t)&&r<ve(t)&&Un(t.childNodes[r],-1)&&(s=!0);;)if(r>0){if(!H(t))break;let l=t.childNodes[r-1];if(Un(l,-1))o=t,i=--r;else if(de(l))t=l,r=t.nodeValue.length;else break}else{if(Au(t))break;{let l=t.previousSibling;for(;l&&Un(l,-1);)o=t.parentNode,i=xe(l),l=l.previousSibling;if(l)t=l,r=ve(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Yi(n,t,r):o&&Yi(n,o,i)}function Yh(n){let e=n.domSel.readRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=ve(t),i,s;for(;;)if(r<o){if(!H(t))break;let l=t.childNodes[r];if(Un(l,1))i=t,s=++r;else break}else{if(Au(t))break;{let l=t.nextSibling;for(;l&&Un(l,1);)i=l.parentNode,s=xe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=ve(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}i&&Yi(n,i,s)}function Au(n){for(let e=n;e;e=e.parentNode){let t=e.pmViewDesc;if(t)return t.node?t.node.isBlock:!1}return!1}function Yi(n,e,t){if(!de(e)){let s,l;(l=hu(e,t))?(e=l,t=0):(s=fu(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection(),o=n.domSel.readRange();if(!r)return;Qr(o)?r.collapse(e,t):r.extend&&(r.collapse(o.anchorNode,o.anchorOffset),r.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function Wc(n,e){let t=n.state.doc.resolve(e);if(!(Se||bu)&&t.parent.inlineContent){let i=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),l=(s.top+s.bottom)/2;if(l>i.top&&l<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}let r=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){r=n.nodeDOM(t.before(i))||r;break}return getComputedStyle(r).direction=="rtl"?"rtl":"ltr"}function jc(n,e,t){let r=n.state.selection;if(r instanceof I&&!r.empty||t.indexOf("s")>-1||Re&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Gi(n.state,e);if(s&&s instanceof P)return kt(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof se?F.near(s,e):F.findFrom(s,e);return l?kt(n,l):!1}return!1}function Kc(n,e){if(!(n.state.selection instanceof I))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))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 s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function Uc(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function Xh(n){if(!we||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSel.readRange();if(e&&H(e)&&t==0&&e.firstChild&&H(e.firstChild)&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Uc(n,r,"true"),setTimeout(()=>Uc(n,r,"false"),20)}return!1}function Qh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Zh(n,e){let t=e.keyCode,r=Qh(e);if(t==8||Re&&t==72&&r=="c")return Kc(n,-1)||sn(n,-1);if(t==46&&!e.shiftKey||Re&&t==68&&r=="c")return Kc(n,1)||sn(n,1);if(t==13||t==27)return!0;if(t==37||Re&&t==66&&r=="c"){let o=t==37?Wc(n,n.state.selection.from)=="ltr"?-1:1:-1;return qc(n,o,r)||sn(n,o)}else if(t==39||Re&&t==70&&r=="c"){let o=t==39?Wc(n,n.state.selection.from)=="ltr"?1:-1:1;return qc(n,o,r)||sn(n,o)}else{if(t==38||Re&&t==80&&r=="c")return jc(n,-1,r)||sn(n,-1);if(t==40||Re&&t==78&&r=="c")return Xh(n)||jc(n,1,r)||sn(n,1);if(r==(Re?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function as(n,e){n.someProp("transformCopied",f=>{e=f(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;t.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=n.someProp("clipboardSerializer")||Le.fromSchema(n.state.schema),l=Lu(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&H(c)&&(u=Du[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=l.createElement(u[f]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),d++}c=a.firstChild}c&&H(c)&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(t)}`);let p=n.someProp("clipboardTextSerializer",f=>f(e,n))||e.content.textBetween(0,e.content.size,`
|
|
6
7
|
|
|
7
|
-
`);return{dom:a,text:
|
|
8
|
-
`))),0,0),n.someProp("transformPasted",
|
|
9
|
-
`),s&&c==a.nodeValue.length)for(let u=a,d;u;u=u.parentNode){if(d=u.nextSibling){d.nodeName=="BR"&&(t=r={node:d.parentNode,offset:Ee(d)+1});break}let f=u.pmViewDesc;if(f&&f.node&&f.node.isBlock)break}}else{let u=a.childNodes[c-1];s=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}let l=o.domSel.readRange();if(Ke&&l.focusNode&&l.focusNode!=r.node&&$(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&Te)&&no(t.node,t.offset,l.anchorNode,l.anchorOffset)&&no(r.node,r.offset,l.focusNode,l.focusOffset)||Fc(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}function wc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(Te&&o&&o.contentEditable=="false")return Xi(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return Xi(o);if(i)return Xi(i)}}function Xi(n){return n.contentEditable="true",Te&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function xc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Jg(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!ou(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Gg(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,Ee(t)+1):e.collapse(t,0)}function Xg(n,e){if(e instanceof B){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Sc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Sc(n)}function Sc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function An(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||H.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function su(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&lu(n,e)?e:null}function lu(n,e){if(!e.anchorNode)return!1;try{return Mn(n.dom,e.anchorNode)&&(n.editable||Mn(n.dom,e.focusNode))}catch{return!1}}function Qg(n){for(let e in Ne){let t=Ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{eb(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&uu(n,!0),!ks(n,r)&&(n.editable||!(r.type in Le))&&t(n,r))},Yg[e]?{passive:!0}:void 0)}Te&&n.dom.addEventListener("input",()=>null),ds(n)}function mo(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Zg(n){n.input.mouseDown&&n.input.mouseDown.done(),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 ds(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ks(n,r))})}function ks(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function eb(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 tb(n,e){!ks(n,e)&&Ne[e.type]&&(n.editable||!(e.type in Le))&&Ne[e.type](n,e)}function Lt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=ug(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}function ar(n){return{left:n.clientX,top:n.clientY}}function nb(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ws(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function au(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function rb(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&B.isSelectable(r)?(au(n,new B(t)),!0):!1}function ob(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof B&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(B.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(au(n,B.create(n.state.doc,o)),!0):!1}function ib(n,e,t,r,o){return ws(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?ob(n,t):rb(n,t))}function sb(n,e,t,r){return ws(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function lb(n,e,t,r){return ws(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function Mc(n,e,t){if(e==-1)return n.inlineContent?H.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return H.create(n,s+1,s+1+i.content.size);if(t&&B.isSelectable(i))return B.create(n,s)}return null}function Cc(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let m=t.indexAfter(),g=!1;m>0;m--){let b=r.child(m-1);if(!b.text)break;let x=i==e?e-t.posAtIndex(m-1):b.text.length,w=x;for(;w>0;w--)if(/\S/.test(b.text[w-1]))g=!0;else if(g)break;if(o=b.text.slice(w,x)+o,i-=x-w,w||i<e-50)break}for(let m=t.index(),g=!1;m<r.childCount;m++){let b=r.child(m);if(!b.text)break;let x=s==e?e-t.posAtIndex(m):0,w=x;for(;w<b.text.length;w++)if(/\S/.test(b.text[w]))g=!0;else if(g)break;if(o+=b.text.slice(x,w),s+=w-x,w<b.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let m of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(m.isWordLike){let g=m.index+i,b=g+m.segment.length;if(b<e)l=b;else if(g>e){a=g;break}else return H.create(n,g,b)}}else{fs.lastIndex=0;for(let m;m=fs.exec(o);){let g=m.index+i,b=g+m[0].length;if(b<e)l=b;else if(g>e){a=g;break}else return H.create(n,g,b)}}let c=o.slice(l-i,e-i),u=o.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return H.create(n,e-d,e+f);let p=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return H.create(n,e-p,e+h)}function Ec(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function Ac(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&B.isSelectable(o))return B.create(e,t.inside)}let r=e.resolve(t.pos);return An(n,r,r)}function ab(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function cb(n,e){return n.composing?!0:Te&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}function db(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!$(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return $(r)&&r.contentEditable=="false"}function uu(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?Yt(n):du(n,20)}function du(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Yt(n),e))}function fu(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function fb(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=Hc(e.focusNode,e.focusOffset),r=zc(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Yt(n,e=!1){if(!(dt&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),fu(n),e||n.docView&&n.docView.damage)){let t=vs(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function pb(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 r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}function hb(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function mb(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?ur(n,r.value,null,o,e):ur(n,r.textContent,r.innerHTML,o,e)},50)}function ur(n,e,t,r,o){let i=Qc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||O.empty)))return!0;if(!i)return!1;let s=hb(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function pu(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," "):""}function hu(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[gb]}function bb(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(ar(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",p=>{i=p(i,n,!1)}):i=Qc(n,pu(e.dataTransfer),cr?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&hu(n,e));if(n.someProp("handleDrop",p=>p(n,e,i||O.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Gr(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:p}=t;p?p.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&B.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new B(f));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,m,g,b)=>p=b),a.setSelection(An(n,f,a.doc.resolve(p)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}function dr(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}function yb(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,p,h,m)=>{let g=m-h-(p-f);for(let b=0;b<l.length;b+=3){let x=l[b+1];if(x<0||f>x+u-d)continue;let w=l[b]+u-d;p>=w?l[b+1]=f<=w?-2:-1:f>=u&&g&&(l[b]+=g,l[b+1]+=g)}d+=g}),u=t.maps[c].map(u,-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 u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),p=f-o,{index:h,offset:m}=r.content.findIndex(d),g=r.maybeChild(h);if(g&&m==d&&m+g.nodeSize==p){let b=l[c+2].mapInner(t,g,u+1,n[c]+i+1,s);b!=we?(l[c]=d,l[c+1]=p,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=vb(l,n,e,t,o,i,s),u=fo(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let p=u.children[d];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new Y(e.sort(Ot),l)}function mu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new re(o.from+e,o.to+e,o.type))}return t}function vb(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+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 gu(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function bu(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function fo(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=gu(n,l,a+t);if(c){i=!0;let u=fo(c,l,t+a+1,r);u!=we&&o.push(a,a+l.nodeSize,u)}});let s=mu(i?bu(n):n,-t).sort(Ot);if(s.length){let l=new fr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new Y(s,o):we}function Ot(n,e){return n.from-e.from||n.to-e.to}function xs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),Tc(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),Tc(e,o,r.copy(i.from,r.to)));break}}}return e}function Tc(n,e,t){for(;e<n.length&&Ot(t,n[e])>0;)e++;n.splice(e,0,t)}function Yi(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=we&&e.push(r)}),n.cursorWrapper&&e.push(Y.create(n.state.doc,[n.cursorWrapper.deco])),uo.from(e)}function kb(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&Mn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],po(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ae&&n.input.lastKeyCode===8)for(let b=s;b>i;b--){let x=o.childNodes[b-1],w=x.pmViewDesc;if(x.nodeName=="BR"&&!w){s=b;break}if(!w||w.size)break}let f=n.state.doc,p=n.someProp("domParser")||St.fromSchema(n.state.schema),h=f.resolve(l),m=null,g=p.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:wb(r),context:h});if(u&&u[0].pos!=null){let b=u[0].pos,x=u[1]&&u[1].pos;x==null&&(x=b),m={anchor:b+l,head:x+l}}return{doc:g,sel:m,from:l,to:a}}function Sb(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let S=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,y=vs(n,n.domSel.range,S);if(y&&!n.state.selection.eq(y)&&n.domSel.active){if(Ae&&dt&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Lt(n,"Enter"))return;let k=n.state.tr.setSelection(y);S=="pointer"?k.setMeta("pointer",!0):S=="key"&&k.scrollIntoView(),s&&k.setMeta("composition",s),n.dispatch(k)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,u=kb(n,e,t,i),d=n.state.doc,f=d.slice(u.from,u.to),p,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(p=n.state.selection.to,h="end"):(p=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let m=Ab(f.content,u.doc.content,u.from,p,h);if(m&&n.input.domChangeCount++,(En&&n.input.lastIOSEnter>Date.now()-225||dt)&&i.some(S=>$(S)&&!xb.test(S.nodeName))&&(!m||m.endA>=m.endB)&&Lt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!m)if(o&&c instanceof H&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let S=Nc(n,n.state.doc,u.sel);if(S&&!S.eq(n.state.selection)){let y=n.state.tr.setSelection(S);s&&y.setMeta("composition",s),n.dispatch(y)}}return}n.state.selection.from<n.state.selection.to&&m.start==m.endB&&n.state.selection instanceof H&&(m.start>n.state.selection.from&&m.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?m.start=n.state.selection.from:m.endA<n.state.selection.to&&m.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(m.endB+=n.state.selection.to-m.endA,m.endA=n.state.selection.to));let g=u.doc.resolveNoCache(m.start-u.from),b=u.doc.resolveNoCache(m.endB-u.from),x=d.resolve(m.start),w=g.sameParent(b)&&g.parent.inlineContent&&x.end()>=m.endA;if((En&&n.input.lastIOSEnter>Date.now()-225&&(!w||i.some(S=>S.nodeName=="DIV"||S.nodeName=="P"))||!w&&Eb(u.doc,g.pos,b.pos))&&Lt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>m.start&&(w?m.endA>m.start&&m.endB==m.start:Cb(d,m.start,m.endA,g,b))&&Lt(n,"Backspace")){dt&&Ae&&n.domSel.suppressChanges();return}Ae&&m.endB==m.start&&(n.input.lastChromeDelete=Date.now()),dt&&!w&&g.start()!=b.start()&&b.parentOffset==0&&g.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==m.endA&&(m.endB-=2,b=u.doc.resolveNoCache(m.endB-u.from),setTimeout(()=>Lt(n,"Enter"),20));let E=m.start,D=m.endA,C=S=>{let y=S||n.state.tr.replace(E,D,u.doc.slice(m.start-u.from,m.endB-u.from));if(u.sel){let k=Nc(n,y.doc,u.sel);k&&!(Ae&&n.composing&&k.empty&&(m.start!=m.endB||n.input.lastChromeDelete<Date.now()-100)&&(k.head==E||k.head==y.mapping.map(D)-1))&&y.setSelection(k)}return s&&y.setMeta("composition",s),y.scrollIntoView()},N;if(w)if(g.pos==b.pos){let S=C(n.state.tr.delete(E,D)),y=d.resolve(m.start).marksAcross(d.resolve(m.endA));y&&S.ensureMarks(y),n.dispatch(S)}else if(m.endA==m.endB&&(N=Mb(g.parent.content.cut(g.parentOffset,b.parentOffset),x.parent.content.cut(x.parentOffset,m.endA-x.start())))){let S=C(n.state.tr);N.type=="add"?S.addMark(E,D,N.mark):S.removeMark(E,D,N.mark),n.dispatch(S)}else if(g.parent.child(g.index()).isText&&g.index()==b.index()-(b.textOffset?0:1)){let S=g.parent.textBetween(g.parentOffset,b.parentOffset),y=()=>C(n.state.tr.insertText(S,E,D));n.someProp("handleTextInput",k=>k(n,E,D,S,y))||n.dispatch(y())}else n.dispatch(C());else n.dispatch(C())}function Nc(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:An(n,e.resolve(t.anchor),e.resolve(t.head))}function Mb(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(A.from(c).eq(n))return{mark:l,type:s}}function Cb(n,e,t,r,o){if(t-e<=o.pos-r.pos||Qi(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Qi(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Qi(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function Eb(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Qi(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Ab(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}function Nb(n){if(!Lc.has(n)&&(Lc.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ke,Oc)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."),Oc=!0}}function Lb(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Ob(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!$(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}function Dc(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 r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[re.node(0,n.state.doc.content.size,e)]}function Rc(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:re.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Pc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Db(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 Ic(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Rb(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Bc(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ee,Zi,oc,Ze,sc,Cn,Ke,es,Ae,$c,Te,En,qe,_c,dt,ho,pg,kn,Sg,Cg,ac,cc,uc,Xt,oo,ns,Kt,Dt,sr,io,so,or,jt,rs,Fg,nu,rr,ze,cs,kc,Ne,Le,Yg,us,fs,cu,ps,ub,cr,ao,gb,fr,co,Jt,hs,re,xn,Gt,Y,we,uo,wb,xb,Tb,ms,Lc,Oc,Qt,Rt=P(()=>{"use strict";K();de();Ye();Ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};Zi=null;oc=/^(img|br|input|textarea|hr)$/i;Ze=typeof navigator<"u"?navigator:null,sc=typeof document<"u"?document:null,Cn=Ze&&Ze.userAgent||"",Ke=/gecko\/(\d+)/i.test(Cn)&&!/edge?\//i.test(Cn);Ke&&+(/Firefox\/(\d+)/.exec(Cn)||[0,0])[1];es=/Chrome\/(\d+)/.exec(Cn),Ae=!!es,$c=es?+es[1]:0,Te=!!Ze&&/Apple Computer/.test(Ze.vendor),En=Te&&(/Mobile\/\w+/.test(Cn)||!!Ze&&Ze.maxTouchPoints>2),qe=En||(Ze?/Mac/.test(Ze.platform):!1),_c=Ze?/Win/.test(Ze.platform):!1,dt=/Android \d/.test(Cn),ho=!!sc&&"webkitFontSmoothing"in sc.documentElement.style,pg=ho?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;kn=null;Sg=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;Cg=/[\u0590-\u08ac]/;ac=null,cc=null,uc=!1;Xt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.damage=0,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(e){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,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=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,r){if(this.contentDOM&&Mn(this.contentDOM,e))if(r<0){let i,s;if(e==this.contentDOM)i=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(s)+s.size:this.posAtStart}else{let i,s;if(e==this.contentDOM)i=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((s=i.pmViewDesc)&&s.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(s):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Ee(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM)){let i=e.compareDocumentPosition(this.contentDOM);i&16?o=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):o=!(i&4)}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??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!($(s)?Mn(s,e):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],i=r+o.size;if(r==e&&i!=r){for(;!o.border&&o.children.length;)for(let s=0;s<o.children.length;s++){let l=o.children[s];if(l.size){o=l;break}}return o}if(e<i)return o.descAt(e-r-o.border);r=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let i=0;r<this.children.length;r++){let s=this.children[r],l=i+s.size;if(l>e){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(;r>0;r--){let i=this.children[r-1];if(i.size||!(i instanceof io||i instanceof oo&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?Ee(i.dom)+1:0}}else{let i,s=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,s=!1);return i&&s&&!i.border&&!i.domAtom?i.domFromPos(0,t):{node:this.contentDOM,offset:i?Ee(i.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=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 s=r,l=0;;l++){let a=this.children[l],c=s+a.size;if(o==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=Ee(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){i=Ee(d.dom);break}t+=d.size}i==-1&&(i=this.contentDOM.childNodes.length);break}s=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:r}=this.domFromPos(e,0);if(!$(t)||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDamage(e){e&&(this.damage|=e,this.markParentDamage())}markParentDamage(){for(let e=this;;){let{parent:t}=e;if(!t||t.damage&1)break;t.damage|=1,e=t}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},oo=class extends Xt{constructor(e,t,r,o){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(r,()=>{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){let l=$(s)?s:document.createElement("span");l!=s&&(l.appendChild(s),s=l),l.hasAttribute("contenteditable")||(l.contentEditable="false"),l.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return!this.damage&&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 ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},ns=class extends Xt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,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}},Kt=class n extends Xt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=je.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.damage&4||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return!(this.damage&4)&&this.mark.eq(e)}markDamage(e){var t;this.damage|=e,(t=this.parent)===null||t===void 0||t.markDamage(2)}slice(e,t,r){let o=n.create(this.parent,this.mark,!0,r),i=this.children,s=this.size;t<s&&(i=is(i,t,s,r)),e>0&&(i=is(i,0,e,r));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()}},Dt=class n extends Xt{constructor(e,t,r,o,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,i,s){let l=i.nodeViews[t.type.name],a,c=l&&l(t,i,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(!ge(u))throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=je.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Xc(u,r,t),c?a=new so(e,t,r,o,u,d||null,f,c):t.isText?new sr(e,t,r,o,u,f):new n(e,t,r,o,u,d||null,f)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}if(!t.contentElement){let r=e&&e.find(o=>$(o)&&e.indexOf(o.parentNode)<0&&this.dom.contains(o));r?t.contentElement=r:t.getContent=()=>A.empty}}return t}matchesNode(e,t,r){return!this.damage&&e.eq(this.node)&&lo(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new rs(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Og(this.node,this.innerDeco,(d,f,p)=>{d.spec.marks?a.syncToMarks(d.spec.marks,r,e,f):d.type.side>=0&&!p&&a.syncToMarks(f==this.node.childCount?W.none:this.node.child(f).marks,r,e,f),a.placeWidget(d,e,o)},(d,f,p,h)=>{a.syncToMarks(d.marks,r,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let m;a.findNodeMatch(d,f,p,h)||l&&e.state.selection.from>o&&e.state.selection.to<o+d.nodeSize&&(m=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,p,m,e,o)||a.updateNextNode(d,f,p,e,h,o)||a.addNode(d,f,p,e,o),o+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],r,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),Gc(this.contentDOM,this.children,e),En&&Dg(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof H)||r<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 s=i.nodeValue,l=Rg(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,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 s=new ns(this,i,t,o);e.input.compositionNodes.push(s),this.children=is(this.children,r,r+o.length,e,s)}update(e,t,r,o,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o,i),!0)}updateInner(e,t,r,o,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,i+1),this.damage=0}updateOuterDeco(e){if(lo(e,this.outerDeco))return;let t=!$(this.nodeDOM),r=this.dom;this.dom=bs(this.dom,this.nodeDOM,lr(this.outerDeco,this.node,t),lr(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){$(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){$(this.nodeDOM)&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};sr=class n extends Dt{constructor(e,t,r,o,i,s){super(e,t,r,o,i,null,s)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.damage&4||this.damage&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.damage&8||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.damage=0,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return!1}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},io=class extends Xt{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},so=class extends Dt{constructor(e,t,r,o,i,s,l,a){super(e,t,r,o,i,s,l),this.spec=a}update(e,t,r,o,i){if(this.damage&4)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}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)}};or=function(n){n&&(this.nodeName=n)};or.prototype=Object.create(null);jt=[new or];rs=class{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ng(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r,o){let i=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;i<l&&(i==s-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<s;)this.destroyRest(),this.top.damage=0,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;o<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a<0&&this.index<this.top.children.length){let u=this.top.children[this.index];u instanceof Kt&&!(u.damage&4)&&u.mark.type==e[s].type&&u.spec.update&&!this.isLocked(u.dom)&&u.spec.update(e[s])&&(u.mark=e[s],a=this.index,this.changed=!0)}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=Kt.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,r,o,i,s){let l=this.top.children[o];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,r,i,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Dt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=i)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&!(a.damage&4)&&lo(t,a.outerDeco));if(!f&&a.update(e,t,r,o,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,r,o,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(o,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!lo(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=Dt.create(this.top,t,r,o,i,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,i){let s=Dt.create(this.top,e,t,r,o,i);s.contentDOM&&s.updateChildren(o,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,r){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 oo(this.top,e,t,r);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 Kt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof sr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Te||Ae)&&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 r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new io(this.top,[],r,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)&&e.contains(this.lock.parentNode))}};Fg=/^(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;nu={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};rr=null;ze=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};ze.null=new ze(null,0,null,0);cs=class{constructor(e){this.view=e,this.range=ze.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=ze.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?Te&&e.root.nodeType===11&&dg(e.dom.ownerDocument)==e.dom?ze.from(Ug(e,t)||t):ze.from(t):ze.null}read(){this.ensureListener();let e=su(this.view);if(!e){this.active=!1,this.range=ze.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{Xg(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||ou(t)){let{desc:o,start:i}=iu(t.docView,r.from,r.to,0);t.cursorWrapper?Gg(t):o instanceof so&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):jg(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),Jg(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=ze.from(e),this.synced=!0}deactivate(){this.range=ze.null,this.active=this.synced=!1}};kc=Te||Ae&&$c<63;Ne={},Le={},Yg={touchstart:!0,touchmove:!0},us=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};Le.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(dt&&Ae&&t.keyCode==13)){if(En&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(Lt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Lt(n,t)||zg(n,t)?t.preventDefault():mo(n,"key")}};Le.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Le.keypress=(n,e)=>{let t=e;if(cb(n)||!t.charCode||t.ctrlKey&&!t.altKey||qe&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof H)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};fs=/[\w_\u00a1-\uffff]+/g;try{fs=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}cu=qe?"metaKey":"ctrlKey";Ne.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;Yt(n);let o="singleClick";r-n.input.lastClick.time<500&&nb(t,n.input.lastClick)&&!t[cu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(ar(t));if(i)if(t.button==0){if(!n.hasFocus()){Wc(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new ps(n,i,t,o)).mightDrag||t.preventDefault()}else mo(n,"pointer")};ps=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[cu],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=Ec(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof B?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof B?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof B&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,u=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let d=e.state.doc.resolve(t.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=ab(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?ib:this.type=="doubleClick"?sb:lb)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(ar(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(ar(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?Ac(r,o,e):this.type=="doubleClick"?Cc(o,e.pos):Mc(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=An(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=An(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=Ec(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?Ac(this.view,r,t):this.type=="doubleClick"?Cc(r,t.pos):Mc(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};Ne.touchstart=n=>{n.input.lastTouch=Date.now(),Yt(n),mo(n,"pointer")};Ne.touchmove=n=>{n.input.lastTouch=Date.now(),mo(n,"pointer")};Ne.contextmenu=n=>Yt(n);ub=dt?5e3:-1;Le.compositionstart=Le.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof H&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Ae&&_c&&db(n)))n.markCursor=n.state.storedMarks||t.marks(),Yt(n,!0),n.markCursor=null;else if(Yt(n,!e.selection.empty),Ke&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&$(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(ge(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}du(n,ub)};Le.compositionend=(n,e)=>{n.composing&&uu(n)};cr=En&&pg<604;Ne.copy=Le.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=cr?null:t.clipboardData,s=r.content(),{dom:l,text:a}=ys(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):pb(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};Le.paste=(n,e)=>{let t=e;if(n.composing&&!dt)return;let r=cr?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&ur(n,pu(r),r.getData("text/html"),o,t)?t.preventDefault():mb(n,t)};ao=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},gb=qe?"altKey":"ctrlKey";Ne.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(ar(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof B?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=B.create(n.state.doc,r.mightDrag.pos);else if(t.target&&$(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=B.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=ys(n,l);(!t.dataTransfer.files.length||!Ae||$c>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(cr?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",cr||t.dataTransfer.setData("text/plain",c),n.dragging=new ao(u,hu(n,t),s)};Ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Le.dragover=Le.dragenter=(n,e)=>e.preventDefault();Le.drop=(n,e)=>{try{bb(n,e,n.dragging)}finally{n.dragging=null}};Ne.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};Ne.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};Ne.beforeinput=(n,e)=>{if(dt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Lt(n,"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 Le)Ne[n]=Le[n];fr=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},co=class n{constructor(e,t){this.toDOM=e,this.spec=t||Gt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new re(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&dr(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Jt=class n{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new re(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},hs=class n{constructor(e,t){this.attrs=e,this.spec=t||Gt}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new re(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&dr(this.attrs,e.attrs)&&dr(this.spec,e.spec)}destroy(){}},re=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new co(t,r))}static inline(e,t,r,o){return new n(e,t,new Jt(r,o))}static node(e,t,r,o){return new n(e,t,new hs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Jt}get widget(){return this.type instanceof co}},xn=[],Gt={},Y=class n{constructor(e,t){this.local=e.length?e:xn,this.children=t.length?t:xn}static create(e,t){return t.length?fo(t,e,0,Gt):we}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==we||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Gt)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new fr(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?yb(this.children,s||[],e,t,r,o,i):s?new n(s.sort(Ot),xn):we}add(e,t){return t.length?this==we?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=gu(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,u,c+1):o.splice(i,0,a,a+l.nodeSize,fo(u,l,c+1,Gt)),i+=3}});let s=mu(i?bu(t):t,-r).sort(Ot);if(s.length){let l=new fr(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(Ot):this.local,o||this.children)}remove(e){return e.length==0||this==we?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=we?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):we}forChild(e,t){if(this==we)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,u=c*3,d=this.children[u];if(d<e)i=c+1;else if(d>e)s=c;else{r=this.children[u+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof Jt){let d=Math.max(l,u.from)-l,f=Math.min(a,u.to)-l;d<f&&(o||(o=[])).push(u.copy(d,f))}}if(o){let c=new n(o.sort(Ot),xn);return r?new uo([c,r]):c}return r||we}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 xs(this.localsInner(e))}localsInner(e){if(this==we)return xn;if(e.inlineContent||!this.local.some(Jt.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Jt||t.push(this.local[r]);return t}forEachSet(e){e(this)}};Y.empty=new Y([],[]);Y.removeOverlap=xs;we=Y.empty,uo=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,Gt));return n.from(r)}forChild(e,t){if(t.isLeaf)return Y.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=we&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||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,r=!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{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?xs(r?t:t.sort(Ot)):xn}static from(e){switch(e.length){case 0:return we;case 1:return e[0];default:return new n(e.every(t=>t instanceof Y)?e:e.reduce((t,r)=>t.concat(r instanceof Y?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};wb=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(Te&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Te&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},xb=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;Tb={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},ms=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);Te&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,Tb),this.started=!0}stop(){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.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=Sn(i))t.add(i);for(let i=e.anchorNode;i;i=Sn(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:ge(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!su(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Ae&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&$(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ke&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=t.domSel.range;for(let f of u){let p=f.parentNode;p&&p.nodeName=="LI"&&(!d||Lb(t,d)!=p)&&f.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&po(t.domSel.range)&&(c=vs(t,t.domSel.range))&&c.eq(F.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&Nb(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Ob(t,a)),Sb(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let f=e.addedNodes[d];t.push(f),ge(f)&&(this.lastChangedTextNode=f)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?Ee(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?Ee(s):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof sr&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},Lc=new WeakMap,Oc=!1;Qt=class{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 us,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Bc),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Pc(this),Rc(this),this.nodeViews=Ic(this),this.docView=dc(this.state.doc,Dc(this),Yi(this),this.dom,this),this.domObserver=new ms(this),this.domSel=new cs(this),this.domObserver.start(),this.domSel.read(),Qg(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&&ds(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Bc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(fu(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ic(this);Rb(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ds(this),this.editable=Pc(this),Rc(this);let a=Yi(this),c=Dc(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&gg(this);s&&this.domObserver.stopped(()=>{let p=d&&Ae&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Db(o.selection,e.selection);if(d){let h=Ae?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=fb(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let m=this.docView.outerDeco;this.docView.destroy(),this.docView=dc(e.doc,c,a,this.dom,this,m)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}this.domSel.sync(p)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&bg(f)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof B){let t=this.docView.domAfterPos(this.state.selection.from);$(t)&&lc(this,t.getBoundingClientRect(),e)}else lc(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new ao(e.slice,e.move,o<0?void 0:B.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&Wc(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return xg(this,e)}coordsAtPos(e,t=1){return Kc(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Ag(this,t||this.state,e)}pasteHTML(e,t){return ur(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ur(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return ys(this,e)}destroy(){this.docView&&(Zg(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Yi(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,ag())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return tb(this,e)}domSelection(){return this.root.getSelection()}};Qt.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))}});function yu(n){var e=Pb&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ib&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?bo:ft)[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}var ft,bo,Pb,Ib,ue,ue,ue,go,vu=P(()=>{"use strict";ft={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:"'"},bo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Pb=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ib=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(ue=0;ue<10;ue++)ft[48+ue]=ft[96+ue]=String(ue);for(ue=1;ue<=24;ue++)ft[ue+111]="F"+ue;for(ue=65;ue<=90;ue++)ft[ue]=String.fromCharCode(ue+32),bo[ue]=String.fromCharCode(ue);for(go in ft)bo.hasOwnProperty(go)||(bo[go]=ft[go])});function zb(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!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))Bb?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Fb(n){let e=Object.create(null);for(let t in n)e[zb(t)]=n[t];return e}function Ss(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 Fe(n){return new _({props:{handleKeyDown:pr(n)}})}function pr(n){let e=Fb(n);return function(t,r){let o=yu(r),i,s=e[Ss(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Ss(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Hb&&r.ctrlKey&&r.altKey)&&(i=ft[r.keyCode])&&i!=o){let l=e[Ss(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Bb,Hb,pt=P(()=>{"use strict";vu();K();Bb=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Hb=typeof navigator<"u"&&/Win/.test(navigator.platform)});function Cs(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function ku(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hr.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(wu).filter(o=>o!==null):[],r=e.resolved;return{id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:Ms(r.by),at:Number(r.at)||0}:null}}function Ms(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function wu(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hr.test(e.id))return null;let t={id:e.id,author:Ms(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(Ms).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function xu(n=[],e){let t=n.map(ku).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=ku(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=wu(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(u=>u.id===l?{...u,text:a.slice(0,5e3),editedAt:Date.now()}:u)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var hr,Su=P(()=>{"use strict";hr=/^[A-Za-z0-9_-]{1,64}$/});var Eu={};He(Eu,{createCommentsPanel:()=>Wb});function Vb(n){let e=0;for(let t of n)e=e*31+t.charCodeAt(0)|0;return Cu[Math.abs(e)%Cu.length]}function qb(n){return n.trim().split(/\s+/).filter(Boolean).slice(0,2).map(t=>[...t][0].toUpperCase()).join("")||"?"}function Wb(n){let{editor:e,store:t,labels:r}=n,o=e.options.language??"en",i=new Intl.RelativeTimeFormat(o,{numeric:"auto"}),s=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}),l=Ce("nova-comments-title"),a=new Map,c=new Map,u=null,d=!1,f=v("div",{className:"nova-comments-list"}),p=v("span",{className:"nova-comments-count"}),h=v("input",{type:"checkbox"});h.addEventListener("change",()=>{d=h.checked,N()});let m=v("aside",{className:"nova-comments","aria-labelledby":l,hidden:!0,onKeydown:(S=>{S.key==="Escape"&&(S.stopPropagation(),n.pending()?n.cancelPending():n.closePanel())})},v("div",{className:"nova-comments-head"},v("h2",{id:l,className:"nova-comments-title"},r.panel),p,v("button",{type:"button",className:"nova-btn nova-comments-close","aria-label":r.close,title:r.close,onClick:()=>n.closePanel()},"\xD7")),v("label",{className:"nova-comments-filter"},h,r.showResolved),f);function g(S){let y=Math.round((S-Date.now())/1e3),k=Math.abs(y),T=k<45?i.format(0,"second"):k<3600?i.format(Math.round(y/60),"minute"):k<86400?i.format(Math.round(y/3600),"hour"):k<86400*7?i.format(Math.round(y/86400),"day"):s.format(S);return v("time",{dateTime:new Date(S).toISOString(),title:s.format(S)},T)}function b(S,y){let k=v("span",{className:"nova-comment-avatar","aria-hidden":"true"},qb(y));return k.style.backgroundColor=Vb(S||y),k}function x(S){let y=Ce("nova-mention-list"),k=v("textarea",{className:"nova-input nova-comment-input",rows:2,maxlength:5e3,placeholder:S.placeholder,"aria-label":S.placeholder,"data-draft":S.key});k.value=a.get(S.key)??S.initial??"";let T=c.get(S.key)??new Map((S.initialMentions??[]).map(q=>[q.id,q]));c.set(S.key,T);let I=v("button",{type:"button",className:"nova-button nova-button-primary"},S.submitLabel),R=v("ul",{id:y,className:"nova-mention-list",role:"listbox","aria-label":r.people,hidden:!0}),z=[],te=0,fe=null,Br=0;n.findUsers&&(k.setAttribute("role","combobox"),k.setAttribute("aria-autocomplete","list"),k.setAttribute("aria-controls",y),k.setAttribute("aria-expanded","false"));let Vn=()=>{fe=null,z=[],R.hidden=!0,R.replaceChildren(),k.setAttribute("aria-expanded","false"),k.removeAttribute("aria-activedescendant")},Kl=()=>{if(!fe)return Vn();R.replaceChildren(...z.length?z.map((q,Be)=>{let Bt=v("li",{id:`${y}-${Be}`,role:"option",className:"nova-mention-option","aria-selected":String(Be===te)},b(q.id,q.name),v("span",{className:"nova-mention-name"},q.name),q.description?v("span",{className:"nova-mention-detail"},q.description):null);return Bt.addEventListener("mousedown",Ht=>{Ht.preventDefault(),Gl(Be)}),Bt}):[v("li",{className:"nova-mention-empty",role:"presentation"},r.noPeople)]),R.hidden=!1,k.setAttribute("aria-expanded","true"),z.length?k.setAttribute("aria-activedescendant",`${y}-${te}`):k.removeAttribute("aria-activedescendant")},Jl=()=>{let q=n.findUsers;if(!q)return;let Be=k.selectionStart??0,Bt=k.value.slice(0,Be),Ht=/(?:^|\s)@([\p{L}\p{N}_.-]{0,30})$/u.exec(Bt);if(!Ht)return Vn();let Yl=Ht[1]??"";fe={start:Be-Yl.length-1,end:Be};let pm=++Br;q(Yl).then(hm=>{pm!==Br||!fe||(z=hm,te=0,Kl())})},Gl=q=>{let Be=z[q];if(!Be||!fe)return;let Bt=`@${Be.name} `;k.value=k.value.slice(0,fe.start)+Bt+k.value.slice(fe.end);let Ht=fe.start+Bt.length;k.setSelectionRange(Ht,Ht),T.set(Be.id,{id:Be.id,name:Be.name}),Vn(),Ei(),k.focus()},Ei=()=>{a.set(S.key,k.value),I.disabled=k.value.trim()===""},Xl=()=>{let q=k.value;q.trim()&&(a.delete(S.key),c.delete(S.key),S.onSubmit(q,[...T.values()]))};k.addEventListener("input",()=>{Ei(),Jl()}),k.addEventListener("click",Jl),k.addEventListener("blur",()=>setTimeout(Vn,0)),k.addEventListener("keydown",q=>{if(fe&&!R.hidden){if(q.key==="ArrowDown"||q.key==="ArrowUp"){if(q.preventDefault(),!z.length)return;te=(te+(q.key==="ArrowDown"?1:-1)+z.length)%z.length,Kl();return}if((q.key==="Enter"&&!q.ctrlKey&&!q.metaKey||q.key==="Tab")&&z.length){q.preventDefault(),Gl(te);return}if(q.key==="Escape"){q.preventDefault(),q.stopPropagation(),Vn();return}}q.key==="Enter"&&(q.ctrlKey||q.metaKey)&&(q.preventDefault(),Xl())}),I.addEventListener("click",Xl),Ei();let fm=S.onCancel?v("button",{type:"button",className:"nova-button",onClick:()=>{a.delete(S.key),c.delete(S.key),S.onCancel()}},r.cancel):null;return v("div",{className:"nova-comment-composer"},v("div",{className:"nova-mention-wrap"},k,R),v("div",{className:"nova-comment-actions"},fm,I))}function w(S){let y=v("p",{className:"nova-comment-text"}),k=(S.mentions??[]).map(R=>`@${R.name}`).sort((R,z)=>z.length-R.length);if(!k.length)return y.textContent=S.text,y;let T=k.map(R=>R.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),I=S.text.split(new RegExp(`(${T.join("|")})`,"g"));return y.append(...I.map(R=>k.includes(R)?v("span",{className:"nova-comment-mention"},R):R)),y}function E(S,y,k){let T=n.canEdit(y),I=u?.threadId===S.id&&u.commentId===y.id&&T,R=y.author.id===n.author.id,z=v("div",{className:"nova-comment-head"},b(y.author.id,y.author.name),v("span",{className:"nova-comment-author"},y.author.name||r.guest,R?v("span",{className:"nova-comment-you"},` (${r.you})`):null),g(y.createdAt),y.editedAt?v("span",{className:"nova-comment-edited"},r.edited):null),te=I?x({key:`edit:${S.id}:${y.id}`,placeholder:r.placeholder,submitLabel:r.save,initial:y.text,initialMentions:y.mentions??[],onSubmit:Br=>{u=null,t.editComment(S.id,y.id,Br.trim())},onCancel:()=>{u=null,N()}}):w(y),fe=T&&!I?v("div",{className:"nova-comment-tools"},v("button",{type:"button",className:"nova-link-btn",onClick:()=>{u={threadId:S.id,commentId:y.id},N(),C(`edit:${S.id}:${y.id}`)}},r.edit),k>0?v("button",{type:"button",className:"nova-link-btn",onClick:()=>t.deleteComment(S.id,y.id)},r.remove):null):null;return v("div",{className:"nova-comment-item"},z,te,fe)}function D(S){let y=n.active()===S.id,k=n.quote(S.id),T=S.comments[0],I=T?n.canEdit(T):!0,R=v("article",{className:["nova-thread",y?"is-active":"",S.resolved?"is-resolved":"",k?"":"is-orphan"].filter(Boolean).join(" "),"data-thread":S.id,tabindex:"-1","aria-current":y?"true":null},k?v("blockquote",{className:"nova-thread-quote"},k.slice(0,140)):v("p",{className:"nova-thread-orphan"},r.orphan),S.comments.map((z,te)=>E(S,z,te)),S.resolved?v("p",{className:"nova-thread-resolved"},r.resolvedBy.replace("{name}",S.resolved.by.name||r.guest)):null,y&&!S.resolved?x({key:`reply:${S.id}`,placeholder:r.replyPlaceholder,submitLabel:r.reply,onSubmit:(z,te)=>n.reply(S.id,z,te)}):null,v("div",{className:"nova-thread-tools"},v("button",{type:"button",className:"nova-button",onClick:()=>n.setResolved(S.id,!S.resolved)},S.resolved?r.reopen:r.resolve),I?v("button",{type:"button",className:"nova-button nova-button-danger",onClick:()=>n.deleteThread(S.id)},r.deleteThread):null));return R.addEventListener("click",z=>{z.target.closest("button, textarea, input, a")||n.active()!==S.id&&n.setActive(S.id,!0)}),R}function C(S){let y=f.querySelector(`textarea[data-draft="${S}"]`);y&&(y.focus(),y.setSelectionRange(y.value.length,y.value.length))}function N(){let S=f.contains(document.activeElement)?document.activeElement.getAttribute("data-draft"):null,y=[...t.threads()].sort((R,z)=>n.positionOf(R.id)-n.positionOf(z.id)||R.createdAt-z.createdAt),k=y.filter(R=>!R.resolved),T=d?y:k;p.textContent=k.length?String(k.length):"",p.setAttribute("aria-label",r.count.replace("{count}",String(k.length)));let I=[];n.pending()&&I.push(v("article",{className:"nova-thread is-active is-new"},v("div",{className:"nova-comment-head"},b(n.author.id,n.author.name),v("span",{className:"nova-comment-author"},n.author.name)),x({key:"new",placeholder:r.placeholder,submitLabel:r.comment,onSubmit:(R,z)=>n.submitPending(R,z),onCancel:()=>n.cancelPending()}))),I.push(...T.map(D)),I.length===0&&I.push(v("p",{className:"nova-comments-empty"},r.empty.replace("{shortcut}",Qe(n.shortcut)))),f.replaceChildren(...I),S&&C(S),f.querySelector(".nova-thread.is-active")?.scrollIntoView?.({block:"nearest"})}return{el:m,render:N,focusComposer:()=>C("new"),destroy:()=>m.remove()}}var Cu,Au=P(()=>{"use strict";Z();Cu=["#2563eb","#db2777","#16a34a","#ea580c","#7c3aed","#0891b2","#ca8a04","#dc2626"]});function Nn(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=v("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},X(M.browse)),a=v("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var xo=P(()=>{"use strict";Z();j()});function ry(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=oy(n),t=n.childCount,r=[],o=0,i=null,s=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==d.childCount)break;let m=d.child(h),{colspan:g,rowspan:b,colwidth:x}=m.attrs;for(let w=0;w<b;w++){if(w+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-w});break}let E=o+w*e;for(let D=0;D<g;D++){r[E+D]==0?r[E+D]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:g-D});let C=x&&x[D];if(C){let N=(E+D)%e*2,S=s[N];S==null||S!=C&&s[N+1]==1?(s[N]=C,s[N+1]=1):S==C&&s[N+1]++}}}o+=g,u+=m.nodeSize}let f=(c+1)*e,p=0;for(;o<f;)r[o++]==0&&p++;p&&(i||(i=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(i||(i=[])).push({type:"zero_sized"});let l=new ie(e,t,r,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&iy(l,s,n),l}function oy(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let o=n.child(r),i=0;if(t)for(let s=0;s<r;s++){let l=n.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let s=0;s<o.childCount;s++){let l=o.child(s);i+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function iy(n,e,t){n.problems||(n.problems=[]);let r={};for(let o=0;o<n.map.length;o++){let i=n.map[o];if(r[i])continue;r[i]=!0;let s=t.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null,a=s.attrs;for(let c=0;c<a.colspan;c++){let u=e[(o+c)%n.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=sy(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function sy(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function ju(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(let s in e){let l=e[s].getFromDOM,a=l&&l(n);a!=null&&(i[s]=a)}return i}function Ku(n,e){let 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(let r in e){let o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function ly(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(let e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function rd(n){let e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:ly}};for(let r in e)t[r]={default:e[r].default,validate:e[r].validate};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:r=>ju(r,e)}],toDOM(r){return["td",Ku(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>ju(r,e)}],toDOM(r){return["th",Ku(r,e),0]}}}}function Se(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}function Zt(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 ay(n){for(let e=n.depth;e>0;e--){let t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function ne(n){let 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 To(n){let 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;let t=Zt(e.$head)||cy(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function cy(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Vs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function uy(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Us(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function od(n,e,t){let r=n.node(-1),o=ie.get(r),i=n.start(-1),s=o.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function en(n,e,t=1){let r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function id(n,e,t=1){let r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function dy(n,e,t){let r=Se(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}function py(n){if(!(n.selection instanceof ee))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(re.node(r,r+t.nodeSize,{class:"selectedCell"}))}),Y.create(n.doc,e)}function hy({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=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--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function my({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let 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--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function gy(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof B&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=ee.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=ee.rowSelection(l,l)}else if(!t){let l=ie.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=ee.create(o,a+1,c)}}else r instanceof H&&hy(r)?i=H.create(o,r.from):r instanceof H&&my(r)&&(i=H.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function ld(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s<i;s++){let a=e.child(s);for(let c=l,u=Math.min(o,s+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?ld(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function yy(n,e){let t,r=(o,i)=>{o.type.spec.tableRole=="table"&&(t=vy(n,o,i,t))};return e?e.doc!=n.doc&&ld(e.doc,n.doc,0,r):n.doc.descendants(r),t}function vy(n,e,t,r){let o=ie.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a<o.height;a++)i.push(0);for(let a=0;a<o.problems.length;a++){let c=o.problems[a];if(c.type=="collision"){let u=e.nodeAt(c.pos);if(!u)continue;let d=u.attrs;for(let f=0;f<d.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,en(d,d.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let s,l;for(let a=0;a<i.length;a++)i[a]&&(s==null&&(s=a),l=a);for(let a=0,c=t+1;a<o.height;a++){let u=e.child(a),d=c+u.nodeSize,f=i[a];if(f>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);let h=[];for(let g=0;g<f;g++){let b=Se(n.schema)[p].createAndFill();b&&h.push(b)}let m=(a==0||s==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),h)}c=d}return r.setMeta(by,{fixTables:!0})}function Ln(n){return ky(e=>e.type.spec.tableRole==="table",n)}function ky(n,e){for(let t=e.depth;t>=0;t-=1){let r=e.node(t);if(n(r))return{node:r,pos:t===0?0:e.before(t),start:e.start(t),depth:t}}return null}function _e(n){let e=n.selection,t=To(n),r=t.node(-1),o=t.start(-1),i=ie.get(r);return{...e instanceof ee?i.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):i.findCell(t.pos-o),tableStart:o,map:i,table:r}}function ad(n,{map:e,tableStart:t,table:r},o){let i=o>0?-1:0;dy(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,id(c.attrs,o-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?Se(r.type.schema).cell:r.nodeAt(e.map[l+i]).type,c=e.positionAt(s,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function cd(n,e){if(!ne(n))return!1;if(e){let t=_e(n);e(ad(n.tr,t,t.left))}return!0}function ud(n,e){if(!ne(n))return!1;if(e){let t=_e(n);e(ad(n.tr,t,t.right))}return!0}function wy(n,{map:e,table:t,tableStart:r},o){let i=n.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(r+a),null,en(u,o-e.colCount(a)));else{let d=n.mapping.slice(i).map(r+a);n.delete(d,d+c.nodeSize)}s+=u.rowspan}}function dd(n,e){if(!ne(n))return!1;if(e){let t=_e(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;wy(r,t,o),o!=t.left;o--){let i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=ie.get(i)}e(r)}return!0}function xy(n,e,t){var r;let o=Se(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((r=e.nodeAt(n.map[i+t*n.width]))===null||r===void 0?void 0:r.type)!=o)return!1;return!0}function fd(n,{map:e,tableStart:t,table:r},o){let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;let s=[],l=o>0?-1:0;xy(e,r,o+l)&&(l=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=r.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?Se(r.type.schema).cell:(a=r.nodeAt(e.map[u+l*e.width]))===null||a===void 0?void 0:a.type,f=d?.createAndFill();f&&s.push(f)}return n.insert(i,Se(r.type.schema).row.create(null,s)),n}function pd(n,e){if(!ne(n))return!1;if(e){let t=_e(n);e(fd(n.tr,t,t.top))}return!0}function js(n,e){if(!ne(n))return!1;if(e){let t=_e(n);e(fd(n.tr,t,t.bottom))}return!0}function Sy(n,{map:e,table:t,tableStart:r},o){let i=0;for(let c=0;c<o;c++)i+=t.child(c).nodeSize;let s=i+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(i+r,s+r);let a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){let f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){let f=t.nodeAt(d),p=f.attrs,h=f.type.create({...p,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+m),h),c+=p.colspan-1}}}}function hd(n,e){if(!ne(n))return!1;if(e){let t=_e(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Sy(r,t,o),o!=t.top;o--){let i=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=ie.get(t.table)}e(r)}return!0}function Ju(n){let e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function My({width:n,height:e,map:t},r){let o=r.top*n+r.left,i=o,s=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[s]==t[s+n])return!0;o++,s++}return!1}function md(n,e){let t=n.selection;if(!(t instanceof ee)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=_e(n),{map:o}=r;if(My(o,r))return!1;if(e){let i=n.tr,s={},l=A.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){let f=o.map[u*o.width+d],p=r.table.nodeAt(f);if(!(s[f]||!p))if(s[f]=!0,a==null)a=f,c=p;else{Ju(p)||(l=l.append(p.content));let h=i.mapping.map(f+r.tableStart);i.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+r.tableStart,null,{...id(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){let u=a+1+c.content.size,d=Ju(c)?a+1:u;i.replaceWith(d+r.tableStart,u+r.tableStart,l)}i.setSelection(new ee(i.doc.resolve(a+r.tableStart))),e(i)}return!0}function gd(n,e){let t=Se(n.schema);return Cy(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Cy(n){return(e,t)=>{let r=e.selection,o,i;if(r instanceof ee){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;o=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var s;if(o=ay(r.$from),!o)return!1;i=(s=Zt(r.$from))===null||s===void 0?void 0:s.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(t){let l=o.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});let u=_e(e),d=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let f;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=o.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&p==u.top||d.insert(f=d.mapping.map(h+u.tableStart,1),n({node:o,row:p,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,n({node:o,row:u.top,col:u.left}),a[0]),r instanceof ee&&d.setSelection(new ee(d.doc.resolve(r.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function bd(n,e){return function(t,r){if(!ne(t))return!1;let o=To(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof ee?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[n]:e})}):i.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(i)}return!0}}function Ey(n){return function(e,t){if(!ne(e))return!1;if(t){let r=Se(e.schema),o=_e(e),i=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[a],r.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(o.tableStart+s[a],r.header_cell,l[a].attrs);t(i)}return!0}}function Gu(n,e,t){let r=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<r.length;o++){let i=e.table.nodeAt(r[o]);if(i&&i.type!==t.header_cell)return!1}return!0}function On(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Ey(n):function(t,r){if(!ne(t))return!1;if(r){let o=Se(t.schema),i=_e(t),s=t.tr,l=Gu("row",i,o),a=Gu("column",i,o),c=(n==="column"?l:n==="row"&&a)?1:0,u=n=="column"?{left:0,top:c,right:1,bottom:i.map.height}:n=="row"?{left:c,top:0,right:i.map.width,bottom:1}:i,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;i.map.cellsInRect(u).forEach(f=>{let p=f+i.tableStart,h=s.doc.nodeAt(p);h&&s.setNodeMarkup(p,d,h.attrs)}),r(s)}return!0}}function Ay(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return o+1;o+=i.nodeSize}}return null}function No(n){return function(e,t){if(!ne(e))return!1;let r=Ay(To(e),n);if(r==null)return!1;if(t){let o=e.doc.resolve(r);t(e.tr.setSelection(H.between(o,uy(o))).scrollIntoView())}return!0}}function yd(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function So(n,e){let t=n.selection;if(!(t instanceof ee))return!1;if(e){let r=n.tr,o=Se(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new O(o,0,0))}),r.docChanged&&e(r)}return!0}function Ty(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content,u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=qs(Se(s).row,new O(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||r?qs(Se(s).row,new O(e,t,r)).content:e);else return null;return Ny(s,l)}function Ny(n,e){let t=[];for(let o=0;o<e.length;o++){let i=e[o];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(A.empty),t[o]<r){let i=Se(n).cell.createAndFill(),s=[];for(let l=t[o];l<r;l++)s.push(i);e[o]=e[o].append(A.from(s))}return{height:e.length,width:r,rows:e}}function qs(n,e){let t=n.createAndFill();return new mn(t).replace(0,t.content.size,e).doc}function Ly({width:n,height:e,rows:t},r,o){if(n!=r){let i=[],s=[];for(let l=0;l<t.length;l++){let a=t[l],c=[];for(let u=i[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked(en(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let p=1;p<f.attrs.rowspan;p++)i[l+p]=(i[l+p]||0)+f.attrs.colspan}s.push(A.from(c))}t=s,n=r}if(e!=o){let i=[];for(let s=0,l=0;s<o;s++,l++){let a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);s+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}i.push(A.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function Oy(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=Se(l),c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){let p=t.child(d);f+=p.nodeSize;let h=[],m;p.lastChild==null||p.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)h.push(m);n.insert(n.mapping.slice(s).map(f-1+r),h)}if(i>e.height){let d=[];for(let h=0,m=(e.height-1)*e.width;h<Math.max(e.width,o);h++){let g=h>=e.width?!1:t.nodeAt(e.map[m+h]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,A.from(d)),p=[];for(let h=e.height;h<i;h++)p.push(f);n.insert(n.mapping.slice(s).map(r+t.nodeSize-2),p)}return!!(c||u)}function Xu(n,e,t,r,o,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=o;c<i;c++){let u=s*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;let f=t.nodeAt(d),{top:p,left:h}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:s-p}),n.insert(n.mapping.slice(l).map(e.positionAt(s,h,t)),f.type.createAndFill({...f.attrs,rowspan:p+f.attrs.rowspan-s})),c+=f.attrs.colspan-1}}return a}function Yu(n,e,t,r,o,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=o;c<i;c++){let u=c*e.width+s,d=e.map[u];if(e.map[u-1]==d){a=!0;let f=t.nodeAt(d),p=e.colCount(d),h=n.mapping.slice(l).map(d+r);n.setNodeMarkup(h,null,en(f.attrs,s-p,f.attrs.colspan-(s-p))),n.insert(h+f.nodeSize,f.type.createAndFill(en(f.attrs,0,s-p))),c+=f.attrs.rowspan-1}}return a}function Qu(n,e,t,r,o){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let s=ie.get(i),{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr,f=0;function p(){if(i=t?d.doc.nodeAt(t-1):d.doc,!i)throw new Error("No table found");s=ie.get(i),f=d.mapping.maps.length}Oy(d,s,i,t,c,u,f)&&p(),Xu(d,s,i,t,a,c,l,f)&&p(),Xu(d,s,i,t,a,c,u,f)&&p(),Yu(d,s,i,t,l,u,a,f)&&p(),Yu(d,s,i,t,l,u,c,f)&&p();for(let h=l;h<u;h++){let m=s.positionAt(h,a,i),g=s.positionAt(h,c,i);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new O(o.rows[h-l],0,0))}p(),d.setSelection(new ee(d.doc.resolve(t+s.positionAt(l,a,i)),d.doc.resolve(t+s.positionAt(u-1,c-1,i)))),e(d)}function Eo(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Mo(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection;if(i instanceof ee)return Eo(t,r,F.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=vd(o,n,e);if(s==null)return!1;if(n=="horiz")return Eo(t,r,F.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=od(l,n,e),c;return a?c=F.near(a,1):e<0?c=F.near(t.doc.resolve(l.before(-1)),-1):c=F.near(t.doc.resolve(l.after(-1)),1),Eo(t,r,c)}}}function Co(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection,s;if(i instanceof ee)s=i;else{let a=vd(o,n,e);if(a==null)return!1;s=new ee(t.doc.resolve(a))}let l=od(s.$headCell,n,e);return l?Eo(t,r,new ee(s.$anchorCell,l)):!1}}function Ry(n,e){let t=n.state.doc,r=Zt(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ee(r))),!0):!1}function Py(n,e,t){if(!ne(n.state))return!1;let r=Ty(t),o=n.state.selection;if(o instanceof ee){r||(r={width:1,height:1,rows:[A.from(qs(Se(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=ie.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=Ly(r,l.right-l.left,l.bottom-l.top),Qu(n.state,n.dispatch,s,l,r),!0}else if(r){let i=To(n.state),s=i.start(-1);return Qu(n.state,n.dispatch,s,ie.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Iy(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;let r=Zu(n,e.target),o;if(e.shiftKey&&n.state.selection instanceof ee)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Zt(n.state.selection.$anchor))!=null&&((t=Fs(n,e))===null||t===void 0?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let u=Fs(n,c),d=Pt.getState(n.state)==null;if(!u||!Us(a,u))if(d)u=a;else return;let f=new ee(a,u);if(d||!n.state.selection.eq(f)){let p=n.state.tr.setSelection(f);d&&p.setMeta(Pt,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),Pt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Pt,-1))}function l(a){let c=a,u=Pt.getState(n.state),d;if(u!=null)d=n.state.doc.resolve(u);else if(Zu(n,c.target)!=r&&(d=Fs(n,e),!d))return s();d&&i(d,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function vd(n,e,t){if(!(n.state.selection instanceof H))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=r.before(o),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?s:null}}return null}function Zu(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Fs(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});if(!t)return null;let{inside:r,pos:o}=t;return r>=0&&Zt(n.state.doc.resolve(r))||Zt(n.state.doc.resolve(o))}function Ws(n,e,t,r,o,i){let s=0,l=!0,a=e.firstChild,c=n.firstChild;if(c){for(let d=0,f=0;d<c.childCount;d++){let{colspan:p,colwidth:h}=c.child(d).attrs;for(let m=0;m<p;m++,f++){let g=o==f?i:h&&h[m],b=g?g+"px":"";if(s+=g||r,g||(l=!1),a)a.style.width!=b&&(a.style.width=b),a=a.nextSibling;else{let x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;a;){var u;let d=a.nextSibling;(u=a.parentNode)===null||u===void 0||u.removeChild(a),a=d}l?(t.style.width=s+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=s+"px")}}function kd({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:r=Ks,lastColumnResizable:o=!0}={}){let i=new _({key:$e,state:{init(s,l){var a;let c=(a=i.spec)===null||a===void 0||(a=a.props)===null||a===void 0?void 0:a.nodeViews,u=Se(l.schema).table.name;return r&&c&&(c[u]=(d,f)=>new r(d,t,f)),new By(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=$e.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Hy(s,l,n,o)},mouseleave:s=>{zy(s)},mousedown:(s,l)=>{Fy(s,l,e,t)}},decorations:s=>{let l=$e.getState(s);if(l&&l.activeHandle>-1)return Wy(s,l.activeHandle)},nodeViews:{}}});return i}function Hy(n,e,t,r){if(!n.editable)return;let o=$e.getState(n.state);if(o&&!o.dragging){let i=_y(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=ed(n,e,"left",t):a-e.clientX<=t&&(s=ed(n,e,"right",t))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=n.state.doc.resolve(s),a=l.node(-1),c=ie.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}wd(n,s)}}}function zy(n){if(!n.editable)return;let e=$e.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&wd(n,-1)}function Fy(n,e,t,r){var o;if(!n.editable)return!1;let i=(o=n.dom.ownerDocument.defaultView)!==null&&o!==void 0?o:window,s=$e.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=n.state.doc.nodeAt(s.activeHandle),a=$y(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta($e,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",u);let f=$e.getState(n.state);f?.dragging&&(Vy(n,f.activeHandle,td(f.dragging,d,t)),n.dispatch(n.state.tr.setMeta($e,{setDragging:null})))}function u(d){if(!d.which)return c(d);let f=$e.getState(n.state);if(f&&f.dragging){let p=td(f.dragging,d,t);nd(n,f.activeHandle,p,r)}}return nd(n,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function $y(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let a=0;a<t;a++)r[a]&&(s-=r[a],l--);return s/l}function _y(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function ed(n,e,t,r){let o=t=="right"?-r:r,i=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=Zt(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;let a=ie.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function td(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function wd(n,e){n.dispatch(n.state.tr.setMeta($e,{setHandle:e}))}function Vy(n,e,t){let r=n.state.doc.resolve(e),o=r.node(-1),i=ie.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+l;if(c&&i.map[u]==i.map[u-i.width])continue;let d=i.map[u],f=o.nodeAt(d).attrs,p=f.colspan==1?0:l-i.colCount(d);if(f.colwidth&&f.colwidth[p]==t)continue;let h=f.colwidth?f.colwidth.slice():qy(f.colspan);h[p]=t,a.setNodeMarkup(s+d,null,{...f,colwidth:h})}a.docChanged&&n.dispatch(a)}function nd(n,e,t,r){let o=n.state.doc.resolve(e),i=o.node(-1),s=o.start(-1),l=ie.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Ws(i,a.firstChild,a,r,l,t)}function qy(n){return Array(n).fill(0)}function Wy(n,e){let t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return Y.empty;let i=ie.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){let u=l+c*i.width;if((l==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){var a;let d=i.map[u],f=s+d+o.nodeAt(d).nodeSize-1,p=document.createElement("div");p.className="column-resize-handle",!((a=$e.getState(n))===null||a===void 0)&&a.dragging&&t.push(re.node(s+d,s+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),t.push(re.widget(f,p))}}return Y.create(n.doc,t)}function xd({allowTableNodeSelection:n=!1}={}){return new _({key:Pt,state:{init(){return null},apply(e,t){let r=e.getMeta(Pt);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:o,pos:i}=e.mapping.mapResult(t);return o?null:i}},props:{decorations:py,handleDOMEvents:{mousedown:Iy},createSelectionBetween(e){return Pt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Ry,handleKeyDown:Dy,handlePaste:Py},appendTransaction(e,t,r){return gy(r,yy(r,t),n)}})}var $s,_s,ie,Pt,ee,fy,by,ex,tx,nx,Dy,Ks,$e,By,Js=P(()=>{"use strict";K();de();Rt();pt();Ye();if(typeof WeakMap<"u"){let n=new WeakMap;$s=e=>n.get(e),_s=(e,t)=>(n.set(e,t),t)}else{let n=[],t=0;$s=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},_s=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}ie=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){let t=this.map[e];if(t!=n)continue;let r=e%this.width,o=e/this.width|0,i=r+1,s=o+1;for(let l=1;i<this.width&&this.map[e+l]==t;l++)i++;for(let l=1;s<this.height&&this.map[e+this.width*l]==t;l++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){let{left:r,right:o,top:i,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[i*this.width+(t<0?r-1:o)]:(t<0?i==0:s==this.height)?null:this.map[r+this.width*(t<0?i-1:s)]}rectBetween(n,e){let{left:t,right:r,top:o,bottom:i}=this.findCell(n),{left:s,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(n){let e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){let i=r*this.width+o,s=this.map[i];t[s]||(t[s]=!0,!(o==n.left&&o&&this.map[i-1]==s||r==n.top&&r&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){let i=o+t.child(r).nodeSize;if(r==n){let s=e+n*this.width,l=(n+1)*this.width;for(;s<l&&this.map[s]<o;)s++;return s==l?i-1:this.map[s]}o=i}}static get(n){return $s(n)||_s(n,ry(n))}};Pt=new J("selectingCells");ee=class mt extends F{constructor(e,t=e){let r=e.node(-1),o=ie.get(r),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);let c=a.map(u=>{let d=r.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new Et(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Vs(r)&&Vs(o)&&Us(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?mt.rowSelection(r,o):i&&this.isColSelection()?mt.colSelection(r,o):new mt(r,o)}return H.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=ie.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a<o.bottom;a++){let c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){let f=t.map[u];if(i[f])continue;i[f]=!0;let p=t.findCell(f),h=e.nodeAt(f);if(!h)throw new RangeError(`No cell with offset ${f} found`);let m=o.left-p.left,g=p.right-o.right;if(m>0||g>0){let b=h.attrs;if(m>0&&(b=en(b,0,m)),g>0&&(b=en(b,b.colspan-g,g)),p.left<o.left){if(h=h.type.createAndFill(b),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else h=h.type.create(b,h.content)}if(p.top<o.top||p.bottom>o.bottom){let b={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(b):h=h.type.create(b,h.content)}c.push(h)}s.push(e.child(a).copy(A.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new O(A.from(l),1,1)}replace(e,t=O.empty){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:l,$to:a}=o[s],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),s?O.empty:t)}let i=F.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new O(A.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=ie.get(t),o=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),o+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=e.node(-1),o=ie.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.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])),s.bottom<o.height&&(e=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new mt(e,t)}isRowSelection(){let e=this.$anchorCell.node(-1),t=ie.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),i=t.colCount(this.$headCell.pos-r);if(Math.min(o,i)>0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof mt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=e.node(-1),o=ie.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.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])),s.right<o.width&&(e=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new mt(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new mt(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new mt(e.resolve(t),e.resolve(r))}getBookmark(){return new fy(this.$anchorCell.pos,this.$headCell.pos)}};ee.prototype.visible=!1;F.jsonID("cell",ee);fy=class sd{constructor(e,t){this.anchor=e,this.head=t}map(e){return new sd(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Us(t,r)?new ee(t,r):F.near(r,1)}};by=new J("fix-tables");ex=On("row",{useDeprecatedLogic:!0}),tx=On("column",{useDeprecatedLogic:!0}),nx=On("cell",{useDeprecatedLogic:!0});Dy=pr({ArrowLeft:Mo("horiz",-1),ArrowRight:Mo("horiz",1),ArrowUp:Mo("vert",-1),ArrowDown:Mo("vert",1),"Shift-ArrowLeft":Co("horiz",-1),"Shift-ArrowRight":Co("horiz",1),"Shift-ArrowUp":Co("vert",-1),"Shift-ArrowDown":Co("vert",1),Backspace:So,"Mod-Backspace":So,Delete:So,"Mod-Delete":So});Ks=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")),Ws(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,Ws(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};$e=new J("tableColumnResizing");By=class Ao{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta($e);if(r&&r.setHandle!=null)return new Ao(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new Ao(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Vs(e.doc.resolve(o))||(o=-1),new Ao(o,t.dragging)}return t}}});function Sd(n){let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Re(n){let e=Sd(n);return e===null||Uy.has(e)}function Pe(n){if(Ky.test(n.trim()))return!0;let e=Sd(n);return e===null||jy.has(e)}var Uy,jy,Ky,gt=P(()=>{"use strict";Uy=new Set(["http:","https:","mailto:","tel:"]),jy=new Set(["http:","https:","blob:"]),Ky=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i});function Qy(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}function Zy(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Md(n){let e=n.style.textAlign;return{align:Po.includes(e)?e:null,lineHeight:U.lineHeight(n.style.lineHeight),dir:Zy(n)}}function Cd(n){let e={};(n.dir==="rtl"||n.dir==="ltr")&&(e.dir=n.dir);let t=[],r=n.align;r&&Po.includes(r)&&t.push(`text-align: ${r};`);let o=U.lineHeight(n.lineHeight);return o&&t.push(`line-height: ${o};`),t.length&&(e.style=t.join(" ")),e}function Ad(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=ev[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function Td(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}function nv(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function Ie(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}function rv(n){let e=[],t=U.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}function iv(n){let e=rd({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>tn(t,n),setDOMAttr:(t,r)=>{let o=Ve(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>U.color(t.getAttribute("data-nova-cell-bg")??t.style.backgroundColor),setDOMAttr:(t,r)=>{let o=U.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return Nd.includes(o)?o:null},setDOMAttr:(t,r)=>{Nd.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=U.length(r.style.width)??U.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:tn(r,n)}}}],e.table.toDOM=t=>{let r=rv(t.attrs);return["table",{...Ve(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=u=>Math.min(ov,Math.max(1,Number.isFinite(u)?Math.floor(u):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(u=>u>0)){let u=c.reduce((f,p)=>f+p,0),d=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${u}px;${d}`}}return a}}return e}function tn(n,e){let t=[...n.classList].filter(r=>Od.test(r)&&e(r));return t.length?t.join(" "):null}function Ve(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>Od.test(t));return e.length?{class:e.join(" ")}:{}}function br(n){return n?{value:n}:!1}function Oo(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}function Ys(n={},e){let t=Object.entries(n.nodes??{}),r=Object.entries(n.marks??{});if(!t.length&&!r.length&&!e)return nn;let o=e?Dd(e):Gs,i=e?Rd(e):Xs;for(let[s]of t)if(s in Gs)throw new Error(`[nova] node "${s}" already exists in the base schema`);for(let[s]of r)if(s in Xs)throw new Error(`[nova] mark "${s}" already exists in the base schema`);return new jn({nodes:{...o,...Object.fromEntries(t)},marks:{...i,...Object.fromEntries(r)}})}var Po,Jy,Gy,Xy,Yy,U,Ed,Do,Ro,ev,tv,Nd,ov,Ld,Od,Lo,Dd,Gs,Rd,Xs,nn,et=P(()=>{"use strict";de();Js();gt();Po=["left","center","right","justify"],Jy=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,Gy=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,Xy=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,Yy=/^[\w\s,'"-]{1,200}$/;U={color:n=>typeof n=="string"&&Jy.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?Qy(n):null,length:n=>typeof n=="string"&&Gy.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&Xy.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&Yy.test(n.trim())?n.trim():null};Ed={align:{default:null},lineHeight:{default:null},dir:{default:null}},Do=["disc","circle","square"],Ro=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],ev={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};tv={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};Nd=["top","middle","bottom"];ov=100;Ld=()=>!1,Od=/^-?[_a-zA-Z][\w-]*$/;Lo={class:{default:null}},Dd=n=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...Ed,...Lo},parseDOM:[{tag:"p",getAttrs:e=>({...Md(e),class:tn(e,n)})}],toDOM:e=>["p",{...Ve(e.attrs.class),...Cd(e.attrs)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},...Ed,...Lo},parseDOM:[1,2,3,4,5,6].map(e=>({tag:`h${e}`,getAttrs:t=>({level:e,...Md(t),class:tn(t,n)})})),toDOM:e=>[`h${e.attrs.level}`,{...Ve(e.attrs.class),...Cd(e.attrs)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...Lo},parseDOM:[{tag:"blockquote",getAttrs:e=>({class:tn(e,n)})}],toDOM:e=>["blockquote",Ve(e.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:e=>({language:e.querySelector("code")?.className.match(/language-([\w-]+)/)?.[1]??null})}],toDOM:e=>["pre",["code",e.attrs.language?{class:`language-${e.attrs.language}`}:{},0]]},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null}},parseDOM:[{tag:"ul",getAttrs:e=>({listStyle:Ad(e,Do,"disc")})}],toDOM:e=>["ul",Td(e.attrs.listStyle,Do),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:e=>{let t=e.getAttribute("start");return{start:t?Number(t):1,listStyle:Ad(e,Ro,"decimal")}}}],toDOM:e=>["ol",{...e.attrs.start===1?{}:{start:e.attrs.start},...Td(e.attrs.listStyle,Ro)},0]},list_item:{content:"paragraph block*",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...Lo},parseDOM:[{tag:"img[src]",getAttrs:e=>{let t=e;return Pe(t.getAttribute("src")??"")?{src:t.getAttribute("src"),alt:t.getAttribute("alt"),title:t.getAttribute("title"),width:Ie(t.getAttribute("width")??t.style.width),height:Ie(t.getAttribute("height")??t.style.height),align:nv(t),class:tn(t,n)}:!1}}],toDOM:e=>{let{alt:t,title:r}=e.attrs,o=Pe(e.attrs.src)?e.attrs.src:"",i=Ie(e.attrs.width),s=Ie(e.attrs.height),l=tv[e.attrs.align];return["img",{src:o,...Ve(e.attrs.class),...t?{alt:t}:{},...r?{title:r}:{},...i?{width:String(i)}:{},...s?{height:String(s)}:{},...l?{style:l}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...iv(n)}),Gs=Dd(Ld),Rd=n=>({link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Re(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Re(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>br(U.color(e))},{tag:"font[color]",getAttrs:e=>br(U.color(e.getAttribute("color")))}],toDOM:e=>Oo("color",U.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>br(U.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>Oo("background-color",U.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>br(U.fontFamily(e))}],toDOM:e=>Oo("font-family",U.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>br(U.length(e))}],toDOM:e=>Oo("font-size",U.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=tn(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",Ve(e.attrs.class),0]}}),Xs=Rd(Ld);nn=new jn({nodes:Gs,marks:Xs})});var Vd={};He(Vd,{default:()=>pv});function _d(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.insertText(e).scrollIntoView()),n.focus()}var Fd,$d,fv,pv,qd=P(()=>{"use strict";j();Fd=M.dateTime,$d={en:{title:"Insert date/time",date:"Date",time:"Time",dateTime:"Date and time",long:"Long date"},ru:{title:"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0434\u0430\u0442\u0443/\u0432\u0440\u0435\u043C\u044F",date:"\u0414\u0430\u0442\u0430",time:"\u0412\u0440\u0435\u043C\u044F",dateTime:"\u0414\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F",long:"\u0414\u0430\u0442\u0430 \u043F\u0440\u043E\u043F\u0438\u0441\u044C\u044E"}},fv={date:{dateStyle:"short"},long:{dateStyle:"long"},time:{timeStyle:"short"},dateTime:{dateStyle:"short",timeStyle:"short"}};pv={name:"insertdatetime",toolbar:"insertdatetime",setup(n){let e=n.options.language??"en",t=$d[e.split("-")[0]]??$d.en,r=()=>n.options.pluginOptions?.insertdatetime?.now?.()??new Date,o=i=>new Intl.DateTimeFormat(e,fv[i]).format(r());n.ui.registry.addMenuItem("insertdatetime",{text:t.title,icon:Fd,onAction:i=>_d(i,o("dateTime"))}),n.ui.registry.addMenuButton("insertdatetime",{icon:Fd,tooltip:t.title,items:i=>["date","long","time","dateTime"].map(s=>{let l=o(s);return{id:s,label:`${t[s]}: ${l}`,onSelect:()=>_d(i,l)}})})}}});function hv(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}function Dn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}function jd(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 bv(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}function Kd(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}function Zs(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function Sv(n){return(e,t)=>{if(e.selection instanceof B&&e.selection.node.isBlock){let{$from:p}=e.selection;return!p.parentOffset||!Ct(e.doc,p.pos)?!1:(t&&t(e.tr.split(p.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof H||e.selection instanceof me)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let p=o.depth;;p--)if(o.node(p).isBlock){c=o.end(p)==o.pos+(o.depth-p),u=o.start(p)==o.pos-(o.depth-p),a=Zs(o.node(p-1).contentMatchAt(o.indexAfter(p-1)));let m=n&&n(o.parent,c,o);s.unshift(m||(c&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=o.pos,f=Ct(r.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Ct(r.doc,d,s.length,s)),!f)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let p=r.mapping.slice(i),h=p.map(o.before(l)),m=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(m.index(),m.index()+1,a)&&r.setNodeMarkup(p.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}function Ev(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Wt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Jd(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Ev(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,h=A.empty;for(let b=s.length-1;b>=0;b--)h=A.from(s[b].create(null,h));h=A.from(o.copy(h));let m=n.tr.step(new he(e.pos-1,p,e.pos,p,new O(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Wt(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:F.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&qt(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Dn(i,"start",!0)&&Dn(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let b=A.empty;for(let w=h.length-1;w>=0;w--)b=A.from(h[w].copy(b));let x=n.tr.step(new he(e.pos-h.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new O(b,h.length,0),0,!0));t(x.scrollIntoView())}return!0}}return!1}function Gd(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(H.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}function Ho(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&gn(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function tl(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function Nv(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Lv(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new Et(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new Et(r,o))}return e}function It(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!Nv(s.doc,u,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let d,f=s.tr;o||(u=Lv(u)),r?d=!u.some(p=>s.doc.rangeHasMark(p.$from.pos,p.$to.pos,n)):d=!u.every(p=>{let h=!1;return f.doc.nodesBetween(p.$from.pos,p.$to.pos,(m,g,b)=>{if(h)return!1;h=!n.isInSet(m.marks)&&!!b&&b.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,p.$from.pos-g),Math.min(m.nodeSize,p.$to.pos-g))))}),!h});for(let p=0;p<u.length;p++){let{$from:h,$to:m}=u[p];if(!d)f.removeMark(h.pos,m.pos,n);else{let g=h.pos,b=m.pos,x=h.nodeAfter,w=m.nodeBefore,E=i&&x&&x.isText?/^\s*/.exec(x.text)[0].length:0,D=i&&w&&w.isText?/\s*$/.exec(w.text)[0].length:0;g+E<b&&(g+=E,b-=D),f.addMark(g,b,n.create(e))}}l(f.scrollIntoView())}return!0}}function yr(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Ud,mv,gv,yv,vv,Bo,kv,el,wv,xv,Mv,Cv,Av,Tv,Qs,Wd,bt,Xd,Ov,Yd,zo=P(()=>{"use strict";Ye();de();K();Ud=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);mv=(n,e,t)=>{let r=hv(n,t);if(!r)return!1;let o=jd(r);if(!o){let s=r.blockRange(),l=s&&qt(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Jd(n,o,e,-1))return!0;if(r.parent.content.size==0&&(Dn(i,"end")||B.isSelectable(i)))for(let s=r.depth;;s--){let l=Xr(n.doc,r.before(s),r.after(s),O.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Dn(i,"end")?F.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):B.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};gv=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=jd(r)}let s=i&&i.nodeBefore;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};yv=(n,e,t)=>{let r=bv(n,t);if(!r)return!1;let o=Kd(r);if(!o)return!1;let i=o.nodeAfter;if(Jd(n,o,e,1))return!0;if(r.parent.content.size==0&&(Dn(i,"start")||B.isSelectable(i))){let s=Xr(n.doc,r.before(),r.after(),O.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Dn(i,"start")?F.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):B.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},vv=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Kd(r)}let s=i&&i.nodeAfter;return!s||!B.isSelectable(s)?!1:(e&&e(n.tr.setSelection(B.create(n.doc,i.pos)).scrollIntoView()),!0)};Bo=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&qt(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},kv=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
10
|
-
`).scrollIntoView()),!0)};el=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=Zs(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(F.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},wv=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof me||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Zs(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(H.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},xv=(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(Ct(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&qt(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};Mv=Sv(),Cv=(n,e)=>(e&&e(n.tr.setSelection(new me(n.doc))),!0);Av=Gd(-1),Tv=Gd(1);Qs=yr(Ud,mv,gv),Wd=yr(Ud,yv,vv),bt={Enter:yr(kv,wv,xv,Mv),"Mod-Enter":el,Backspace:Qs,"Mod-Backspace":Qs,"Shift-Backspace":Qs,Delete:Wd,"Mod-Delete":Wd,"Mod-a":Cv},Xd={"Ctrl-h":bt.Backspace,"Alt-Backspace":bt["Mod-Backspace"],"Ctrl-d":bt.Delete,"Ctrl-Alt-Backspace":bt["Mod-Delete"],"Alt-Delete":bt["Mod-Delete"],"Alt-d":bt["Mod-Delete"],"Ctrl-a":Av,"Ctrl-e":Tv};for(let n in bt)Xd[n]=bt[n];Ov=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Yd=Ov?Xd:bt});var Fo,be,Qd,Dv,nl,Zd=P(()=>{"use strict";Fo=200,be=function(){};be.prototype.append=function(e){return e.length?(e=be.from(e),!this.length&&e||e.length<Fo&&this.leafAppend(e)||this.length<Fo&&e.leafPrepend(this)||this.appendInner(e)):this};be.prototype.prepend=function(e){return e.length?be.from(e).append(this):this};be.prototype.appendInner=function(e){return new Dv(this,e)};be.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?be.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};be.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};be.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};be.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};be.from=function(e){return e instanceof be?e:e&&e.length?new Qd(e):be.empty};Qd=(function(n){function e(r){n.call(this),this.values=r}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,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Fo)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Fo)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})(be);be.empty=new Qd([]);Dv=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.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(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(be),nl=be});function Pv(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}function Bv(n,e,t,r){let o=t.getMeta(rn),i;if(o)return o.historyState;t.getMeta(rf)&&(n=new nt(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(rn))return s.getMeta(rn).redo?new nt(n.done.addTransform(t,void 0,r,$o(e)),n.undone,ef(t.mapping.maps),n.prevTime,n.prevComposition):new nt(n.done,n.undone.addTransform(t,void 0,r,$o(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Hv(t,n.prevRanges)),c=s?rl(n.prevRanges,t.mapping):ef(t.mapping.maps);return new nt(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,$o(e)),on.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new nt(n.done.rebased(t,i),n.undone.rebased(t,i),rl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new nt(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),rl(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Hv(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function ef(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function rl(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function zv(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof Vt||i instanceof Mt)&&(o=i.to)}if(o>-1)return F.near(n.doc.resolve(o))}return n.selection}function Fv(n,e,t){let r=$o(e),o=rn.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,zv(e,i.transform).getBookmark(),o,r),a=new nt(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(rn,{redo:t,historyState:a})}function $o(n){let e=n.plugins;if(tf!=e){ol=!1,tf=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){ol=!0;break}}return ol}function nf(n){return n.setMeta(rf,!0)}function of(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new _({key:rn,state:{init(){return new nt(on.empty,on.empty,null,0,-1)},apply(e,t,r){return Bv(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?il:r=="historyRedo"?sl:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function _o(n,e){return(t,r)=>{let o=rn.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=Fv(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var Rv,on,tt,nt,Iv,ol,tf,rn,rf,il,sl,Dx,Rx,Vo=P(()=>{"use strict";Zd();Ye();K();Rv=500,on=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new tt(d.map));let p=d.step.map(o.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new tt(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new tt(e.mapping.maps[u],d,t),p;(p=a&&a.merge(f))&&(f=p,u?i.pop():l=l.slice(0,l.length-1)),i.push(f),t&&(s++,t=void 0),o||(a=f)}let c=s-r.depth;return c>Iv&&(l=Pv(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new Yn;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new tt(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=t;this.items.forEach(f=>{let p=i.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=i.maps[p];if(f.step){let m=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(i.slice(a+1,p));g&&l++,r.push(new tt(h,m,g))}else r.push(new tt(h))},o);let c=[];for(let f=t;f<s;f++)c.push(new tt(i.maps[f]));let u=this.items.slice(0,o).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>Rv&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&i++;let d=new tt(c.invert(),a,u),f,p=o.length-1;(f=o.length&&o[p].merge(d))?o[p]=f:o.push(d)}}else s.map&&r--},this.items.length,0),new n(nl.from(o.reverse()),i)}};on.empty=new on(nl.empty,0);tt=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},nt=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Iv=20;ol=!1,tf=null;rn=new J("history"),rf=new J("closeHistory");il=_o(!1,!0),sl=_o(!0,!0),Dx=_o(!1,!1),Rx=_o(!0,!1)});function sf(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return $v(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function $v(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new $t(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new $t(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=gn(i,t,r,e);return l?(n&&_v(n,e,l,o,t),!0):!1}function _v(n,e,t,r,o){let i=A.empty;for(let u=t.length-1;u>=0;u--)i=A.from(t[u].type.create(t[u].attrs,i));n.step(new he(e.start-(r?2:0),e.end,e.start,e.end,new O(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&Ct(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Rn(n,e){return n instanceof lt?e==n:n.indexOf(e)>-1}function lf(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!Rn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!Rn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let d=A.empty,f=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-f;b>=o.depth-3;b--)d=A.from(o.node(b).copy(d));let p=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;d=d.append(A.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(f-1)),m=t.tr.replace(h,o.after(-p),new O(d,4-f,0)),g=-1;m.doc.nodesBetween(h,m.doc.content.size,(b,x)=>{if(g>-1)return!1;b.isTextblock&&b.content.size==0&&(g=x+1)}),g>-1&&m.setSelection(F.near(m.doc.resolve(g))),r(m.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return Ct(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function ll(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&Rn(n,s.firstChild.type));return i?t?Rn(n,r.node(i.depth-1).type)?Vv(e,t,i):qv(e,t,i):!0:!1}}function Vv(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new he(o-1,i,o,i,new O(A.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new $t(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=qt(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return Wt(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function qv(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,h=t.endIndex-1,m=t.startIndex;h>m;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.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),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?A.empty:A.from(o))))return!1;let d=i.pos,f=d+s.nodeSize;return r.step(new he(d-(l?1:0),f+(a?1:0),d+1,f-1,new O((l?A.empty:A.from(o.copy(A.empty))).append(a?A.empty:A.from(o.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function af(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&Rn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!Rn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?a.lastChild.lastChild.type.create():null),d=new O(A.from(a.type.create(null,A.from(l.type.create(null,u)))),c?3:1,0),f=i.start,p=i.end;t(e.tr.step(new he(f-(c?3:1),p,f,p,d,1,!0)).scrollIntoView())}return!0}}var al=P(()=>{"use strict";Ye();de();K()});function qo(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=G(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}function uf(n,e={}){let t=tl(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{}}));o(i.scrollIntoView())}return!0}}function Pn(n){return ln("heading",e=>uf(e,{level:n}))}function cf(n){return(e,t)=>rt(e,n)?ll(G(e).list_item)(e,t):sf(n)(e,t)}function df(n,e){return(t,r)=>Pe(n)?(r?.(t.tr.replaceSelectionWith(G(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function vr(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function rt(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function an(n){return n.selection.$from.parent.attrs.align??"left"}function ff(n,e){let t=n.selection.$from.parent,r=G(n),o=oe(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return vr(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return rt(n,r.blockquote);case"bulletList":return rt(n,r.bullet_list);case"orderedList":return rt(n,r.ordered_list);case"alignLeft":return an(n)==="left";case"alignCenter":return an(n)==="center";case"alignRight":return an(n)==="right";case"alignJustify":return an(n)==="justify";default:return!1}}function In(n){let{$from:e}=n.selection,t=oe(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function kr(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,u=i[i.length-1];u&&u.to===a?u.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var G,oe,ln,sn,Wv,Uv,jv,Q,Oe=P(()=>{"use strict";zo();Vo();al();gt();G=n=>n.schema.nodes,oe=n=>n.schema.marks,ln=(n,e)=>(t,r,o)=>e(G(t)[n])(t,r,o),sn=(n,e)=>(t,r,o)=>e(oe(t)[n])(t,r,o);Wv=(n,e)=>(e?.(n.tr.replaceSelectionWith(G(n).horizontal_rule.create()).scrollIntoView()),!0),Uv=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=oe(n);if(o){let l=kr(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},jv=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=oe(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};Q={bold:sn("bold",It),italic:sn("italic",It),underline:sn("underline",It),strike:sn("strike",It),code:sn("code",It),subscript:sn("subscript",It),superscript:sn("superscript",It),paragraph:ln("paragraph",n=>uf(n)),h1:Pn(1),h2:Pn(2),h3:Pn(3),h4:Pn(4),h5:Pn(5),h6:Pn(6),blockquote:(n,e)=>rt(n,G(n).blockquote)?Bo(n,e):Ho(G(n).blockquote)(n,e),codeBlock:ln("code_block",n=>tl(n)),bulletList:ln("bullet_list",cf),orderedList:ln("ordered_list",cf),indent:ln("list_item",af),outdent:ln("list_item",ll),alignLeft:qo(null),alignCenter:qo("center"),alignRight:qo("right"),alignJustify:qo("justify"),horizontalRule:Wv,unlink:Uv,clearFormatting:jv,undo:il,redo:sl}});function Bn(n){return Kv.test(n.type)}function Jv(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function pf(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===G(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function wr(n,e,t){let r=e.filter(Bn),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=G(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView());let c=n.options.uploadImage,u=c?n.ui.notify({text:n.ui.t("image.uploading"),timeout:0}):null;(c?c(i,f=>u?.setText(`${n.ui.t("image.uploading")} ${Math.round(f)}%`)):Jv(i)).then(f=>{if(!Pe(f))throw new Error(`Unsafe image URL returned: ${f}`);let p=pf(o,s);if(p===null)return;let h=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...h.attrs,src:f}).setMeta("addToHistory",!1))}).catch(f=>{console.error("[nova] image upload failed",f);let p=pf(o,s);p!==null&&o.dispatch(o.state.tr.delete(p,p+1).setMeta("addToHistory",!1)),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error"})}).finally(()=>{u?.close(),URL.revokeObjectURL(s)})}}function Gv(n,e="pasted-image"){let t=n.match(mf);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function Xv(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===G(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function Yv(n,e){let t=n.options.uploadImage,r=t?Gv(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!Pe(i))throw new Error(`Unsafe image URL returned: ${i}`);Xv(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error"})}finally{o.close()}}function hf(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&mf.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function gf(n){return new _({key:new J("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=G(r).image,s=hf(t.doc,i),l=[...hf(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{Yv(n,a)})),null}})}function bf(n){return new _({key:new J("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(Bn);return o.length?(wr(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(Bn);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return wr(n,r,o?.pos),!0}}})}function Wo(n){let{t:e}=n.ui,t=v("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1"}),r=v("button",{type:"button",className:"nova-dropzone"},X(M.upload),v("span",{},e("image.drop"))),o=ce({label:e("image.url"),type:"url",placeholder:"https://"}),i=ce({label:e("image.alt"),hint:e("image.altHint")});Nn(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=v("div",{className:"nova-form"},r,t,v("div",{className:"nova-divider"},v("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!Pe(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(df(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(Bn);u.length&&(l.close(),wr(n,u))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function cn(n){let{selection:e}=n;return e instanceof B&&e.node.type===G(n).image?{node:e.node,pos:e.from}:null}function xr(n){return(e,t)=>{let r=cn(e);if(!r)return!1;if(t){let o=e.tr.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n});o.setSelection(B.create(o.doc,r.pos)),t(o)}return!0}}function yf(n,e){let t=cn(n.view.state);if(!t)return!1;if(e===null)return n.exec(xr({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(xr({width:l,height:a?Math.round(l*a):null}))}function vf(n){let e=cn(n.view.state);if(!e)return;let{t}=n.ui,r=ce({label:t("image.alt"),value:e.node.attrs.alt??"",hint:t("image.altHint")}),o=ce({label:t("link.tooltip"),value:e.node.attrs.title??""});n.ui.openDialog({title:t("image.editAlt"),body:v("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(xr({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}var Kv,mf,Sr=P(()=>{"use strict";xo();K();Oe();Oe();At();Z();j();gt();Kv=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;mf=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i});function kf(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function cl(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?kr(n,oe(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function Qv(n){return(e,t)=>{let r=kf(n.href);if(!r||!Re(r))return!1;if(!t)return!0;let{from:o,to:i}=cl(e),s=oe(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let u=oe(e).link.removeFromSet(e.doc.resolve(o).marks()),d=e.schema.text(a??(l||r),s.addToSet(u));c.replaceWith(o,i,d)}else c.removeMark(o,i,oe(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function Mr(){return(n,e)=>{let{from:t,to:r}=cl(n);return t===r||!n.doc.rangeHasMark(t,r,oe(n).link)?!1:(e?.(n.tr.removeMark(t,r,oe(n).link)),!0)}}function ot(n){let{t:e}=n.ui,t=n.view.state,r=In(t),o=cl(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
|
|
11
|
-
`)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=ce({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=ce({label:e("link.text"),value:i}),c=ce({label:e("link.tooltip"),value:r?.title??""}),u=tc(e("link.newTab"),r?.target==="_blank");Nn(n,l,"file",f=>{f.text&&!a.input.value.trim()&&(a.input.value=f.text),f.title&&(c.input.value=f.title)});let d=v("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:d,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let f=kf(l.input.value);return!f||!Re(f)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),e("link.invalid")):(n.exec(Qv({href:f,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}var Hn=P(()=>{"use strict";xo();Oe();Oe();At();Z();gt()});function Zv(n,e,t=!0,r=nn){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let u=0;u<n;u++){let d=t&&u===0?l:s,f=[];for(let p=0;p<e;p++)f.push(d.create(null,a.create()));c.push(i.create(null,f))}return o.create(null,c)}function it(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||ne(r))return!1;if(o){let i=Zv(n,e,t,r.schema),s=r.tr.replaceSelectionWith(i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(H.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function wf(){return[kd({cellMinWidth:48,defaultCellMinWidth:48,View:ul}),xd(),Fe({Tab:e0,"Shift-Tab":No(-1)})]}function xf(n){return bd("background",n)}function Sf(n){if(!ne(n))return!1;let e=Ln(n.selection.$from)?.node.firstChild;if(!e||e.childCount===0)return!1;let t=!0;return e.forEach(r=>{r.type!==n.schema.nodes.table_header&&(t=!1)}),t}function Mf(n){if(!ne(n))return!1;let e=Ln(n.selection.$from)?.node;if(!e)return!1;let t=!0;return e.forEach(r=>{r.firstChild?.type!==n.schema.nodes.table_header&&(t=!1)}),t}function Cf(n){let{state:e}=n.view;if(!ne(e))return null;let t=Ln(e.selection.$from);return t?n.view.nodeDOM(t.pos)?.getBoundingClientRect()??null:null}function Ef(n,e,t){let r=1,o=1,i=[],s=v("div",{className:"nova-grid-caption","aria-live":"polite"}),l=v("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let u=Number(c.dataset.row),d=Number(c.dataset.col);c.classList.toggle("is-on",u<=r&&d<=o),c.tabIndex=u===r&&d===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=Cr;c++)for(let u=1;u<=Cr;u++){let d=v("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,u),"data-row":String(c),"data-col":String(u)});d.addEventListener("mouseenter",()=>{r=c,o=u,a()}),d.addEventListener("click",()=>n(c,u)),i.push(d),l.append(d)}return l.addEventListener("keydown",c=>{let d={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];d&&(c.preventDefault(),r=Math.min(Cr,Math.max(1,r+d[0])),o=Math.min(Cr,Math.max(1,o+d[1])),a(),i[(r-1)*Cr+(o-1)].focus())}),a(),v("div",{className:"nova-grid-panel"},l,s)}function t0(n){let e=n.replace(/\s/g,"").replace(/^[^\d+-]+|[^\d]+$/g,"").replace(/,(?=\d{3}(?:\D|$))/g,"").replace(",",".");return/^[+-]?\d+(\.\d+)?$/.test(e)?Number(e):null}function n0(n){if(!ne(n))return null;let e=_e(n),t=e.table,r=!1;if(t.descendants(s=>((s.attrs.colspan>1||s.attrs.rowspan>1)&&(r=!0),!r&&s.type.spec.tableRole!=="cell"&&s.type.spec.tableRole!=="header_cell")),r)return null;let o=n.schema.nodes,i=0;for(let s=0;s<t.childCount;s++){let l=!0;if(t.child(s).forEach(a=>{a.type!==o.table_header&&(l=!1)}),!l)break;i++}return t.childCount-i<2?null:{pos:e.tableStart-1,table:t,column:e.left,headerRows:i}}function dl(n,e){return(t,r)=>{let o=n0(t);if(!o)return!1;if(r){let{table:i,column:s,headerRows:l,pos:a}=o,c=[];i.forEach(x=>c.push(x));let u=c.slice(0,l),d=c.slice(l),f=d.map(x=>s<x.childCount?x.child(s).textContent.trim():""),p=f.map(t0),h=f.every((x,w)=>x===""||p[w]!==null),m=new Intl.Collator(e,{numeric:!0,sensitivity:"base"}),g=d.map((x,w)=>({row:x,i:w})).sort((x,w)=>{let E=f[x.i],D=f[w.i];if(!E||!D)return E?-1:D?1:x.i-w.i;let C=h?p[x.i]-p[w.i]:m.compare(E,D);return(n==="asc"?C:-C)||x.i-w.i}).map(({row:x})=>x),b=i.copy(A.from([...u,...g]));r(t.tr.replaceWith(a,a+i.nodeSize,b).scrollIntoView())}return!0}}function Af(n){let e=Ln(n.selection.$from);return e?{width:e.node.attrs.width??null,align:e.node.attrs.align??null,class:e.node.attrs.class??null}:null}function Tf(n){return(e,t)=>{let r=Ln(e.selection.$from);if(!r||n.width!==null&&!U.length(n.width))return!1;let o={...r.node.attrs,width:n.width,align:n.align};return n.class!==void 0&&(o.class=Ve(n.class).class??null),t?.(e.tr.setNodeMarkup(r.pos,void 0,o)),!0}}function Nf(n){let e=[];if(n.selection instanceof ee)return n.selection.forEachCell((r,o)=>e.push({node:r,pos:o})),e;let{$from:t}=n.selection;for(let r=t.depth;r>0;r--){let o=t.node(r),i=o.type.spec.tableRole;if(i==="cell"||i==="header_cell"){e.push({node:o,pos:t.before(r)});break}}return e}function Lf(n){let e=Nf(n)[0];if(!e)return null;let t=e.node.attrs.colwidth;return{valign:e.node.attrs.valign??null,header:e.node.type===n.schema.nodes.table_header,width:t?.[0]??null,class:e.node.attrs.class??null}}function Of(n){return(e,t)=>{let r=Nf(e);if(!r.length||n.width!=null&&!(n.width>=24&&n.width<=4e3))return!1;if(!t)return!0;let o=e.schema.nodes,i=e.tr;for(let{pos:s,node:l}of r){let a=n.header===void 0?l.type:n.header?o.table_header:o.table_cell,c={...l.attrs,...n.valign!==void 0?{valign:n.valign}:{},...n.class!==void 0?{class:Ve(n.class).class??null}:{}};i.setNodeMarkup(s,a,c)}if(n.width!==void 0){let s=_e(e),l=s.map,a=new Set;for(let c=s.left;c<s.right;c++)for(let u=0;u<l.height;u++){let d=l.map[u*l.width+c],f=d*1e3+c;if(a.has(f))continue;a.add(f);let p=s.tableStart+d,h=i.doc.nodeAt(p);if(!h)continue;let m=c-l.colCount(d),g=[...h.attrs.colwidth??new Array(h.attrs.colspan).fill(0)];g[m]=n.width??0,i.setNodeMarkup(p,void 0,{...h.attrs,colwidth:g.every(b=>!b)?null:g})}}return t(i),!0}}var Cr,e0,We,ul,zn=P(()=>{"use strict";pt();de();K();Js();et();Z();Cr=10;e0=(n,e,t)=>{if(!ne(n))return!1;if(No(1)(n,e,t)||!e)return!0;let r=n;return js(n,o=>{r=n.apply(o),e(o)}),No(1)(r,e,t)};We={addRowBefore:pd,addRowAfter:js,deleteRow:hd,addColumnBefore:cd,addColumnAfter:ud,deleteColumn:dd,mergeCells:md,splitCell:gd,toggleHeaderRow:On("row"),toggleHeaderColumn:On("column"),deleteTable:yd};ul=class extends Ks{constructor(e,t){super(e,t),this.apply(e)}update(e){return super.update(e)?(this.apply(e),!0):!1}apply(e){let t=U.length(e.attrs.width);t&&(this.table.style.width=t,this.table.style.minWidth="");let r=e.attrs.align;this.table.style.marginLeft=r?"auto":"",this.table.style.marginRight=r==="center"?"auto":"";let o=Ve(e.attrs.class).class;o?this.table.setAttribute("class",o):this.table.removeAttribute("class")}}});var Bf={};He(Bf,{DEFAULT_INSERT:()=>Rf,DEFAULT_SELECTION:()=>Df,default:()=>o0,hasTextSelection:()=>Pf,isOnEmptyLine:()=>If});function Pf(n){let{selection:e}=n.view.state;return!(e instanceof H)||e.empty||e.$from.parent.type.spec.code?!1:n.view.state.doc.textBetween(e.from,e.to).trim().length>0}function If(n){let{selection:e}=n.view.state;if(!e.empty)return!1;let{$from:t}=e;return t.depth===1&&t.parent.type===n.schema.nodes.paragraph&&t.parent.content.size===0&&!ne(n.view.state)}function r0(n){let e=document.createElement("input");e.type="file",e.accept="image/png,image/jpeg,image/gif,image/webp,image/avif",e.addEventListener("change",()=>{let t=[...e.files??[]].filter(Bn);t.length&&wr(n,t)}),e.click()}var Df,Rf,o0,Hf=P(()=>{"use strict";K();Sr();Hn();zn();j();Df="bold italic underline | quicklink h2 h3 blockquote",Rf="quickimage quicktable";o0={name:"quickbars",setup(n){let{registry:e,t}=n.ui,r=n.options.pluginOptions?.quickbars??{};e.addButton("quicklink",{icon:M.link,tooltip:t("link"),shortcut:"Mod-k",onAction:s=>ot(s)}),e.addButton("quickimage",{icon:M.image,tooltip:t("image"),onAction:s=>r0(s)}),e.addButton("quicktable",{icon:M.table,tooltip:t("table.insert"),onAction:s=>s.exec(it(2,2))});let o=r.selection===void 0?Df:r.selection;o&&e.addContextToolbar("quickbars-selection",{label:t("quickbars.selection"),predicate:Pf,items:o,position:"selection",placement:"top-start",priority:10});let i=r.insert===void 0?Rf:r.insert;i&&e.addContextToolbar("quickbars-insert",{label:t("quickbars.insert"),predicate:If,items:i,position:"selection",placement:"bottom-start"})}}});var Ff={};He(Ff,{default:()=>l0});var zf,i0,s0,l0,$f=P(()=>{"use strict";j();ke();zf=M.charmap,i0={en:{title:"Special character",search:"Search characters",empty:"Nothing found",groups:["Currency","Typography","Math","Arrows","Latin","Greek"]},ru:{title:"\u0421\u043F\u0435\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0441\u0438\u043C\u0432\u043E\u043B",search:"\u041F\u043E\u0438\u0441\u043A \u0441\u0438\u043C\u0432\u043E\u043B\u0430",empty:"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",groups:["\u0412\u0430\u043B\u044E\u0442\u044B","\u0422\u0438\u043F\u043E\u0433\u0440\u0430\u0444\u0438\u043A\u0430","\u041C\u0430\u0442\u0435\u043C\u0430\u0442\u0438\u043A\u0430","\u0421\u0442\u0440\u0435\u043B\u043A\u0438","\u041B\u0430\u0442\u0438\u043D\u0438\u0446\u0430","\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435"]}},s0=[[["\u20AC","euro"],["\xA3","pound"],["\xA5","yen"],["\u20BD","ruble"],["$","dollar"],["\xA2","cent"],["\u20B4","hryvnia"],["\u20B8","tenge"],["\u20B9","rupee"],["\u20A9","won"],["\u20BA","lira"],["\u20BF","bitcoin"]],[["\u2014","em dash"],["\u2013","en dash"],["\u2026","ellipsis"],["\xAB","left guillemet"],["\xBB","right guillemet"],["\u201E","low double quote"],["\u201C","left double quote"],["\u201D","right double quote"],["\u2018","left single quote"],["\u2019","right single quote apostrophe"],["\u2022","bullet"],["\xB7","middle dot"],["\xA7","section"],["\xB6","paragraph pilcrow"],["\u2020","dagger"],["\u2021","double dagger"],["\xA9","copyright"],["\xAE","registered"],["\u2122","trademark"],["\xB0","degree"],["\u2116","numero number"],["\u2030","per mille"],["\u2032","prime minutes"],["\u2033","double prime seconds"],["\xA1","inverted exclamation"],["\xBF","inverted question"]],[["\xB1","plus minus"],["\xD7","multiply times"],["\xF7","divide"],["\u2260","not equal"],["\u2248","approximately"],["\u2264","less or equal"],["\u2265","greater or equal"],["\u221E","infinity"],["\u221A","square root"],["\u2211","sum sigma"],["\u220F","product"],["\u222B","integral"],["\u2202","partial"],["\u2206","increment delta"],["\u2208","element of"],["\u2209","not element of"],["\u2229","intersection"],["\u222A","union"],["\u2282","subset"],["\u2200","for all"],["\u2203","exists"],["\xAC","not"],["\u2227","and"],["\u2228","or"],["\xBD","one half"],["\u2153","one third"],["\xBC","one quarter"],["\xBE","three quarters"],["\xB2","superscript two squared"],["\xB3","superscript three cubed"],["\xB5","micro"],["\u2030","per mille"]],[["\u2190","left arrow"],["\u2192","right arrow"],["\u2191","up arrow"],["\u2193","down arrow"],["\u2194","left right arrow"],["\u2195","up down arrow"],["\u21D0","left double arrow"],["\u21D2","right double arrow implies"],["\u21D4","left right double arrow iff"],["\u21A9","return arrow"],["\u2197","north east arrow"],["\u2198","south east arrow"]],[["\xE0","a grave"],["\xE1","a acute"],["\xE2","a circumflex"],["\xE4","a umlaut"],["\xE5","a ring"],["\xE6","ae ligature"],["\xE7","c cedilla"],["\xE9","e acute"],["\xE8","e grave"],["\xEA","e circumflex"],["\xEB","e umlaut"],["\xED","i acute"],["\xEF","i umlaut"],["\xF1","n tilde"],["\xF3","o acute"],["\xF4","o circumflex"],["\xF6","o umlaut"],["\xF8","o slash"],["\u0153","oe ligature"],["\xDF","sharp s eszett"],["\xFA","u acute"],["\xFC","u umlaut"],["\xFD","y acute"],["\u0142","l stroke"],["\u0161","s caron"],["\u017E","z caron"]],[["\u03B1","alpha"],["\u03B2","beta"],["\u03B3","gamma"],["\u03B4","delta"],["\u03B5","epsilon"],["\u03B8","theta"],["\u03BB","lambda"],["\u03BC","mu"],["\u03C0","pi"],["\u03C3","sigma"],["\u03C6","phi"],["\u03C9","omega"],["\u0394","capital delta"],["\u03A3","capital sigma"],["\u03A9","capital omega ohm"]]],l0={name:"charmap",toolbar:"charmap",setup(n){let e=V(n,i0),t=s0.map((o,i)=>({title:e.groups[i],items:o})),r=o=>Zr({groups:t,searchLabel:e.search,emptyText:e.empty,className:"nova-charmap",onPick:i=>{o(),vn(n,i)}});n.ui.registry.addPanelButton("charmap",{icon:zf,tooltip:e.title,isEnabled:o=>o.isEditable(),render:(o,i)=>r(i)}),n.ui.registry.addMenuItem("charmap",{text:e.title,icon:zf,onAction:()=>eo(n,e.title,r)})}}});var qf={};He(qf,{default:()=>c0});var _f,a0,Vf,c0,Wf=P(()=>{"use strict";j();ke();_f=M.emoji,a0={en:{title:"Emoji",search:"Search emoji",empty:"No emoji found",groups:["Smileys","Gestures","Hearts","Nature","Food","Activities","Objects","Symbols"]},ru:{title:"\u042D\u043C\u043E\u0434\u0437\u0438",search:"\u041F\u043E\u0438\u0441\u043A \u044D\u043C\u043E\u0434\u0437\u0438",empty:"\u042D\u043C\u043E\u0434\u0437\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B",groups:["\u0421\u043C\u0430\u0439\u043B\u044B","\u0416\u0435\u0441\u0442\u044B","\u0421\u0435\u0440\u0434\u0446\u0430","\u041F\u0440\u0438\u0440\u043E\u0434\u0430","\u0415\u0434\u0430","\u0417\u0430\u043D\u044F\u0442\u0438\u044F","\u041F\u0440\u0435\u0434\u043C\u0435\u0442\u044B","\u0421\u0438\u043C\u0432\u043E\u043B\u044B"]}},Vf=[[["\u{1F600}","grinning"],["\u{1F603}","smiley"],["\u{1F604}","smile"],["\u{1F601}","grin"],["\u{1F606}","laughing"],["\u{1F605}","sweat smile"],["\u{1F602}","joy tears"],["\u{1F642}","slight smile"],["\u{1F609}","wink"],["\u{1F60A}","blush"],["\u{1F607}","innocent halo"],["\u{1F60D}","heart eyes"],["\u{1F929}","star struck"],["\u{1F618}","kiss"],["\u{1F60B}","yum"],["\u{1F60E}","sunglasses cool"],["\u{1F914}","thinking"],["\u{1F610}","neutral"],["\u{1F60F}","smirk"],["\u{1F634}","sleeping"],["\u{1F62E}","open mouth surprised"],["\u{1F622}","cry sad"],["\u{1F62D}","sob"],["\u{1F621}","angry rage"],["\u{1F92F}","mind blown"],["\u{1F973}","party"],["\u{1F917}","hug"],["\u{1F644}","eye roll"],["\u{1F62C}","grimace"],["\u{1F913}","nerd"]],[["\u{1F44D}","thumbs up like yes"],["\u{1F44E}","thumbs down dislike no"],["\u{1F44F}","clap"],["\u{1F64C}","raised hands"],["\u{1F64F}","pray thanks please"],["\u{1F44B}","wave hello"],["\u270C\uFE0F","victory peace"],["\u{1F91D}","handshake deal"],["\u{1F4AA}","muscle strong"],["\u{1F44C}","ok"],["\u{1F91E}","fingers crossed"],["\u{1F449}","point right"],["\u{1F440}","eyes look"]],[["\u2764\uFE0F","red heart love"],["\u{1F9E1}","orange heart"],["\u{1F49B}","yellow heart"],["\u{1F49A}","green heart"],["\u{1F499}","blue heart"],["\u{1F49C}","purple heart"],["\u{1F5A4}","black heart"],["\u{1F494}","broken heart"],["\u{1F4AF}","hundred"],["\u2728","sparkles"],["\u{1F525}","fire hot"],["\u2B50","star"]],[["\u2600\uFE0F","sun"],["\u{1F319}","moon"],["\u26C5","cloud sun"],["\u{1F327}\uFE0F","rain"],["\u2744\uFE0F","snow"],["\u{1F308}","rainbow"],["\u{1F338}","blossom flower"],["\u{1F333}","tree"],["\u{1F340}","clover luck"],["\u{1F436}","dog"],["\u{1F431}","cat"],["\u{1F98A}","fox"],["\u{1F43B}","bear"],["\u{1F427}","penguin"],["\u{1F98B}","butterfly"]],[["\u{1F34E}","apple"],["\u{1F34C}","banana"],["\u{1F355}","pizza"],["\u{1F354}","burger"],["\u{1F370}","cake"],["\u{1F36A}","cookie"],["\u2615","coffee"],["\u{1F375}","tea"],["\u{1F37A}","beer"],["\u{1F377}","wine"],["\u{1F382}","birthday cake"]],[["\u26BD","soccer football"],["\u{1F3C0}","basketball"],["\u{1F3BE}","tennis"],["\u{1F3AE}","video game"],["\u{1F3B5}","music note"],["\u{1F3A8}","art palette"],["\u{1F389}","tada celebration"],["\u{1F381}","gift present"],["\u{1F3C6}","trophy winner"],["\u{1F680}","rocket launch"],["\u2708\uFE0F","airplane travel"]],[["\u{1F4A1}","bulb idea"],["\u{1F4CC}","pin"],["\u{1F4CE}","paperclip attachment"],["\u{1F4C5}","calendar date"],["\u{1F4C8}","chart up growth"],["\u{1F4C9}","chart down"],["\u{1F4DD}","memo note"],["\u{1F4DA}","books"],["\u{1F4BB}","laptop computer"],["\u{1F4F1}","phone mobile"],["\u{1F512}","lock secure"],["\u{1F511}","key"],["\u23F0","alarm clock"],["\u{1F4E7}","email mail"],["\u{1F4B0}","money bag"],["\u{1F6E0}\uFE0F","tools"]],[["\u2705","check done yes"],["\u274C","cross no"],["\u26A0\uFE0F","warning"],["\u2757","exclamation"],["\u2753","question"],["\u2795","plus"],["\u2796","minus"],["\u{1F534}","red circle"],["\u{1F7E2}","green circle"],["\u{1F535}","blue circle"],["\u2B06\uFE0F","up"],["\u2B07\uFE0F","down"],["\u{1F195}","new"],["\u{1F197}","ok button"]]],c0={name:"emoticons",toolbar:"emoticons",setup(n){let e=V(n,a0),t=Vf.map((i,s)=>({title:e.groups[s],items:i})),r=Vf.flat(),o=i=>Zr({groups:t,searchLabel:e.search,emptyText:e.empty,className:"nova-emoticons",onPick:s=>{i(),vn(n,s)}});n.ui.registry.addPanelButton("emoticons",{icon:_f,tooltip:e.title,isEnabled:i=>i.isEditable(),render:(i,s)=>o(s)}),n.ui.registry.addMenuItem("emoticons",{text:e.title,icon:_f,onAction:()=>eo(n,e.title,o)}),n.ui.registry.addAutocompleter("emoticons",{trigger:":",minChars:2,label:e.title,maxResults:8,fetch:i=>{let s=i.toLowerCase();return/^[a-z]+$/.test(s)?r.filter(([,l])=>l.split(" ").some(a=>a.startsWith(s))).map(([l,a])=>({value:l,label:a,icon:l})):[]},onSelect:(i,s,l)=>{let{state:a,dispatch:c}=l.view;c(a.tr.insertText(i.value,s.from,s.to).scrollIntoView())}})}}});var Kf={};He(Kf,{default:()=>d0});var Uf,jf,u0,d0,Jf=P(()=>{"use strict";j();pt();ke();Uf="\xA0",jf=M.nonBreaking,u0={en:{title:"Nonbreaking space"},ru:{title:"\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B"}},d0={name:"nonbreaking",toolbar:"nonbreaking",prosemirrorPlugins:()=>[Fe({"Mod-Shift-Space":(n,e)=>(e?.(n.tr.insertText(Uf).scrollIntoView()),!0)})],setup(n){let{title:e}=V(n,u0),t={icon:jf,tooltip:e,shortcut:"Mod-Shift-Space",isEnabled:()=>n.isEditable(),onAction:()=>vn(n,Uf)};n.ui.registry.addButton("nonbreaking",t),n.ui.registry.addMenuItem("nonbreaking",{text:e,icon:jf,onAction:t.onAction})}}});function f0(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}function Uo({rules:n}){let e=new _({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return Gf(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Gf(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Gf(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-p0),l.parentOffset,null,"\uFFFC")+r,u=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let d=0;d<o.length;d++){let f=o[d];if(!f.inCodeMark&&u.some(g=>g.type.spec.code))continue;if(l.parent.type.spec.code){if(!f.inCode)continue}else if(f.inCode==="only")continue;let p=f.match.exec(c);if(!p||p[0].length<r.length)continue;let h=e-(p[0].length-r.length);if(!f.inCodeMark){let g=!1;if(s.doc.nodesBetween(h,l.pos,b=>{b.isInline&&b.marks.some(x=>x.type.spec.code)&&(g=!0)}),g)continue}let m=f.handler(s,p,h,t,r);if(m)return f.undoable&&m.setMeta(i,{transform:m,from:e,to:t,text:r}),n.dispatch(m),!0}return!1}function jo(n,e,t,r){let o,i;return e instanceof lt?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new Ue(n,(s,l,a,c)=>{let u=t instanceof Function?t(l):t,d=s.tr.delete(a,c),f=d.doc.resolve(a),p=f.blockRange(),h=p&&gn(p,i,u);if(!h)return null;d.wrap(p,h);let m=d.doc.resolve(a-1).nodeBefore;return m&&m.type==i&&Wt(d.doc,a-1)&&(!r||r(l,m))&&d.join(a-1),d},o)}function fl(n,e,t){let r,o;return e instanceof lt?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new Ue(n,(i,s,l,a)=>{let c=i.doc.resolve(l),u=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,u):null},r)}var Ue,p0,Xf,Yf,TS,NS,LS,OS,pl=P(()=>{"use strict";K();Ye();de();Ue=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?f0(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};p0=500;Xf=new Ue(/--$/,"\u2014",{inCodeMark:!1}),Yf=new Ue(/\.\.\.$/,"\u2026",{inCodeMark:!1}),TS=new Ue(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),NS=new Ue(/"$/,"\u201D",{inCodeMark:!1}),LS=new Ue(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),OS=new Ue(/'$/,"\u2019",{inCodeMark:!1})});var ep={};He(ep,{default:()=>g0});function Zf(n){return/^www\./i.test(n)?`https://${n}`:/^[\w.+-]+@/.test(n)?`mailto:${n}`:n}function Qf(n,e,t){let r=n.doc.resolve(t);if(!r.parent.isTextblock||r.parent.type.spec.code)return!1;let i=r.parent.textBetween(0,r.parentOffset,void 0,"\uFFFC").match(h0);if(!i)return!1;let s=i[1],l=t-i[2].length,a=l-s.length,c=oe(n).link;if(n.doc.rangeHasMark(a,l,c))return!1;let u=Zf(s);return Re(u)?(e.addMark(a,l,c.create({href:u})),!0):!1}var h0,m0,g0,tp=P(()=>{"use strict";pl();K();Oe();gt();h0=/(?:^|[\s(])((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,;:!?)\]'"]|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)([.,;:!?)\]'"]*)$/i,m0=/^(?:https?:\/\/|www\.)\S+$|^mailto:\S+$/i;g0={name:"autolink",prosemirrorPlugins:n=>[Uo({rules:[new Ue(/\S\s$/,(e,t,r,o)=>{if(!n.isAllowed("link"))return null;let i=e.tr,s=r+t[0].length-1;return Qf(e,i,s)?i.insertText(t[0].slice(-1),o).removeStoredMark(oe(e).link):null})]}),new _({appendTransaction(e,t,r){if(!n.isAllowed("link")||!e.some(a=>a.docChanged))return null;let{$from:o,empty:i}=r.selection;if(!i||o.parentOffset!==0||o.depth<1)return null;let s=F.findFrom(r.doc.resolve(o.before()),-1,!0);if(!s||!s.empty||s.$from.parentOffset!==s.$from.parent.content.size)return null;let l=r.tr;return Qf(r,l,s.from)?l:null}}),new _({props:{handlePaste(e,t){let{state:r}=e;if(r.selection.empty||!n.isAllowed("link"))return!1;let o=(t.clipboardData?.getData("text/plain")??"").trim();if(!m0.test(o))return!1;let i=Zf(o);if(!Re(i))return!1;let{from:s,to:l}=r.selection,a=oe(r).link;return e.dispatch(r.tr.removeMark(s,l,a).addMark(s,l,a.create({href:i}))),!0}}})]}});var rp={};He(rp,{default:()=>v0});function y0(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}var np,b0,v0,op=P(()=>{"use strict";j();ke();np=M.save,b0={en:{restore:"Restore last draft",found:"An unsaved draft was found. Use \u201CRestore last draft\u201D to bring it back.",restored:"Draft restored"},ru:{restore:"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A",found:"\u041D\u0430\u0439\u0434\u0435\u043D \u043D\u0435\u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0439 \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A. \u0415\u0433\u043E \u043C\u043E\u0436\u043D\u043E \u0432\u0435\u0440\u043D\u0443\u0442\u044C \u043A\u043D\u043E\u043F\u043A\u043E\u0439 \xAB\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\xBB.",restored:"\u0427\u0435\u0440\u043D\u043E\u0432\u0438\u043A \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D"}};v0={name:"autosave",toolbar:"restoredraft",setup(n){let e=n.options.pluginOptions?.autosave??{},t=V(n,b0),r=y0(),o=e.key??`novaprose-draft:${typeof location>"u"?"":location.pathname}:${n.options.element.id||"editor"}`,i=e.delay??1e3,s=(e.retention??10080)*6e4,l=()=>{try{let h=JSON.parse(r?.getItem(o)??"null");return!h||typeof h.html!="string"||Date.now()-h.time>s?null:h}catch{return null}},a=l();a&&a.html===n.getHTML()&&(a=null),a&&n.ui.notify({text:t.found,timeout:8e3});let c,u=()=>{c=void 0;try{n.isEmpty()?r?.removeItem(o):r?.setItem(o,JSON.stringify({html:n.getHTML(),time:Date.now()}))}catch{}},d=n.on("change",()=>{a=null,clearTimeout(c),c=setTimeout(u,i)}),f=()=>{let h=a??l();h&&(n.setContent(h.html),a=null,n.ui.notify({text:t.restored}),n.focus())},p={icon:np,tooltip:t.restore,isEnabled:()=>n.isEditable()&&a!==null,onAction:f};return n.ui.registry.addButton("restoredraft",p),n.ui.registry.addMenuItem("restoredraft",{text:t.restore,icon:np,onAction:f}),()=>{d(),c!==void 0&&(clearTimeout(c),u())}}}});var ip={};He(ip,{default:()=>k0});var k0,sp=P(()=>{"use strict";k0={name:"autoresize",setup(n){let{minHeight:e,maxHeight:t}=n.options.pluginOptions?.autoresize??{},r=n.root.querySelector(".nova-content");if(r)return n.root.classList.add("nova-autoresize"),e!==void 0&&n.root.style.setProperty("--nova-min-height",`${e}px`),t!==void 0&&(r.style.maxHeight=`${t}px`),()=>{n.root.classList.remove("nova-autoresize"),n.root.style.removeProperty("--nova-min-height"),r.style.removeProperty("max-height")}}}});var ap={};He(ap,{default:()=>x0});var lp,w0,x0,cp=P(()=>{"use strict";j();ke();lp=M.visualBlocks,w0={en:{title:"Show blocks"},ru:{title:"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438"}},x0={name:"visualblocks",toolbar:"visualblocks",setup(n){let{title:e}=V(n,w0),t=n.options.pluginOptions?.visualblocks??{},r=()=>n.root.classList.contains("nova-visualblocks"),o=()=>{n.root.classList.toggle("nova-visualblocks"),n.updateUI(),n.focus()};return t.default&&n.root.classList.add("nova-visualblocks"),n.ui.registry.addToggleButton("visualblocks",{icon:lp,tooltip:e,isActive:r,onAction:o}),n.ui.registry.addToggleMenuItem("visualblocks",{text:e,icon:lp,isActive:r,onAction:o}),()=>n.root.classList.remove("nova-visualblocks")}}});var fp={};He(fp,{default:()=>C0});function M0(n){return n.view.state.selection.$from.parent.attrs.dir??null}function dp(n){return(e,t)=>{let{paragraph:r,heading:o}=G(e),i=e.tr,s=!1;return e.doc.nodesBetween(e.selection.from,e.selection.to,(l,a)=>l.type!==r&&l.type!==o?!0:(s=!0,i.setNodeMarkup(a,void 0,{...l.attrs,dir:n}),!1)),s?(t?.(i),!0):!1}}var up,S0,C0,pp=P(()=>{"use strict";j();Oe();ke();up={ltr:M.ltr,rtl:M.rtl},S0={en:{ltr:"Left to right",rtl:"Right to left"},ru:{ltr:"\u0421\u043B\u0435\u0432\u0430 \u043D\u0430\u043F\u0440\u0430\u0432\u043E",rtl:"\u0421\u043F\u0440\u0430\u0432\u0430 \u043D\u0430\u043B\u0435\u0432\u043E"}};C0={name:"directionality",toolbar:"ltr rtl",setup(n){let e=V(n,S0);for(let t of["ltr","rtl"]){let r=()=>M0(n)===t,o=()=>{n.exec(dp(r()?null:t)),n.focus()};n.ui.registry.addToggleButton(t,{icon:up[t],tooltip:e[t],isActive:r,isEnabled:i=>i.can(dp(t)),onAction:o}),n.ui.registry.addToggleMenuItem(t,{text:e[t],icon:up[t],isActive:r,onAction:o})}}}});var hp={};He(hp,{default:()=>T0});function hl(n,e){let{$from:t}=n.selection;for(let r=t.depth;r>0;r--){let o=t.node(r);if(o.type===e)return{pos:t.before(r),attrs:o.attrs}}return null}function A0(n,e,t,r){let o=()=>G(n.view.state)[e];hl(n.view.state,o())||n.exec(e==="bullet_list"?"bulletList":"orderedList");let i=hl(n.view.state,o());if(!i)return;let{state:s,dispatch:l}=n.view;l(s.tr.setNodeMarkup(i.pos,void 0,{...i.attrs,listStyle:t===r?null:t})),n.focus()}var E0,T0,mp=P(()=>{"use strict";Oe();et();ke();E0={en:{disc:"Default",circle:"Circle",square:"Square",decimal:"Default (1, 2, 3)","lower-alpha":"Lower alpha (a, b, c)","upper-alpha":"Upper alpha (A, B, C)","lower-roman":"Lower roman (i, ii, iii)","upper-roman":"Upper roman (I, II, III)","lower-greek":"Lower greek (\u03B1, \u03B2, \u03B3)"},ru:{disc:"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",circle:"\u041A\u0440\u0443\u0436\u043E\u043A",square:"\u041A\u0432\u0430\u0434\u0440\u0430\u0442",decimal:"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E (1, 2, 3)","lower-alpha":"\u0421\u0442\u0440\u043E\u0447\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (a, b, c)","upper-alpha":"\u041F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (A, B, C)","lower-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0435 (i, ii, iii)","upper-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u043F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 (I, II, III)","lower-greek":"\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435 (\u03B1, \u03B2, \u03B3)"}};T0={name:"advlist",setup(n){let e=V(n,E0),t=n.options.pluginOptions?.advlist??{},r=[{control:"bullist",kind:"bullet_list",styles:t.bullets??[...Do],fallback:"disc"},{control:"numlist",kind:"ordered_list",styles:t.numbers??[...Ro],fallback:"decimal"}];for(let{control:o,kind:i,styles:s,fallback:l}of r){let a=n.ui.registry.get(o);if(!a||a.type!=="button")continue;let{type:c,...u}=a;n.ui.registry.addSplitButton(o,{...u,items:d=>{let f=hl(d.view.state,G(d.view.state)[i]),p=f?.attrs.listStyle??(f?l:null);return s.map(h=>({id:h,label:e[h],active:p===h,onSelect:()=>A0(d,i,h,l)}))}})}}}});function Zo(n){gp.has(n)||(gp.add(n),console.warn(`[nova] formats: ${n}`))}function Je(n){return Array.isArray(n)?n.flatMap(Je):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function Er(n){let e=[];for(let t of n)e.push(...Je(t.classes)),"items"in t&&t.items&&e.push(...Er(t.items));return e}function Xo(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&Po.includes(r)?e.align=r:t==="line-height"&&U.lineHeight(r)?e.lineHeight=U.lineHeight(r):Zo(`style "${t}" is not supported on blocks`);return e}function bl(n,e){let t=oe(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[N0[e.inline]];i&&r.push(i.create())}let o=Je(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=L0[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):Zo(`style "${i}: ${s}" is not supported on text`)}return r}function ti(n,e){let t=[],r=a=>e.some(c=>Qo[c](a)),{selection:o}=n;if(o instanceof B&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(u=>u.pos===c)&&t.push({node:a,pos:c})}),t}function ml(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function yl(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function vp(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}function bp(n,e){return e.selector?ti(n,ei(e)).length>0:!0}function yp(n,e){return n.type.name==="image"?!0:Object.entries(Xo(e)).every(([t,r])=>n.attrs[t]===r)}function O0(n,e){let t=Je(e.classes);if(e.block){if(e.block==="blockquote"){let o=yl(n);return!!o&&Go(o.node.attrs.class,t)}let r=n.selection.$from.parent;return Qo[e.block](r)&&Go(r.attrs.class,t)&&yp(r,e)}if(e.selector){let r=ti(n,ei(e));return r.length>0&&r.some(({node:o})=>Go(o.attrs.class,t)&&yp(o,e))}if(e.inline){let r=bl(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let u=n.storedMarks??o.marks();return r.every(d=>u.some(f=>gl(f,d)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,u=>{u.isText&&(a=!0,r.every(d=>u.marks.some(f=>gl(f,d)))||(c=!1))}),a&&c}return!1}function gl(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?Go(n.attrs.class,Je(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function D0(n,e,t){let r=Je(t.classes),o=G(n);if(t.block==="blockquote"){let i=yl(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:Ko(i.node.attrs.class,r)}),!0):Ho(o.blockquote,{class:Ko(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of ml(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=Xo(t);for(let{node:a,pos:c}of ml(n)){if(a.type===o.code_block&&a.textContent.includes(`
|
|
12
|
-
`))continue;let u=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...vp(a.attrs),...i?{level:i}:{},...l,class:Ko(u?a.attrs.class:null,r)})}return!0}if(t.selector){let i=Xo(t),s=ti(n,ei(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:Ko(l.attrs.class,r)})}return n.selection instanceof B&&e.setSelection(B.create(e.doc,n.selection.from)),!0}if(t.inline){let i=bl(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let u of i)e.addMark(a.pos,c.pos,u);return!0}return!1}function R0(n,e,t){let r=Je(t.classes),o=G(n);if(t.block==="blockquote"){let i=yl(n);if(!i)return;let s=Jo(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}Bo(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of ml(n))Qo[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...vp(i.attrs),class:t.block==="p"?Jo(i.attrs.class,r):null});return}if(t.selector){let i=Xo(t);for(let{node:s,pos:l}of ti(n,ei(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:Jo(s.attrs.class,r)})}n.selection instanceof B&&e.setSelection(B.create(e.doc,n.selection.from));return}if(t.inline){let i=bl(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let u=(n.storedMarks??c.marks()).filter(d=>!i.some(f=>gl(d,f)));e.setStoredMarks(u);return}for(let u of i){if(u.type.name!=="span_class"){e.removeMark(l,a,u.type);continue}n.doc.nodesBetween(l,a,(d,f)=>{if(!d.isText)return;let p=d.marks.find(b=>b.type===u.type);if(!p)return;let h=Math.max(f,l),m=Math.min(f+d.nodeSize,a);e.removeMark(h,m,u.type);let g=Jo(p.attrs.class,Je(u.attrs.class));g&&e.addMark(h,m,u.type.create({class:g}))})}}}var N0,L0,Qo,gp,Go,Ko,Jo,ei,Yo,kp=P(()=>{"use strict";K();zo();Oe();et();N0={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},L0={color:{mark:"color",read:U.color},"background-color":{mark:"background",read:U.color},"font-family":{mark:"font_family",read:U.fontFamily},"font-size":{mark:"font_size",read:U.length}},Qo={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},gp=new Set;Go=(n,e)=>{let t=Je(n);return e.every(r=>t.includes(r))},Ko=(n,e)=>{let t=[...new Set([...Je(n),...e])];return t.length?t.join(" "):null},Jo=(n,e)=>{let t=Je(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};ei=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>Qo[e]?!0:(Zo(`selector "${e}" is not supported`),!1));Yo=class{constructor(e,t){this.editor=e;this.allowedClasses=t}editor;allowedClasses;registry=new Map;register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),Er(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||Zo(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>bp(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>O0(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>bp(this.editor.view.state,o))??t[0];return this.run((o,i)=>D0(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>R0(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}}});function B0(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function H0(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function z0(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function vl(n,e){let t=[];for(let{prelude:r,body:o}of B0(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(P0.test(r))t.push(`${r}{${o}}`);else if(I0.test(r))t.push(`${r}{${vl(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=H0(r).map(s=>z0(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
|
|
13
|
-
`)}function F0(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}async function kl(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=F0(await r.text(),t);if(e>=3)return o.replace(wp,"");let i=[...o.matchAll(wp)];for(let s of i){let l=s[3].trim(),a="";try{a=await kl(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function xp(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}var P0,I0,wp,Sp=P(()=>{"use strict";P0=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,I0=/^@(media|supports|container|layer|document|scope)\b/i;wp=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi});function Mp(n={}){return new _({view(e){return new wl(e,n)}})}var wl,Cp=P(()=>{"use strict";K();Ye();wl=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let p=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(p){let h=p.getBoundingClientRect(),m=d?h.bottom:h.top;d&&f&&(m=(m+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:m-g,bottom:m+g}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;r={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,p=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*p}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Gr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}});function Ep(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function $0(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||Ep(o.type))return!0;if(o.inlineContent)return!1}}return!0}function _0(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||Ep(o.type))return!0;if(o.inlineContent)return!1}}return!0}function Ap(){return new _({props:{decorations:U0,createSelectionBetween(n,e,t){return e.pos==t.pos&&Me.valid(t)?new Me(t):null},handleClick:q0,handleKeyDown:V0,handleDOMEvents:{beforeinput:W0}}})}function ni(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof H){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Me.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new Me(c))),!0):!1}}function q0(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!Me.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&B.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Me(r))),!0)}function W0(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Me))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=A.empty;for(let s=r.length-1;s>=0;s--)o=A.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new O(o,0,0));return i.setSelection(H.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function U0(n){if(!(n.selection instanceof Me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",Y.create(n.doc,[re.widget(n.selection.head,e,{key:"gapcursor"})])}var Me,xl,V0,Tp=P(()=>{"use strict";pt();K();de();Rt();Me=class n extends F{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):F.near(r)}content(){return O.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new xl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!$0(e)||!_0(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!B.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};Me.prototype.visible=!1;Me.findFrom=Me.findGapCursorFrom;F.jsonID("gapcursor",Me);xl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return Me.valid(t)?new Me(t):F.near(t)}};V0=pr({ArrowLeft:ni("horiz",-1),ArrowRight:ni("horiz",1),ArrowUp:ni("vert",-1),ArrowDown:ni("vert",1)})});var ri,Np=P(()=>{"use strict";ri={"toolbar.label":"Formatting","toolbar.options":"options","editor.label":"Rich text editor","editor.required":"Please fill in this field.",undo:"Undo",redo:"Redo",bold:"Bold",italic:"Italic",underline:"Underline",strike:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",link:"Link",unlink:"Remove link",image:"Image",bulletList:"Bulleted list",orderedList:"Numbered list",indent:"Increase indent",outdent:"Decrease indent",align:"Alignment",alignLeft:"Align left",alignCenter:"Align center",alignRight:"Align right",alignJustify:"Justify",blockquote:"Quote",codeBlock:"Code block",horizontalRule:"Horizontal line",clearFormatting:"Clear formatting",more:"More",moreFormats:"More formatting",blocks:"Text style",styles:"Formats","styles.headings":"Headings","styles.inline":"Inline","styles.blocks":"Blocks","styles.align":"Align",paragraph:"Paragraph",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",fontFamily:"Font",fontSize:"Font size",lineHeight:"Line height",default:"Default",textColor:"Text color",backgroundColor:"Highlight color",removeColor:"Remove color",customColor:"Custom color","dialog.cancel":"Cancel","dialog.save":"Save","dialog.insert":"Insert","dialog.close":"Close","link.title":"Insert link","link.editTitle":"Edit link","link.url":"URL","link.text":"Text to display","link.tooltip":"Title (tooltip)","link.newTab":"Open in new tab","link.open":"Open link","link.edit":"Edit link","link.copy":"Copy link","link.copied":"Link copied","link.invalid":"This URL is not allowed","image.title":"Insert image","image.url":"Image URL","image.alt":"Alternative text","image.altHint":"Describe the image for people using screen readers","image.upload":"Upload","image.drop":"Drop an image here or click to choose","image.uploading":"Uploading image\u2026","image.uploadFailed":"Image upload failed","image.invalid":"This image URL is not allowed","image.or":"or","image.toolbar":"Image options","image.alignLeft":"Float left","image.alignCenter":"Center","image.alignRight":"Float right","image.editAlt":"Alternative text","image.size":"Size","image.sizeSmall":"Small (25%)","image.sizeMedium":"Medium (50%)","image.sizeLarge":"Large (75%)","image.sizeFull":"Full width","image.sizeOriginal":"Original size","image.delete":"Remove image","status.words":"{count} words","status.resize":"Resize editor","dialog.browse":"Browse",pasteAsText:"Paste as text","menu.label":"Menu","menu.file":"File","menu.edit":"Edit","menu.view":"View","menu.insert":"Insert","menu.format":"Format","menu.table":"Table","menu.help":"Help",selectAll:"Select all",print:"Print","table.rows":"Rows","table.cols":"Columns","table.invalidSize":"Enter a number from 1 to 50","quickbars.selection":"Quick formatting","quickbars.insert":"Quick insert","search.title":"Find and replace","search.find":"Find","search.replace":"Replace with","search.next":"Next match","search.prev":"Previous match","search.replaceOne":"Replace","search.replaceAll":"Replace all","search.matchCase":"Match case","search.wholeWord":"Whole words only","search.count":"{current} of {total}","search.none":"No results",fullscreen:"Fullscreen",preview:"Preview",sourceCode:"Source code",help:"Keyboard shortcuts","help.formatting":"Text formatting","help.blocks":"Paragraphs and lists","help.editing":"Editing","help.navigation":"Navigation","help.slash":"Insert block (slash commands)","help.toMenubar":"Move to the menu bar","help.toToolbar":"Move to the toolbar","help.toContextToolbar":"Move to the image/table toolbar","help.toEditor":"Back to the text","help.nextCell":"Next table cell",table:"Table","table.insert":"Insert table","table.size":"{rows} \xD7 {cols}","table.toolbar":"Table options","table.rowBefore":"Insert row above","table.rowAfter":"Insert row below","table.rowDelete":"Delete row","table.colBefore":"Insert column left","table.colAfter":"Insert column right","table.colDelete":"Delete column","table.merge":"Merge cells","table.split":"Split cell","table.rowHeader":"Header row","table.colHeader":"Header column","table.cellBackground":"Cell background","table.delete":"Delete table","table.sort":"Sort","table.sortAsc":"Sort A \u2192 Z, 1 \u2192 9","table.sortDesc":"Sort Z \u2192 A, 9 \u2192 1","table.props":"Table properties","table.style":"Style","table.styleDefault":"Default","table.width":"Width","table.widthHint":"For example 100% or 600px. Leave empty to fit the content.","table.invalidWidth":"Enter a width such as 100% or 600px","table.align":"Alignment on the page","table.alignDefault":"Default","table.alignCenter":"Center","table.alignRight":"Right","table.cellProps":"Cell properties","table.valign":"Vertical alignment","table.valignTop":"Top","table.valignMiddle":"Middle","table.valignBottom":"Bottom","table.cellType":"Cell type","table.cellData":"Data cell","table.cellHeader":"Header cell","table.colWidth":"Column width, px","table.colWidthHint":"Leave empty to fit the content.","table.invalidColWidth":"Enter a number from 24 to 4000","slash.label":"Commands","slash.empty":"No matching commands"}});var Lp,Op=P(()=>{"use strict";Lp={"toolbar.label":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","toolbar.options":"\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B","editor.label":"\u0422\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440","editor.required":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u044D\u0442\u043E \u043F\u043E\u043B\u0435.",undo:"\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",redo:"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",bold:"\u0416\u0438\u0440\u043D\u044B\u0439",italic:"\u041A\u0443\u0440\u0441\u0438\u0432",underline:"\u041F\u043E\u0434\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",strike:"\u0417\u0430\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",code:"\u041A\u043E\u0434 \u0432 \u0441\u0442\u0440\u043E\u043A\u0435",subscript:"\u041F\u043E\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",superscript:"\u041D\u0430\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",link:"\u0421\u0441\u044B\u043B\u043A\u0430",unlink:"\u0423\u0431\u0440\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443",image:"\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",bulletList:"\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",orderedList:"\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",indent:"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",outdent:"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",align:"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",alignLeft:"\u041F\u043E \u043B\u0435\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignCenter:"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443",alignRight:"\u041F\u043E \u043F\u0440\u0430\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignJustify:"\u041F\u043E \u0448\u0438\u0440\u0438\u043D\u0435",blockquote:"\u0426\u0438\u0442\u0430\u0442\u0430",codeBlock:"\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430",horizontalRule:"\u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u043B\u0438\u043D\u0438\u044F",clearFormatting:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",more:"\u0415\u0449\u0451",moreFormats:"\u0415\u0449\u0451 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",blocks:"\u0421\u0442\u0438\u043B\u044C \u0442\u0435\u043A\u0441\u0442\u0430",styles:"\u0424\u043E\u0440\u043C\u0430\u0442\u044B","styles.headings":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438","styles.inline":"\u0422\u0435\u043A\u0441\u0442","styles.blocks":"\u0411\u043B\u043E\u043A\u0438","styles.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",paragraph:"\u041E\u0431\u044B\u0447\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442",h1:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1",h2:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2",h3:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3",h4:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4",h5:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 5",h6:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 6",fontFamily:"\u0428\u0440\u0438\u0444\u0442",fontSize:"\u0420\u0430\u0437\u043C\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430",lineHeight:"\u041C\u0435\u0436\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B",default:"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",textColor:"\u0426\u0432\u0435\u0442 \u0442\u0435\u043A\u0441\u0442\u0430",backgroundColor:"\u0426\u0432\u0435\u0442 \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u044F",removeColor:"\u0423\u0431\u0440\u0430\u0442\u044C \u0446\u0432\u0435\u0442",customColor:"\u0421\u0432\u043E\u0439 \u0446\u0432\u0435\u0442","dialog.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","dialog.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","dialog.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C","dialog.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","link.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.editTitle":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.url":"\u0410\u0434\u0440\u0435\u0441","link.text":"\u0422\u0435\u043A\u0441\u0442 \u0441\u0441\u044B\u043B\u043A\u0438","link.tooltip":"\u041F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430 (title)","link.newTab":"\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435","link.open":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.edit":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copy":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copied":"\u0421\u0441\u044B\u043B\u043A\u0430 \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0430","link.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.url":"\u0410\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.altHint":"\u041E\u043F\u0438\u0448\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044E\u0449\u0438\u0445 \u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0434\u0438\u043A\u0442\u043E\u0440","image.upload":"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C","image.drop":"\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0441\u044E\u0434\u0430 \u0438\u043B\u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0432\u044B\u0431\u0440\u0430\u0442\u044C","image.uploading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F\u2026","image.uploadFailed":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.or":"\u0438\u043B\u0438","image.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alignLeft":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043B\u0435\u0432\u0430","image.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","image.alignRight":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043F\u0440\u0430\u0432\u0430","image.editAlt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.size":"\u0420\u0430\u0437\u043C\u0435\u0440","image.sizeSmall":"\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439 (25%)","image.sizeMedium":"\u0421\u0440\u0435\u0434\u043D\u0438\u0439 (50%)","image.sizeLarge":"\u0411\u043E\u043B\u044C\u0448\u043E\u0439 (75%)","image.sizeFull":"\u0412\u043E \u0432\u0441\u044E \u0448\u0438\u0440\u0438\u043D\u0443","image.sizeOriginal":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440","image.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","status.words":"\u0421\u043B\u043E\u0432: {count}","status.resize":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0440\u0430\u0437\u043C\u0435\u0440 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0430","dialog.browse":"\u041E\u0431\u0437\u043E\u0440",pasteAsText:"\u0412\u0441\u0442\u0430\u0432\u043B\u044F\u0442\u044C \u043A\u0430\u043A \u0442\u0435\u043A\u0441\u0442","menu.label":"\u041C\u0435\u043D\u044E","menu.file":"\u0424\u0430\u0439\u043B","menu.edit":"\u041F\u0440\u0430\u0432\u043A\u0430","menu.view":"\u0412\u0438\u0434","menu.insert":"\u0412\u0441\u0442\u0430\u0432\u043A\u0430","menu.format":"\u0424\u043E\u0440\u043C\u0430\u0442","menu.table":"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","menu.help":"\u0421\u043F\u0440\u0430\u0432\u043A\u0430",selectAll:"\u0412\u044B\u0434\u0435\u043B\u0438\u0442\u044C \u0432\u0441\u0451",print:"\u041F\u0435\u0447\u0430\u0442\u044C","table.rows":"\u0421\u0442\u0440\u043E\u043A\u0438","table.cols":"\u0421\u0442\u043E\u043B\u0431\u0446\u044B","table.invalidSize":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 1 \u0434\u043E 50","quickbars.selection":"\u0411\u044B\u0441\u0442\u0440\u043E\u0435 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","quickbars.insert":"\u0411\u044B\u0441\u0442\u0440\u0430\u044F \u0432\u0441\u0442\u0430\u0432\u043A\u0430","search.title":"\u041D\u0430\u0439\u0442\u0438 \u0438 \u0437\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.find":"\u041D\u0430\u0439\u0442\u0438","search.replace":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430","search.next":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.prev":"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.replaceOne":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.replaceAll":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u0432\u0441\u0435","search.matchCase":"\u0423\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u0440\u0435\u0433\u0438\u0441\u0442\u0440","search.wholeWord":"\u0422\u043E\u043B\u044C\u043A\u043E \u0441\u043B\u043E\u0432\u043E \u0446\u0435\u043B\u0438\u043A\u043E\u043C","search.count":"{current} \u0438\u0437 {total}","search.none":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",fullscreen:"\u041D\u0430 \u0432\u0435\u0441\u044C \u044D\u043A\u0440\u0430\u043D",preview:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",sourceCode:"HTML-\u043A\u043E\u0434",help:"\u0413\u043E\u0440\u044F\u0447\u0438\u0435 \u043A\u043B\u0430\u0432\u0438\u0448\u0438","help.formatting":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0442\u0435\u043A\u0441\u0442\u0430","help.blocks":"\u0410\u0431\u0437\u0430\u0446\u044B \u0438 \u0441\u043F\u0438\u0441\u043A\u0438","help.editing":"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","help.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","help.slash":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0431\u043B\u043E\u043A (\u0441\u043B\u044D\u0448-\u043A\u043E\u043C\u0430\u043D\u0434\u044B)","help.toMenubar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0433\u043B\u0430\u0432\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","help.toToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u0432","help.toContextToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438/\u0442\u0430\u0431\u043B\u0438\u0446\u044B","help.toEditor":"\u0412\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F \u0432 \u0442\u0435\u043A\u0441\u0442","help.nextCell":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u044F\u0447\u0435\u0439\u043A\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B",table:"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","table.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.size":"{rows} \xD7 {cols}","table.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.rowBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0432\u044B\u0448\u0435","table.rowAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u043D\u0438\u0436\u0435","table.rowDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443","table.colBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043B\u0435\u0432\u0430","table.colAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043F\u0440\u0430\u0432\u0430","table.colDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446","table.merge":"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438","table.split":"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443","table.rowHeader":"\u0421\u0442\u0440\u043E\u043A\u0430 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.colHeader":"\u0421\u0442\u043E\u043B\u0431\u0435\u0446 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.cellBackground":"\u0424\u043E\u043D \u044F\u0447\u0435\u0439\u043A\u0438","table.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.sort":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0430","table.sortAsc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0410 \u2192 \u042F, 1 \u2192 9","table.sortDesc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u042F \u2192 \u0410, 9 \u2192 1","table.props":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.style":"\u0421\u0442\u0438\u043B\u044C","table.styleDefault":"\u041E\u0431\u044B\u0447\u043D\u044B\u0439","table.width":"\u0428\u0438\u0440\u0438\u043D\u0430","table.widthHint":"\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 100% \u0438\u043B\u0438 600px. \u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidWidth":"\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0448\u0438\u0440\u0438\u043D\u0443, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 100% \u0438\u043B\u0438 600px","table.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435 \u043D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435","table.alignDefault":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","table.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.alignRight":"\u0421\u043F\u0440\u0430\u0432\u0430","table.cellProps":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u044F\u0447\u0435\u0439\u043A\u0438","table.valign":"\u0412\u0435\u0440\u0442\u0438\u043A\u0430\u043B\u044C\u043D\u043E\u0435 \u0432\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435","table.valignTop":"\u0421\u0432\u0435\u0440\u0445\u0443","table.valignMiddle":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.valignBottom":"\u0421\u043D\u0438\u0437\u0443","table.cellType":"\u0422\u0438\u043F \u044F\u0447\u0435\u0439\u043A\u0438","table.cellData":"\u041E\u0431\u044B\u0447\u043D\u0430\u044F","table.cellHeader":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A","table.colWidth":"\u0428\u0438\u0440\u0438\u043D\u0430 \u0441\u0442\u043E\u043B\u0431\u0446\u0430, px","table.colWidthHint":"\u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidColWidth":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 24 \u0434\u043E 4000","slash.label":"\u041A\u043E\u043C\u0430\u043D\u0434\u044B","slash.empty":"\u041D\u0435\u0442 \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438\u0445 \u043A\u043E\u043C\u0430\u043D\u0434"}});function Rp(n="en",e={}){let t=n.toLowerCase(),r=Dp[t]??Dp[t.split("-")[0]]??ri,o={...ri,...r,...e};return(i,s)=>{let l=o[i]??i;return s?l.replace(/\{(\w+)\}/g,(a,c)=>String(s[c]??`{${c}}`)):l}}var Dp,Pp=P(()=>{"use strict";Np();Op();Dp={en:ri,ru:Lp}});function Ip(n=()=>!0,e=nn){let{nodes:t}=e,r=[Yf,Xf];n("blockquote")&&r.push(jo(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(jo(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(jo(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(fl(/^```$/,t.code_block));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(fl(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return Uo({rules:r})}var Bp=P(()=>{"use strict";pl();et()});function Hp(n=e=>Q[e]){let e={"Mod-z":Sl(n,"undo"),"Shift-Mod-z":Sl(n,"redo"),"Mod-b":Q.bold,"Mod-i":Q.italic,"Mod-u":Q.underline,"Mod-Shift-x":Q.strike,"Mod-e":Q.code,"Mod-,":Q.subscript,"Mod-.":Q.superscript,"Mod-Alt-0":Q.paragraph,"Mod-Alt-1":Q.h1,"Mod-Alt-2":Q.h2,"Mod-Alt-3":Q.h3,"Mod-Alt-4":Q.h4,"Mod-Alt-5":Q.h5,"Mod-Alt-6":Q.h6,"Mod-Shift-7":Q.orderedList,"Mod-Shift-8":Q.bulletList,"Mod-Shift-l":Q.alignLeft,"Mod-Shift-e":Q.alignCenter,"Mod-Shift-r":Q.alignRight,"Mod-Shift-j":Q.alignJustify,"Mod-\\":Q.clearFormatting,"Shift-Enter":K0,Enter:(t,r)=>lf(G(t).list_item)(t,r),Tab:Q.indent,"Shift-Tab":Q.outdent};return j0||(e["Mod-y"]=Sl(n,"redo")),[Fe(e),Fe(Yd)]}var j0,K0,Sl,zp=P(()=>{"use strict";zo();pt();al();Oe();j0=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),K0=yr(el,(n,e)=>(e?.(n.tr.replaceSelectionWith(G(n).hard_break.create()).scrollIntoView()),!0)),Sl=(n,e)=>(t,r,o)=>n(e)(t,r,o)});function J0(n){return/data-pm-slice=/.test(n)?"nova":/<google-sheets-html-origin|data-sheets-(root|value)/i.test(n)?"google-sheets":/id="docs-internal-guid-/.test(n)?"google-docs":/urn:schemas-microsoft-com:office:excel|ProgId"?\s+content="?Excel\.Sheet/i.test(n)?"excel":/urn:schemas-microsoft-com:office:word|class="?Mso|mso-list:|content="?Microsoft Word/i.test(n)?"word":/class="[^"]*\b(TextRun|OutlineElement|EOP|SCXW\d+|BCX\d+)\b|data-ccp-props|paraid=/.test(n)?"word-online":/content="?LibreOffice|content="?OpenOffice/i.test(n)?"libreoffice":"web"}function Vp(n,e="clean"){let t=J0(n);if(t==="nova")return n;let r=document.createElement("template");r.innerHTML=n;let o=document.createElement("div");return o.append(r.content),G0(o),Y0(o),t==="word"&&o1(o),t==="google-docs"&&c1(o),l1(o),u1(o),o.querySelectorAll("[style]").forEach(i=>p1(i,e)),e==="clean"&&h1(o),m1(o),g1(o),b1(o),y1(o),t!=="web"&&o.querySelectorAll("[class]").forEach(i=>i.removeAttribute("class")),o.innerHTML}function Ml(n){let e=new Map;for(let t of n.split(";")){let r=t.indexOf(":");if(r<0)continue;let o=t.slice(0,r).trim().toLowerCase(),i=t.slice(r+1).trim().replace(/\s*!important$/i,"");o&&i&&e.set(o,i)}return e}function qp(n){return[...n].map(([e,t])=>`${e}: ${t}`).join("; ")}function G0(n){let e=[...n.querySelectorAll("style")].map(o=>o.textContent??"");if(!e.length)return;let t=[],r=e.join(`
|
|
14
|
-
`).replace(/\/\*[\s\S]*?\*\//g,"").replace(/<!--|-->/g,"");for(let o of r.matchAll(/([^{}@]+)\{([^{}]*)\}/g)){let i=Ml(o[2]);for(let s of o[1].split(",")){let l=s.trim().match(/^([a-z][a-z0-9]*)?\.([\w-]+)$/i);l&&t.push({tag:(l[1]??"").toLowerCase(),cls:l[2],decls:i})}}t.length&&n.querySelectorAll("[class]").forEach(o=>{let i=o.className.split(/\s+/).filter(Boolean),s=new Map;for(let l of t)i.includes(l.cls)&&(l.tag&&l.tag!==o.tagName.toLowerCase()||l.decls.forEach((a,c)=>s.set(c,a)));s.size&&(Ml(o.getAttribute("style")??"").forEach((l,a)=>s.set(a,l)),o.setAttribute("style",qp(s)))})}function Y0(n){let e=document.createTreeWalker(n,NodeFilter.SHOW_COMMENT),t=[];for(;e.nextNode();)t.push(e.currentNode);t.forEach(r=>r.parentNode?.removeChild(r));for(let r of[...n.querySelectorAll("*")]){if(!n.contains(r))continue;let o=r.tagName.toUpperCase();if(X0.test(o)){r.remove();continue}if(o.includes(":")){let i=o.split(":")[0];i==="O"||i==="V"?r.remove():Fn(r)}}n.querySelectorAll("span.EOP").forEach(r=>{/^\s*$/.test(r.textContent??"")&&r.remove()}),n.querySelectorAll("a").forEach(r=>{let o=r.getAttribute("href")??"",i=o.match(/^https?:\/\/(www\.)?google\.[a-z.]+\/url\?(.*)$/i);if(i){let s=new URLSearchParams(i[2]).get("q");s&&r.setAttribute("href",s)}(!o||/^#_(ftn|edn|msocom|Toc|Ref)/i.test(o))&&Fn(r)}),n.querySelectorAll('br[style*="page-break"]').forEach(r=>r.remove()),n.querySelectorAll('[style*="mso-element:footnote-list"], [style*="mso-element:comment-list"], [style*="mso-element:endnote-list"]').forEach(r=>r.remove())}function Z0(n){let t=(n.getAttribute("style")??"").match(/mso-list:\s*(l\d+)\s+level(\d+)/i);if(!t)return null;let r=[...n.querySelectorAll("[style]")].find(a=>/mso-list:\s*Ignore/i.test(a.getAttribute("style")??"")),o=(r?.textContent??"").replace(/\s+/g,"");r?.remove();let i=Q0.test(o),{style:s,start:l}=i?n1(o):{style:r1(o),start:1};return{el:n,level:Math.max(1,Math.min(9,Number(t[2]))),ordered:i,start:l,style:s}}function t1(n){let e=0,t=n.toLowerCase();for(let r=0;r<t.length;r++){let o=Fp[t[r]],i=Fp[t[r+1]??""]??0;e+=o<i?-o:o}return e}function n1(n){let e=n.match(/\d+/);if(e)return{style:null,start:Number(e[0])};let t=n.replace(/[^a-z]/gi,"");return e1.test(t)?{style:t===t.toLowerCase()?"lower-roman":"upper-roman",start:t1(t)}:{style:t===t.toLowerCase()?"lower-alpha":"upper-alpha",start:t.toLowerCase().charCodeAt(0)-96}}function r1(n){return n==="o"?"circle":/^[§▪■]$/.test(n)?"square":null}function o1(n){let e=[...n.querySelectorAll("p, div, h1, h2, h3, h4, h5, h6")].filter(o=>/mso-list:\s*l\d+\s+level\d+/i.test(o.getAttribute("style")??""));for(let o of e.filter(i=>/^H[1-6]$/.test(i.tagName)))o.querySelectorAll("[style]").forEach(i=>{if(!/mso-list:\s*Ignore/i.test(i.getAttribute("style")??""))return;let s=(i.textContent??"").replace(/\s+/g,"");i.replaceWith(i.ownerDocument.createTextNode(`${s} `))});let t=e.filter(o=>!/^H[1-6]$/.test(o.tagName)),r=new Set;for(let o of t){if(r.has(o))continue;let i=[],s=o;for(;s instanceof HTMLElement&&t.includes(s);){let l=Z0(s);if(!l)break;i.push(l),r.add(s),s=Wp(s)}i.length&&i1(i)}}function Wp(n){let e=n.nextSibling;for(;e&&e.nodeType===Node.TEXT_NODE&&!e.textContent?.trim();)e=e.nextSibling;return e instanceof Element?e:null}function i1(n){let e=n[0].el.ownerDocument,t=n[0].el,r=[],o=null;for(let i of n){for(;r.length&&r[r.length-1].level>i.level;)r.pop();let s=r[r.length-1];if(!s||s.level<i.level){let c=e.createElement(i.ordered?"ol":"ul");i.ordered&&i.start!==1&&c.setAttribute("start",String(i.start)),i.style&&(c.style.listStyleType=i.style),s?(s.list.lastElementChild??s.list.appendChild(e.createElement("li"))).appendChild(c):o=c,s={list:c,level:i.level},r.push(s)}let l=e.createElement("li"),a=e.createElement("p");for(;i.el.firstChild;)a.appendChild(i.el.firstChild);l.appendChild(a),s.list.appendChild(l)}t.replaceWith(o),n.slice(1).forEach(i=>i.el.remove())}function s1(n){let e=n.getAttribute("aria-level")??n.getAttribute("data-aria-level"),t=e?Number(e):NaN;return Number.isFinite(t)&&t>=1?Math.min(9,t):null}function l1(n){n.querySelectorAll("div").forEach(r=>{let o=r.children.length===1?r.firstElementChild:null;o&&/^(UL|OL)$/.test(o.tagName)&&!r.textContent?.replace(o.textContent??"","").trim()&&Fn(r)}),n.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol").forEach(r=>{let o=r.previousElementSibling;o?.tagName==="LI"&&o.appendChild(r)});let e=[...n.querySelectorAll("ul, ol")].filter(r=>!r.parentElement?.closest("ul, ol")&&r.querySelector("li[aria-level], li[data-aria-level]")),t=new Set;for(let r of e){if(t.has(r)||!n.contains(r))continue;let o=[],i=r;for(;i&&/^(UL|OL)$/.test(i.tagName);){t.add(i),Up(i,1,o);let l=Wp(i);i!==r&&i.remove(),i=l}if(!o.length)continue;let s=r.ownerDocument.createElement("div");r.replaceWith(s),a1(o,s)}}function Up(n,e,t){for(let r of[...n.children]){if(r.tagName!=="LI")continue;let o=s1(r)??e,i=[...r.children].filter(l=>/^(UL|OL)$/.test(l.tagName));i.forEach(l=>l.remove());let s=r.ownerDocument.createElement("div");for(;r.firstChild;)s.appendChild(r.firstChild);t.push({el:s,level:o,ordered:n.tagName==="OL",start:Number(n.getAttribute("start")??1)||1}),i.forEach(l=>Up(l,o+1,t))}}function a1(n,e){let t=e.ownerDocument,r=[],o=null;for(let i of n){for(;r.length&&r[r.length-1].level>i.level;)r.pop();let s=r[r.length-1];if(!s||s.level<i.level){let a=t.createElement(i.ordered?"ol":"ul");i.ordered&&i.start!==1&&!s&&a.setAttribute("start",String(i.start)),s?(s.list.lastElementChild??s.list.appendChild(t.createElement("li"))).appendChild(a):o=a,s={list:a,level:i.level},r.push(s)}let l=t.createElement("li");for(;i.el.firstChild;)l.appendChild(i.el.firstChild);s.list.appendChild(l)}e.replaceWith(o)}function c1(n){n.querySelectorAll('[id^="docs-internal-guid-"]').forEach(Fn),n.querySelectorAll('li[role="checkbox"]').forEach(e=>{e.removeAttribute("role"),e.removeAttribute("aria-checked")})}function u1(n){n.querySelectorAll('p.MsoTitle, p[class*="Title"]').forEach(e=>{/\bMsoTitle\b|^Title$/.test(e.className)&&v1(e,"h1")}),n.querySelectorAll('div.WordSection1, div[class^="WordSection"], div.Section1').forEach(Fn)}function p1(n,e){let t=Ml(n.getAttribute("style")??""),r=new Map;t.forEach((s,l)=>{if(l.startsWith("mso-")){l==="mso-highlight"&&!$p.test(s)&&!t.has("background-color")&&r.set("background-color",s);return}if(!(l.startsWith("-webkit-")||l.startsWith("-moz-"))){if(l==="background"){let a=s.split(/\s+/)[0];/^(#[0-9a-f]{3,8}|rgba?\([^)]*\)|[a-z]+)$/i.test(a)&&!r.has("background-color")&&r.set("background-color",a);return}if(l==="text-decoration"||l==="text-decoration-line"){/underline/.test(s)?r.set("text-decoration","underline"):/line-through/.test(s)&&r.set("text-decoration","line-through");return}e==="clean"&&f1.test(l)||e==="clean"&&l==="vertical-align"&&/^(TD|TH)$/.test(n.tagName)||r.set(l,s)}});let o=r.get("color");o&&d1.test(o.trim())&&e==="clean"&&r.delete("color");let i=r.get("background-color");i&&$p.test(i.trim())&&r.delete("background-color"),r.get("font-weight")==="normal"&&n.tagName!=="B"&&r.delete("font-weight"),r.get("font-style")==="normal"&&r.delete("font-style"),r.get("text-decoration")==="none"&&r.delete("text-decoration"),r.get("vertical-align")==="baseline"&&r.delete("vertical-align"),/^(left|start)$/i.test(r.get("text-align")??"")&&r.delete("text-align"),e==="clean"&&n.closest("a")&&(r.delete("color"),r.get("text-decoration")==="underline"&&r.delete("text-decoration")),r.size?n.setAttribute("style",qp(r)):n.removeAttribute("style")}function h1(n){n.querySelectorAll("table, tr, td, th, col, colgroup").forEach(e=>{e.removeAttribute("width"),e.removeAttribute("height"),e.removeAttribute("valign")})}function m1(n){for(let e of[...n.querySelectorAll("span, font")].reverse()){if(!n.contains(e))continue;e.hasAttribute("style")||e.tagName==="FONT"&&e.hasAttribute("color")||Fn(e)}n.querySelectorAll("[class]").forEach(e=>e.removeAttribute("class")),n.querySelectorAll("[lang]").forEach(e=>e.removeAttribute("lang")),n.querySelectorAll("[dir]").forEach(e=>{/^rtl$/i.test(e.getAttribute("dir")??"")||e.removeAttribute("dir")})}function g1(n){n.querySelectorAll("br").forEach(e=>{let t=e.parentElement;if(!t||!(t===n||t.tagName==="DIV"||t.tagName==="TD"||t.tagName==="LI"))return;let r=_p(e,-1),o=_p(e,1);(r&&Cl.test(r.tagName)||o&&Cl.test(o.tagName)||!r&&!o&&t===n)&&e.remove()})}function _p(n,e){let t=e<0?n.previousSibling:n.nextSibling;for(;t&&t.nodeType===Node.TEXT_NODE&&!t.textContent?.trim();)t=e<0?t.previousSibling:t.nextSibling;return t instanceof Element?t:null}function b1(n){n.querySelectorAll("p").forEach(e=>{e.children.length===0&&/^\s*$/.test(e.textContent??"")&&(e.textContent="")})}function y1(n){n.querySelectorAll("td, th").forEach(e=>{let t=e.style.textAlign,r=[...e.children].some(i=>Cl.test(i.tagName));if(!t||r||!e.textContent?.trim())return;let o=e.ownerDocument.createElement("p");for(o.style.textAlign=t;e.firstChild;)o.appendChild(e.firstChild);e.appendChild(o),e.style.removeProperty("text-align"),e.getAttribute("style")||e.removeAttribute("style")})}function Fn(n){let e=n.parentNode;if(e){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}}function v1(n,e){let t=n.ownerDocument.createElement(e);for(let r of[...n.attributes])t.setAttribute(r.name,r.value);for(;n.firstChild;)t.appendChild(n.firstChild);return n.replaceWith(t),t}var X0,Q0,e1,Fp,d1,$p,f1,Cl,jp=P(()=>{"use strict";X0=/^(STYLE|SCRIPT|META|LINK|TITLE|XML|HEAD|NOSCRIPT|TEMPLATE)$/;Q0=/^[([]?(\d+(\.\d+)*[.)\]]?|[a-z]{1,4}[.)\]])$/i;e1=/^(i|ii|iii|iv|v|vi|vii|viii|ix|x|xi|xii)$/i,Fp={i:1,v:5,x:10};d1=/^(black|windowtext|auto|#000|#000000|rgb\(0,\s*0,\s*0\)|initial|inherit)$/i,$p=/^(transparent|white|window|auto|none|#fff|#ffffff|rgba?\(255,\s*255,\s*255(,\s*1)?\)|rgba\(\d+,\s*\d+,\s*\d+,\s*0\)|initial|inherit)$/i,f1=/^(font|font-family|font-size|line-height|margin|margin-.+|padding|padding-.+|text-indent|letter-spacing|word-spacing|white-space|height|width|min-height|border|border-.+|tab-stops|layout-grid-mode|page-break-.+|break-.+|orphans|widows|direction|unicode-bidi|font-variant.*|text-transform)$/i;Cl=/^(P|DIV|H[1-6]|UL|OL|TABLE|BLOCKQUOTE|PRE|HR)$/});function k1(n,e){let t=0;for(let r=e;r<n.length;r++){let o=n[r];if(o==="\\"){r++;continue}if(o==="{")t++;else if(o==="}"&&(t--,t===0))return r}return-1}function w1(n){let e="",t=0;for(let r=0;r<n.length;r++){let o=n[r];if(o==="\\"){t===0&&(e+=o+(n[r+1]??"")),r++;continue}o==="{"?t++:o==="}"?t--:t===0&&(e+=o)}return e}function S1(n){if(n.length%2!==0||n.length/2>x1||!/^[0-9a-f]+$/i.test(n))return null;let e="";for(let t=0;t<n.length;t+=2)e+=String.fromCharCode(parseInt(n.slice(t,t+2),16));return btoa(e)}function Kp(n){let e=[],t=0;for(;;){let r=n.indexOf("{\\pict",t);if(r<0)break;let o=k1(n,r);if(o<0)break;if(t=o+1,/\\nonshppict\s*$/.test(n.slice(Math.max(0,r-16),r)))continue;let i=w1(n.slice(r+1,o)),s=/\\pngblip(?![a-z])/.test(i)?"image/png":/\\jpegblip(?![a-z])/.test(i)?"image/jpeg":null;if(!s)continue;let l=i.replace(/\\[a-z]+-?\d* ?/gi,"").replace(/\s+/g,""),a=S1(l);if(!a)continue;let c=atob(a.slice(0,12));(s==="image/png"?c.startsWith("\x89PNG"):c.charCodeAt(0)===255&&c.charCodeAt(1)===216)&&e.push({type:s,base64:a})}return e}function Jp(n){return/<img[^>]+src=["']?file:/i.test(n)}function Gp(n,e){let t=document.createElement("template");t.innerHTML=n;let r=[...t.content.querySelectorAll("img")].filter(o=>/^file:/i.test(o.getAttribute("src")??""));return!r.length||r.length!==e.length?n:(r.forEach((o,i)=>{let s=e[i];o.setAttribute("src",`data:${s.type};base64,${s.base64}`)}),t.innerHTML)}var x1,Xp=P(()=>{"use strict";x1=20*1024*1024});function C1(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
|
|
8
|
+
`);return{dom:a,text:p,slice:e}}function cs(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",p=>{e=p(e,i||r,n)}),i)return l=new D(A.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
9
|
+
`))),0,0),n.someProp("transformPasted",p=>{l=p(l,n,!0)}),l;let d=n.someProp("clipboardTextParser",p=>p(e,o,r,n));if(d)l=d;else{let p=o.marks(),{schema:f}=n.state,h=Le.fromSchema(f);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let m=s.appendChild(document.createElement("p"));g&&m.appendChild(h.serializeNode(f.text(g,p)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),s=rm(t),Zr&&om(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&!H(p);)p=p.nextSibling;if(!p)break;s=p}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Qe.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!em.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)l=im(Jc(l,+u[1],+u[2]),u[4]);else if(l=D.maxOpen(tm(l.content,o),!0),l.openStart||l.openEnd){let d=0,p=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;p<l.openEnd&&!f.type.spec.isolating;p++,f=f.lastChild);l=Jc(l,d,p)}return n.someProp("transformPasted",d=>{l=d(l,n,r)}),l}var em=/^(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 tm(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,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&Nu(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Ou(s[s.length-1],i.length));let u=Tu(l,a);s.push(u),o=o.matchType(u.type),i=a}}),s)return A.from(s)}return n}function Tu(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,A.from(n));return n}function Nu(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let i=Nu(n,e,t,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(A.from(Tu(t,n,o+1))))}}function Ou(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Ou(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(A.empty,!0);return n.copy(t.append(r))}function Xi(n,e,t,r,o,i){let s=e<0?n.firstChild:n.lastChild,l=s.content;return n.childCount>1&&(i=0),o<r-1&&(l=Xi(l,e,t,r,o+1,i)),o>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(A.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Jc(n,e,t){return e<n.openStart&&(n=new D(Xi(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new D(Xi(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}var Du={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Lu(){return document.implementation.createHTMLDocument("title")}var jn=null;function nm(n){let e=window.trustedTypes;if(!e)return n;if(!jn){if(jn=e.defaultPolicy)try{return jn.createHTML(n)}catch{}jn=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})}return jn.createHTML(n)}function rm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Lu(),r=t.body,o=/<([a-z][^>\s]+)/i.exec(n),i;if((i=o&&Du[o[1].toLowerCase()])&&(n=i.map(s=>"<"+s+">").join("")+n+i.map(s=>"</"+s+">").reverse().join("")),r.innerHTML=nm(n),i)for(let s=0;s<i.length;s++)r=r.querySelector(i[s])||r;for(let s=0;s<t.styleSheets.length;s++){let l=t.styleSheets[s];for(let a=0;a<l.rules.length;a++){let c=l.rules[a];if(c instanceof CSSStyleRule){let u=r.querySelectorAll(c.selectorText);for(let d=0;d<u.length;d++)u[d].style.cssText+=c.style.cssText}}}return r}function om(n){let e=n.querySelectorAll(Se?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent=="\xA0"&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function im(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:i,openEnd:s}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs()||!a.createAndFill(null,o))break;try{o=A.from(a.create(r[l+1],o))}catch{break}i++,s++}return new D(o,i,s)}var Ne=class n{constructor(e,t,r,o){this.anchorNode=e,this.anchorOffset=t,this.focusNode=r,this.focusOffset=o}static from(e){return e instanceof n?e:new n(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset)}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};Ne.null=new Ne(null,0,null,0);var Qi=class{constructor(e){this.view=e,this.range=Ne.null,this.active=!1,this.synced=!1,this.suppress=!1,this.currentDocument=null,this.onSelectionChange=this.onSelectionChange.bind(this)}ensureListener(){let e=this.view.dom.ownerDocument;e!=this.currentDocument&&(this.currentDocument&&this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=e,e.addEventListener("selectionchange",this.onSelectionChange))}destroy(){this.currentDocument&&(this.currentDocument.removeEventListener("selectionchange",this.onSelectionChange),this.currentDocument=null),this.active=!1,this.range=Ne.null}suppressChanges(){this.suppress=!0,setTimeout(()=>this.suppress=!1,50)}onSelectionChange(){if(this.suppress&&this.view.hasFocus())return this.sync();this.read()&&this.view.domObserver.flush(!1)}readRange(){let{view:e}=this,t=e.dom.isConnected!==!1&&e.domSelection();return t?we&&e.root.nodeType===11&&Ch(e.dom.ownerDocument)==e.dom?Ne.from(sm(e,t)||t):Ne.from(t):Ne.null}read(){this.ensureListener();let e=Iu(this.view);if(!e){this.active=!1,this.range=Ne.null;return}return this.active=!0,this.range.eq(e)?!1:(this.range=e,this.synced=!1,!0)}sync(e=!1){let{view:t}=this;t.docView&&(this.ensureListener(),t.domObserver.stopped(()=>{dm(t,t.state.selection);let r=t.state.selection;if(t.input.mouseDown||Ru(t)){let{desc:o,start:i}=Pu(t.docView,r.from,r.to,0);t.cursorWrapper?um(t):o instanceof Kr&&o.spec.setSelection?o.spec.setSelection(r.anchor-i,r.head-i,t.root):lm(t,e,o,i),this.synced=this.active=!0}r.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),cm(t))),this.range=this.readRange()}))}ignore(e=this.readRange()){this.range=Ne.from(e),this.synced=!0}deactivate(){this.range=Ne.null,this.active=this.synced=!1}};function sm(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Gc(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Gc(n,t):null}function Gc(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=n.domAtPos(n.state.selection.anchor);return Vr(s.node,s.offset,o,i)&&([t,r,o,i]=[o,i,t,r]),new Ne(t,r,o,i)}function us(n,e,t=null){let r=n.state.doc;if(!e.focusNode)return null;let o=n.docView.nearestDesc(e.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(e.focusNode,e.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Qr(e)){for(a=s;o&&!o.node;)o=o.parent;if(o&&o.node.isAtom&&P.isSelectable(o.node)&&o.parent&&!(o.node.isInline&&wh(e.focusNode,e.focusOffset,o.dom))){let d=o.posBefore;c=new P(s==d?l:r.resolve(d))}else if(Ie&&t=="key"&&s>n.state.selection.to&&H(e.focusNode)&&e.focusOffset==e.focusNode.childNodes.length&&o&&o.posAtStart>n.state.selection.to)for(let d=e.focusNode;;d=d.parentNode){if(getComputedStyle(d).overflow!="visible"){c=F.findFrom(r.resolve(o.posAtStart),1);break}if(d==o.dom||d.nextSibling||!d.parentNode||!H(d.parentNode))break}}else{if(e instanceof n.dom.ownerDocument.defaultView.Selection&&e.rangeCount>1){let d=s,p=s;for(let f=0;f<e.rangeCount;f++){let h=e.getRangeAt(f);d=Math.min(d,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),p=Math.max(p,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(d<0)return null;[a,s]=p==n.state.selection.anchor?[p,d]:[d,p],l=r.resolve(s)}else a=n.docView.posFromDOM(e.anchorNode,e.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=t=="pointer"||n.state.selection.head<l.pos&&!i?1:-1;c=pn(n,u,l,d)}return c}function Ru(n){return n.editable?n.hasFocus():Hu(n,n.domSel.readRange())&&(!document.activeElement||document.activeElement.contains(n.dom))}function lm(n,e,t,r){let o=n.state.selection,{anchor:i,head:s}=o,l,a;Yc&&!(o instanceof I)&&(o.$from.parent.inlineContent||(l=Xc(n,o.from)),!o.empty&&!o.$from.parent.inlineContent&&(a=Xc(n,o.to)));let c=t.domFromPos(i-r,i>r?-1:1),u=s==i?c:t.domFromPos(s-r,s>r?-1:1);am(i,s,c,u,n,e),Yc&&(l&&Qc(l),a&&Qc(a))}function Pu(n,e,t,r=0){for(let o=0,i=r;o<n.children.length;o++){let s=n.children[o],l=i+s.size;if(e>i&&t<l)return Pu(s,e,t,i+s.border);i=l}return{desc:n,start:r}}function am(n,e,t,r,o,i){let s=!1;if((Ie||we)&&n==e){let{node:a,offset:c}=t;if(de(a)){if(s=!!(c&&a.nodeValue[c-1]==`
|
|
10
|
+
`),s&&c==a.nodeValue.length)for(let u=a,d;u;u=u.parentNode){if(d=u.nextSibling){d.nodeName=="BR"&&(t=r={node:d.parentNode,offset:xe(d)+1});break}let p=u.pmViewDesc;if(p&&p.node&&p.node.isBlock)break}}else{let u=a.childNodes[c-1];s=u&&(u.nodeName=="BR"||u.contentEditable=="false")}}let l=o.domSel.readRange();if(Ie&&l.focusNode&&l.focusNode!=r.node&&H(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&we)&&Vr(t.node,t.offset,l.anchorNode,l.anchorOffset)&&Vr(r.node,r.offset,l.focusNode,l.focusOffset)||mu(o.domSelection(),{focusNode:r.node,focusOffset:r.offset,anchorNode:t.node,anchorOffset:t.offset})}var Yc=we||Se&&gu<63;function Xc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,i=r?t.childNodes[r-1]:null;if(we&&o&&o.contentEditable=="false")return _i(o);if((!o||o.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(o)return _i(o);if(i)return _i(i)}}function _i(n){return n.contentEditable="true",we&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Qc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function cm(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ru(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function um(n){let e=n.domSelection();if(!e)return;let t=n.cursorWrapper.dom;t.nodeName=="IMG"?e.collapse(t.parentNode,xe(t)+1):e.collapse(t,0)}function dm(n,e){if(e instanceof P){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Zc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Zc(n)}function Zc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function pn(n,e,t,r){let o=n.someProp("createSelectionBetween",i=>i(n,e,t))||I.between(e,t,r);return n.someProp("adjustSelectionFromDOM",i=>{o=i(n,o)}),o}function Iu(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Hu(n,e)?e:null}function Hu(n,e){if(!e.anchorNode)return!1;try{return cn(n.dom,e.anchorNode)&&(n.editable||cn(n.dom,e.focusNode))}catch{return!1}}var Ee={},Ce={},pm={touchstart:!0,touchmove:!0},Zi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastKeyDispatched=!1,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function fm(n){for(let e in Ee){let t=Ee[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{mm(n,r)&&(n.input.composing&&(r.type=="keydown"||r.type=="beforeinput")&&r.isComposing===!1&&zu(n,!0),!ds(n,r)&&(n.editable||!(r.type in Ce))&&t(n,r))},pm[e]?{passive:!0}:void 0)}we&&n.dom.addEventListener("input",()=>null),es(n)}function eo(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function hm(n){n.input.mouseDown&&n.input.mouseDown.done(),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 es(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>ds(n,r))})}function ds(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function mm(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 gm(n,e){!ds(n,e)&&Ee[e.type]&&(n.editable||!(e.type in Ce))&&Ee[e.type](n,e)}function Mt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=Eh(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",r=>r(n,e)))}Ce.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),n.input.lastKeyDispatched=!1,!(ot&&Se&&t.keyCode==13)){if(dn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(Mt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Mt(n,t)||Zh(n,t)?t.preventDefault():eo(n,"key")}};Ce.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Ce.keypress=(n,e)=>{let t=e;if(wm(n)||!t.charCode||t.ctrlKey&&!t.altKey||Re&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof I)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(o).scrollIntoView();!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o,i))&&n.dispatch(i()),t.preventDefault()}};function Yn(n){return{left:n.clientX,top:n.clientY}}function bm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ps(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function Bu(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function ym(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&P.isSelectable(r)?(Bu(n,new P(t)),!0):!1}function vm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof P&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(P.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(Bu(n,P.create(n.state.doc,o)),!0):!1}function km(n,e,t,r,o){return ps(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?vm(n,t):ym(n,t))}function Mm(n,e,t,r){return ps(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function xm(n,e,t,r){return ps(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))}function eu(n,e,t){if(e==-1)return n.inlineContent?I.create(n,0,n.content.size):null;let r=n.resolve(e);for(let o=r.depth+1;o>0;o--){let i=o>r.depth?r.nodeAfter:r.node(o),s=r.before(o);if(i.inlineContent)return I.create(n,s+1,s+1+i.content.size);if(t&&P.isSelectable(i))return P.create(n,s)}return null}var ts=/[\w_\u00a1-\uffff]+/g;try{ts=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}function tu(n,e){let t=n.resolve(e),r=t.node(),o="",i=e,s=e;for(let g=t.indexAfter(),m=!1;g>0;g--){let b=r.child(g-1);if(!b.text)break;let k=i==e?e-t.posAtIndex(g-1):b.text.length,y=k;for(;y>0;y--)if(/\S/.test(b.text[y-1]))m=!0;else if(m)break;if(o=b.text.slice(y,k)+o,i-=k-y,y||i<e-50)break}for(let g=t.index(),m=!1;g<r.childCount;g++){let b=r.child(g);if(!b.text)break;let k=s==e?e-t.posAtIndex(g):0,y=k;for(;y<b.text.length;y++)if(/\S/.test(b.text[y]))m=!0;else if(m)break;if(o+=b.text.slice(k,y),s+=y-k,y<b.text.length||s>e+50)break}let l=i,a=s;if(Intl.Segmenter){for(let g of new Intl.Segmenter(void 0,{granularity:"word"}).segment(o))if(g.isWordLike){let m=g.index+i,b=m+g.segment.length;if(b<e)l=b;else if(m>e){a=m;break}else return I.create(n,m,b)}}else{ts.lastIndex=0;for(let g;g=ts.exec(o);){let m=g.index+i,b=m+g[0].length;if(b<e)l=b;else if(m>e){a=m;break}else return I.create(n,m,b)}}let c=o.slice(l-i,e-i),u=o.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,p=/^\S*/.exec(u)[0].length;if(d||p)return I.create(n,e-d,e+p);let f=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return I.create(n,e-f,e+h)}var Fu=Re?"metaKey":"ctrlKey";Ee.mousedown=(n,e)=>{let t=e,r=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>r-500)return!1;wt(n);let o="singleClick";r-n.input.lastClick.time<500&&bm(t,n.input.lastClick)&&!t[Fu]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?o="doubleClick":n.input.lastClick.type=="doubleClick"&&(o="tripleClick")),n.input.lastClick={time:r,x:t.clientX,y:t.clientY,type:o,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(Yn(t));if(i)if(t.button==0){if(!n.hasFocus()){ku(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new ns(n,i,t,o)).mightDrag||t.preventDefault()}else eo(n,"pointer")};var ns=class{constructor(e,t,r,o){var i;this.view=e,this.startPos=t,this.event=r,this.type=o,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!r[Fu],this.extend=r.shiftKey,this.anchorDoc=this.startDoc;let s=nu(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof P?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof P?e.nodeDOM(l.from).getBoundingClientRect():e.coordsAtPos(l.anchor);this.anchorOffset={x:(a.left+a.right)/2-s.x,y:(a.top+a.bottom)/2-s.y}}else this.anchorOffset={x:r.clientX-s.x,y:r.clientY-s.y};if(o=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof P&&l.from<=t.pos&&l.to>=t.pos)c=l.from,a=l.node,u=!0;else if(t.inside>-1)a=e.state.doc.nodeAt(t.inside),c=t.inside;else{let d=e.state.doc.resolve(t.pos);a=d.parent,c=d.depth?d.before():-1}if(u||c>-1&&a.type.spec.draggable&&a.type.spec.selectable!==!1){let d=(i=e.docView.descAt(c))===null||i===void 0?void 0:i.nodeDOM;this.mightDrag={node:a,elt:d,pos:c,addAttr:!1},d&&!d.draggable&&(this.mightDrag.addAttr=!0,e.domObserver.stopped(()=>d.draggable=!0))}else this.mightDrag=Sm(e,r)}else this.mightDrag=!1;e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),this.mightDrag||this.select(this.startPos,!0)}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null),typeof this.mightDrag=="object"&&this.mightDrag.addAttr&&this.view.domObserver.stopped(()=>this.mightDrag.elt.removeAttribute("draggable"))}maybeRunHandler(e,t){return(this.type=="singleClick"?km:this.type=="doubleClick"?Mm:xm)(this.view,e.pos,e.inside,t,this.selectNode)}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.startPos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Yn(e))),t&&(this.didMove||this.maybeRunHandler(t,e)||this.select(t,!0),e.preventDefault())}move(e){if(e.buttons==0){this.done();return}if(!this.didMove&&(Math.abs(this.event.x-e.clientX)>8||Math.abs(this.event.y-e.clientY)>8)&&(this.didMove=!0,this.mightDrag=!1),!this.mightDrag){let t=this.view.posAtCoords(Yn(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:r}=this,{doc:o}=r.state,i=this.type=="singleClick"?ru(r,o,e):this.type=="doubleClick"?tu(o,e.pos):eu(o,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(o.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=pn(r,o.resolve(this.anchorRange.from),o.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=pn(r,o.resolve(this.anchorRange.to),o.resolve(i.from)))),i.eq(r.state.selection)||r.dispatch(r.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=nu(this.view),t=this.view.posAtCoords({left:this.anchorOffset.x+e.x,top:this.anchorOffset.y+e.y});if(!t)this.anchorRange=null;else{let{doc:r}=this.view.state;this.anchorRange=this.type=="singleClick"?ru(this.view,r,t):this.type=="doubleClick"?tu(r,t.pos):eu(r,t.inside,!1),this.anchorDoc=this.view.state.doc}}};function nu(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function ru(n,e,t){if(t.inside>-1){let o=e.nodeAt(t.inside);if(o.isAtom&&P.isSelectable(o))return P.create(e,t.inside)}let r=e.resolve(t.pos);return pn(n,r,r)}function Sm(n,e){let{selection:t}=n.state;if(t.empty)return!1;let r=n.domSelection();if(!r||r.rangeCount==0)return!0;let o=r.getRangeAt(0).getClientRects();for(let i=0;i<o.length;i++){let s=o[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}Ee.touchstart=n=>{n.input.lastTouch=Date.now(),wt(n),eo(n,"pointer")};Ee.touchmove=n=>{n.input.lastTouch=Date.now(),eo(n,"pointer")};Ee.contextmenu=n=>wt(n);function wm(n,e){return n.composing?!0:we&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Em=ot?5e3:-1;Ce.compositionstart=Ce.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof I&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Se&&bu&&Cm(n)))n.markCursor=n.state.storedMarks||t.marks(),wt(n,!0),n.markCursor=null;else if(wt(n,!e.selection.empty),Ie&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:r,focusOffset:o}=n.domSel.range;r&&H(r)&&o!=0;){let i=o<0?r.lastChild:r.childNodes[o-1];if(!i)break;if(de(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else r=i,o=-1}n.input.composing=!0}_u(n,Em)};function Cm(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!H(e)||t>=e.childNodes.length)return!1;let r=e.childNodes[t];return H(r)&&r.contentEditable=="false"}Ce.compositionend=(n,e)=>{n.composing&&zu(n)};function zu(n,e=!1){n.input.composing=!1,n.input.compositionEndedAt=Date.now(),n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.badSafariComposition?n.domObserver.forceFlush():n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,e?wt(n):_u(n,20)}function _u(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>wt(n),e))}function $u(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function Am(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=fu(e.focusNode,e.focusOffset),r=hu(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function wt(n,e=!1){if(!(ot&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),$u(n),e||n.docView&&n.docView.damage)){let t=us(n,n.domSel.readRange()),r=n.state.selection;t&&!t.eq(r)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function Tm(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 r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Xn=dn&&Th<604;Ee.copy=Ce.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Xn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=as(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Tm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Nm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Om(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Qn(n,r.value,null,o,e):Qn(n,r.textContent,r.innerHTML,o,e)},50)}function Qn(n,e,t,r,o){let i=cs(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||D.empty)))return!0;if(!i)return!1;let s=Nm(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Vu(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," "):""}Ce.paste=(n,e)=>{let t=e;if(n.composing&&!ot)return;let r=Xn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Qn(n,Vu(r),r.getData("text/html"),o,t)?t.preventDefault():Om(n,t)};var Jr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Dm=Re?"altKey":"ctrlKey";function qu(n,e){let t;return n.someProp("dragCopies",r=>{t=t||r(e)}),t!=null?!t:!e[Dm]}Ee.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Yn(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof P?o.to-1:o.to))){if(r&&typeof r.mightDrag=="object")s=P.create(n.state.doc,r.mightDrag.pos);else if(t.target&&H(t.target)){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(s=P.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=as(n,l);(!t.dataTransfer.files.length||!Se||gu>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Xn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Xn||t.dataTransfer.setData("text/plain",c),n.dragging=new Jr(u,qu(n,t),s)};Ee.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Ce.dragover=Ce.dragenter=(n,e)=>e.preventDefault();Ce.drop=(n,e)=>{try{Lm(n,e,n.dragging)}finally{n.dragging=null}};function Lm(n,e,t){if(!e.dataTransfer)return;let r=n.posAtCoords(Yn(e));if(!r)return;let o=n.state.doc.resolve(r.pos),i=t&&t.slice;i?n.someProp("transformPasted",f=>{i=f(i,n,!1)}):i=cs(n,Vu(e.dataTransfer),Xn?null:e.dataTransfer.getData("text/html"),!1,o);let s=!!(t&&qu(n,e));if(n.someProp("handleDrop",f=>f(n,e,i||D.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?zn(n.state.doc,o.pos,i):o.pos;l==null&&(l=o.pos);let a=n.state.tr;if(s){let{node:f}=t;f?f.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i),a.doc.eq(d))return;let p=a.doc.resolve(c);if(u&&P.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new P(p));else{let f=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,m,b)=>f=b),a.setSelection(pn(n,p,a.doc.resolve(f)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}Ee.focus=n=>{if(n.input.lastFocus=Date.now(),!n.focused&&(n.domObserver.stopped(()=>n.dom.classList.add("ProseMirror-focused")),n.focused=!0,n.domSel.read(),!n.domSel.synced)){let e=n.domSel.range;setTimeout(()=>{let t=n.domSel.readRange();t&&e.eq(t)&&n.domSel.sync()},20)}};Ee.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stopped(()=>n.dom.classList.remove("ProseMirror-focused")),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domSel.deactivate(),n.focused=!1)};Ee.beforeinput=(n,e)=>{if(ot&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Mt(n,"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 Ce)Ee[n]=Ce[n];function Zn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var er=class{constructor(e){this.frag=e,this.index=0,this.off=0}nodeAt(e){for(;this.off<=e&&this.index<this.frag.childCount;){let t=this.frag.child(this.index);if(this.off==e)return t;this.off+=t.nodeSize,this.index++}return null}},Gr=class n{constructor(e,t){this.toDOM=e,this.spec=t||Vt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ae(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Zn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},$t=class n{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ae(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},rs=class n{constructor(e,t){this.attrs=e,this.spec=t||Vt}map(e,t,r,o){let i=e.mapResult(t.from+o,1);if(i.deleted)return null;let s=e.mapResult(t.to+o,-1);return s.deleted||s.pos<=i.pos?null:new ae(i.pos-r,s.pos-r,this)}valid(e,t,r){let o=r.nodeAt(t.from);return!!o&&!o.isText&&t.from+o.nodeSize==t.to}eq(e){return this==e||e instanceof n&&Zn(this.attrs,e.attrs)&&Zn(this.spec,e.spec)}destroy(){}},ae=class n{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new n(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new n(e,e,new Gr(t,r))}static inline(e,t,r,o){return new n(e,t,new $t(r,o))}static node(e,t,r,o){return new n(e,t,new rs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof $t}get widget(){return this.type instanceof Gr}},ln=[],Vt={},G=class n{constructor(e,t){this.local=e.length?e:ln,this.children=t.length?t:ln}static create(e,t){return t.length?Xr(t,e,0,Vt):ye}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,i){for(let s=0;s<this.local.length;s++){let l=this.local[s];if(l.from>t)break;l.to>=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;s<this.children.length&&!(this.children[s]>=t);s+=3)if(this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==ye||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Vt)}mapInner(e,t,r,o,i){let s;if(this.local.length){let l=new er(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,r,o);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Rm(this.children,s||[],e,t,r,o,i):s?new n(s.sort(xt),ln):ye}add(e,t){return t.length?this==ye?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,i=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ju(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,u,c+1):o.splice(i,0,a,a+l.nodeSize,Xr(u,l,c+1,Vt)),i+=3}});let s=Wu(i?Ku(t):t,-r).sort(xt);if(s.length){let l=new er(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||s.splice(a--,1)}return new n(s.length?this.local.concat(s).sort(xt):this.local,o||this.children)}remove(e){return e.length==0||this==ye?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let i=0;i<r.length;i+=3){let s,l=r[i]+t,a=r[i+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;r==this.children&&(r=this.children.slice());let c=r[i+2].removeInner(s,l+1);c!=ye?r[i+2]=c:(r.splice(i,3),i-=3)}if(o.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<o.length;l++)o[l].eq(s,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new n(o,r):ye}forChild(e,t){if(this==ye)return this;if(t.isLeaf)return n.empty;let r,o,i=0,s=this.children.length/3;for(;i<s;){let c=i+s>>>1,u=c*3,d=this.children[u];if(d<e)i=c+1;else if(d>e)s=c;else{r=this.children[u+2];break}}let l=e+1,a=l+t.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<a&&u.to>l&&u.type instanceof $t){let d=Math.max(l,u.from)-l,p=Math.min(a,u.to)-l;d<p&&(o||(o=[])).push(u.copy(d,p))}}if(o){let c=new n(o.sort(xt),ln);return r?new Yr([c,r]):c}return r||ye}eq(e){if(this==e)return!0;if(!(e instanceof n)||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 fs(this.localsInner(e))}localsInner(e){if(this==ye)return ln;if(e.inlineContent||!this.local.some($t.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof $t||t.push(this.local[r]);return t}forEachSet(e){e(this)}};G.empty=new G([],[]);G.removeOverlap=fs;var ye=G.empty,Yr=class n{constructor(e){this.members=e}map(e,t){let r=this.members.map(o=>o.map(e,t,Vt));return n.from(r)}forChild(e,t){if(t.isLeaf)return G.empty;let r=[];for(let o=0;o<this.members.length;o++){let i=this.members[o].forChild(e,t);i!=ye&&(i instanceof n?r=r.concat(i.members):r.push(i))}return n.from(r)}eq(e){if(!(e instanceof n)||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,r=!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{r&&(t=t.slice(),r=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?fs(r?t:t.sort(xt)):ln}static from(e){switch(e.length){case 0:return ye;case 1:return e[0];default:return new n(e.every(t=>t instanceof G)?e:e.reduce((t,r)=>t.concat(r instanceof G?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Rm(n,e,t,r,o,i,s){let l=n.slice();for(let c=0,u=i;c<t.maps.length;c++){let d=0;t.maps[c].forEach((p,f,h,g)=>{let m=g-h-(f-p);for(let b=0;b<l.length;b+=3){let k=l[b+1];if(k<0||p>k+u-d)continue;let y=l[b]+u-d;f>=y?l[b+1]=p<=y?-2:-1:p>=u&&m&&(l[b]+=m,l[b+1]+=m)}d+=m}),u=t.maps[c].map(u,-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 u=t.map(n[c]+i),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let p=t.map(n[c+1]+i,-1),f=p-o,{index:h,offset:g}=r.content.findIndex(d),m=r.maybeChild(h);if(m&&g==d&&g+m.nodeSize==f){let b=l[c+2].mapInner(t,m,u+1,n[c]+i+1,s);b!=ye?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Pm(l,n,e,t,o,i,s),u=Xr(c,r,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,p=0;d<u.children.length;d+=3){let f=u.children[d];for(;p<l.length&&l[p]<f;)p+=3;l.splice(p,0,u.children[d],u.children[d+1],u.children[d+2])}}return new G(e.sort(xt),l)}function Wu(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new ae(o.from+e,o.to+e,o.type))}return t}function Pm(n,e,t,r,o,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+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 ju(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<r&&((o||(o=[])).push(s),n[i]=null);return o}function Ku(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Xr(n,e,t,r){let o=[],i=!1;e.forEach((l,a)=>{let c=ju(n,l,a+t);if(c){i=!0;let u=Xr(c,l,t+a+1,r);u!=ye&&o.push(a,a+l.nodeSize,u)}});let s=Wu(i?Ku(n):n,-t).sort(xt);if(s.length){let l=new er(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(r.onRemove&&r.onRemove(s[a].spec),s.splice(a--,1))}return s.length||o.length?new G(s,o):ye}function xt(n,e){return n.from-e.from||n.to-e.to}function fs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let i=e[o];if(i.from==r.from){i.to!=r.to&&(e==n&&(e=n.slice()),e[o]=i.copy(i.from,r.to),ou(e,o+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,i.from),ou(e,o,r.copy(i.from,r.to)));break}}}return e}function ou(n,e,t){for(;e<n.length&&xt(t,n[e])>0;)e++;n.splice(e,0,t)}function $i(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ye&&e.push(r)}),n.cursorWrapper&&e.push(G.create(n.state.doc,[n.cursorWrapper.deco])),Yr.from(e)}function Im(n,e,t,r){let{node:o,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&cn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],Qr(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Se&&n.input.lastKeyCode===8)for(let b=s;b>i;b--){let k=o.childNodes[b-1],y=k.pmViewDesc;if(k.nodeName=="BR"&&!y){s=b;break}if(!y||y.size)break}let p=n.state.doc,f=n.someProp("domParser")||Qe.fromSchema(n.state.schema),h=p.resolve(l),g=null,m=f.parse(o,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Hm(r),context:h});if(u&&u[0].pos!=null){let b=u[0].pos,k=u[1]&&u[1].pos;k==null&&(k=b),g={anchor:b+l,head:k+l}}return{doc:m,sel:g,from:l,to:a}}var Hm=n=>e=>{let t=e.pmViewDesc;if(t)return t.parseRule(n);if(e.nodeName=="BR"&&e.parentNode){if(we&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||we&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},Bm=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Fm(n,e,t,r,o,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,v=us(n,n.domSel.range,O);if(v&&!n.state.selection.eq(v)&&n.domSel.active){if(Se&&ot&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Mt(n,"Enter"))return;let x=n.state.tr.setSelection(v);O=="pointer"?x.setMeta("pointer",!0):O=="key"&&x.scrollIntoView(),s&&x.setMeta("composition",s),n.dispatch(x)}return}let l=n.state.doc.resolve(e),a=l.sharedDepth(t);e=l.before(a+1),t=n.state.doc.resolve(t).after(a+1);let c=n.state.selection,u=Im(n,e,t,i),d=n.state.doc,p=d.slice(u.from,u.to),f,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(f=n.state.selection.to,h="end"):(f=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let g=Vm(p.content,u.doc.content,u.from,f,h);if(g&&n.input.domChangeCount++,(dn&&n.input.lastIOSEnter>Date.now()-225||ot)&&i.some(O=>H(O)&&!Bm.test(O.nodeName))&&(!g||g.endA>=g.endB)&&Mt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!g)if(o&&c instanceof I&&!c.empty&&c.$head.sameParent(c.$anchor)&&!n.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))g={start:c.from,endA:c.to,endB:c.to};else{if(u.sel){let O=iu(n,n.state.doc,u.sel);if(O&&!O.eq(n.state.selection)){let v=n.state.tr.setSelection(O);s&&v.setMeta("composition",s),n.dispatch(v)}}return}n.state.selection.from<n.state.selection.to&&g.start==g.endB&&n.state.selection instanceof I&&(g.start>n.state.selection.from&&g.start<=n.state.selection.from+2&&n.state.selection.from>=u.from?g.start=n.state.selection.from:g.endA<n.state.selection.to&&g.endA>=n.state.selection.to-2&&n.state.selection.to<=u.to&&(g.endB+=n.state.selection.to-g.endA,g.endA=n.state.selection.to));let m=u.doc.resolveNoCache(g.start-u.from),b=u.doc.resolveNoCache(g.endB-u.from),k=d.resolve(g.start),y=m.sameParent(b)&&m.parent.inlineContent&&k.end()>=g.endA;if((dn&&n.input.lastIOSEnter>Date.now()-225&&(!y||i.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!y&&$m(u.doc,m.pos,b.pos))&&Mt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>g.start&&(y?g.endA>g.start&&g.endB==g.start:_m(d,g.start,g.endA,m,b))&&Mt(n,"Backspace")){ot&&Se&&n.domSel.suppressChanges();return}Se&&g.endB==g.start&&(n.input.lastChromeDelete=Date.now()),ot&&!y&&m.start()!=b.start()&&b.parentOffset==0&&m.depth==b.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==g.endA&&(g.endB-=2,b=u.doc.resolveNoCache(g.endB-u.from),setTimeout(()=>Mt(n,"Enter"),20));let w=g.start,N=g.endA,L=O=>{let v=O||n.state.tr.replace(w,N,u.doc.slice(g.start-u.from,g.endB-u.from));if(u.sel){let x=iu(n,v.doc,u.sel);x&&!(Se&&n.composing&&x.empty&&(g.start!=g.endB||n.input.lastChromeDelete<Date.now()-100)&&(x.head==w||x.head==v.mapping.map(N)-1))&&v.setSelection(x)}return s&&v.setMeta("composition",s),v.scrollIntoView()},R;if(y)if(m.pos==b.pos){let O=L(n.state.tr.delete(w,N)),v=d.resolve(g.start).marksAcross(d.resolve(g.endA));v&&O.ensureMarks(v),n.dispatch(O)}else if(g.endA==g.endB&&(R=zm(m.parent.content.cut(m.parentOffset,b.parentOffset),k.parent.content.cut(k.parentOffset,g.endA-k.start())))){let O=L(n.state.tr);R.type=="add"?O.addMark(w,N,R.mark):O.removeMark(w,N,R.mark),n.dispatch(O)}else if(m.parent.child(m.index()).isText&&m.index()==b.index()-(b.textOffset?0:1)){let O=m.parent.textBetween(m.parentOffset,b.parentOffset),v=()=>L(n.state.tr.insertText(O,w,N));n.someProp("handleTextInput",x=>x(n,w,N,O,v))||n.dispatch(v())}else n.dispatch(L());else n.dispatch(L())}function iu(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:pn(n,e.resolve(t.anchor),e.resolve(t.head))}function zm(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(o.length==1&&i.length==0)l=o[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(A.from(c).eq(n))return{mark:l,type:s}}function _m(n,e,t,r,o){if(t-e<=o.pos-r.pos||Vi(r,!0,!1)<o.pos)return!1;let i=n.resolve(e);if(!r.parent.inlineContent){let l=i.nodeAfter;return l!=null&&t==e+l.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=n.resolve(Vi(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Vi(s,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(s.parent.content)}function $m(n,e,t){let r=0,o=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?r++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&o++}),o==0&&r==1}function Vi(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Vm(n,e,t,r,o){let i=n.findDiffStart(e,t),s=t+n.size,l=t+e.size;if(i==null)return null;let{a,b:c}=n.findDiffEnd(e,s,l);if(o=="end"){let u=Math.max(0,i-Math.min(a,c));r-=a+u-i}if(a<i&&s<l){let u=r<=i&&r>=a?i-r:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}var qm={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},is=class{constructor(e){this.view=e,this.queue=[],this.flushingSoon=-1,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.started=!1,this.observer=new window.MutationObserver(t=>{for(let r=0;r<t.length;r++)this.queue.push(t[r]);we&&e.composing&&t.some(r=>r.type=="childList"&&r.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()})}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(e=!1){this.flushingSoon>-1?(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush(!0)):e&&this.flush(!0)}start(){this.observer.takeRecords(),this.observer.observe(this.view.dom,qm),this.started=!0}stop(){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.started=!1}stopped(e){if(!this.started)return e();this.stop();try{return e()}finally{this.start()}}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=an(i))t.add(i);for(let i=e.anchorNode;i;i=an(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:de(r)?r.parentNode:r}))return this.view.domSel.ignore(e),!0}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(e=!0){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let r=this.pendingRecords();r.length&&(this.queue=[]),e&&t.domSel.read();let o=!t.domSel.suppress&&!t.domSel.synced&&!!Iu(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<r.length;u++){let d=this.registerMutation(r[u],a);d&&(i=i<0?d.from:Math.min(d.from,i),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(t.input.lastKeyCode==8||t.input.lastKeyCode==46||Se&&(t.composing||t.input.compositionEndedAt>Date.now()-50)&&r.some(u=>u.type=="childList"&&u.removedNodes.length))){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;for(;d&&H(d);){if(d.contentEditable=="false"){u.parentNode.removeChild(u);break}d=d.firstChild}}}else if(Ie&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,p]=u;d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}else{let{focusNode:d}=t.domSel.range;for(let p of u){let f=p.parentNode;f&&f.nodeName=="LI"&&(!d||jm(t,d)!=f)&&p.remove()}}}let c=null;i<0&&o&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&Qr(t.domSel.range)&&(c=us(t,t.domSel.range))&&c.eq(F.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||o)&&(i>-1&&Wm(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Km(t,a)),Fm(this.view,i,s,o,l,a),t.docView&&t.docView.damage?t.updateState(t.state):o&&t.domSel.sync())}registerMutation(e,t){var r;if(t.indexOf(e.target)>-1)return null;let o;for(let i=e.target;i&&!(o=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(o==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!o||o.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let p=e.addedNodes[d];t.push(p),de(p)&&(this.lastChangedTextNode=p)}if(o.contentDOM&&o.contentDOM!=o.dom&&!o.contentDOM.contains(e.target))return o.markDamage(4),{from:o.posBefore,to:o.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?xe(i)+1:0,a=o.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?xe(s):e.target.childNodes.length,u=o.localPosFromDOM(e.target,c,1);return o.markDamage(!((r=o.contentDOM)===null||r===void 0)&&r.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(o.markDamage(4),{from:o.posAtStart-o.border,to:o.posAtEnd+o.border}):(this.lastChangedTextNode=e.target,o.markDamage(o instanceof Jn&&e.target==o.nodeDOM?8:4),{from:o.posAtStart,to:o.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},su=new WeakMap,lu=!1;function Wm(n){if(!su.has(n)&&(su.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,lu)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."),lu=!0}}function jm(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Km(n,e){var t;let{focusNode:r,focusOffset:o}=n.domSel.range;for(let i of e)if(((t=i.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=i.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||!H(a)||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(i,l.firstChild),r==i&&n.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}var Um=cs,Jm=wt,fn=class{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 Zi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(pu),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=uu(this),cu(this),this.nodeViews=du(this),this.docView=$c(this.state.doc,au(this),$i(this),this.dom,this),this.domObserver=new is(this),this.domSel=new Qi(this),this.domObserver.start(),this.domSel.read(),fm(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&&es(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(pu),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&($u(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let f=du(this);Ym(f,this.nodeViews)&&(this.nodeViews=f,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&es(this),this.editable=uu(this),cu(this);let a=$i(this),c=au(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(o.selection))&&(s=!0);let p=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Dh(this);s&&this.domObserver.stopped(()=>{let f=d&&Se&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Gm(o.selection,e.selection);if(d){let h=Se?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=Am(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let g=this.docView.outerDeco;this.docView.destroy(),this.docView=$c(e.doc,c,a,this.dom,this,g)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(f=!0)}this.domSel.sync(f)}),this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():p&&Lh(p)}scrollToSelection(){let e=this.domSel.range.focusNode;if(!(!e||!this.domSel.active)){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof P){let t=this.docView.domAfterPos(this.state.selection.from);H(t)&&Bc(this,t.getBoundingClientRect(),e)}else Bc(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 r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let i=r.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new Jr(e.slice,e.move,o<0?void 0:P.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(o=t?t(l):l))return o}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&ku(this.dom),this.domSel.sync()}get root(){let e=this.dom.isConnected!==!1;e||(this._root=null);let t=this._root;if(t==null&&e){for(let r=this.dom.parentNode;r;r=r.parentNode)if(r.nodeType==9||r.nodeType==11&&r.host)return r.getSelection||(Object.getPrototypeOf(r).getSelection=()=>r.ownerDocument.getSelection()),this._root=r}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Bh(this,e)}coordsAtPos(e,t=1){return Su(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Vh(this,t||this.state,e)}pasteHTML(e,t){return Qn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Qn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return as(this,e)}destroy(){this.docView&&(hm(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],$i(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Sh())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return gm(this,e)}domSelection(){return this.root.getSelection()}};fn.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))};function au(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 r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ae.node(0,n.state.doc.content.size,e)]}function cu(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 uu(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Gm(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 du(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ym(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function pu(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 gs={};Z(gs,{keydownHandler:()=>ro,keymap:()=>Ke});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:"'"},no={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Xm=typeof navigator<"u"&&/Mac/.test(navigator.platform),Qm=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(te=0;te<10;te++)it[48+te]=it[96+te]=String(te);var te;for(te=1;te<=24;te++)it[te+111]="F"+te;var te;for(te=65;te<=90;te++)it[te]=String.fromCharCode(te+32),no[te]=String.fromCharCode(te);var te;for(to in it)no.hasOwnProperty(to)||(no[to]=it[to]);var to;function Uu(n){var e=Xm&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Qm&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?no: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}var Zm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),eg=typeof navigator<"u"&&/Win/.test(navigator.platform);function tg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))r=!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))Zm?s=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function ng(n){let e=Object.create(null);for(let t in n)e[tg(t)]=n[t];return e}function ms(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 Ke(n){return new z({props:{handleKeyDown:ro(n)}})}function ro(n){let e=ng(n);return function(t,r){let o=Uu(r),i,s=e[ms(o,r)];if(s&&s(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[ms(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(eg&&r.ctrlKey&&r.altKey)&&(i=it[r.keyCode])&&i!=o){let l=e[ms(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Ms={};Z(Ms,{COMMENT_ID_RE:()=>hn,COMMENT_MAX_LENGTH:()=>oo,COMMENT_NAME_MAX_LENGTH:()=>vs,createCommentStore:()=>ks,newCommentId:()=>io,sanitizeThread:()=>bs});var hn=/^[A-Za-z0-9_-]{1,64}$/,oo=5e3,vs=80;function io(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function bs(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hn.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(Ju).filter(o=>o!==null):[],r=e.resolved;return{id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:r&&typeof r=="object"?{by:ys(r.by),at:Number(r.at)||0}:null}}function ys(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function Ju(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!hn.test(e.id))return null;let t={id:e.id,author:ys(e.author),text:String(e.text??"").slice(0,5e3),createdAt:Number(e.createdAt)||0};if(e.editedAt&&(t.editedAt=Number(e.editedAt)||0),Array.isArray(e.mentions)){let r=e.mentions.slice(0,20).map(ys).filter(o=>/^[\w.@:+-]{1,128}$/.test(o.id)&&o.name);r.length&&(t.mentions=r)}return t}function ks(n=[],e){let t=n.map(bs).filter(s=>s!==null),r=new Set,o=s=>{t=s,e?.(t),r.forEach(l=>l())},i=(s,l)=>o(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return r.add(s),()=>r.delete(s)},createThread(s){let l=bs(s);!l||t.some(a=>a.id===l.id)||o([...t,l])},reply(s,l){let a=Ju(l);a&&i(s,c=>({...c,comments:[...c.comments,a]}))},editComment(s,l,a){i(s,c=>({...c,comments:c.comments.map(u=>u.id===l?{...u,text:a.slice(0,5e3),editedAt:Date.now()}:u)}))},deleteComment(s,l){i(s,a=>({...a,comments:a.comments.filter(c=>c.id!==l)}))},setResolved(s,l){i(s,a=>({...a,resolved:l??null}))},deleteThread(s){o(t.filter(l=>l.id!==s))}}}var rg={en:{list:"People",empty:"No matches"}},xs=/^[\w.@:+-]{1,128}$/,og=80,so=n=>n.replace(/^@/,"").trim().slice(0,og);async function Ss(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&xs.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:so(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}var Gu={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return xs.test(t)?{id:t,name:so(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":xs.test(n.attrs.id)?n.attrs.id:null},`@${so(String(n.attrs.name))}`],leafText:n=>`@${so(String(n.attrs.name))}`}},setup(n){let e=n.options.pluginOptions?.mentions;if(!e?.fetch){console.warn("[nova] mentions: set pluginOptions.mentions.fetch to search people");return}let t=le(n,"mentions",rg),r=e.maxResults??8,o=new Map;n.ui.registry.addAutocompleter("mentions",{trigger:"@",label:t.list,emptyText:t.empty,maxResults:r,fetch:async i=>{let s=await Ss(e.fetch,i,r);return o=new Map(s.map(l=>[l.id,l])),s.map(l=>({value:l.id,label:l.name,...l.description?{detail:l.description}:{}}))},onSelect:(i,s,l)=>{let a=o.get(i.value)??{id:i.value,name:i.label},{state:c,dispatch:u}=l.view,d=l.schema.nodes.mention.create({id:a.id,name:a.name});u(c.tr.replaceWith(s.from,s.to,[d,c.schema.text(" ")]).scrollIntoView()),e.onMention?.(a,l)}})}};var ig={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"}},Yu=S.commentAdd,Xu=S.comments,lo="Mod-Alt-m",st=new K("nova-comments"),Es=new WeakMap;function ws(n){return Es.get(n)}function Qu(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function sg(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var Zu={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return hn.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":hn.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Ke({[lo]:()=>ws(n)?.startComment()??!1}),new z({key:st,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(st),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=ws(n),o=st.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of Qu(t.doc)){if(!s.has(c))continue;let d=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:p,to:f}of u)l.push(ae.inline(p,f,{class:d}))}if(o.pending){let{from:c,to:u}=o.pending;l.push(ae.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=G.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=ws(n);if(!o||st.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=sg(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=le(n,"comments",ig),t=n.options.pluginOptions?.comments??{},r=t.store??ks(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(y,w=[])=>[...new Map(w.map(L=>[L.id,L])).values()].filter(L=>y.includes(`@${L.name}`)),a=(y,w)=>{let N=l(y,w);return{id:io(),author:o,text:y,createdAt:Date.now(),...N.length?{mentions:N}:{}}},c=(y,w)=>{w.mentions?.length&&t.onMention?.({threadId:y,comment:w,users:w.mentions})},u=()=>st.getState(n.view.state),d=y=>n.view.dispatch(n.view.state.tr.setMeta(st,y)),p=null,f=!1;n.ui.registry.addSidebar("comments",{title:e.panel,button:!1,header:!1,render:async y=>{let{createCommentsPanel:w}=await import(__novaChunk("tinymce-chunks/comments-panel-37cba890.js") );return p=w(h),y.append(p.el),()=>p?.destroy()},onShow:()=>{f=!0,p&&(p.el.hidden=!1),n.root.classList.add("nova-comments-open"),p?.render()},onHide:()=>{f=!1,p&&(p.el.hidden=!0),n.root.classList.remove("nova-comments-open"),u().pending&&d({pending:null})}});let h={editor:n,store:r,author:o,labels:e,shortcut:lo,pending:()=>u().pending,active:()=>u().active,setActive(y,w=!1){u().active!==y&&d({active:y}),p?.render();let N=y?h.ranges(y)[0]:void 0;if(w&&N){let{node:L}=n.view.domAtPos(N.from);(L instanceof Element?L:L.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:y}=n.view.state;return y.empty||!n.isEditable()?!1:(d({pending:{from:y.from,to:y.to},active:null}),h.openPanel().then(()=>{p?.render(),p?.focusComposer()}),!0)},cancelPending(){d({pending:null}),p?.render(),n.focus()},findUsers:s?y=>Ss(s,y):null,submitPending(y,w){let N=u().pending,L=y.trim().slice(0,5e3);if(!N||!L)return null;let R=io("t"),O=a(L,w);r.createThread({id:R,createdAt:O.createdAt,comments:[O],resolved:null});let{state:v}=n.view;return n.view.dispatch(v.tr.addMark(N.from,N.to,i().create({id:R})).setMeta(st,{pending:null,active:R}).setMeta("addToHistory",!1)),p?.render(),c(R,O),R},reply(y,w,N){let L=w.trim().slice(0,5e3);if(!L)return;let R=a(L,N);r.reply(y,R),c(y,R)},ranges:y=>Qu(n.view.state.doc).get(y)??[],quote(y){let{doc:w}=n.view.state;return h.ranges(y).map(({from:N,to:L})=>w.textBetween(N,L," ")).join(" \u2026 ")},positionOf:y=>h.ranges(y)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(y){let{state:w}=n.view,N=w.tr;for(let{from:L,to:R}of h.ranges(y))N.removeMark(L,R,i().create({id:y}));u().active===y&&N.setMeta(st,{active:null}),(N.docChanged||N.getMeta(st))&&n.view.dispatch(N.setMeta("addToHistory",!1)),r.deleteThread(y)},setResolved(y,w){r.setResolved(y,w?{by:o,at:Date.now()}:null),w&&u().active===y&&d({active:null})},canEdit:y=>t.canEdit?t.canEdit(y,o):y.author.id===o.id,isPanelOpen:()=>f,openPanel:()=>n.ui.sidebar.show("comments"),closePanel(){f&&(n.ui.sidebar.hide({restoreFocus:!1}),n.focus())}};Es.set(n,h);let g=r.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),p?.render())}),m=()=>h.startComment(),b=()=>h.isPanelOpen()?h.closePanel():void h.openPanel(),k=y=>y.isEditable()&&!y.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:Yu,tooltip:e.add,shortcut:lo,isEnabled:k,onAction:m}),n.ui.registry.addToggleButton("showcomments",{icon:Xu,tooltip:e.show,isActive:()=>f,onAction:b}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:Yu,shortcut:lo,isEnabled:k,onAction:m}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:Xu,isActive:()=>f,onAction:b}),()=>{g(),Es.delete(n)}}};var ed={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"}},td=/^[\w.:-]{1,100}$/,lg=/^data-[a-z0-9-]{1,40}$/;function co(n){return n.options.pluginOptions?.mergetags??{}}function ag(n){let e=co(n).attribute??"data-mergetag";return lg.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var rd=n=>Array.isArray(n.items);function ao(n){return(co(n).list??[]).flatMap(e=>rd(e)?e.items:[e])}function od(n,e){return ao(n).find(t=>t.key===e)?.label}function cg(n){let e=ag(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return td.test(o)?{key:o,label:od(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=td.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label==null||t.attrs.label===""?r:String(t.attrs.label);return["span",{[e]:r,contenteditable:"false"},o]}}}}var Cs=class{constructor(e,t,r){E(this,"node",e);E(this,"editor",t);E(this,"unknownTitle",r);E(this,"dom");this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}render(){let e=this.node.attrs.key,t=od(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!co(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}};function nd(n,e,t){let{state:r,dispatch:o}=n.view,i=n.schema.nodes.mergetag.create({key:e.key,label:e.label}),s=t?r.tr.replaceWith(t.from,t.to,i):r.tr.replaceSelectionWith(i,!1);o(s.scrollIntoView()),n.focus()}var id={name:"mergetags",toolbar:"mergetags",nodes:cg,prosemirrorPlugins:n=>{let e=le(n,"mergetags",ed);return[new z({props:{nodeViews:{mergetag:(t,r)=>new Cs(t,n,e.unknown)}}})]},setup(n){let e=le(n,"mergetags",ed);n.ui.registry.addMenuButton("mergetags",{icon:S.mergeTags,tooltip:e.insert,isEnabled:t=>t.isEditable()&&ao(t).length>0,items:t=>{let r=[],o=(i,s)=>({id:s,label:i.label,onSelect:()=>nd(t,i)});return(co(t).list??[]).forEach((i,s)=>{rd(i)?(r.length&&r.push({type:"separator"}),r.push({type:"heading",label:i.title}),i.items.forEach((l,a)=>r.push(o(l,`mergetag-${s}-${a}`)))):r.push(o(i,`mergetag-${s}`))}),r}}),n.ui.registry.addAutocompleter("mergetags",{trigger:"{{",label:e.search,emptyText:e.empty,maxResults:12,fetch:(t,r)=>{let o=t.toLowerCase();return ao(r).filter(i=>i.label.toLowerCase().includes(o)||i.key.toLowerCase().includes(o)).map(i=>({value:i.key,label:i.label,detail:i.key}))},onSelect:(t,r,o)=>{let i=ao(o).find(s=>s.key===t.value);i&&nd(o,i,r)}})}};var sd=/^[A-Za-z0-9_-]{1,64}$/,Ds=/^[\w.@:+-]{1,128}$/,As={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions"}},ld=S.suggest,ug=S.review,dg=S.check,pg=S.close,tr=new K("nova-suggestions"),Ls="nova-suggestions-own",ad=["#1a7f37","#8250df","#bf3989","#0969da","#bc4c00","#1b7c83"];function fg(n){let e=0;for(let t of String(n??""))e=e*31+t.charCodeAt(0)|0;return ad[Math.abs(e)%ad.length]}function cd(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function ud(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!sd.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:Ds.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":sd.test(t.attrs.id)?t.attrs.id:null,"data-author":Ds.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}var Rs=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete});function hg(n){return!n.docChanged||n.getMeta(Ls)||n.getMeta("addToHistory")===!1||n.getMeta("history$")||n.getMeta("y-sync$")?.isChangeOrigin?!1:n.steps.every(t=>t instanceof ue)}function Ts(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function pd(n,e,t){let r=[];return n.forEach(o=>{o.isInline?r.push(t&&!t.allowsMarkType(e.type)?o:o.mark(e.addToSet(o.marks))):r.push(o.copy(pd(o.content,e,o.type)))}),A.from(r)}function mg(n,e,t){if(!hg(n))return n;let r=Rs(e.schema),o=e.tr,i=Date.now(),s=c=>c,l=null,a=null;if(n.steps.forEach(c=>{let u=c,d=o.steps.length,p=s,f=p(u.from),h=Math.max(f,p(u.to));if(h>f){let b=[],k=[];if(o.doc.nodesBetween(f,h,(N,L)=>{if(!N.isInline)return!0;let R=Math.max(L,f),O=Math.min(L+N.nodeSize,h);return R>=O||(N.marks.some(x=>x.type===r.insert&&x.attrs.author===t.id)?b.push({from:R,to:O}):r.delete.isInSet(N.marks)||k.push({from:R,to:O})),!1}),k.length){let N=k[0],L=Ts(o.doc,N.from,r.delete,t.id)??Ts(o.doc,k[k.length-1].to,r.delete,t.id)??r.delete.create({id:cd(),author:t.id,name:t.name,time:i});for(let R of k)o.addMark(R.from,R.to,L)}for(let N of b.reverse())o.delete(N.from,N.to);let y=o.mapping.slice(d);f=y.map(f,1),h=y.map(h,-1);let w=e.selection;n.steps.length===1&&u.slice.size===0&&w.empty&&w.from===u.from&&n.selection.head===u.from&&(l=h)}if(u.slice.size>0){let b=h;if(!u.slice.openStart)for(let N=o.doc.resolve(b).nodeAfter;N&&r.delete.isInSet(N.marks);)b+=N.nodeSize,N=o.doc.resolve(b).nodeAfter;let k=Ts(o.doc,b,r.insert,t.id)??r.insert.create({id:cd(),author:t.id,name:t.name,time:i}),y=o.doc.resolve(b),w=pd(u.slice.content,k,u.slice.openStart?null:y.parent.type);o.replace(b,b,new D(w,u.slice.openStart,u.slice.openEnd)),n.steps.length===1&&(a=b+u.slice.size)}let g=u.getMap().invert(),m=o.mapping.slice(d);s=b=>m.map(p(g.map(b,-1)),1)}),l!==null)o.setSelection(I.create(o.doc,l));else if(a!==null&&n.selection.empty)o.setSelection(I.create(o.doc,a));else{let c=s(n.selection.anchor),u=s(n.selection.head);try{o.setSelection(I.create(o.doc,c,u))}catch{}}for(let c of["addToHistory","uiEvent","paste","scrollIntoView"]){let u=n.getMeta(c);u!==void 0&&o.setMeta(c,u)}return n.scrolledIntoView&&o.scrollIntoView(),o}function nr(n){let e=Rs(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isInline)return!0;for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:"";l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a})}return!1}),t}function Ns(n,e,t){let r=Rs(n.schema),o=n.tr.setMeta(Ls,!0),i=nr(n.doc).filter(s=>!t||t.includes(s.id));for(let s of[...i].sort((l,a)=>a.from-l.from))s.kind==="insert"==(e==="reject")?o.delete(s.from,s.to):o.removeMark(s.from,s.to,s.kind==="insert"?r.insert:r.delete);return o}function dd(n){let{from:e}=n.selection;return nr(n.doc).find(t=>e>=t.from&&e<=t.to&&(t.to>e||t.from<e))??null}function mn(n){return tr.getState(n)?.enabled??!1}function Os(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(tr,{enabled:e}).setMeta(Ls,!0)),n.updateUI()}var fd={name:"suggestions",toolbar:"suggestions reviewsuggestions",marks:{suggestion_insert:ud("insert"),suggestion_delete:ud("delete")},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new z({key:tr,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(tr);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>tr.getState(r)?.enabled?{class:"nova-suggesting"}:{},decorations(r){if(t?.doc===r.doc)return t.set;let o=le(n,"suggestions",As),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=G.create(r.doc,nr(r.doc).map(l=>ae.inline(l.from,l.to,{title:(l.kind==="insert"?o.inserted:o.deleted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.kind==="insert"?"nova-sugg-insert":"nova-sugg-delete",style:`--nova-suggestion: ${fg(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),Ke({"Mod-Alt-Shift-e":()=>e.force?!1:(Os(n,!mn(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!mn(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=le(t,"suggestions",As),i={id:Ds.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return mg(n,e,i)},setup(n){let e=n.options.pluginOptions?.suggestions??{},t=le(n,"suggestions",As),r=e.canReview!==!1,o=c=>n.view.dispatch(c),i=()=>dd(n.view.state),s=c=>{let u=i();u&&o(Ns(n.view.state,c,[u.id])),n.focus()},l=c=>{let{state:u}=n.view,d=nr(u.doc),p=u.selection.from,f=c===1?d.find(h=>h.from>p)??d[0]:[...d].reverse().find(h=>h.to<p)??d[d.length-1];if(!f){n.ui.notify(t.none);return}o(u.tr.setSelection(I.create(u.doc,f.from)).scrollIntoView()),n.focus()},a=()=>nr(n.view.state.doc).length>0;n.ui.registry.addToggleButton("suggestions",{icon:ld,tooltip:t.toggle,shortcut:"Mod-Alt-Shift-e",isActive:c=>mn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Os(c,!mn(c.view.state))}),n.ui.registry.addMenuButton("reviewsuggestions",{icon:ug,tooltip:t.review,isEnabled:a,items:()=>[{id:"next",label:t.next,onSelect:()=>l(1)},{id:"previous",label:t.previous,onSelect:()=>l(-1)},...r?[{type:"separator"},{id:"accept-all",label:t.acceptAll,onSelect:()=>o(Ns(n.view.state,"accept"))},{id:"reject-all",label:t.rejectAll,onSelect:()=>o(Ns(n.view.state,"reject"))}]:[]]}),r&&(n.ui.registry.addButton("acceptsuggestion",{icon:dg,text:t.accept,tooltip:t.accept,onAction:()=>s("accept")}),n.ui.registry.addButton("rejectsuggestion",{icon:pg,text:t.reject,tooltip:t.reject,onAction:()=>s("reject")}),n.ui.registry.addContextToolbar("suggestion",{label:t.toolbar,predicate:c=>dd(c.view.state)!==null,items:"acceptsuggestion rejectsuggestion",position:"selection",placement:"bottom-start",priority:20})),n.ui.registry.addMenuItem("suggestions",{text:t.toggle,icon:ld,isActive:c=>mn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Os(c,!mn(c.view.state))})}};function gn(n,e,t,r){let{filePicker:o,filePickerTypes:i}=n.options;if(!o||i&&!i.includes(t))return;let{input:s}=e,l=M("button",{type:"button",className:"nova-btn nova-input-action","aria-label":n.ui.t("dialog.browse"),title:n.ui.t("dialog.browse")},V(S.browse)),a=M("div",{className:"nova-input-group"});s.replaceWith(a),a.append(s,l),l.addEventListener("click",async()=>{l.disabled=!0;try{let c=await o({type:t,value:s.value});if(!c?.url)return;s.value=c.url,s.removeAttribute("aria-invalid"),r?.(c)}catch(c){console.error("[nova] filePicker failed:",c)}finally{l.disabled=!1,s.isConnected&&s.focus()}})}var qs={};Z(qs,{ALIGNMENTS:()=>ir,BULLET_STYLES:()=>Is,CELL_VALIGN:()=>Fs,IMAGE_ALIGN_STYLES:()=>Bs,INDENT_STEP:()=>$s,MAX_INDENT:()=>xd,ORDERED_STYLES:()=>Hs,classAttr:()=>He,createSchema:()=>po,cssValue:()=>q,imageSize:()=>ne,indentLevel:()=>bn,schema:()=>At,tableStyle:()=>Sd});function gg(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,o=Number(n.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length===o?r:null};for(let[s,l]of Object.entries(e)){let a=l.getFromDOM?.(n);a!=null&&(i[s]=a)}return i}function bg(n,e){let t={};n.attrs.colspan!==1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!==1&&(t.rowspan=n.attrs.rowspan),Array.isArray(n.attrs.colwidth)&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(let[r,o]of Object.entries(e))o.setDOMAttr?.(n.attrs[r],t);return t}function yg(n){if(n!==null&&(!Array.isArray(n)||n.some(e=>typeof e!="number")))throw new TypeError("colwidth must be null or an array of numbers")}function hd(n){let e=n.cellAttributes,t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:yg}};for(let[o,i]of Object.entries(e))t[o]={default:i.default};let r=(o,i)=>({content:n.cellContent,attrs:t,tableRole:i,isolating:!0,parseDOM:[{tag:o,getAttrs:s=>gg(s,e)}],toDOM:s=>[o,bg(s,e),0]});return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:r("td","cell"),table_header:r("th","header_cell")}}function Et(n){let{$head:e}=n.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="row")return!0;return!1}var Ps={};Z(Ps,{isSafeImageUrl:()=>ce,isSafeLinkUrl:()=>Oe});var vg=new Set(["http:","https:","mailto:","tel:"]),kg=new Set(["http:","https:","blob:"]),Mg=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i;function md(n){if(typeof n!="string")return null;let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function Oe(n){if(typeof n!="string")return!1;let e=md(n);return e===null||vg.has(e)}function ce(n){if(typeof n!="string")return!1;if(Mg.test(n.trim()))return!0;let e=md(n);return e===null||kg.has(e)}var ir=["left","center","right","justify"],xg=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,Sg=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,wg=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,Eg=/^[\w\s,'"-]{1,200}$/;function Cg(n){let e=n.trim().toLowerCase(),t=e.match(/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(1|1\.0+)\s*)?\)$/);if(t)return"#"+t.slice(1,4).map(o=>Math.min(255,Number(o)).toString(16).padStart(2,"0")).join("");let r=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return r?`#${r[1]}${r[1]}${r[2]}${r[2]}${r[3]}${r[3]}`:e}var q={color:n=>typeof n=="string"&&xg.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?Cg(n):null,length:n=>typeof n=="string"&&Sg.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&wg.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&Eg.test(n.trim())?n.trim():null},$s=40,xd=10;function bn(n){let e=Math.trunc(Number(n));return Number.isFinite(e)?Math.min(xd,Math.max(0,e)):0}var Ag=/^(\d+(?:\.\d+)?)(px|pt|em|rem)$/,Tg={px:1,pt:4/3,em:16,rem:16};function Ng(n,e){if(n.parentElement?.tagName==="LI")return 0;let t=n.style,r=e==="rtl"?t.marginRight||t.paddingRight:t.marginLeft||t.paddingLeft,o=Ag.exec(r?.trim()??"");return o?bn(Math.round(Number(o[1])*Tg[o[2]]/$s)):0}function Og(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function gd(n,e=!1){let t=n.style.textAlign,r=Og(n);return{align:ir.includes(t)?t:null,lineHeight:q.lineHeight(n.style.lineHeight),dir:r,indent:Ng(n,r??(e?"rtl":null))}}function bd(n,e=!1){let t={};(n.dir==="rtl"||n.dir==="ltr")&&(t.dir=n.dir);let r=n.dir==="rtl"||e&&n.dir!=="ltr",o=[],i=n.align;i&&ir.includes(i)&&o.push(`text-align: ${i};`);let s=q.lineHeight(n.lineHeight);s&&o.push(`line-height: ${s};`);let l=bn(n.indent);return l&&o.push(`margin-${r?"right":"left"}: ${l*$s}px;`),o.length&&(t.style=o.join(" ")),t}var yd={align:{default:null},lineHeight:{default:null},dir:{default:null},indent:{default:0}},Is=["disc","circle","square"],Hs=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],Dg={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};function vd(n,e,t){let r=n.style.listStyleType.toLowerCase(),o=Dg[n.getAttribute("type")??""]??"",i=e.includes(r)?r:e.includes(o)?o:null;return i===t?null:i}function kd(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}var Bs={left:"float: left; margin: 0 1em 1em 0;",right:"float: right; margin: 0 0 1em 1em;",center:"display: block; margin-left: auto; margin-right: auto;"};function Md(n){let e=n.style.float||n.getAttribute("align");return e==="left"||e==="right"?e:n.style.display==="block"&&n.style.marginLeft==="auto"&&n.style.marginRight==="auto"?"center":null}function ne(n){if(n==null||n==="")return null;let e=String(n).trim().match(/^(\d{1,5})(px)?$/);if(!e)return null;let t=Number(e[1]);return t>=1&&t<=1e4?t:null}var Fs=["top","middle","bottom"];function Sd(n){let e=[],t=q.length(n.width);return t&&e.push(`width: ${t};`),n.align==="center"?e.push("margin-left: auto; margin-right: auto;"):n.align==="right"&&e.push("margin-left: auto;"),e.join(" ")}var Lg=100;function Rg(n){let e=hd({tableGroup:"block",cellContent:"block+",cellAttributes:{class:{default:null,getFromDOM:t=>Ct(t,n),setDOMAttr:(t,r)=>{let o=He(t).class;o&&(r.class=o)}},background:{default:null,getFromDOM:t=>q.color(t.getAttribute("data-nova-cell-bg")??t.style?.backgroundColor),setDOMAttr:(t,r)=>{let o=q.color(t);o&&(r.style=`${r.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:t=>{let r=t,o=(r.style.verticalAlign||r.getAttribute("valign")||"").toLowerCase();return Fs.includes(o)?o:null},setDOMAttr:(t,r)=>{Fs.includes(t)&&(r.style=`${r.style??""}vertical-align: ${t};`)}}}});e.table.attrs={width:{default:null},align:{default:null},class:{default:null}},e.table.parseDOM=[{tag:"table",getAttrs:t=>{let r=t,o=q.length(r.style.width)??q.length(`${r.getAttribute("width")??""}px`),i=l=>l==="auto",s=r.getAttribute("align")==="center"||i(r.style.marginLeft)&&i(r.style.marginRight)?"center":r.getAttribute("align")==="right"||i(r.style.marginLeft)?"right":null;return{width:o,align:s,class:Ct(r,n)}}}],e.table.toDOM=t=>{let r=Sd(t.attrs);return["table",{...He(t.attrs.class),...r?{style:r}:{}},["tbody",0]]};for(let t of["table_cell","table_header"]){let r=e[t],o=r.parseDOM[0],i=o.getAttrs;o.getAttrs=l=>{let a=i(l);if(!a)return a;let c=u=>Math.min(Lg,Math.max(1,Number.isFinite(u)?Math.floor(u):1));return{...a,colspan:c(a.colspan),rowspan:c(a.rowspan)}};let s=r.toDOM;r.toDOM=l=>{let a=s(l),c=l.attrs.colwidth;if(c?.every(u=>u>0)){let u=c.reduce((p,f)=>p+f,0),d=a[1].style?` ${a[1].style}`:"";a[1]={...a[1],style:`width: ${u}px;${d}`}}return a}}return e}var Vs=()=>!1,wd=/^-?[_a-zA-Z][\w-]*$/;function Pg(n){let e=Math.trunc(Number(n));return e>=1&&e<=6?e:1}function Ct(n,e){let t=[...n.classList].filter(r=>wd.test(r)&&e(r));return t.length?t.join(" "):null}function He(n){if(typeof n!="string")return{};let e=n.split(/\s+/).filter(t=>wd.test(t));return e.length?{class:e.join(" ")}:{}}var rr={class:{default:null}},Ed=(n,e=!1)=>({doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...yd,...rr},parseDOM:[{tag:"p",getAttrs:t=>({...gd(t,e),class:Ct(t,n)})}],toDOM:t=>["p",{...He(t.attrs.class),...bd(t.attrs,e)},0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},...yd,...rr},parseDOM:[1,2,3,4,5,6].map(t=>({tag:`h${t}`,getAttrs:r=>({level:t,...gd(r,e),class:Ct(r,n)})})),toDOM:t=>[`h${Pg(t.attrs.level)}`,{...He(t.attrs.class),...bd(t.attrs,e)},0]},blockquote:{group:"block",content:"block+",defining:!0,attrs:{...rr},parseDOM:[{tag:"blockquote",getAttrs:t=>({class:Ct(t,n)})}],toDOM:t=>["blockquote",He(t.attrs.class),0]},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>["hr"]},code_block:{group:"block",content:"text*",marks:"",code:!0,defining:!0,attrs:{language:{default:null}},parseDOM:[{tag:"pre",preserveWhitespace:"full",getAttrs:t=>({language:t.querySelector("code")?.className.match(/language-([\w-]+)/)?.[1]??null})}],toDOM:t=>["pre",["code",t.attrs.language?{class:`language-${t.attrs.language}`}:{},0]]},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null}},parseDOM:[{tag:"ul",getAttrs:t=>({listStyle:vd(t,Is,"disc")})}],toDOM:t=>["ul",kd(t.attrs.listStyle,Is),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:t=>{let r=t.getAttribute("start");return{start:r?Number(r):1,listStyle:vd(t,Hs,"decimal")}}}],toDOM:t=>["ol",{...t.attrs.start===1?{}:{start:t.attrs.start},...kd(t.attrs.listStyle,Hs)},0]},list_item:{content:"paragraph block*",defining:!0,parseDOM:[{tag:"li"}],toDOM:()=>["li",0]},text:{group:"inline"},figure:{group:"block",content:"figure_image figcaption",draggable:!0,isolating:!0,attrs:{align:{default:null},...rr},parseDOM:[{tag:"figure",getAttrs:t=>{let r=t,o=r.querySelector("img");return!o||!ce(o.getAttribute("src")??"")?!1:{align:Md(r),class:Ct(r,n)}}}],toDOM:t=>{let r=ne(t.firstChild?.attrs.width),o=Bs[t.attrs.align]??"",i=`${o}${r?`${o?" ":""}width: ${r}px;`:""}`;return["figure",{...He(t.attrs.class),...i?{style:i}:{}},0]}},figure_image:{atom:!0,selectable:!1,attrs:{src:{default:""},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}},parseDOM:[{tag:"img[src]",context:"figure/",priority:60,getAttrs:t=>{let r=t;return ce(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=ce(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height);return["img",{src:i,...r?{alt:r}:{},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{}}]}},figcaption:{content:"inline*",parseDOM:[{tag:"figcaption",context:"figure/"}],toDOM:()=>["figcaption",0]},image:{group:"inline",inline:!0,draggable:!0,attrs:{src:{},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},align:{default:null},...rr},parseDOM:[{tag:"img[src]",getAttrs:t=>{let r=t;return ce(r.getAttribute("src")??"")?{src:r.getAttribute("src"),alt:r.getAttribute("alt"),title:r.getAttribute("title"),width:ne(r.getAttribute("width")??r.style.width),height:ne(r.getAttribute("height")??r.style.height),align:Md(r),class:Ct(r,n)}:!1}}],toDOM:t=>{let{alt:r,title:o}=t.attrs,i=ce(t.attrs.src)?t.attrs.src:"",s=ne(t.attrs.width),l=ne(t.attrs.height),a=Bs[t.attrs.align];return["img",{src:i,...He(t.attrs.class),...r?{alt:r}:{},...o?{title:o}:{},...s?{width:String(s)}:{},...l?{height:String(l)}:{},...a?{style:a}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...Rg(n)}),zs=Ed(Vs),Cd=n=>({link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>{let t=e;return Oe(t.getAttribute("href")??"")?{href:t.getAttribute("href"),title:t.getAttribute("title"),target:t.getAttribute("target")}:!1}}],toDOM:e=>{let{title:t,target:r}=e.attrs;return["a",{href:Oe(e.attrs.href)?e.attrs.href:"#",...t?{title:t}:{},...r?{target:r,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>e.style?.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>["strong",0]},italic:{parseDOM:[{tag:"em"},{tag:"i"},{style:"font-style=italic"}],toDOM:()=>["em",0]},underline:{parseDOM:[{tag:"u"},{style:"text-decoration=underline"}],toDOM:()=>["u",0]},strike:{parseDOM:[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration=line-through"}],toDOM:()=>["s",0]},code:{parseDOM:[{tag:"code"}],toDOM:()=>["code",0]},subscript:{excludes:"superscript",parseDOM:[{tag:"sub"},{style:"vertical-align=sub"}],toDOM:()=>["sub",0]},superscript:{excludes:"subscript",parseDOM:[{tag:"sup"},{style:"vertical-align=super"}],toDOM:()=>["sup",0]},color:{attrs:{value:{}},parseDOM:[{style:"color",getAttrs:e=>or(q.color(e))},{tag:"font[color]",getAttrs:e=>or(q.color(e.getAttribute("color")))}],toDOM:e=>uo("color",q.color(e.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:e=>or(q.color(e))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:e=>uo("background-color",q.color(e.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:e=>or(q.fontFamily(e))}],toDOM:e=>uo("font-family",q.fontFamily(e.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:e=>or(q.length(e))}],toDOM:e=>uo("font-size",q.length(e.attrs.value))},span_class:{attrs:{class:{}},parseDOM:[{tag:"span[class]",consuming:!1,getAttrs:e=>{let t=Ct(e,n);return t?{class:t}:!1}}],toDOM:e=>["span",He(e.attrs.class),0]}}),_s=Cd(Vs);function or(n){return n?{value:n}:!1}function uo(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}var At=new Xt({nodes:zs,marks:_s});function po(n={},e,t,r="ltr"){let o=r==="rtl",i=Object.entries(n.nodes??{}),s=Object.entries(n.marks??{});if(!i.length&&!s.length&&!e&&!t&&!o)return At;let l=e||o?Ed(e??Vs,o):zs,a=e?Cd(e):_s,c={};t&&({nodes:l,marks:a}=t.apply({nodes:l,marks:a},c));for(let[u]of i)if(u in zs)throw new Error(`[nova] node "${u}" already exists in the base schema`);for(let[u]of s)if(u in _s)throw new Error(`[nova] mark "${u}" already exists in the base schema`);return c.schema=new Xt({nodes:{...l,...Object.fromEntries(i)},marks:{...a,...Object.fromEntries(s)}}),c.schema}var Ig=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,Hg=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,Bg=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function fo(n){if(typeof n!="string")return null;let e=n.trim(),t=e.match(Ig);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(Hg);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:Bg.test(e)?{kind:"video",src:e}:null}var Ad=S.media,Fg={en:{title:"Video",url:"Video URL",hint:"YouTube, Vimeo or a link to an .mp4 / .webm file",name:"Title (for screen readers)",invalid:"This video address is not supported",save:"Insert"}};function Td(n,e){let t=e?fo(e):null;return t?{...t,width:ne(n.getAttribute("width"))??560,height:ne(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function zg(n){let e=fo(n.attrs.src);if(!e)return null;let t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e.kind==="video"?M("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):M("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var Nd={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>Td(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Td(e,t)}}],toDOM:n=>{let e=fo(n.attrs.src),t=String(ne(n.attrs.width)??560),r=String(ne(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new z({props:{nodeViews:{media:n=>{let e=zg(n);return{dom:M("div",{className:"nova-media",contenteditable:"false"},e,M("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],setup(n){let e=le(n,"media",Fg),t=()=>{let{selection:o}=n.view.state;return o instanceof P&&o.node.type.name==="media"?o:null},r=()=>{let o=t(),i=ee({label:e.url,type:"url",placeholder:"https://",hint:e.hint,value:o?.node.attrs.src??""}),s=ee({label:e.name,value:o?.node.attrs.title??""});gn(n,i,"media",l=>{l.title&&(s.input.value=l.title)}),n.ui.openDialog({title:e.title,body:M("div",{className:"nova-form"},i.el,s.el),submitLabel:e.save,onSubmit:()=>{let l=fo(i.input.value);if(!l)return e.invalid;let{state:a,dispatch:c}=n.view,u={...l,title:s.input.value.trim()},d=t();return c(d?a.tr.setNodeMarkup(d.from,void 0,{...d.node.attrs,...u}):a.tr.replaceSelectionWith(n.schema.nodes.media.create(u)).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("media",{icon:Ad,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("media",{text:e.title,icon:Ad,onAction:r})}};var Od=S.pageBreak,_g={en:{title:"Page break"}},Dd={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},setup(n){let{title:e}=le(n,"pagebreak",_g),t=()=>{let{state:r,dispatch:o}=n.view,i=n.schema.nodes.pagebreak;o(r.tr.replaceSelectionWith(i.create()).scrollIntoView()),n.focus()};n.ui.registry.addButton("pagebreak",{icon:Od,tooltip:e,isEnabled:r=>r.isEditable(),onAction:t}),n.ui.registry.addMenuItem("pagebreak",{text:e,icon:Od,onAction:t})}};U("insertdatetime",()=>import(__novaChunk("tinymce-chunks/insertdatetime-e0dbcf63.js") ));U("quickbars",()=>import(__novaChunk("tinymce-chunks/quickbars-d937e10a.js") ));U("charmap",()=>import(__novaChunk("tinymce-chunks/charmap-4b14307a.js") ));U("emoticons",()=>import(__novaChunk("tinymce-chunks/emoticons-7e6da0b6.js") ));U("nonbreaking",()=>import(__novaChunk("tinymce-chunks/nonbreaking-49bdb0d2.js") ));U("autolink",()=>import(__novaChunk("tinymce-chunks/autolink-7e2e7be2.js") ));U("autosave",()=>import(__novaChunk("tinymce-chunks/autosave-4fd46720.js") ));U("autoresize",()=>import(__novaChunk("tinymce-chunks/autoresize-d6c9537b.js") ));U("visualblocks",()=>import(__novaChunk("tinymce-chunks/visualblocks-58c88e5d.js") ));U("anchor",Rc);U("pagebreak",Dd);U("media",Nd);U("comments",Zu);U("mentions",Gu);U("mergetags",id);U("suggestions",fd);U("directionality",()=>import(__novaChunk("tinymce-chunks/directionality-60dba768.js") ));U("advlist",()=>import(__novaChunk("tinymce-chunks/advlist-7a360f16.js") ));U("revisionhistory",()=>import(__novaChunk("tinymce-chunks/revisionhistory-d6306426.js") ));var ma={};Z(ma,{API_CHANGE_META:()=>vr,Editor:()=>kr,REMOTE_CHANGE_META:()=>ha,createEditor:()=>ti,parseContent:()=>fa});var Rd=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function $g(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Vg=(n,e,t)=>{let r=$g(n,t);if(!r)return!1;let o=Pd(r);if(!o){let s=r.blockRange(),l=s&>(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Hd(n,o,e,-1))return!0;if(r.parent.content.size==0&&(yn(i,"end")||P.isSelectable(i)))for(let s=r.depth;;s--){let l=_n(n.doc,r.before(s),r.after(s),D.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(yn(i,"end")?F.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):P.create(a.doc,o.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||r.node(s-1).childCount>1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1};function yn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var qg=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=Pd(r)}let s=i&&i.nodeBefore;return!s||!P.isSelectable(s)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Pd(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 Wg(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}var jg=(n,e,t)=>{let r=Wg(n,t);if(!r)return!1;let o=Id(r);if(!o)return!1;let i=o.nodeAfter;if(Hd(n,o,e,1))return!0;if(r.parent.content.size==0&&(yn(i,"start")||P.isSelectable(i))){let s=_n(n.doc,r.before(),r.after(),D.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(yn(i,"start")?F.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):P.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0):!1},Kg=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;i=Id(r)}let s=i&&i.nodeAfter;return!s||!P.isSelectable(s)?!1:(e&&e(n.tr.setSelection(P.create(n.doc,i.pos)).scrollIntoView()),!0)};function Id(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}var ho=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&>(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Ug=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
11
|
+
`).scrollIntoView()),!0)};function js(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}var Ks=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=js(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(F.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Jg=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof se||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=js(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(I.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Gg=(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(et(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&>(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Yg(n){return(e,t)=>{if(e.selection instanceof P&&e.selection.node.isBlock){let{$from:f}=e.selection;return!f.parentOffset||!et(e.doc,f.pos)?!1:(t&&t(e.tr.split(f.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof I||e.selection instanceof se)&&r.deleteSelection();let{$from:o}=r.selection,i=r.steps.length,s=[],l,a,c=!1,u=!1;for(let f=o.depth;;f--)if(o.node(f).isBlock){c=o.end(f)==o.pos+(o.depth-f),u=o.start(f)==o.pos-(o.depth-f),a=js(o.node(f-1).contentMatchAt(o.indexAfter(f-1)));let g=n&&n(o.parent,c,o);s.unshift(g||(c&&a?{type:a}:null)),l=f;break}else{if(f==1)return!1;s.unshift(null)}let d=o.pos,p=et(r.doc,d,s.length,s);if(p||(s[0]=a?{type:a}:null,p=et(r.doc,d,s.length,s)),!p)return!1;if(r.split(d,s.length,s),!c&&u&&o.node(l).type!=a){let f=r.mapping.slice(i),h=f.map(o.before(l)),g=r.doc.resolve(h);a&&o.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&r.setNodeMarkup(f.map(o.before(l)),a)}return t&&t(r.scrollIntoView()),!0}}var Xg=Yg();var Qg=(n,e)=>(e&&e(n.tr.setSelection(new se(n.doc))),!0);function Zg(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||bt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Hd(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Zg(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let f=e.pos+i.nodeSize,h=A.empty;for(let b=s.length-1;b>=0;b--)h=A.from(s[b].create(null,h));h=A.from(o.copy(h));let g=n.tr.step(new ie(e.pos-1,f,e.pos,f,new D(h,1,0),s.length,!0)),m=g.doc.resolve(f+2*s.length);m.nodeAfter&&m.nodeAfter.type==o.type&&bt(g.doc,m.pos)&&g.join(m.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||r>0&&a?null:F.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),p=d&>(d);if(p!=null&&p>=e.depth)return t&&t(n.tr.lift(d,p).scrollIntoView()),!0;if(c&&yn(i,"start",!0)&&yn(o,"end")){let f=o,h=[];for(;h.push(f),!f.isTextblock;)f=f.lastChild;let g=i,m=1;for(;!g.isTextblock;g=g.firstChild)m++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(t){let b=A.empty;for(let y=h.length-1;y>=0;y--)b=A.from(h[y].copy(b));let k=n.tr.step(new ie(e.pos-h.length,e.pos+i.nodeSize,e.pos+m,e.pos+i.nodeSize-m,new D(b,h.length,0),0,!0));t(k.scrollIntoView())}return!0}}return!1}function Bd(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(I.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var eb=Bd(-1),tb=Bd(1);function mo(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&It(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Us(n,e=null){return function(t,r){let o=!1;for(let i=0;i<t.selection.ranges.length&&!o;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s<t.selection.ranges.length;s++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[s];i.setBlockType(l,a,n,e)}r(i.scrollIntoView())}return!0}}function nb(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:i,$to:s}=e[o],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function rb(n){let e=[];for(let t=0;t<n.length;t++){let{$from:r,$to:o}=n[t];r.doc.nodesBetween(r.pos,o.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new Bt(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.pos<o.pos&&e.push(new Bt(r,o))}return e}function Tt(n,e=null,t){let r=(t&&t.removeWhenPresent)!==!1,o=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!nb(s.doc,u,n,o))return!1;if(l)if(c)n.isInSet(s.storedMarks||c.marks())?l(s.tr.removeStoredMark(n)):l(s.tr.addStoredMark(n.create(e)));else{let d,p=s.tr;o||(u=rb(u)),r?d=!u.some(f=>s.doc.rangeHasMark(f.$from.pos,f.$to.pos,n)):d=!u.every(f=>{let h=!1;return p.doc.nodesBetween(f.$from.pos,f.$to.pos,(g,m,b)=>{if(h)return!1;h=!n.isInSet(g.marks)&&!!b&&b.type.allowsMarkType(n)&&!(g.isText&&/^\s*$/.test(g.textBetween(Math.max(0,f.$from.pos-m),Math.min(g.nodeSize,f.$to.pos-m))))}),!h});for(let f=0;f<u.length;f++){let{$from:h,$to:g}=u[f];if(!d)p.removeMark(h.pos,g.pos,n);else{let m=h.pos,b=g.pos,k=h.nodeAfter,y=g.nodeBefore,w=i&&k&&k.isText?/^\s*/.exec(k.text)[0].length:0,N=i&&y&&y.isText?/\s*$/.exec(y.text)[0].length:0;m+w<b&&(m+=w,b-=N),p.addMark(m,b,n.create(e))}}l(p.scrollIntoView())}return!0}}function vn(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}var Ws=vn(Rd,Vg,qg),Ld=vn(Rd,jg,Kg),lt={Enter:vn(Ug,Jg,Gg,Xg),"Mod-Enter":Ks,Backspace:Ws,"Mod-Backspace":Ws,"Shift-Backspace":Ws,Delete:Ld,"Mod-Delete":Ld,"Mod-a":Qg},Fd={"Ctrl-h":lt.Backspace,"Alt-Backspace":lt["Mod-Backspace"],"Ctrl-d":lt.Delete,"Ctrl-Alt-Backspace":lt["Mod-Delete"],"Alt-Delete":lt["Mod-Delete"],"Alt-d":lt["Mod-Delete"],"Ctrl-a":eb,"Ctrl-e":tb};for(let n in lt)Fd[n]=lt[n];var ob=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,zd=ob?Fd:lt;var ol={};Z(ol,{commands:()=>W,getActiveAlign:()=>Nt,getLinkAt:()=>Kt,insertImage:()=>nl,isCommandActive:()=>rl,isMarkActive:()=>xn,isNodeActive:()=>Be,listIndent:()=>el,listOutdent:()=>tl,markRange:()=>Ut,marksOf:()=>Y,nodesOf:()=>$,setLink:()=>Tb});var Qs={};Z(Qs,{closeHistory:()=>fb,history:()=>Xs,isHistoryTransaction:()=>yb,redo:()=>ko,redoDepth:()=>bb,redoNoScroll:()=>mb,undo:()=>vo,undoDepth:()=>gb,undoNoScroll:()=>hb});var go=200,pe=function(){};pe.prototype.append=function(e){return e.length?(e=pe.from(e),!this.length&&e||e.length<go&&this.leafAppend(e)||this.length<go&&e.leafPrepend(this)||this.appendInner(e)):this};pe.prototype.prepend=function(e){return e.length?pe.from(e).append(this):this};pe.prototype.appendInner=function(e){return new ib(this,e)};pe.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?pe.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};pe.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};pe.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};pe.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};pe.from=function(e){return e instanceof pe?e:e&&e.length?new _d(e):pe.empty};var _d=(function(n){function e(r){n.call(this),this.values=r}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,s,l){for(var a=i;a<s;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,i,s,l){for(var a=i-1;a>=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=go)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=go)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})(pe);pe.empty=new _d([]);var ib=(function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.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(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,i,s){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(r,Math.min(o,l),i,s)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var i=this.left.length;return o<=i?this.left.slice(r,o):r>=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(pe),Js=pe;var sb=500,Wt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,p)=>{if(!d.step){o||(o=this.remapping(r,p+1),i=o.maps.length),i--,u.push(d);return}if(o){u.push(new Ue(d.map));let f=d.step.map(o.slice(i)),h;f&&s.maybeStep(f).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ue(h,void 0,void 0,c.length+u.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=o?d.selection.map(o.slice(i)):d.selection,a=new n(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),p=new Ue(e.mapping.maps[u],d,t),f;(f=a&&a.merge(p))&&(p=f,u?i.pop():l=l.slice(0,l.length-1)),i.push(p),t&&(s++,t=void 0),o||(a=p)}let c=s-r.depth;return c>ab&&(l=lb(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new Zt;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Ue(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let r=[],o=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(p=>{p.selection&&l--},o);let a=t;this.items.forEach(p=>{let f=i.getMirror(--a);if(f==null)return;s=Math.min(s,f);let h=i.maps[f];if(p.step){let g=e.steps[f].invert(e.docs[f]),m=p.selection&&p.selection.map(i.slice(a+1,f));m&&l++,r.push(new Ue(h,g,m))}else r.push(new Ue(h))},o);let c=[];for(let p=t;p<s;p++)c.push(new Ue(i.maps[p]));let u=this.items.slice(0,o).append(c).append(r),d=new n(u,l);return d.emptyItemCount()>sb&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=s.selection&&s.selection.map(t.slice(r));u&&i++;let d=new Ue(c.invert(),a,u),p,f=o.length-1;(p=o.length&&o[f].merge(d))?o[f]=p:o.push(d)}}else s.map&&r--},this.items.length,0),new n(Js.from(o.reverse()),i)}};Wt.empty=new Wt(Js.empty,0);function lb(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var Ue=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},Je=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},ab=20;function cb(n,e,t,r){let o=t.getMeta(Ge),i;if(o)return o.historyState;t.getMeta(qd)&&(n=new Je(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Ge))return s.getMeta(Ge).redo?new Je(n.done.addTransform(t,void 0,r,bo(e)),n.undone,$d(t.mapping.maps),n.prevTime,n.prevComposition):new Je(n.done,n.undone.addTransform(t,void 0,r,bo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!ub(t,n.prevRanges)),c=s?Gs(n.prevRanges,t.mapping):$d(t.mapping.maps);return new Je(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,bo(e)),Wt.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),Gs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Je(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Gs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function ub(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&o>=e[i]&&(t=!0)}),t}function $d(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Gs(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),i=e.map(n[r+1],-1);o<=i&&t.push(o,i)}return t}function db(n,e){for(let t=0;t<e.steps.length;t++){let r=e.mapping.maps[t],o=-1;if(r.forEach((i,s)=>o=s),o<0){let i=e.steps[t];(i instanceof mt||i instanceof Ze)&&(o=i.to)}if(o>-1)return F.near(n.doc.resolve(o))}return n.selection}function pb(n,e,t){let r=bo(e),o=Ge.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,db(e,i.transform).getBookmark(),o,r),a=new Je(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Ge,{redo:t,historyState:a})}var Ys=!1,Vd=null;function bo(n){let e=n.plugins;if(Vd!=e){Ys=!1,Vd=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ys=!0;break}}return Ys}function fb(n){return n.setMeta(qd,!0)}var Ge=new K("history"),qd=new K("closeHistory");function Xs(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new z({key:Ge,state:{init(){return new Je(Wt.empty,Wt.empty,null,0,-1)},apply(e,t,r){return cb(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?vo:r=="historyRedo"?ko:null;return!o||!e.editable?!1:(t.preventDefault(),o(e.state,e.dispatch))}}}})}function yo(n,e){return(t,r)=>{let o=Ge.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=pb(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var vo=yo(!1,!0),ko=yo(!0,!0),hb=yo(!1,!1),mb=yo(!0,!1);function gb(n){let e=Ge.getState(n);return e?e.done.eventCount:0}function bb(n){let e=Ge.getState(n);return e?e.undone.eventCount:0}function yb(n){return n.getMeta(Ge)!=null}function Wd(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i);if(!s)return!1;let l=r?t.tr:null;return vb(l,s,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function vb(n,e,t,r=null){let o=!1,i=e,s=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new ft(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ft(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=It(i,t,r,e);return l?(n&&kb(n,e,l,o,t),!0):!1}function kb(n,e,t,r,o){let i=A.empty;for(let u=t.length-1;u>=0;u--)i=A.from(t[u].type.create(t[u].attrs,i));n.step(new ie(e.start-(r?2:0),e.end,e.start,e.end,new D(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==o&&(s=u+1);let l=t.length-s,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,p=!0;u<d;u++,p=!1)!p&&l&&et(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function kn(n,e){return n instanceof qe?e==n:n.indexOf(e)>-1}function jd(n,e){return function(t,r){let{$from:o,$to:i,node:s}=t.selection;if(s&&s.isBlock||o.depth<2||!o.sameParent(i))return!1;let l=o.node(-1);if(!kn(n,l.type))return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||!kn(n,o.node(-3).type)||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let d=A.empty,p=o.index(-1)?1:o.index(-2)?2:3;for(let b=o.depth-p;b>=o.depth-3;b--)d=A.from(o.node(b).copy(d));let f=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;d=d.append(A.from(o.node(-3).type.createAndFill()));let h=o.before(o.depth-(p-1)),g=t.tr.replace(h,o.after(-f),new D(d,4-p,0)),m=-1;g.doc.nodesBetween(h,g.doc.content.size,(b,k)=>{if(m>-1)return!1;b.isTextblock&&b.content.size==0&&(m=k+1)}),m>-1&&g.setSelection(F.near(g.doc.resolve(m))),r(g.scrollIntoView())}return!0}let a=i.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return et(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Mo(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,s=>s.childCount>0&&kn(n,s.firstChild.type));return i?t?kn(n,r.node(i.depth-1).type)?Mb(e,t,i):xb(e,t,i):!0:!1}}function Mb(n,e,t){let r=n.tr,o=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;o<i&&(r.step(new ie(o-1,i,o,i,new D(A.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new ft(r.doc.resolve(t.$from.pos),r.doc.resolve(i),t.depth));let l=gt(t);if(l==null)return!1;r.lift(t,l);let a=r.doc.resolve(r.mapping.map(o,-1)-1);return bt(r.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&r.join(a.pos),e(r.scrollIntoView()),!0}function xb(n,e,t){let r=n.tr,o=t.parent;for(let f=t.end,h=t.endIndex-1,g=t.startIndex;h>g;h--)f-=o.child(h).nodeSize,r.delete(f-1,f+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.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),u=i.index(-1);if(!c.canReplace(u+(l?0:1),u+1,s.content.append(a?A.empty:A.from(o))))return!1;let d=i.pos,p=d+s.nodeSize;return r.step(new ie(d-(l?1:0),p+(a?1:0),d+1,p-1,new D((l?A.empty:A.from(o.copy(A.empty))).append(a?A.empty:A.from(o.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Zs(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&kn(n,c.firstChild.type));if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(!kn(n,a.type))return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=A.from(c?a.lastChild.lastChild.type.create():null),d=new D(A.from(a.type.create(null,A.from(l.type.create(null,u)))),c?3:1,0),p=i.start,f=i.end;t(e.tr.step(new ie(p-(c?3:1),f,p,f,d,1,!0)).scrollIntoView())}return!0}}var $=n=>n.schema.nodes,Y=n=>n.schema.marks,sr=(n,e)=>(t,r,o)=>e($(t)[n])(t,r,o),jt=(n,e)=>(t,r,o)=>e(Y(t)[n])(t,r,o);function xo(n){return(e,t)=>{let{from:r,to:o}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(r,o,(l,a)=>{let c=$(e);(l.type===c.paragraph||l.type===c.heading)&&(s=!0,i=i.setNodeMarkup(a,void 0,{...l.attrs,align:n}))}),s?(t?.(i),!0):!1}}var Sb=(n,e)=>(e?.(n.tr.replaceSelectionWith($(n).horizontal_rule.create()).scrollIntoView()),!0),wb=(n,e)=>{let{from:t,to:r,empty:o,$from:i}=n.selection,s=Y(n);if(o){let l=Ut(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,r,s.link)?(e?.(n.tr.removeMark(t,r,s.link)),!0):!1},Eb=(n,e)=>{let{from:t,to:r,empty:o}=n.selection;if(o)return!1;if(e){let i=Y(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,r,l));e(s)}return!0};function Ud(n){return(e,t)=>{let r=$(e),o=[],{from:i,to:s}=e.selection;if(e.doc.nodesBetween(i,s,(l,a,c)=>{if(l.type!==r.paragraph&&l.type!==r.heading)return!0;if(c?.type!==r.list_item){let u=bn(l.attrs.indent),d=bn(u+n);d!==u&&o.push({pos:a,attrs:{...l.attrs,indent:d}})}return!1}),!o.length)return!1;if(t){let l=e.tr;for(let{pos:a,attrs:c}of o)l.setNodeMarkup(a,void 0,c);t(l.scrollIntoView())}return!0}}var Cb=(n,e,t)=>Zs($(n).list_item)(n,e,t)||Ud(1)(n,e,t),Ab=(n,e,t)=>Mo($(n).list_item)(n,e,t)||Ud(-1)(n,e,t),el=(n,e,t)=>Zs($(n).list_item)(n,e,t),tl=(n,e,t)=>Mo($(n).list_item)(n,e,t);function Jd(n,e={}){let t=Us(n,e);return(r,o)=>{if(!t(r))return!1;if(o){let i=r.tr;for(let s of r.selection.ranges)i.setBlockType(s.$from.pos,s.$to.pos,n,l=>({...e,..."align"in n.spec.attrs&&l.attrs.align?{align:l.attrs.align}:{},..."lineHeight"in n.spec.attrs&&l.attrs.lineHeight?{lineHeight:l.attrs.lineHeight}:{},..."dir"in n.spec.attrs&&l.attrs.dir?{dir:l.attrs.dir}:{},..."indent"in n.spec.attrs&&l.attrs.indent?{indent:l.attrs.indent}:{}}));o(i.scrollIntoView())}return!0}}function Mn(n){return sr("heading",e=>Jd(e,{level:n}))}var W={bold:jt("bold",Tt),italic:jt("italic",Tt),underline:jt("underline",Tt),strike:jt("strike",Tt),code:jt("code",Tt),subscript:jt("subscript",Tt),superscript:jt("superscript",Tt),paragraph:sr("paragraph",n=>Jd(n)),h1:Mn(1),h2:Mn(2),h3:Mn(3),h4:Mn(4),h5:Mn(5),h6:Mn(6),blockquote:(n,e)=>Be(n,$(n).blockquote)?ho(n,e):mo($(n).blockquote)(n,e),codeBlock:sr("code_block",n=>Us(n)),bulletList:sr("bullet_list",Kd),orderedList:sr("ordered_list",Kd),indent:Cb,outdent:Ab,alignLeft:xo(null),alignCenter:xo("center"),alignRight:xo("right"),alignJustify:xo("justify"),horizontalRule:Sb,unlink:wb,clearFormatting:Eb,undo:vo,redo:ko};function Kd(n){return(e,t)=>Be(e,n)?Mo($(e).list_item)(e,t):Wd(n)(e,t)}function Tb(n,e={}){return(t,r)=>{if(!Oe(n))return!1;let{from:o,to:i,empty:s,$from:l}=t.selection,a=Y(t),c=a.link.create({href:n,title:e.title??null,target:e.target??null});if(s){let u=Ut(t,a.link,l.pos);return u?(r?.(t.tr.removeMark(u.from,u.to,a.link).addMark(u.from,u.to,c)),!0):(r?.(t.tr.insert(o,t.schema.text(n,[c]))),!0)}return r?.(t.tr.removeMark(o,i,a.link).addMark(o,i,c)),!0}}function nl(n,e){return(t,r)=>ce(n)?(r?.(t.tr.replaceSelectionWith($(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function xn(n,e){let{from:t,$from:r,to:o,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??r.marks()):n.doc.rangeHasMark(t,o,e)}function Be(n,e,t){let{$from:r,to:o}=n.selection;for(let i=r.depth;i>0;i--){let s=r.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return o<=r.end(i)}return!1}function Nt(n){return n.selection.$from.parent.attrs.align??"left"}function rl(n,e){let t=n.selection.$from.parent,r=$(n),o=Y(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return xn(n,o[e]);case"paragraph":return t.type===r.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===r.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===r.code_block;case"blockquote":return Be(n,r.blockquote);case"bulletList":return Be(n,r.bullet_list);case"orderedList":return Be(n,r.ordered_list);case"alignLeft":return Nt(n)==="left";case"alignCenter":return Nt(n)==="center";case"alignRight":return Nt(n)==="right";case"alignJustify":return Nt(n)==="justify";default:return!1}}function Kt(n){let{$from:e}=n.selection,t=Y(n),r=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return r?r.attrs:null}function Ut(n,e,t){let r=n.doc.resolve(t),o=r.start(),i=[];return r.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=o+l,c=a+s.nodeSize,u=i[i.length-1];u&&u.to===a?u.to=c:i.push({from:a,to:c})}),i.find(s=>s.from<=t&&t<=s.to)??null}var Nb={strong:"bold",b:"bold",em:"italic",i:"italic",u:"underline",s:"strike",strike:"strike",del:"strike",code:"code",sub:"subscript",sup:"superscript"},Ob={color:{mark:"color",read:q.color},"background-color":{mark:"background",read:q.color},"font-family":{mark:"font_family",read:q.fontFamily},"font-size":{mark:"font_size",read:q.length}},To={p:n=>n.type.name==="paragraph",h1:n=>n.type.name==="heading"&&n.attrs.level===1,h2:n=>n.type.name==="heading"&&n.attrs.level===2,h3:n=>n.type.name==="heading"&&n.attrs.level===3,h4:n=>n.type.name==="heading"&&n.attrs.level===4,h5:n=>n.type.name==="heading"&&n.attrs.level===5,h6:n=>n.type.name==="heading"&&n.attrs.level===6,blockquote:n=>n.type.name==="blockquote",pre:n=>n.type.name==="code_block",img:n=>n.type.name==="image"},Gd=new Set;function No(n){Gd.has(n)||(Gd.add(n),console.warn(`[nova] formats: ${n}`))}function Fe(n){return Array.isArray(n)?n.flatMap(Fe):typeof n=="string"?n.split(/\s+/).filter(Boolean):[]}function lr(n){let e=[];for(let t of n)e.push(...Fe(t.classes)),"items"in t&&t.items&&e.push(...lr(t.items));return e}var Eo=(n,e)=>{let t=Fe(n);return e.every(r=>t.includes(r))},So=(n,e)=>{let t=[...new Set([...Fe(n),...e])];return t.length?t.join(" "):null},wo=(n,e)=>{let t=Fe(n).filter(r=>!e.includes(r));return t.length?t.join(" "):null};function Co(n){let e={};for(let[t,r]of Object.entries(n.styles??{}))t==="text-align"&&ir.includes(r)?e.align=r:t==="line-height"&&q.lineHeight(r)?e.lineHeight=q.lineHeight(r):No(`style "${t}" is not supported on blocks`);return e}function ll(n,e){let t=Y(n),r=[];if(e.inline&&e.inline!=="span"){let i=t[Nb[e.inline]];i&&r.push(i.create())}let o=Fe(e.classes);o.length&&t.span_class&&r.push(t.span_class.create({class:o.join(" ")}));for(let[i,s]of Object.entries(e.styles??{})){let l=Ob[i],a=l?.read(s),c=l?t[l.mark]:void 0;c&&a?r.push(c.create({value:a})):No(`style "${i}: ${s}" is not supported on text`)}return r}var Oo=n=>(n.selector??"").split(",").map(e=>e.trim().toLowerCase()).filter(e=>To[e]?!0:(No(`selector "${e}" is not supported`),!1));function Do(n,e){let t=[],r=a=>e.some(c=>To[c](a)),{selection:o}=n;if(o instanceof P&&r(o.node))return[{node:o.node,pos:o.from}];let{$from:i,from:s,to:l}=o;for(let a=i.depth;a>0;a--){let c=i.node(a);r(c)&&t.push({node:c,pos:i.before(a)})}return n.doc.nodesBetween(s,l,(a,c)=>{r(a)&&!t.some(u=>u.pos===c)&&t.push({node:a,pos:c})}),t}function il(n){let e=[],{from:t,to:r}=n.selection;return n.doc.nodesBetween(t,r,(o,i)=>o.isTextblock?(e.push({node:o,pos:i}),!1):!0),e}function al(n){let{$from:e}=n.selection;for(let t=e.depth;t>0;t--){let r=e.node(t);if(r.type.name==="blockquote")return{node:r,pos:e.before(t)}}return null}function Qd(n){return{align:n.align??null,lineHeight:n.lineHeight??null,dir:n.dir??null}}var Ao=class{constructor(e,t){E(this,"editor",e);E(this,"allowedClasses",t);E(this,"registry",new Map)}register(e,t){let r=Array.isArray(t)?t:[t];this.registry.set(e,r),lr(r).forEach(o=>this.allowedClasses.add(o))}unregister(e){this.registry.delete(e)}has(e){return this.registry.has(e)}get(e){return this.registry.get(e)}resolve(e){if(typeof e!="string")return[e];let t=this.registry.get(e);return t||No(`unknown format "${e}"`),t??[]}canApply(e){if(!this.editor.isEditable())return!1;let t=this.editor.view.state;return this.resolve(e).some(r=>Yd(t,r))}match(e){let t=this.editor.view.state;return this.resolve(e).some(r=>Db(t,r))}apply(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);if(!t.length)return!1;let r=t.find(o=>Yd(this.editor.view.state,o))??t[0];return this.run((o,i)=>Lb(o,i,r))}remove(e){if(!this.editor.isEditable())return!1;let t=this.resolve(e);return t.length?this.run((r,o)=>t.forEach(i=>Rb(r,o,i))):!1}toggle(e){return this.match(e)?this.remove(e):this.apply(e)}run(e){let{view:t}=this.editor,r=t.state.tr;return e(t.state,r)===!1?!1:((r.docChanged||r.storedMarksSet)&&t.dispatch(r.scrollIntoView()),t.focus(),!0)}};function Yd(n,e){return e.selector?Do(n,Oo(e)).length>0:!0}function Xd(n,e){return n.type.name==="image"?!0:Object.entries(Co(e)).every(([t,r])=>n.attrs[t]===r)}function Db(n,e){let t=Fe(e.classes);if(e.block){if(e.block==="blockquote"){let o=al(n);return!!o&&Eo(o.node.attrs.class,t)}let r=n.selection.$from.parent;return To[e.block](r)&&Eo(r.attrs.class,t)&&Xd(r,e)}if(e.selector){let r=Do(n,Oo(e));return r.length>0&&r.some(({node:o})=>Eo(o.attrs.class,t)&&Xd(o,e))}if(e.inline){let r=ll(n,e);if(!r.length)return!1;let{$from:o,empty:i,from:s,to:l}=n.selection;if(i){let u=n.storedMarks??o.marks();return r.every(d=>u.some(p=>sl(p,d)))}let a=!1,c=!0;return n.doc.nodesBetween(s,l,u=>{u.isText&&(a=!0,r.every(d=>u.marks.some(p=>sl(p,d)))||(c=!1))}),a&&c}return!1}function sl(n,e){return n.type!==e.type?!1:e.type.name==="span_class"?Eo(n.attrs.class,Fe(e.attrs.class)):e.attrs.value===void 0||n.attrs.value===e.attrs.value}function Lb(n,e,t){let r=Fe(t.classes),o=$(n);if(t.block==="blockquote"){let i=al(n);return i?(e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:So(i.node.attrs.class,r)}),!0):mo(o.blockquote,{class:So(null,r)})(n,s=>s.steps.forEach(l=>e.step(l)))}if(t.block==="pre"){for(let{node:i,pos:s}of il(n))i.type!==o.code_block&&e.setNodeMarkup(s,o.code_block,{language:null});return!0}if(t.block){let i=t.block==="p"?0:Number(t.block.slice(1)),s=i?o.heading:o.paragraph,l=Co(t);for(let{node:a,pos:c}of il(n)){if(a.type===o.code_block&&a.textContent.includes(`
|
|
12
|
+
`))continue;let u=a.type===s&&(!i||a.attrs.level===i);e.setNodeMarkup(c,s,{...Qd(a.attrs),...i?{level:i}:{},...l,class:So(u?a.attrs.class:null,r)})}return!0}if(t.selector){let i=Co(t),s=Do(n,Oo(t));if(!s.length)return!1;for(let{node:l,pos:a}of s){let c=l.type.name==="image"?{}:i;e.setNodeMarkup(a,void 0,{...l.attrs,...c,class:So(l.attrs.class,r)})}return n.selection instanceof P&&e.setSelection(P.create(e.doc,n.selection.from)),!0}if(t.inline){let i=ll(n,t);if(!i.length)return!1;let{empty:s,ranges:l}=n.selection;if(s){let a=n.storedMarks??n.selection.$from.marks();for(let c of i)a=c.addToSet(a);return e.setStoredMarks(a),!0}for(let{$from:a,$to:c}of l)for(let u of i)e.addMark(a.pos,c.pos,u);return!0}return!1}function Rb(n,e,t){let r=Fe(t.classes),o=$(n);if(t.block==="blockquote"){let i=al(n);if(!i)return;let s=wo(i.node.attrs.class,r);if(r.length&&s!==null){e.setNodeMarkup(i.pos,void 0,{...i.node.attrs,class:s});return}ho(n,l=>l.steps.forEach(a=>e.step(a)));return}if(t.block){for(let{node:i,pos:s}of il(n))To[t.block](i)&&e.setNodeMarkup(s,o.paragraph,{...Qd(i.attrs),class:t.block==="p"?wo(i.attrs.class,r):null});return}if(t.selector){let i=Co(t);for(let{node:s,pos:l}of Do(n,Oo(t))){let a={};s.type.name!=="image"&&("align"in i&&s.attrs.align===i.align&&(a.align=null),"lineHeight"in i&&s.attrs.lineHeight===i.lineHeight&&(a.lineHeight=null)),e.setNodeMarkup(l,void 0,{...s.attrs,...a,class:wo(s.attrs.class,r)})}n.selection instanceof P&&e.setSelection(P.create(e.doc,n.selection.from));return}if(t.inline){let i=ll(n,t),{empty:s,from:l,to:a,$from:c}=n.selection;if(s){let u=(n.storedMarks??c.marks()).filter(d=>!i.some(p=>sl(d,p)));e.setStoredMarks(u);return}for(let u of i){if(u.type.name!=="span_class"){e.removeMark(l,a,u.type);continue}n.doc.nodesBetween(l,a,(d,p)=>{if(!d.isText)return;let f=d.marks.find(b=>b.type===u.type);if(!f)return;let h=Math.max(p,l),g=Math.min(p+d.nodeSize,a);e.removeMark(h,g,u.type);let m=wo(f.attrs.class,Fe(u.attrs.class));m&&e.addMark(h,g,u.type.create({class:m}))})}}}var Pb=/^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i,Ib=/^@(media|supports|container|layer|document|scope)\b/i;function Hb(n){let e=[],t=0,r=0,o=0,i="";for(;t<n.length;){let s=n[t];if(s==="/"&&n[t+1]==="*"){let l=n.indexOf("*/",t+2),a=l===-1?n.length:l+2;if(o===0){n=n.slice(0,t)+n.slice(a);continue}t=a;continue}if(s==='"'||s==="'"){for(t++;t<n.length&&n[t]!==s;)t+=n[t]==="\\"?2:1;t++;continue}if(s==="{")o===0&&(i=n.slice(r,t).trim(),r=t+1),o++;else if(s==="}")o--,o===0&&(e.push({prelude:i,body:n.slice(r,t)}),r=t+1),o<0&&(o=0);else if(s===";"&&o===0){let l=n.slice(r,t).trim();l&&e.push({prelude:l,body:null}),r=t+1}t++}return e}function Bb(n){let e=[],t=0,r="",o=0;for(let i=0;i<n.length;i++){let s=n[i];r?s==="\\"?i++:s===r&&(r=""):s==='"'||s==="'"?r=s:s==="("||s==="["?t++:s===")"||s==="]"?t--:s===","&&t===0&&(e.push(n.slice(o,i)),o=i+1)}return e.push(n.slice(o)),e.map(i=>i.trim()).filter(Boolean)}function Fb(n,e){let t=n,r=!1;for(;;){let o=t.match(/^(html|body|:root)(?![\w-])\s*/i);if(!o)break;r=!0,t=t.slice(o[0].length)}if(!r)return`${e} ${n}`;if(/^[.#[:]/.test(t)){let o=t.search(/[\s>+~]/);return o===-1?`${e}${t}`:`${e}${t.slice(0,o)} ${t.slice(o).trim()}`}return t?`${e} ${t}`:e}function cl(n,e){let t=[];for(let{prelude:r,body:o}of Hb(n)){if(o===null){/^@layer\b/i.test(r)&&t.push(`${r};`);continue}if(Pb.test(r))t.push(`${r}{${o}}`);else if(Ib.test(r))t.push(`${r}{${cl(o,e)}}`);else{if(r.startsWith("@"))continue;{let i=Bb(r).map(s=>Fb(s,e));i.length&&t.push(`${i.join(", ")}{${o}}`)}}}return t.join(`
|
|
13
|
+
`)}function zb(n,e){return n.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi,(t,r,o)=>{if(/^(data:|https?:|\/\/|#)/i.test(o))return t;try{return`url(${r}${new URL(o,e).href}${r})`}catch{return t}})}var Zd=/@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;async function ul(n,e=0){let t=new URL(n,document.baseURI).href,r=await fetch(t);if(!r.ok)throw new Error(`HTTP ${r.status}`);let o=zb(await r.text(),t);if(e>=3)return o.replace(Zd,"");let i=[...o.matchAll(Zd)];for(let s of i){let l=s[3].trim(),a="";try{a=await ul(new URL(s[2],t).href,e+1)}catch(c){console.warn(`[nova] contentCss: could not load ${s[2]}`,c)}o=o.replace(s[0],l?`@media ${l}{${a}}`:a)}return o}function ep(n,e){let t=n.getRootNode();if("adoptedStyleSheets"in t&&typeof CSSStyleSheet<"u"&&"replaceSync"in CSSStyleSheet.prototype)try{let i=new CSSStyleSheet;return i.replaceSync(e),t.adoptedStyleSheets=[...t.adoptedStyleSheets,i],()=>{t.adoptedStyleSheets=t.adoptedStyleSheets.filter(s=>s!==i)}}catch{}let o=document.createElement("style");return o.setAttribute("data-nova-content-css",""),o.textContent=e,n.prepend(o),()=>o.remove()}function tp(n={}){return new z({view(e){return new dl(e,n)}})}var dl=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(this.cursorPos!=null&&t.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,i=o.getBoundingClientRect(),s=i.width/o.offsetWidth,l=i.height/o.offsetHeight;if(t){let d=e.nodeBefore,p=e.nodeAfter;if(d||p){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let h=f.getBoundingClientRect(),g=d?h.bottom:h.top;d&&p&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let m=this.width/2*l;r={left:h.left,right:h.right,top:g-m,bottom:g+m}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),p=this.width/2*s;r={left:d.left-p,right:d.left+p,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),p=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*p,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/s+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/s+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=zn(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);t!=null&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}};var ke=class n extends F{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):F.near(r)}content(){return D.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new pl(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!_b(e)||!$b(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!P.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};ke.prototype.visible=!1;ke.findFrom=ke.findGapCursorFrom;F.jsonID("gapcursor",ke);var pl=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ke.valid(t)?new ke(t):F.near(t)}};function np(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function _b(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||np(o.type))return!0;if(o.inlineContent)return!1}}return!0}function $b(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||np(o.type))return!0;if(o.inlineContent)return!1}}return!0}function rp(){return new z({props:{decorations:jb,createSelectionBetween(n,e,t){return e.pos==t.pos&&ke.valid(t)?new ke(t):null},handleClick:qb,handleKeyDown:Vb,handleDOMEvents:{beforeinput:Wb}}})}var Vb=ro({ArrowLeft:Lo("horiz",-1),ArrowRight:Lo("horiz",1),ArrowUp:Lo("vert",-1),ArrowDown:Lo("vert",1)});function Lo(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof I){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ke.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ke(c))),!0):!1}}function qb(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ke.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&P.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ke(r))),!0)}function Wb(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ke))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=A.empty;for(let s=r.length-1;s>=0;s--)o=A.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new D(o,0,0));return i.setSelection(I.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function jb(n){if(!(n.selection instanceof ke))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",G.create(n.doc,[ae.widget(n.selection.head,e,{key:"gapcursor"})])}var Sl={};Z(Sl,{UPLOAD_RETRY_DELAYS:()=>sp,dataUrlToFile:()=>ap,embeddedImageUploadPlugin:()=>gl,exitImageCaption:()=>kl,getSelectedImage:()=>ze,hasImageCaption:()=>yl,imageDropPastePlugin:()=>bl,isSupportedImage:()=>ar,openImageAltDialog:()=>xl,openImageDialog:()=>cr,setImageAttrs:()=>Sn,setImageWidthFraction:()=>Ml,toggleImageCaption:()=>vl,uploadEmbeddedImage:()=>ml,uploadImages:()=>Ro});var Kb=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;function ar(n){return Kb.test(n.type)}function Ub(n){return new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(r.error??new Error("FileReader failed")),r.readAsDataURL(n)})}function fl(n,e){let t=null;return n.state.doc.descendants((r,o)=>t!==null?!1:(r.type===$(n.state).image&&r.attrs.src===e&&(t=o),!0)),t}function Ro(n,e,t){let r=e.filter(ar),o=n.view;for(let i of r){let s=URL.createObjectURL(i),l=$(o.state).image.create({src:s,alt:null}),a=o.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),o.dispatch(a.scrollIntoView()),hl(n,i,s,0)}}var sp=[1e3,3e3],Po=class extends Error{};function hl(n,e,t,r){let o=n.view,{t:i}=n.ui,s=n.options.uploadImage,l=s?n.ui.notify({text:i("image.uploading"),timeout:0}):null,a=s?s(e,d=>l?.setText(`${i("image.uploading")} ${Math.round(d)}%`)):Ub(e),c=()=>URL.revokeObjectURL(t),u=()=>{let d=o.isDestroyed?null:fl(o,t);d!==null&&o.dispatch(o.state.tr.delete(d,d+1).setMeta("addToHistory",!1)),c()};a.then(d=>{if(!ce(d))throw new Po(`Unsafe image URL returned: ${d}`);let p=o.isDestroyed?null:fl(o,t);if(p!==null){let f=o.state.doc.nodeAt(p);o.dispatch(o.state.tr.setNodeMarkup(p,void 0,{...f.attrs,src:d}).setMeta("addToHistory",!1))}c()}).catch(d=>{if(o.isDestroyed||fl(o,t)===null)return c();let p=sp[r];if(s&&p!==void 0&&!(d instanceof Po)){let f=n.ui.notify({text:i("image.retrying"),timeout:0});setTimeout(()=>{if(f.close(),o.isDestroyed)return c();hl(n,e,t,r+1)},p);return}console.error("[nova] image upload failed",d),n.ui.notify({text:i("image.uploadFailed"),type:"error",actions:[{label:i("image.retry"),onAction:()=>hl(n,e,t,0)},{label:i("image.delete"),onAction:u}],onClose:u})}).finally(()=>l?.close())}var lp=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i;function ap(n,e="pasted-image"){let t=n.match(lp);if(!t)return null;let r=t[1].toLowerCase();try{let o=atob(t[2]),i=new Uint8Array(o.length);for(let l=0;l<o.length;l++)i[l]=o.charCodeAt(l);let s=r.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:r})}catch{return null}}function Jb(n,e,t){let r=n.state.tr;n.state.doc.descendants((o,i)=>{o.type===$(n.state).image&&o.attrs.src===e&&r.setNodeMarkup(i,void 0,{...o.attrs,src:t})}),r.docChanged&&n.dispatch(r.setMeta("addToHistory",!1))}async function ml(n,e){let t=n.options.uploadImage,r=t?ap(e):null;if(!t||!r)return;let o=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(r,s=>o.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!ce(i))throw new Error(`Unsafe image URL returned: ${i}`);Jb(n.view,e,i)}catch(i){console.error("[nova] embedded image upload failed",i),n.ui.notify({text:n.ui.t("image.uploadFailed"),type:"error",actions:[{label:n.ui.t("image.retry"),onAction:()=>{ml(n,e)}}]})}finally{o.close()}}function op(n,e){let t=new Set;return n.descendants(r=>{r.type===e&&lp.test(r.attrs.src)&&t.add(r.attrs.src)}),t}function gl(n){return new z({key:new K("nova-embedded-image-upload"),appendTransaction(e,t,r){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=$(r).image,s=op(t.doc,i),l=[...op(r.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{ml(n,a)})),null}})}function bl(n){return new z({key:new K("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let r=t.clipboardData;if(!r||r.getData("text/html"))return!1;let o=[...r.files].filter(ar);return o.length?(Ro(n,o),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let r=[...t.dataTransfer?.files??[]].filter(ar);if(!r.length)return!1;t.preventDefault();let o=e.posAtCoords({left:t.clientX,top:t.clientY});return Ro(n,r,o?.pos),!0}}})}function cr(n){let{t:e}=n.ui,t=M("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1","aria-label":e("image.drop"),"aria-hidden":"true"}),r=M("button",{type:"button",className:"nova-dropzone"},V(S.upload),M("span",{},e("image.drop"))),o=ee({label:e("image.url"),type:"url",placeholder:"https://"}),i=ee({label:e("image.alt"),hint:e("image.altHint")});gn(n,o,"image",c=>{c.alt&&(i.input.value=c.alt)});let s=M("div",{className:"nova-form"},r,t,M("div",{className:"nova-divider"},M("span",{},e("image.or"))),o.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:o.input,onSubmit:()=>{let c=o.input.value.trim();return!c||!ce(c)?(o.input.setAttribute("aria-invalid","true"),o.input.focus(),e("image.invalid")):(n.exec(nl(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(ar);u.length&&(l.close(),Ro(n,u))};r.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),r.addEventListener("dragover",c=>{c.preventDefault(),r.classList.add("is-dragover")}),r.addEventListener("dragleave",()=>r.classList.remove("is-dragover")),r.addEventListener("drop",c=>{c.preventDefault(),r.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function ze(n){let{selection:e}=n,t=$(n),r=(i,s)=>i.type===t.figure?{node:i,pos:s,attrs:{...i.firstChild?.attrs,align:i.attrs.align}}:{node:i,pos:s,attrs:i.attrs};if(e instanceof P&&(e.node.type===t.image||e.node.type===t.figure))return r(e.node,e.from);let{$from:o}=e;for(let i=o.depth;i>0;i--)if(o.node(i).type===t.figure)return r(o.node(i),o.before(i));return null}function yl(n){return ze(n)?.node.type===$(n).figure}var Gb=["src","alt","title","width","height"],ip=n=>Object.fromEntries(Gb.map(e=>[e,n[e]??null])),vl=(n,e)=>{let t=ze(n);if(!t)return!1;let r=$(n),{pos:o,node:i,attrs:s}=t;if(!e)return!0;let l=n.tr;if(i.type===r.figure){let f=r.image.create({...ip(s),align:s.align??null}),h=[r.paragraph.create(null,f)],g=i.child(1);return g.content.size&&h.push(r.paragraph.create(null,g.content)),l.replaceWith(o,o+i.nodeSize,h),l.setSelection(P.create(l.doc,o+1)),e(l.scrollIntoView()),!0}let a=n.doc.resolve(o),c=a.before(a.depth),u=a.after(a.depth),d=r.figure.create({align:s.align??null},[r.figure_image.create(ip(s)),r.figcaption.create()]),p=3;return a.parent.childCount===1?(l.replaceWith(c,u,d),l.setSelection(I.create(l.doc,c+p))):(l.insert(u,d),l.delete(o,o+i.nodeSize),l.setSelection(I.create(l.doc,l.mapping.map(u,-1)+p))),e(l.scrollIntoView()),!0},kl=(n,e)=>{let{$from:t}=n.selection;if(t.parent.type!==$(n).figcaption)return!1;if(e){let r=t.after(t.depth-1),o=n.tr.insert(r,$(n).paragraph.create());o.setSelection(I.create(o.doc,r+1)),e(o.scrollIntoView())}return!0};function Sn(n){return(e,t)=>{let r=ze(e);if(!r)return!1;if(t){let o=e.tr;if(r.node.type===$(e).figure){let{align:i,...s}=n;if(i!==void 0&&o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,align:i}),Object.keys(s).length){let l=r.node.firstChild;o.setNodeMarkup(r.pos+1,void 0,{...l.attrs,...s})}}else o.setNodeMarkup(r.pos,void 0,{...r.node.attrs,...n}),o.setSelection(P.create(o.doc,r.pos));t(o)}return!0}}function Ml(n,e){let t=ze(n.view.state);if(!t)return!1;if(e===null)return n.exec(Sn({width:null,height:null}));let o=n.view.nodeDOM(t.pos)?.querySelector("img")??null,i=getComputedStyle(n.view.dom),s=n.view.dom.clientWidth-parseFloat(i.paddingLeft||"0")-parseFloat(i.paddingRight||"0"),l=Math.max(24,Math.round(s*e)),a=o&&o.naturalWidth?o.naturalHeight/o.naturalWidth:null;return n.exec(Sn({width:l,height:a?Math.round(l*a):null}))}function xl(n){let e=ze(n.view.state);if(!e)return;let{t}=n.ui,r=ee({label:t("image.alt"),value:String(e.attrs.alt??""),hint:t("image.altHint")}),o=ee({label:t("link.tooltip"),value:String(e.attrs.title??"")});n.ui.openDialog({title:t("image.editAlt"),body:M("div",{className:"nova-form"},r.el,o.el),submitLabel:t("dialog.save"),initialFocus:r.input,onSubmit:()=>(n.exec(Sn({alt:r.input.value.trim()||null,title:o.input.value.trim()||null})),!0)})}var Al={};Z(Al,{InputRule:()=>_e,closeDoubleQuote:()=>dp,closeSingleQuote:()=>fp,ellipsis:()=>Cl,emDash:()=>El,inputRules:()=>wl,openDoubleQuote:()=>up,openSingleQuote:()=>pp,smartQuotes:()=>Zb,textblockTypeInputRule:()=>Io,undoInputRule:()=>Qb,wrappingInputRule:()=>ur});var _e=class{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Yb(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}};function Yb(n){return function(e,t,r,o){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),r+=s;let l=r-o;l>0&&(i=t[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}var Xb=500;function wl({rules:n}){let e=new z({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,i){return cp(t,r,o,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&cp(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function cp(n,e,t,r,o,i){if(n.composing)return!1;let s=n.state,l=s.doc.resolve(e),a=n.state.selection,c=l.parent.textBetween(Math.max(0,l.parentOffset-Xb),l.parentOffset,null,"\uFFFC")+r,u=e==a.from&&t==a.to&&n.state.storedMarks||(e==t?l.marks():l.marksAcross(s.doc.resolve(t))||[]);for(let d=0;d<o.length;d++){let p=o[d];if(!p.inCodeMark&&u.some(m=>m.type.spec.code))continue;if(l.parent.type.spec.code){if(!p.inCode)continue}else if(p.inCode==="only")continue;let f=p.match.exec(c);if(!f||f[0].length<r.length)continue;let h=e-(f[0].length-r.length);if(!p.inCodeMark){let m=!1;if(s.doc.nodesBetween(h,l.pos,b=>{b.isInline&&b.marks.some(k=>k.type.spec.code)&&(m=!0)}),m)continue}let g=p.handler(s,f,h,t,r);if(g)return p.undoable&&g.setMeta(i,{transform:g,from:e,to:t,text:r}),n.dispatch(g),!0}return!1}var Qb=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],i;if(o.spec.isInputRules&&(i=o.getState(n))){if(e){let s=n.tr,l=i.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1},El=new _e(/--$/,"\u2014",{inCodeMark:!1}),Cl=new _e(/\.\.\.$/,"\u2026",{inCodeMark:!1}),up=new _e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),dp=new _e(/"$/,"\u201D",{inCodeMark:!1}),pp=new _e(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),fp=new _e(/'$/,"\u2019",{inCodeMark:!1}),Zb=[up,dp,pp,fp];function ur(n,e,t,r){let o,i;return e instanceof qe?i=e:(o=e,i=e.nodeType,t=e.getAttrs,r=e.joinPredicate),new _e(n,(s,l,a,c)=>{let u=t instanceof Function?t(l):t,d=s.tr.delete(a,c),p=d.doc.resolve(a),f=p.blockRange(),h=f&&It(f,i,u);if(!h)return null;d.wrap(f,h);let g=d.doc.resolve(a-1).nodeBefore;return g&&g.type==i&&bt(d.doc,a-1)&&(!r||r(l,g))&&d.join(a-1),d},o)}function Io(n,e,t){let r,o;return e instanceof qe?o=e:(r=e,o=e.nodeType,t=e.getAttrs),new _e(n,(i,s,l,a)=>{let c=i.doc.resolve(l),u=t instanceof Function?t(s):t;return c.node(-1).canReplaceWith(c.index(-1),c.indexAfter(-1),o)?i.tr.delete(l,a).setBlockType(l,l,o,u):null},r)}function hp(n=()=>!0,e=At){let{nodes:t}=e,r=[Cl,El];n("blockquote")&&r.push(ur(/^\s*>\s$/,t.blockquote)),n("numlist")&&r.push(ur(/^(\d+)\.\s$/,t.ordered_list,o=>({start:Number(o[1])}),(o,i)=>i.childCount+i.attrs.start===Number(o[1]))),n("bullist")&&r.push(ur(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&r.push(Io(/^```$/,t.code_block));for(let o=1;o<=6;o++)n(`h${o}`)&&r.push(Io(new RegExp(`^(#{${o}})\\s$`),t.heading,{level:o}));return wl({rules:r})}var ey=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ty=vn(Ks,(n,e)=>(e?.(n.tr.replaceSelectionWith($(n).hard_break.create()).scrollIntoView()),!0)),Tl=(n,e)=>(t,r,o)=>n(e)(t,r,o);function mp(n=e=>W[e]){let e={"Mod-z":Tl(n,"undo"),"Shift-Mod-z":Tl(n,"redo"),"Mod-b":W.bold,"Mod-i":W.italic,"Mod-u":W.underline,"Mod-Shift-x":W.strike,"Mod-e":W.code,"Mod-,":W.subscript,"Mod-.":W.superscript,"Mod-Alt-0":W.paragraph,"Mod-Alt-1":W.h1,"Mod-Alt-2":W.h2,"Mod-Alt-3":W.h3,"Mod-Alt-4":W.h4,"Mod-Alt-5":W.h5,"Mod-Alt-6":W.h6,"Mod-Shift-7":W.orderedList,"Mod-Shift-8":W.bulletList,"Mod-Shift-l":W.alignLeft,"Mod-Shift-e":W.alignCenter,"Mod-Shift-r":W.alignRight,"Mod-Shift-j":W.alignJustify,"Mod-\\":W.clearFormatting,"Shift-Enter":ty,Enter:vn(kl,(t,r)=>jd($(t).list_item)(t,r)),Tab:el,"Shift-Tab":tl,"Mod-]":W.indent,"Mod-[":W.outdent};return ey||(e["Mod-y"]=Tl(n,"redo")),[Ke(e),Ke(zd)]}var Dl={};Z(Dl,{applyLink:()=>gp,normalizeUrl:()=>Nl,openLinkDialog:()=>at,removeLink:()=>wn});function Nl(n){let e=n.trim();return e?/^[a-z][a-z0-9+.-]*:/i.test(e)||/^[/#?.]/.test(e)?e:/^[^\s@/]+@[^\s@/]+\.[^\s@/]+$/.test(e)?`mailto:${e}`:/^(www\.)?[^\s/]+\.[a-z]{2,}([/:?#].*)?$/i.test(e)?`https://${e}`:e:""}function Ol(n){let{from:e,to:t,empty:r,$from:o}=n.selection;return r?Ut(n,Y(n).link,o.pos)??{from:e,to:t}:{from:e,to:t}}function gp(n){return(e,t)=>{let r=Nl(n.href);if(!r||!Oe(r))return!1;if(!t)return!0;let{from:o,to:i}=Ol(e),s=Y(e).link.create({href:r,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(o,i),a=n.text?.trim()?n.text:null,c=e.tr;if(o===i||a!==null&&a!==l){let u=Y(e).link.removeFromSet(e.doc.resolve(o).marks()),d=e.schema.text(a??(l||r),s.addToSet(u));c.replaceWith(o,i,d)}else c.removeMark(o,i,Y(e).link).addMark(o,i,s);return t(c.scrollIntoView()),!0}}function wn(){return(n,e)=>{let{from:t,to:r}=Ol(n);return t===r||!n.doc.rangeHasMark(t,r,Y(n).link)?!1:(e?.(n.tr.removeMark(t,r,Y(n).link)),!0)}}function at(n){let{t:e}=n.ui,t=n.view.state,r=Kt(t),o=Ol(t),i=t.doc.textBetween(o.from,o.to),s=!i.includes(`
|
|
14
|
+
`)&&t.selection.$from.sameParent(t.doc.resolve(o.to)),l=ee({label:e("link.url"),type:"url",value:r?.href??"",placeholder:"https://",required:!0}),a=ee({label:e("link.text"),value:i}),c=ee({label:e("link.tooltip"),value:r?.title??""}),u=Ac(e("link.newTab"),r?.target==="_blank");gn(n,l,"file",p=>{p.text&&!a.input.value.trim()&&(a.input.value=p.text),p.title&&(c.input.value=p.title)});let d=M("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(r?"link.editTitle":"link.title"),body:d,submitLabel:e(r?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let p=Nl(l.input.value);return!p||!Oe(p)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),e("link.invalid")):(n.exec(gp({href:p,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}function ny(n,e){let t=0;for(let r=e;r<n.length;r++){let o=n[r];if(o==="\\"){r++;continue}if(o==="{")t++;else if(o==="}"&&(t--,t===0))return r}return-1}function ry(n){let e="",t=0;for(let r=0;r<n.length;r++){let o=n[r];if(o==="\\"){t===0&&(e+=o+(n[r+1]??"")),r++;continue}o==="{"?t++:o==="}"?t--:t===0&&(e+=o)}return e}var oy=20*1024*1024;function iy(n){if(n.length%2!==0||n.length/2>oy||!/^[0-9a-f]+$/i.test(n))return null;let e="";for(let t=0;t<n.length;t+=2)e+=String.fromCharCode(parseInt(n.slice(t,t+2),16));return btoa(e)}function Ll(n){let e=[],t=0;for(;;){let r=n.indexOf("{\\pict",t);if(r<0)break;let o=ny(n,r);if(o<0)break;if(t=o+1,/\\nonshppict\s*$/.test(n.slice(Math.max(0,r-16),r)))continue;let i=ry(n.slice(r+1,o)),s=/\\pngblip(?![a-z])/.test(i)?"image/png":/\\jpegblip(?![a-z])/.test(i)?"image/jpeg":null;if(!s)continue;let l=i.replace(/\\[a-z]+-?\d* ?/gi,"").replace(/\s+/g,""),a=iy(l);if(!a)continue;let c=atob(a.slice(0,12));(s==="image/png"?c.startsWith("\x89PNG"):c.charCodeAt(0)===255&&c.charCodeAt(1)===216)&&e.push({type:s,base64:a})}return e}function Rl(n){return/<img[^>]+src=["']?file:/i.test(n)}function Pl(n,e){let t=document.createElement("template");t.innerHTML=n;let r=[...t.content.querySelectorAll("img")].filter(o=>/^file:/i.test(o.getAttribute("src")??""));return!r.length||r.length!==e.length?n:(r.forEach((o,i)=>{let s=e[i];o.setAttribute("src",`data:${s.type};base64,${s.base64}`)}),t.innerHTML)}var Ho=null,Il=null;function Hl(){return Il??(Il=import(__novaChunk("tinymce-chunks/paste-office-a38659d6.js") ).then(n=>Ho=n,()=>(Il=null,null))),Il}var sy=new K("nova-paste");function ly(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,r="",o=i=>{if(i.nodeType===Node.TEXT_NODE){r+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(o);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){r+=`
|
|
15
15
|
`;return}let s=t.test(i.tagName);s&&r&&!r.endsWith(`
|
|
16
16
|
`)&&(r+=`
|
|
17
17
|
`),i.childNodes.forEach(o),s&&(r+=`
|
|
@@ -19,23 +19,23 @@
|
|
|
19
19
|
`).map(i=>i.trim()).join(`
|
|
20
20
|
`).replace(/\n{3,}/g,`
|
|
21
21
|
|
|
22
|
-
`).trim()}function
|
|
22
|
+
`).trim()}function bp(n){let e=!1;return new z({key:sy,props:{transformPasted(t,r){let{selection:o}=r.state,i=o.$from.parent;return t.openStart>0&&o.empty&&i.isTextblock&&i.content.size===0&&t.content.firstChild?.isBlock?new D(t.content,0,t.openEnd):t},transformPastedHTML(t){let{pastePreprocess:r,pastePostprocess:o,pasteStyles:i}=n.options,s=r?r(t,n):t;if(Ho&&(s=Ho.cleanPastedHTML(s,i??"clean")),o){let l=document.createElement("template");l.innerHTML=s;let a=document.createElement("div");a.append(l.content),o(a,n),s=a.innerHTML}return s},handleDOMEvents:{paste(t,r){if(Ho||e||n.isPasteAsText())return!1;let o=r.clipboardData,i=o?.getData("text/html");if(!i)return!1;let s=Rl(i)?o?.getData("text/rtf")??"":"";return r.preventDefault(),Hl().then(()=>{if(t.isDestroyed)return;let l=s&&n.isAllowed("image")?Pl(i,Ll(s)):i;e=!0;try{t.pasteHTML(l)}finally{e=!1}}),!0}},handlePaste(t,r,o){if(e)return!1;let i=r.clipboardData?.getData("text/html");if(!n.isPasteAsText()){let l=i&&Rl(i)?r.clipboardData?.getData("text/rtf"):"";if(!i||!l||!n.isAllowed("image"))return!1;let a=Pl(i,Ll(l));if(a===i)return!1;e=!0;try{t.pasteHTML(a,r)}finally{e=!1}return!0}let s=i?ly(i):r.clipboardData?.getData("text/plain")||o.content.textBetween(0,o.content.size,`
|
|
23
23
|
|
|
24
|
-
`);if(!s)return!1;e=!0;try{t.pasteText(s)}finally{e=!1}return!0}}})}var M1,Qp=P(()=>{"use strict";de();K();jp();Xp();M1=new J("nova-paste")});function A1(n){n.querySelectorAll("td, th").forEach(e=>{let t=e.style.backgroundColor;t&&(e.setAttribute(E1,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}function Ar(n){let e=Zp.get(n);return e||(e=new El(n,St.fromSchema(n).rules),Zp.set(n,e)),e}var E1,El,Zp,NM,eh=P(()=>{"use strict";de();et();E1="data-nova-cell-bg";El=class extends St{atomSelector;prepare(e){A1(e),this.atomSelector??=Object.values(this.schema.nodes).filter(t=>t.spec.ignoreStyles).flatMap(t=>(t.spec.parseDOM??[]).map(r=>r.tag)).filter(t=>!!t).join(", "),!(!this.atomSelector||!("querySelectorAll"in e))&&e.querySelectorAll(this.atomSelector).forEach(t=>{t.removeAttribute("style")})}parse(e,t){return this.prepare(e),super.parse(e,t)}parseSlice(e,t){return this.prepare(e),super.parseSlice(e,t)}},Zp=new WeakMap;NM=Ar(nn)});function oi(n,e,t){let r=[],o=v("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(v("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(v("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=v("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=v("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?v("span",{className:"nova-menu-check"},a.active?X(M.check):null):null,a.icon?X(a.icon):null,c,a.shortcut?v("kbd",{className:"nova-menu-shortcut"},Qe(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),r.push(u),o.append(u)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),u=c.indexOf(document.activeElement);switch(a.key){case"ArrowDown":a.preventDefault(),l(u+1);break;case"ArrowUp":a.preventDefault(),l(u-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let d=a.key.toLowerCase(),f=u+1;[...c.slice(f),...c.slice(0,f)].find(h=>h.textContent?.trim().toLowerCase().startsWith(d))?.focus()}}}),o}function ii(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Al=P(()=>{"use strict";Z();j()});function rh(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=p=>p.title.startsWith("menu.")?o(p.title):p.title,a=p=>{let h=[];for(let m of p.items.split(/\s+/)){if(!m)continue;if(m==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(m))continue;let g=n.ui.registry.getMenuItem(m);g&&h.push({id:m,label:g.text,...g.icon?{icon:g.icon}:{},...g.shortcut?{shortcut:g.shortcut}:{},...g.isActive?{active:g.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(g.isEnabled?!g.isEnabled(n):!1),onSelect:()=>g.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],u=null,d=()=>{u?.popover.close(),u=null},f=(p,h)=>{d();let m=c[p],g=r[m.dataset.menu],b=a(g);if(!b.length)return;let x=oi(b,()=>n.ui.closePopover(),l(g));x.addEventListener("keydown",E=>{if(E.key!=="ArrowLeft"&&E.key!=="ArrowRight")return;E.preventDefault();let D=(p+(E.key==="ArrowRight"?1:-1)+c.length)%c.length;f(D,!0)}),m.setAttribute("aria-expanded","true");let w=n.ui.openPopover({anchor:m,content:x,ignore:[e],className:"nova-popover-menu",onClose:E=>{m.setAttribute("aria-expanded","false"),u?.popover===w&&(u=null),E==="escape"&&m.focus()}});u={index:p,popover:w},h&&ii(x)};for(let p of t.split(/\s+/).filter(Boolean)){let h=r[p];if(!h)continue;let m=v("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":p,tabindex:c.length===0?"0":"-1"},l(h)),g=c.length;m.addEventListener("click",b=>{if(u?.index===g)return d();f(g,b.detail===0)}),m.addEventListener("mouseenter",()=>{u&&u.index!==g&&f(g,!1)}),c.push(m),e.append(m)}return e.addEventListener("keydown",p=>{let h=c.indexOf(document.activeElement);if(h<0)return;let m=g=>{p.preventDefault();let b=(g+c.length)%c.length;c.forEach((x,w)=>x.tabIndex=w===b?0:-1),c[b].focus()};p.key==="ArrowRight"?m(h+1):p.key==="ArrowLeft"?m(h-1):p.key==="Home"?m(0):p.key==="End"?m(c.length-1):p.key==="ArrowDown"?(p.preventDefault(),f(h,!0)):p.key==="Escape"&&(p.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",p=>{p.target.closest("button")&&p.preventDefault()},{signal:s}),{focus:()=>(c.find(p=>p.tabIndex===0)??c[0])?.focus(),destroy:()=>{d(),i.abort(),e.replaceChildren()}}}var th,nh,oh=P(()=>{"use strict";Z();Al();th={file:{title:"menu.file",items:"preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen"},insert:{title:"menu.insert",items:"image link inserttable hr | insertdatetime"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tabledelete"},help:{title:"menu.help",items:"help"}},nh="file edit view insert format table help"});function N1(n){let e=v("iframe",{title:"print","aria-hidden":"true",tabindex:"-1"});e.style.cssText="position:fixed;width:0;height:0;border:0;right:0;bottom:0;visibility:hidden",document.body.append(e);let t=e.contentDocument;if(!t)return e.remove();let r=t.createElement("style");r.textContent=T1,t.head.append(r),t.body.append(je.fromSchema(n.schema).serializeFragment(n.view.state.doc.content,{document:t}));let o=e.contentWindow,i=()=>setTimeout(()=>e.remove(),1e3);o?.addEventListener("afterprint",i),o?.focus(),o?.print(),i()}function L1(n){let{t:e}=n.ui,t=ce({label:e("table.rows"),value:"3"}),r=ce({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:v("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(it(o,i)),!0)}})}function ih(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:M.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new me(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:M.print,shortcut:"Mod-p",onAction:r=>N1(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:M.table,isEnabled:r=>r.can(it(1,1)),onAction:r=>L1(r)})}var T1,sh=P(()=>{"use strict";de();K();zn();At();Z();j();T1=`
|
|
24
|
+
`);if(!s)return!1;e=!0;try{t.pasteText(s)}finally{e=!1}return!0}}})}var Jl={};Z(Jl,{MAX_GRID:()=>En,createTable:()=>yp,createTableGridPanel:()=>Ul,getCellProps:()=>Wl,getTableProps:()=>Vl,hasHeaderColumn:()=>$l,hasHeaderRow:()=>_l,insertTable:()=>ct,isCellSelection:()=>cy,isInTable:()=>Et,loadTables:()=>Fl,loadedTables:()=>ay,setCellBackground:()=>zl,setCellProps:()=>jl,setTableProps:()=>ql,sortTable:()=>Bo,tableCommands:()=>De,tableRect:()=>Kl});var fe=null,Bl=null;function Fl(){return Bl??(Bl=import(__novaChunk("tinymce-chunks/table-80284f6f.js") ).then(n=>fe=n,n=>(console.warn("[nova] failed to load table editing",n),Bl=null,null))),Bl}function ay(){return fe}var $e=n=>(e,t,r)=>fe?fe.tableCommands[n](e,t,r):!1,De={addRowBefore:$e("addRowBefore"),addRowAfter:$e("addRowAfter"),deleteRow:$e("deleteRow"),addColumnBefore:$e("addColumnBefore"),addColumnAfter:$e("addColumnAfter"),deleteColumn:$e("deleteColumn"),mergeCells:$e("mergeCells"),splitCell:$e("splitCell"),toggleHeaderRow:$e("toggleHeaderRow"),toggleHeaderColumn:$e("toggleHeaderColumn"),deleteTable:$e("deleteTable")};function zl(n){return(e,t,r)=>fe?fe.setCellBackground(n)(e,t,r):!1}function _l(n){return fe?.hasHeaderRow(n)??!1}function $l(n){return fe?.hasHeaderColumn(n)??!1}function cy(n){return fe?.isCellSelection(n)??!1}function Vl(n){return fe?.getTableProps(n)??null}function ql(n){return(e,t,r)=>fe?fe.setTableProps(n)(e,t,r):!1}function Wl(n){return fe?.getCellProps(n)??null}function jl(n){return(e,t,r)=>fe?fe.setCellProps(n)(e,t,r):!1}function Bo(n,e){return(t,r,o)=>fe?fe.sortTable(n,e)(t,r,o):!1}var En=10;function Kl(n){let{$from:e}=n.view.state.selection;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole==="table")return n.view.nodeDOM(e.before(t))?.getBoundingClientRect()??null;return null}function yp(n,e,t=!0,r=At){let{table:o,table_row:i,table_cell:s,table_header:l,paragraph:a}=r.nodes,c=[];for(let u=0;u<n;u++){let d=t&&u===0?l:s,p=[];for(let f=0;f<e;f++)p.push(d.create(null,a.create()));c.push(i.create(null,p))}return o.create(null,c)}function ct(n,e,t=!0){return(r,o)=>{if(n<1||e<1||n>100||e>50||Et(r))return!1;if(o){let i=yp(n,e,t,r.schema),s=r.tr.replaceSelectionWith(i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(I.near(s.doc.resolve(l+3))),o(s.scrollIntoView())}return!0}}function Ul(n,e,t){let r=1,o=1,i=[],s=M("div",{className:"nova-grid-caption","aria-live":"polite"}),l=M("div",{className:"nova-grid",role:"grid","aria-label":t}),a=()=>{for(let c of i){let u=Number(c.dataset.row),d=Number(c.dataset.col);c.classList.toggle("is-on",u<=r&&d<=o),c.tabIndex=u===r&&d===o?0:-1}s.textContent=e(r,o)};for(let c=1;c<=En;c++)for(let u=1;u<=En;u++){let d=M("button",{type:"button",className:"nova-grid-cell",role:"gridcell","aria-label":e(c,u),"data-row":String(c),"data-col":String(u)});d.addEventListener("mouseenter",()=>{r=c,o=u,a()}),d.addEventListener("click",()=>n(c,u)),i.push(d),l.append(d)}return l.addEventListener("keydown",c=>{let d={ArrowRight:[0,1],ArrowLeft:[0,-1],ArrowDown:[1,0],ArrowUp:[-1,0]}[c.key];d&&(c.preventDefault(),r=Math.min(En,Math.max(1,r+d[0])),o=Math.min(En,Math.max(1,o+d[1])),a(),i[(r-1)*En+(o-1)].focus())}),a(),M("div",{className:"nova-grid-panel"},l,s)}var Gl=new WeakSet,Yl=new WeakMap,vp=new WeakSet;function Xl(n){for(let e of n){let t=e.spec,r=t.view;!r||vp.has(e)||(vp.add(e),t.view=o=>{let i=Yl.get(o);i||Yl.set(o,i=new Map);let s=i.get(e);s||i.set(e,s=r(o));let l=s;return{update:(a,c)=>l.update?.(a,c),destroy:()=>{Gl.has(o)||(i.delete(e),l.destroy?.())}}})}}function Ql(n,e){Xl(e),Gl.add(n);try{n.updateState(n.state.reconfigure({plugins:e}))}finally{Gl.delete(n)}let t=Yl.get(n);if(t)for(let[r,o]of t)e.includes(r)||(t.delete(r),o.destroy?.())}var Fo="data-nova-own-style",Zl=null;function ea(n){Zl=n}var kp=!1;function Mp(n){return!!n.extendedValidElements||!!n.customElements||/\[/.test(n.validElements??"")?Zl?Zl.create(n):(kp||(kp=!0,console.warn("[nova] attribute lists, extendedValidElements and customElements need: import { htmlRules } from '@novaprose/core/html-rules'; registerHtmlRules(htmlRules);")),null):null}var uy="data-nova-cell-bg",ta="http://www.w3.org/1999/xhtml",dy="http://www.w3.org/1998/Math/MathML";function py(n){let e=[...n.querySelectorAll("*")].filter(t=>t.namespaceURI!==ta&&(t.parentElement?.namespaceURI??ta)===ta);for(let t of e){let r=t.namespaceURI===dy?t.textContent??"":"";t.replaceWith(t.ownerDocument.createTextNode(r))}}function fy(n){py(n),n.querySelectorAll("td, th").forEach(e=>{if(!e.style)return;let t=e.style.backgroundColor;t&&(e.setAttribute(uy,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}var na=class extends Qe{constructor(){super(...arguments);E(this,"atomSelector");E(this,"ownStyleSelector")}prepare(t){fy(t),this.ownStyleSelector??(this.ownStyleSelector=Object.values(this.schema.nodes).flatMap(r=>r.spec.ownStyleTags??[]).join(", ")),this.ownStyleSelector&&"querySelectorAll"in t&&t.querySelectorAll(this.ownStyleSelector).forEach(r=>{let o=r.getAttribute("style");o!==null&&(r.setAttribute(Fo,o),r.removeAttribute("style"))}),this.atomSelector??(this.atomSelector=Object.values(this.schema.nodes).filter(r=>r.spec.ignoreStyles).flatMap(r=>(r.spec.parseDOM??[]).map(o=>o.tag)).filter(r=>!!r).join(", ")),!(!this.atomSelector||!("querySelectorAll"in t))&&t.querySelectorAll(this.atomSelector).forEach(r=>{r.removeAttribute("style")})}parse(t,r){return this.prepare(t),super.parse(t,r)}parseSlice(t,r){return this.prepare(t),super.parseSlice(t,r)}},xp=new WeakMap;function dr(n){let e=xp.get(n);return e||(e=new na(n,Qe.fromSchema(n).rules),xp.set(n,e)),e}var A0=dr(At);function zo(n,e,t){let r=[],o=M("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>(a.type===void 0||a.type==="item")&&a.active!==void 0);for(let a of n){if(a.type==="separator"){o.append(M("div",{className:"nova-menu-sep",role:"separator"}));continue}if(a.type==="heading"){o.append(M("div",{className:"nova-menu-heading",role:"presentation"},a.label));continue}let c=M("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=M("button",{type:"button",className:"nova-menu-item",role:a.active===void 0?"menuitem":a.checkbox?"menuitemcheckbox":"menuitemradio",tabindex:"-1","data-id":a.id,disabled:a.disabled??!1,...a.active!==void 0?{"aria-checked":String(a.active)}:{}},i?M("span",{className:"nova-menu-check"},a.active?V(S.check):null):null,a.icon?V(a.icon):null,c,a.shortcut?M("kbd",{className:"nova-menu-shortcut"},tt(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),r.push(u),o.append(u)}let s=()=>r.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return o.addEventListener("keydown",a=>{let c=s(),u=c.indexOf(j(o));switch(a.key){case"ArrowDown":a.preventDefault(),l(u+1);break;case"ArrowUp":a.preventDefault(),l(u-1);break;case"Home":a.preventDefault(),l(0);break;case"End":a.preventDefault(),l(c.length-1);break;case"Tab":a.preventDefault();break;default:if(a.key.length===1&&/\S/.test(a.key)){let d=a.key.toLowerCase(),p=u+1;[...c.slice(p),...c.slice(0,p)].find(h=>h.textContent?.trim().toLowerCase().startsWith(d))?.focus()}}}),o}function _o(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Sp={file:{title:"menu.file",items:"preview | print"},edit:{title:"menu.edit",items:"undo redo | selectall | searchreplace pastetext"},view:{title:"menu.view",items:"code preview | fullscreen"},insert:{title:"menu.insert",items:"image link inserttable hr | insertdatetime"},format:{title:"menu.format",items:"bold italic underline strikethrough superscript subscript inlinecode | paragraph h1 h2 h3 blockquote codeblock | alignleft aligncenter alignright alignjustify | removeformat"},table:{title:"menu.table",items:"inserttable | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tabledelete"},help:{title:"menu.help",items:"help"}},wp="file edit view insert format table help";function Ep(n,e,t,r){let{t:o}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",o("menu.label"));let i=new AbortController,{signal:s}=i,l=f=>f.title.startsWith("menu.")?o(f.title):f.title,a=f=>{let h=[];for(let g of f.items.split(/\s+/)){if(!g)continue;if(g==="|"){h.length&&h[h.length-1].type!=="separator"&&h.push({type:"separator"});continue}if(!n.isAllowed(g))continue;let m=n.ui.registry.getMenuItem(g);m&&h.push({id:g,label:m.text,...m.icon?{icon:m.icon}:{},...m.shortcut?{shortcut:m.shortcut}:{},...m.isActive?{active:m.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(m.isEnabled?!m.isEnabled(n):!1),onSelect:()=>m.onAction(n)})}for(;h.length&&h[h.length-1].type==="separator";)h.pop();return h},c=[],u=null,d=()=>{u?.popover.close(),u=null},p=(f,h)=>{d();let g=c[f],m=r[g.dataset.menu],b=a(m);if(!b.length)return;let k=zo(b,()=>n.ui.closePopover(),l(m));k.addEventListener("keydown",w=>{let N=Me(w,k);if(N!=="ArrowLeft"&&N!=="ArrowRight")return;w.preventDefault();let L=(f+(N==="ArrowRight"?1:-1)+c.length)%c.length;p(L,!0)}),g.setAttribute("aria-expanded","true");let y=n.ui.openPopover({anchor:g,content:k,ignore:[e],className:"nova-popover-menu",onClose:w=>{g.setAttribute("aria-expanded","false"),u?.popover===y&&(u=null),w==="escape"&&g.focus()}});u={index:f,popover:y},h&&_o(k)};for(let f of t.split(/\s+/).filter(Boolean)){let h=r[f];if(!h)continue;let g=M("button",{type:"button",className:"nova-menubar-item",role:"menuitem","aria-haspopup":"menu","aria-expanded":"false","data-menu":f,tabindex:c.length===0?"0":"-1"},l(h)),m=c.length;g.addEventListener("click",b=>{if(u?.index===m)return d();p(m,b.detail===0)}),g.addEventListener("mouseenter",()=>{u&&u.index!==m&&p(m,!1)}),c.push(g),e.append(g)}return e.addEventListener("keydown",f=>{let h=c.indexOf(j(e));if(h<0)return;let g=b=>{f.preventDefault();let k=(b+c.length)%c.length;c.forEach((y,w)=>y.tabIndex=w===k?0:-1),c[k].focus()},m=Me(f,e);m==="ArrowRight"?g(h+1):m==="ArrowLeft"?g(h-1):f.key==="Home"?g(0):f.key==="End"?g(c.length-1):f.key==="ArrowDown"?(f.preventDefault(),p(h,!0)):f.key==="Escape"&&(f.preventDefault(),n.focus())},{signal:s}),e.addEventListener("mousedown",f=>{f.target.closest("button")&&f.preventDefault()},{signal:s}),{focus:()=>(c.find(f=>f.tabIndex===0)??c[0])?.focus(),destroy:()=>{d(),i.abort(),e.replaceChildren()}}}var hy=`
|
|
25
25
|
body { font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #000; margin: 2cm; }
|
|
26
26
|
img { max-width: 100%; height: auto; }
|
|
27
27
|
table { border-collapse: collapse; width: 100%; }
|
|
28
28
|
td, th { border: 1px solid #999; padding: 4px 8px; vertical-align: top; }
|
|
29
29
|
pre { white-space: pre-wrap; background: #f5f5f5; padding: 8px; }
|
|
30
30
|
blockquote { border-left: 3px solid #ccc; margin-left: 0; padding-left: 1em; color: #444; }
|
|
31
|
-
|
|
32
|
-
`).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):
|
|
33
|
-
`)&&
|
|
31
|
+
`;function my(n){let e=M("iframe",{title:"print","aria-hidden":"true",tabindex:"-1"});e.style.cssText="position:fixed;width:0;height:0;border:0;right:0;bottom:0;visibility:hidden",document.body.append(e);let t=e.contentDocument;if(!t)return e.remove();let r=t.createElement("style");r.textContent=hy,t.head.append(r),t.body.append(Le.fromSchema(n.schema).serializeFragment(n.view.state.doc.content,{document:t}));let o=e.contentWindow,i=()=>setTimeout(()=>e.remove(),1e3);o?.addEventListener("afterprint",i),o?.focus(),o?.print(),i()}function gy(n){let{t:e}=n.ui,t=ee({label:e("table.rows"),value:"3"}),r=ee({label:e("table.cols"),value:"3"});for(let o of[t,r])o.input.type="number",o.input.min="1",o.input.max="50",o.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:M("div",{className:"nova-form nova-form-row"},t.el,r.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let o=Number(t.input.value),i=Number(r.input.value);return!Number.isInteger(o)||!Number.isInteger(i)||o<1||i<1||o>50||i>50?e("table.invalidSize"):(n.exec(ct(o,i)),!0)}})}function Cp(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:S.paragraph,shortcut:"Mod-Alt-0",isActive:r=>r.view.state.selection.$from.parent.type.name==="paragraph",onAction:r=>r.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:r=>{r.view.dispatch(r.view.state.tr.setSelection(new se(r.view.state.doc))),r.focus()}}),e.addMenuItem("print",{text:t("print"),icon:S.print,shortcut:"Mod-p",onAction:r=>my(r)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:S.table,isEnabled:r=>r.can(ct(1,1)),onAction:r=>gy(r)})}var Ap={b:"strong",i:"em",strike:"s",del:"s",tbody:"table",thead:"table",tfoot:"table",caption:"table",colgroup:"table",col:"table",figcaption:"figure"},by=["p","h1","h2","h3","h4","h5","h6","blockquote","pre","hr","ul","ol","li","img","figure","br","table","tr","td","th","strong","em","u","s","code","a","sub","sup","span"];var yy={bold:["strong"],italic:["em"],underline:["u"],strikethrough:["s"],strike:["s"],inlinecode:["code"],code:["code"],subscript:["sub"],superscript:["sup"],link:["a"],unlink:["a"],quicklink:["a"],image:["img"],quickimage:["img"],table:["table"],quicktable:["table"],inserttable:["table"],tableinsertrowbefore:["table"],tableinsertrowafter:["table"],tabledeleterow:["table"],tableinsertcolbefore:["table"],tableinsertcolafter:["table"],tabledeletecol:["table"],tablemergecells:["table"],tablesplitcells:["table"],tabledelete:["table"],tablerowheader:["th"],tablecolheader:["th"],tablecellbackground:["style:background-color"],bullist:["ul"],bulletlist:["ul"],numlist:["ol"],orderedlist:["ol"],blockquote:["blockquote"],codeblock:["pre"],hr:["hr"],horizontalrule:["hr"],h1:["h1"],h2:["h2"],h3:["h3"],h4:["h4"],h5:["h5"],h6:["h6"],forecolor:["span","style:color"],backcolor:["span","style:background-color"],fontfamily:["span","style:font-family"],fontsize:["span","style:font-size"],lineheight:["style:line-height"],align:["style:text-align"],alignleft:["style:text-align"],aligncenter:["style:text-align"],alignright:["style:text-align"],alignjustify:["style:text-align"],imagealignleft:["style:float"],imagealigncenter:["style:float"],imagealignright:["style:float"]};function ra(n){if(n===void 0)return null;let e=new Set;for(let t of n.split(",")){let r=t.trim().replace(/^[-#+!]+/,"").replace(/\[.*$/,"").toLowerCase();for(let o of r.split("/")){let i=o.trim();i&&e.add(Ap[i]??i)}}return e}function vy(n){if(n===void 0)return null;let e=typeof n=="string"?n:Object.values(n).join(",");return new Set(e.split(",").map(t=>t.trim().toLowerCase()).filter(Boolean))}var $o=class{constructor(e){E(this,"tags");E(this,"styles");let t=ra(e.validElements),r=ra(e.invalidElements)??new Set,o=new Set(t??by);if(t)for(let i of ra(e.extendedValidElements)??[])o.add(i);(o.has("ul")||o.has("ol"))&&o.add("li"),o.has("table")&&(o.add("tr"),o.add("td"));for(let i of r)o.delete(i);o.add("p"),this.tags=o,this.styles=vy(e.validStyles)}isTagAllowed(e){let t=e.toLowerCase();return this.tags.has(Ap[t]??t)}isStyleAllowed(e){return!this.styles||this.styles.has(e.toLowerCase())}isAllowed(e){let t=yy[e.toLowerCase()];return t?t.every(r=>r.startsWith("style:")?this.isStyleAllowed(r.slice(6)):this.isTagAllowed(r)):!0}markAllowed(e){switch(e.type.name){case"bold":return this.isTagAllowed("strong");case"italic":return this.isTagAllowed("em");case"underline":return this.isTagAllowed("u");case"strike":return this.isTagAllowed("s");case"code":return this.isTagAllowed("code");case"link":return this.isTagAllowed("a");case"subscript":return this.isTagAllowed("sub");case"superscript":return this.isTagAllowed("sup");case"color":return this.isTagAllowed("span")&&this.isStyleAllowed("color");case"background":return this.isTagAllowed("span")&&this.isStyleAllowed("background-color");case"font_family":return this.isTagAllowed("span")&&this.isStyleAllowed("font-family");case"font_size":return this.isTagAllowed("span")&&this.isStyleAllowed("font-size");default:return!0}}blockAttrs(e){return{...e,...this.isStyleAllowed("text-align")?{}:{align:null},...this.isStyleAllowed("line-height")?{}:{lineHeight:null},...this.isStyleAllowed("margin-left")?{}:{indent:0}}}normalize(e){let t=e.type.schema,{nodes:r}=t;if(e.isText){let l=e.marks.filter(a=>this.markAllowed(a));return[l.length===e.marks.length?e:e.mark(l)]}let o=e.marks.filter(l=>this.markAllowed(l));switch(e.type){case r.image:return this.isTagAllowed("img")?[r.image.create({...e.attrs,...this.isStyleAllowed("float")?{}:{align:null}},null,o)]:[];case r.figure:{let l=e.childCount>1?e.child(1).content:null,a=l?.size?[r.paragraph.create(null,this.normalizeChildren(l))]:[],c=e.firstChild;if(!this.isTagAllowed("img")||!c)return a;let u=this.isStyleAllowed("float")?e.attrs.align:null;if(!this.isTagAllowed("figure")){let d=r.image.create({...c.attrs,align:u});return[r.paragraph.create(null,d),...a]}return[r.figure.create({...e.attrs,align:u},e.content)]}case r.hard_break:return this.isTagAllowed("br")?[e.mark(o)]:[t.text(" ",o)];case r.horizontal_rule:return this.isTagAllowed("hr")?[e]:[]}let i=this.normalizeChildren(e.content),s=(l=e.type,a=e.attrs)=>{try{return[l.createChecked(a,i,e.marks)]}catch{let c=l.createAndFill(a,i,e.marks);return c?[c]:i.content.length?oa(i):[]}};switch(e.type){case r.paragraph:return s(r.paragraph,this.blockAttrs(e.attrs));case r.heading:return this.isTagAllowed(`h${e.attrs.level}`)?s(r.heading,this.blockAttrs(e.attrs)):s(r.paragraph,this.blockAttrs({align:e.attrs.align,lineHeight:e.attrs.lineHeight}));case r.blockquote:return this.isTagAllowed("blockquote")?s():oa(i);case r.code_block:return this.isTagAllowed("pre")?s():e.textContent.split(`
|
|
32
|
+
`).map(l=>r.paragraph.create(null,l?t.text(l):null));case r.bullet_list:case r.ordered_list:return this.isTagAllowed(e.type===r.bullet_list?"ul":"ol")?s(e.type,{...e.attrs,...this.isStyleAllowed("list-style-type")?{}:{listStyle:null}}):ky(i);case r.table:return this.isTagAllowed("table")?s():My(i);case r.table_header:return this.isTagAllowed("th")?s():s(r.table_cell,e.attrs);case r.table_cell:return s(r.table_cell,{...e.attrs,...this.isStyleAllowed("background-color")?{}:{background:null}});default:return s()}}normalizeChildren(e){let t=[];return e.forEach(r=>t.push(...this.normalize(r))),A.from(t)}normalizeDoc(e){let t=this.normalizeChildren(e.content),r=e.type.schema;return e.type.createAndFill(null,t.size?t:r.nodes.paragraph.create())}};function oa(n){let e=[],t=[],r=()=>{t.length&&e.push(t[0].type.schema.nodes.paragraph.create(null,t)),t=[]};return n.forEach(o=>{o.isInline?t.push(o):(r(),e.push(o))}),r(),e}function ky(n){let e=[];return n.forEach(t=>{t.type===t.type.schema.nodes.list_item?t.content.forEach(r=>e.push(r)):e.push(...oa(A.from(t)))}),e}function My(n){let e=[];return n.forEach(t=>t.forEach(r=>r.forEach(o=>e.push(o)))),e}var xy=new K("nova-content-rules");function Tp(n){return new z({key:xy,appendTransaction(e,t,r){if(!e.some(c=>c.docChanged))return null;let o=t.doc.content.findDiffStart(r.doc.content);if(o===null)return null;let i=t.doc.content.findDiffEnd(r.doc.content)?.b??r.doc.content.size,s=r.doc,l=[];if(s.forEach((c,u)=>{let d=u,p=u+c.nodeSize;if(p<o||d>Math.max(o,i))return;let f=n.normalize(c);f.length===1&&f[0].eq(c)||l.push({from:d,to:p,nodes:f})}),!l.length)return null;let a=r.tr;for(let{from:c,to:u,nodes:d}of l.reverse())d.length?a.replaceWith(c,u,d):a.doc.childCount>1?a.delete(c,u):a.replaceWith(c,u,r.schema.nodes.paragraph.create());return a.setMeta("addToHistory",e.every(c=>c.getMeta("addToHistory")!==!1))}})}var pr=1e4,Sy="\uFFFC",Jt=new K("nova-search"),ia={query:"",caseSensitive:!1,wholeWord:!1,matches:[],current:-1};function wy({query:n,caseSensitive:e,wholeWord:t}){if(!n)return null;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=t?`(?<![\\p{L}\\p{N}_])${r}(?![\\p{L}\\p{N}_])`:r;return new RegExp(o,e?"gu":"giu")}function Np(n,e){let t=wy(e);if(!t)return[];let r=[];return n.descendants((o,i)=>{if(r.length>=pr)return!1;if(!o.isTextblock)return!0;let s=o.textBetween(0,o.content.size,void 0,Sy);t.lastIndex=0;let l;for(;(l=t.exec(s))&&r.length<pr;){if(l[0].length===0){t.lastIndex+=1;continue}r.push({from:i+1+l.index,to:i+1+l.index+l[0].length})}return!1}),r}function Op(n,e){if(!n.length)return-1;let t=n.findIndex(r=>r.from>=e);return t<0?0:t}function Dp(){return new z({key:Jt,state:{init:()=>ia,apply(n,e,t,r){let o=n.getMeta(Jt);if(o?.type==="clear")return ia;if(o?.type==="set"){let i=Np(r.doc,o.options);return{...o.options,matches:i,current:Op(i,r.selection.from)}}if(o?.type==="goto")return{...e,current:o.index};if(n.docChanged&&e.query){let i=Np(r.doc,e),s=e.matches[e.current]?.from,l=s===void 0?-1:Op(i,n.mapping.map(s));return{...e,matches:i,current:l}}return e}},props:{decorations(n){let e=Jt.getState(n);return e?.matches.length?G.create(n.doc,e.matches.map((t,r)=>ae.inline(t.from,t.to,{class:r===e.current?"nova-search-match nova-search-current":"nova-search-match"}))):null}}})}function Cn(n){return Jt.getState(n)??ia}function Lp(n){return(e,t)=>(t?.(e.tr.setMeta(Jt,{type:"set",options:n})),!0)}var Rp=(n,e)=>(e?.(n.tr.setMeta(Jt,{type:"clear"})),!0);function Ey(n,e,t){return n.setMeta(Jt,{type:"goto",index:t}).setSelection(I.create(n.doc,e.from,e.to)).scrollIntoView()}function fr(n=1){return(e,t)=>{let{matches:r,current:o}=Cn(e);if(!r.length)return!1;let s=o>=0&&e.selection.from===r[o].from&&e.selection.to===r[o].to||o<0?(Math.max(o,0)+n+r.length)%r.length:o;return t&&t(Ey(e.tr,r[s],s)),!0}}function Pp(n){return(e,t)=>{let{matches:r,current:o}=Cn(e),i=r[o];if(!i)return!1;if(t){let s=e.tr,l=e.doc.resolve(i.from).marksAcross(e.doc.resolve(i.to))??[];n?s.replaceWith(i.from,i.to,e.schema.text(n,l)):s.delete(i.from,i.to);let a=s.mapping.map(i.to);t(s.setSelection(I.create(s.doc,a)).scrollIntoView())}return!0}}function Ip(n){return(e,t)=>{let{matches:r}=Cn(e);if(!r.length)return!1;if(t){let o=e.tr;for(let i=r.length-1;i>=0;i--){let{from:s,to:l}=r[i],a=e.doc.resolve(s).marksAcross(e.doc.resolve(l))??[];n?o.replaceWith(s,l,e.schema.text(n,a)):o.delete(s,l)}t(o.scrollIntoView())}return!0}}function Hp(n,e){let{t}=n.ui,r=Te("nova-find"),o=Te("nova-replace"),i=M("input",{id:r,type:"search",className:"nova-input",placeholder:t("search.find"),"aria-label":t("search.find"),autocomplete:"off",spellcheck:"false"}),s=M("input",{id:o,type:"text",className:"nova-input",placeholder:t("search.replace"),"aria-label":t("search.replace"),autocomplete:"off",spellcheck:"false"}),l=M("span",{className:"nova-search-count","aria-live":"polite"}),a=(R,O)=>{let v=M("button",{type:"button",className:"nova-btn nova-search-toggle","aria-pressed":"false","aria-label":R,"data-tooltip":R},O);return n.ui.tooltip.attach(v),v.addEventListener("click",()=>{v.setAttribute("aria-pressed",String(v.getAttribute("aria-pressed")!=="true")),y(),i.focus()}),v},c=a(t("search.matchCase"),"Aa"),u=a(t("search.wholeWord"),"ab|"),d=(R,O,v)=>{let x=M("button",{type:"button",className:"nova-btn","aria-label":O,"data-tooltip":O},V(R));return n.ui.tooltip.attach(x),x.addEventListener("click",v),x},p=d(S.chevronUp,t("search.prev"),()=>{n.exec(fr(-1)),i.focus()}),f=d(S.chevronDown,t("search.next"),()=>{n.exec(fr(1)),i.focus()}),h=d(S.close,t("dialog.close"),()=>L.close()),g=M("button",{type:"button",className:"nova-button"},t("search.replaceOne")),m=M("button",{type:"button",className:"nova-button"},t("search.replaceAll"));g.addEventListener("click",()=>{w(),n.exec(Pp(s.value)),n.exec(fr(1)),s.focus()}),m.addEventListener("click",()=>{w(),n.exec(Ip(s.value)),s.focus()});let b=M("div",{className:"nova-search",role:"search","aria-label":t("search.title"),hidden:!0},M("div",{className:"nova-search-row"},i,l,c,u,p,f,h),M("div",{className:"nova-search-row"},s,g,m));e.parentElement.insertBefore(b,e);let k=null,y=()=>{k&&clearTimeout(k),k=null,Lp({query:i.value,caseSensitive:c.getAttribute("aria-pressed")==="true",wholeWord:u.getAttribute("aria-pressed")==="true"})(n.view.state,n.view.dispatch)},w=()=>{(k||Cn(n.view.state).query!==i.value)&&y()};i.addEventListener("input",()=>{k&&clearTimeout(k),k=setTimeout(y,120)}),i.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),w(),n.exec(fr(R.shiftKey?-1:1)),i.focus())}),s.addEventListener("keydown",R=>{R.key==="Enter"&&(R.preventDefault(),g.click(),s.focus())}),b.addEventListener("keydown",R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),L.close())}),b.addEventListener("mousedown",R=>{R.target.closest("button")&&R.preventDefault()});let N=()=>{if(b.hidden)return;let{matches:R,current:O,query:v}=Cn(n.view.state),x=R.length;v?x?l.textContent=t("search.count",{current:O+1,total:x>=pr?`${pr}+`:x}):l.textContent=t("search.none"):l.textContent="",b.classList.toggle("is-empty",!!v&&!x);for(let C of[p,f,g,m])C.disabled=!x;g.disabled=!x||!n.isEditable(),m.disabled=!x||!n.isEditable()},L={open(){let R=b.hidden;b.hidden=!1;let{from:O,to:v,empty:x}=n.view.state.selection,C=x?"":n.view.state.doc.textBetween(O,v," ");C&&!C.includes(`
|
|
33
|
+
`)&&C.length<=100&&(i.value=C),(R||C)&&y(),i.focus(),i.select(),N()},close(){b.hidden||(b.hidden=!0,k&&clearTimeout(k),Rp(n.view.state,n.view.dispatch),n.focus())},isOpen:()=>!b.hidden,update:N,destroy(){k&&clearTimeout(k),b.remove()}};return L}function sa(n){return n.root.classList.contains("nova-fullscreen")}function hr(n,e=!sa(n)){n.root.classList.toggle("nova-fullscreen",e),document.documentElement.classList.toggle("nova-fullscreen-lock",e),n.ui.closePopover(),n.updateUI(),n.focus()}function Bp(n){let{t:e}=n.ui,t=M("div",{className:"nova-prosemirror nova-preview"});t.append(Le.fromSchema(n.schema).serializeFragment(n.view.state.doc.content)),t.querySelectorAll("a[href]").forEach(r=>{r.setAttribute("target","_blank"),r.setAttribute("rel","noopener noreferrer")}),n.ui.openDialog({title:e("preview"),body:t,size:"large",cancelLabel:e("dialog.close")})}function Cy(n){return n.replace(/(<\/(p|h[1-6]|ul|ol|li|blockquote|pre|table|tbody|tr)>|<hr>)/g,`$1
|
|
34
34
|
`).replace(/(<(ul|ol|table|tbody|tr|blockquote)( [^>]*)?>)/g,`$1
|
|
35
35
|
`).replace(/\n{2,}/g,`
|
|
36
|
-
`).trim()}function wh(n){let{t:e}=n.ui,t=$1(n.getHTML()),r=v("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&n.setContent(r.value),!0)})}function li(n){let{t:e}=n.ui,t=v("div",{className:"nova-help"});for(let{group:r,rows:o}of _1)t.append(v("section",{},v("h3",{},e(r)),v("table",{className:"nova-help-table"},v("tbody",{},o.map(({label:i,keys:s})=>v("tr",{},v("td",{},e(i)),v("td",{},v("kbd",{},s.length===1?s:Qe(s)))))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var _1,Dl=P(()=>{"use strict";de();Z();_1=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}]});function Mh(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(Sh," ")}function q1(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(Sh," ")}function G1(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:j1.has(t)?Re(e)?e:null:K1.has(t)?Pe(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>Pe(o))?e:null:t==="style"&&J1.test(e)?null:e}function X1(n){xh.has(n)||(xh.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}function Rl(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:Mh(n)};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!W1.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=U1.has(r.toLowerCase());o&&X1(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[p,h]of Object.entries(l)){if(h==null)continue;let m=p.includes(" ")?p.split(" ")[1]:p;if(!Y1.test(m))continue;let g=G1(m,String(h));g!==null&&(i+=` ${m}="${q1(g)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(V1.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",u="",d=!1;for(let p of s){if(p===0){if(d)throw new Error("[nova] toDOM spec has more than one content hole");d=!0;continue}let h=Rl(p);if(d){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");u+=h.html}else h.hole?(c+=h.open,u+=h.close,d=!0):c+=h.html}if(o)return{open:"",close:"",hole:d,html:""};let f=`</${r}>`;return{open:a+c,close:u+f,hole:d,html:a+c+u+f}}var V1,Sh,W1,U1,j1,K1,J1,xh,Y1,yt,ai=P(()=>{"use strict";gt();V1=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Sh=new RegExp("\xA0","g");W1=/^[a-z][a-z0-9-]*$/i,U1=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),j1=new Set(["href","xlink:href","action","formaction","cite"]),K1=new Set(["src","poster","data","background"]),J1=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;xh=new Set;Y1=/^[a-z_:][a-z0-9_.:-]*$/i;yt=class{cache=new Map;serializeFragment(e){let t="",r=[],o=[],i=s=>{for(;r.length>s;)t+=o.pop(),r.pop()};return e.forEach(s=>{if(!s.isInline){i(0),t+=this.serializeNode(s);return}let l=0;for(;l<r.length&&l<s.marks.length&&r[l].eq(s.marks[l]);)l++;i(l);for(let a=l;a<s.marks.length;a++){let c=s.marks[a],u=this.renderMark(c,s.isText);t+=u.open,o.push(u.close),r.push(c)}t+=s.isText?Mh(s.text??""):this.serializeNode(s)}),i(0),r=[],o=[],t}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=Rl(t(e));return r.hole?r.open+this.serializeFragment(e.content)+r.close:r.html}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=`${e.type.name}:${JSON.stringify(e.attrs)}`,i=this.cache.get(o);return i||(i=Rl(r(e,t)),this.cache.size>500&&this.cache.clear(),this.cache.set(o,i)),i}}});function vt(n,e){return(t,r)=>{let o=oe(t)[n],i=e===null?null:Q1[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function st(n,e){let t=oe(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function Or(n){return(e,t)=>{let r=n===null?null:U.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===G(e).paragraph||a.type===G(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function Pl(n){return n.selection.$from.parent.attrs.lineHeight??null}var Q1,Il=P(()=>{"use strict";Oe();et();Q1={color:U.color,background:U.color,font_family:U.fontFamily,font_size:U.length}});function ui(n){let t=[],r=n.current?.toLowerCase()??null,o=v("div",{className:"nova-swatches",role:"grid","aria-label":n.label});for(let l of n.colors){let a=r===l.toLowerCase(),c=v("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":l,"aria-selected":String(a),title:l,tabindex:"-1"},a?X(M.check):null);c.style.setProperty("--swatch",l),c.addEventListener("click",()=>n.onPick(l)),t.push(c),o.append(c)}(t.find(l=>l.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",l=>{let a=t.indexOf(document.activeElement);if(a<0)return;let u={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[l.key];if(u===void 0)return;l.preventDefault();let d=t[Math.min(t.length-1,Math.max(0,a+u))];t[a].tabIndex=-1,d.tabIndex=0,d.focus()});let i=v("button",{type:"button",className:"nova-panel-action"},X(M.clearFormatting),n.removeLabel);i.addEventListener("click",()=>n.onPick(null));let s=v("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return s.addEventListener("change",()=>n.onPick(s.value)),v("div",{className:"nova-color-panel"},o,v("div",{className:"nova-panel-footer"},i,v("label",{className:"nova-panel-action"},s,n.customLabel)))}var ci,Bl=P(()=>{"use strict";Z();j();ci=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"]});function Ch(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:M.table,tooltip:t("table.insert"),isEnabled:i=>i.can(it(1,1)),render:(i,s)=>Ef((l,a)=>{s(),i.exec(it(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:u=>u.exec(a),isEnabled:u=>u.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",M.rowBefore,We.addRowBefore),o("tableinsertrowafter","table.rowAfter",M.rowAfter,We.addRowAfter),o("tabledeleterow","table.rowDelete",M.rowDelete,We.deleteRow),o("tableinsertcolbefore","table.colBefore",M.colBefore,We.addColumnBefore),o("tableinsertcolafter","table.colAfter",M.colAfter,We.addColumnAfter),o("tabledeletecol","table.colDelete",M.colDelete,We.deleteColumn),o("tablemergecells","table.merge",M.merge,We.mergeCells),o("tablesplitcells","table.split",M.split,We.splitCell),o("tablerowheader","table.rowHeader",M.rowHeader,We.toggleHeaderRow,i=>Sf(i.view.state)),o("tablecolheader","table.colHeader",M.colHeader,We.toggleHeaderColumn,i=>Mf(i.view.state)),o("tabledelete","table.delete",M.tableDelete,We.deleteTable),e.addPanelButton("tablecellbackground",{icon:M.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>ne(i.view.state),render:(i,s)=>ui({colors:i.options.colors??ci,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(xf(l))}})}),e.addMenuButton("advtablesort",{icon:M.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(dl("asc")),items:i=>["asc","desc"].map(s=>({id:s,label:t(s==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(dl(s,i.options.language))}))}),e.addButton("tableprops",{icon:M.tableProps,tooltip:t("table.props"),isEnabled:i=>ne(i.view.state),onAction:i=>Z1(i)}),e.addButton("tablecellprops",{icon:M.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>ne(i.view.state),onAction:i=>ek(i)}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>ne(i.view.state),anchor:i=>Cf(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"})}function Eh(n,e,t){if(!e?.length)return null;let{t:r}=n.ui,o=[{value:"",label:r("table.styleDefault")}];for(let i of e)i.value&&o.push({value:i.value,label:i.title});return t&&!o.some(i=>i.value===t)&&o.push({value:t,label:t}),tr({label:r("table.style"),value:t??"",options:o})}function Z1(n){let{t:e}=n.ui,t=Af(n.view.state);if(!t)return;let r=ce({label:e("table.width"),hint:e("table.widthHint"),value:t.width??""}),o=tr({label:e("table.align"),value:t.align??"",options:[{value:"",label:e("table.alignDefault")},{value:"center",label:e("table.alignCenter")},{value:"right",label:e("table.alignRight")}]}),i=Eh(n,n.options.tableClassList,t.class??null);n.ui.openDialog({title:e("table.props"),body:v("div",{className:"nova-form"},i?.el??null,r.el,o.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l={width:r.input.value.trim().replace(/^(\d+(\.\d+)?)$/,"$1px")||null,align:o.select.value||null,...i?{class:i.select.value||null}:{}};return n.exec(Tf(l))||e("table.invalidWidth")}})}function ek(n){let{t:e}=n.ui,t=Lf(n.view.state);if(!t)return;let r=tr({label:e("table.valign"),value:t.valign??"",options:[{value:"",label:e("table.alignDefault")},{value:"top",label:e("table.valignTop")},{value:"middle",label:e("table.valignMiddle")},{value:"bottom",label:e("table.valignBottom")}]}),o=tr({label:e("table.cellType"),value:t.header?"th":"td",options:[{value:"td",label:e("table.cellData")},{value:"th",label:e("table.cellHeader")}]}),i=ce({label:e("table.colWidth"),hint:e("table.colWidthHint"),value:t.width?String(t.width):""}),s=Eh(n,n.options.tableCellClassList,t.class??null);n.ui.openDialog({title:e("table.cellProps"),body:v("div",{className:"nova-form"},s?.el??null,r.el,o.el,i.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l=i.input.value.trim(),a=l?Number(l.replace(/px$/i,"")):null;return a!==null&&!(Number.isInteger(a)&&a>=24&&a<=4e3)?e("table.invalidColWidth"):(n.exec(Of({valign:r.select.value||null,header:o.select.value==="th",width:a,...s?{class:s.select.value||null}:{}})),!0)}})}var Ah=P(()=>{"use strict";zn();Bl();At();Z();j()});function Th(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}function Nh(n){let e=n.split(",")[0].trim().replace(/["']/g,"");return ok[e.toLowerCase()]??e}function ik(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}function Oh(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(y,k,T,I)=>e.addButton(y,{icon:T,tooltip:t(k),...Ge[k]?{shortcut:Ge[k]}:{},onAction:R=>R.exec(k),isEnabled:R=>R.can(k),...I?{isActive:I}:{}}),i=(y,k,T,I)=>o(y,k,I,()=>vr(r(),n.schema.marks[T]));o("undo","undo",M.undo),o("redo","redo",M.redo),i("bold","bold","bold",M.bold),i("italic","italic","italic",M.italic),i("underline","underline","underline",M.underline),i("strikethrough","strike","strike",M.strike),i("inlinecode","code","code",M.code),i("subscript","subscript","subscript",M.subscript),i("superscript","superscript","superscript",M.superscript),o("bullist","bulletList",M.bulletList,()=>rt(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",M.orderedList,()=>rt(r(),n.schema.nodes.ordered_list)),o("indent","indent",M.indent),o("outdent","outdent",M.outdent),o("blockquote","blockquote",M.blockquote,()=>rt(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",M.codeBlock,()=>rt(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",M.horizontalRule),o("removeformat","clearFormatting",M.clearFormatting);let s=[["alignLeft","left",M.alignLeft],["alignCenter","center",M.alignCenter],["alignRight","right",M.alignRight],["alignJustify","justify",M.alignJustify]];for(let[y,k,T]of s)o(y.toLowerCase(),y,T,()=>an(r())===k);e.addMenuButton("align",{icon:M.alignLeft,tooltip:t("align"),isEnabled:y=>y.can("alignLeft"),items:y=>s.map(([k,T,I])=>({id:k,label:t(k),icon:I,...Ge[k]?{shortcut:Ge[k]}:{},active:an(y.view.state)===T,onSelect:()=>y.exec(k)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let y=r().selection.$from.parent;return y.type===n.schema.nodes.heading?`h${y.attrs.level}`:y.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let y=1;y<=6;y++){let k=`h${y}`;e.addToggleButton(k,{...y<=3?{icon:M[`h${y}`]}:{text:`H${y}`},tooltip:t(k),...Ge[k]?{shortcut:Ge[k]}:{},isActive:()=>a()===k,isEnabled:T=>T.can(k)||a()===k,onAction:T=>T.exec(a()===k?"paragraph":k)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},u=()=>{let y=n.options.blockFormats;return y?.length?y.flatMap(({label:k,block:T})=>{let I=c[T],R=l.find(z=>z.command===I);return R?[{...R,label:k}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>u().find(y=>y.command===a())?.label??t(a()),minChars:11,isEnabled:y=>u().some(({command:k})=>y.can(k)),items:y=>u().filter(({command:k})=>y.isAllowed(k)).map(({command:k,style:T,label:I})=>({id:k,label:I??t(k),labelStyle:T,...Ge[k]?{shortcut:Ge[k]}:{},active:a()===k,onSelect:()=>y.exec(k)}))});let d="p,h1,h2,h3,h4,h5,h6",f=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(y=>({title:t(`h${y}`),block:`h${y}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(y=>({title:t(`align${y==="justify"?"Justify":y[0].toUpperCase()+y.slice(1)}`),selector:d,styles:{"text-align":y}}))}],p=y=>y.format??y,h=y=>{let k=y.format?n.formatter.get(y.format)?.[0]:y,T=[],I=k?.block;I&&/^h[1-6]$/.test(I)&&T.push("font-weight: 700"),(k?.inline==="strong"||k?.inline==="b")&&T.push("font-weight: 700"),(k?.inline==="em"||k?.inline==="i")&&T.push("font-style: italic"),k?.inline==="u"&&T.push("text-decoration: underline"),(k?.inline==="s"||k?.inline==="strike"||k?.inline==="del")&&T.push("text-decoration: line-through"),(k?.inline==="code"||I==="pre")&&T.push("font-family: ui-monospace, monospace");for(let R of["color","background-color","font-family"]){let z=k?.styles?.[R];z&&/^[#\w\s,'"().%-]+$/.test(z)&&T.push(`${R}: ${z}`)}return T.join("; ")},m=y=>y.flatMap(k=>k.items?m(k.items):[k]),g=()=>{let y=n.options.styleFormats;return y?n.options.styleFormatsMerge?[...f(),...y]:y:f()};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:y=>m(g()).find(k=>y.formatter.match(p(k)))?.title??t("styles"),items:y=>{let k=[],T=(I,R)=>{I.forEach((z,te)=>{if(z.items){k.length&&k.push({type:"separator"}),k.push({type:"heading",label:z.title}),T(z.items,`${R}${te}-`);return}k.push({id:`style-${R}${te}`,label:z.title,labelStyle:h(z),active:y.formatter.match(p(z)),disabled:!y.formatter.canApply(p(z)),onSelect:()=>y.formatter.toggle(p(z))})})};return T(g(),""),k}});let b=n.options.fontFamilies??tk;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:y=>{let k=st(r(),"font_family");if(k)return b.find(I=>Lh(k,I.value))?.label??Nh(k);let T=Th(y)?.fontFamily;return T?Nh(T):t("fontFamily")},items:y=>{let k=st(y.view.state,"font_family");return[{id:"default",label:t("default"),active:k===null,onSelect:()=>y.exec(vt("font_family",null))},{type:"separator"},...b.map(T=>({id:T.label,label:T.label,labelStyle:`font-family: ${T.value}`,active:Lh(k,T.value),onSelect:()=>y.exec(vt("font_family",T.value))}))]}});let x=n.options.fontSizes??nk;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:y=>st(r(),"font_size")??ik(Th(y)?.fontSize??"")??"\u2014",items:y=>{let k=st(y.view.state,"font_size");return[{id:"default",label:t("default"),active:k===null,onSelect:()=>y.exec(vt("font_size",null))},{type:"separator"},...x.map(T=>({id:T,label:T,active:k===T,onSelect:()=>y.exec(vt("font_size",T))}))]}});let w=n.options.lineHeights??rk;e.addMenuButton("lineheight",{icon:M.lineHeight,tooltip:t("lineHeight"),isEnabled:y=>y.can(Or(null)),items:y=>{let k=Pl(y.view.state);return[{id:"default",label:t("default"),active:k===null,onSelect:()=>y.exec(Or(null))},...w.map(T=>({id:T,label:T,active:k===T,onSelect:()=>y.exec(Or(T))}))]}});let E=(y,k,T,I)=>e.addPanelButton(y,{icon:T,tooltip:t(I),indicator:()=>st(r(),k),render:(R,z)=>ui({colors:R.options.colors??ci,current:st(R.view.state,k),label:t(I),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:te=>{z(),R.exec(vt(k,te))}})});E("forecolor","color",M.textColor,"textColor"),E("backcolor","background",M.highlight,"backgroundColor");let D=[["superscript","superscript",M.superscript],["subscript","subscript",M.subscript],["code","code",M.code]];e.addMenuButton("moreformats",{icon:M.formatMore,tooltip:t("moreFormats"),isActive:y=>D.some(([,k])=>vr(y.view.state,n.schema.marks[k])),items:y=>[...D.filter(([k])=>y.isAllowed(k)).map(([k,T,I])=>({id:k,label:t(k),icon:I,checkbox:!0,active:vr(y.view.state,n.schema.marks[T]),disabled:!y.can(k),...Ge[k]?{shortcut:Ge[k]}:{},onSelect:()=>y.exec(k)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:M.clearFormatting,disabled:!y.can("clearFormatting"),shortcut:Ge.clearFormatting,onSelect:()=>y.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:M.pasteText,checkbox:!0,active:y.isPasteAsText(),onSelect:()=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}]}),e.addToggleButton("pastetext",{icon:M.pasteText,tooltip:t("pasteAsText"),isActive:y=>y.isPasteAsText(),onAction:y=>{y.setPasteAsText(!y.isPasteAsText()),y.focus()}}),e.addButton("link",{icon:M.link,tooltip:t("link"),shortcut:"Mod-k",onAction:y=>ot(y),isActive:()=>!!In(r())}),e.addButton("unlink",{icon:M.unlink,tooltip:t("unlink"),onAction:y=>y.exec(Mr()),isEnabled:y=>y.can(Mr())}),e.addButton("image",{icon:M.image,tooltip:t("image"),onAction:y=>Wo(y)});let C=()=>cn(r())?.node.attrs.align??null,N=(y,k,T,I)=>e.addToggleButton(y,{icon:T,tooltip:t(I),isActive:()=>C()===k,onAction:R=>R.exec(xr({align:C()===k?null:k}))});N("imagealignleft","left",M.imageLeft,"image.alignLeft"),N("imagealigncenter","center",M.imageCenter,"image.alignCenter"),N("imagealignright","right",M.imageRight,"image.alignRight");let S=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:M.resize,tooltip:t("image.size"),items:y=>S.map(([k,T])=>({id:k,label:t(k),onSelect:()=>yf(y,T)}))}),e.addButton("imagealt",{icon:M.altText,tooltip:t("image.editAlt"),onAction:y=>vf(y)}),e.addButton("imagedelete",{icon:M.trash,tooltip:t("image.delete"),onAction:y=>y.exec((k,T)=>cn(k)?(T?.(k.tr.deleteSelection().scrollIntoView()),!0):!1)}),Ch(n),e.addButton("searchreplace",{icon:M.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:y=>y.openSearch()}),e.addToggleButton("fullscreen",{icon:M.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:y=>Ol(y),onAction:y=>Lr(y)}),e.addButton("preview",{icon:M.preview,tooltip:t("preview"),onAction:y=>kh(y)}),e.addButton("code",{icon:M.sourceCode,tooltip:t("sourceCode"),onAction:y=>wh(y)}),e.addButton("help",{icon:M.help,tooltip:t("help"),shortcut:"Alt-0",onAction:y=>li(y)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:y=>!!cn(y.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt | imagedelete"})}var tk,nk,rk,Ge,ok,Lh,Dh=P(()=>{"use strict";Oe();Sr();Hn();Il();Bl();Ah();Dl();j();tk=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],nk=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],rk=["1","1.15","1.5","2","2.5","3"],Ge={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};ok={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};Lh=(n,e)=>n!==null&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase()});function kt(n,e,t){let r=window.innerWidth,o=window.innerHeight,{width:i,height:s}=n.getBoundingClientRect(),l=o-e.bottom,a=e.top,u=t==="top-start"?a>=s+6||a>l:l<s+6&&a>l,d=u?e.top-s-6:e.bottom+6,f=t==="bottom-end"?e.right-i:t==="bottom"?e.left+e.width/2-i/2:e.left;f=Math.max(8,Math.min(f,r-i-8)),d=Math.max(8,Math.min(d,o-s-8)),n.style.left=`${Math.round(f)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.side=u?"top":"bottom"}var Dr,_n,dn=P(()=>{"use strict";Dr=[],_n=class{el;options;closed=!1;constructor(e){this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),document.addEventListener("keydown",this.onKeyDown,!0),document.addEventListener("pointerdown",this.onPointerDown,!0),Dr.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}reposition=()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();kt(this.el,r,t)};close(e="api"){this.closed||(this.closed=!0,Dr.splice(Dr.indexOf(this),1),document.removeEventListener("keydown",this.onKeyDown,!0),document.removeEventListener("pointerdown",this.onPointerDown,!0),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}focusWasInside=!1;onKeyDown=e=>{e.key!=="Escape"||e.defaultPrevented||Dr[Dr.length-1]===this&&(e.target?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(document.activeElement),this.close("escape")))};onPointerDown=e=>{if(this.options.dismissOnOutside===!1)return;let t=e.target;this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside")}}});function Rh(n){return new _({key:new J("nova-link-bubble"),view(e){let{t}=n.ui,r=v("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(c,u,d)=>{let f=v("button",{type:"button",className:"nova-btn","aria-label":u,"data-tooltip":u},X(c));return f.addEventListener("click",d),n.ui.tooltip.attach(f),f},i=v("div",{className:"nova-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},X(M.externalLink),r,v("span",{className:"nova-bubble-sep"}),o(M.edit,t("link.edit"),()=>ot(n)),o(M.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(M.unlink,t("unlink"),()=>n.exec(Mr())));i.addEventListener("mousedown",c=>{c.target.closest("button")&&c.preventDefault()}),n.ui.overlayHost.append(i);let s=()=>{i.hidden=!0},l=()=>{let c=e.state,u=In(c),d=e.hasFocus()||i.contains(document.activeElement);if(!u||!d||!n.isEditable()||n.ui.activeDialog||!c.selection.empty){s();return}let f=kr(c,oe(c).link,c.selection.from);if(!f)return s();r.textContent=u.href,r.title=u.href,Re(u.href)?r.setAttribute("href",u.href):r.removeAttribute("href"),i.hidden=!1;let p=e.coordsAtPos(f.from),h=e.coordsAtPos(f.to),m=new DOMRect(p.left,p.top,Math.max(1,h.right-p.left),h.bottom-p.top);kt(i,m,"bottom-start")},a=c=>{i.contains(c.relatedTarget)||s()};return e.dom.addEventListener("blur",a),i.addEventListener("focusout",c=>{!i.contains(c.relatedTarget)&&!e.hasFocus()&&s()}),{update:l,destroy(){e.dom.removeEventListener("blur",a),i.remove()}}}})}var Ph=P(()=>{"use strict";K();Oe();Hn();Oe();gt();Z();j();dn()});function zl(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function Fl(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let S of zl(t)){let y=v("div",{className:"nova-tb-group",role:"group"});for(let k of S){if(!n.isAllowed(k))continue;let T=i.registry.get(k);if(!T){o&&console.warn(`[nova] Unknown toolbar item "${k}"`);continue}let I=Rr(n,k,T);c.push(I),y.append(I.el)}y.childElementCount&&(u.push(y),e.append(y))}let d=v("div",{className:"nova-toolbar nova-tb-overflow",role:"group"}),f=v("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-haspopup":"true","aria-expanded":"false","data-tooltip":s("more"),hidden:!0},X(M.more));i.tooltip.attach(f);let p=null,h=()=>{p?.close(),p=null},m=i.onDialogOpen(h);f.addEventListener("click",S=>{if(p)return h();f.setAttribute("aria-expanded","true");let y=new _n({host:i.overlayHost,anchor:f,placement:"bottom-end",content:d,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,f],onClose:k=>{p=null,f.setAttribute("aria-expanded","false"),k==="escape"&&y.focusWasInside&&f.focus()}});p=y,S.detail===0&&d.querySelector("button:not(:disabled)")?.focus()}),r==="sliding"&&e.append(f);let g=()=>{if(r!=="sliding")return;for(let y of u)e.insertBefore(y,f);if(f.hidden=!0,e.scrollWidth<=e.clientWidth+1){h();return}f.hidden=!1;let S=u.length;for(;S>1&&e.scrollWidth>e.clientWidth+1;)S-=1,d.prepend(u[S]);d.childElementCount||(f.hidden=!0),p?.reposition(),D()},b=-1,x=typeof ResizeObserver<"u"&&r==="sliding"?new ResizeObserver(()=>{e.clientWidth!==b&&(b=e.clientWidth,g())}):null;x?.observe(e);let w=()=>[...e.querySelectorAll("button")].filter(S=>!S.disabled&&!S.hidden),E=null,D=()=>{let S=w();(!E||!S.includes(E))&&(E=S[0]??null);for(let y of e.querySelectorAll("button"))y.tabIndex=y===E?0:-1};e.addEventListener("focusin",S=>{let y=S.target;y instanceof HTMLButtonElement&&e.contains(y)&&(E=y,D())},{signal:a}),e.addEventListener("keydown",S=>{let y=w(),k=y.indexOf(document.activeElement);if(k<0)return;let T=null;if(S.key==="ArrowRight")T=k+1;else if(S.key==="ArrowLeft")T=k-1;else if(S.key==="Home")T=0;else if(S.key==="End")T=y.length-1;else if(S.key==="Escape"){S.preventDefault(),n.focus();return}T!==null&&(S.preventDefault(),y[(T+y.length)%y.length].focus())},{signal:a});let C=S=>{S.target.closest("button")&&S.preventDefault()};e.addEventListener("mousedown",C,{signal:a}),d.addEventListener("mousedown",C),d.addEventListener("keydown",S=>{if(S.key==="Escape")return;let y=[...d.querySelectorAll("button")].filter(T=>!T.disabled),k=y.indexOf(document.activeElement);k<0||(S.key==="ArrowRight"||S.key==="ArrowDown"?(S.preventDefault(),y[(k+1)%y.length].focus()):(S.key==="ArrowLeft"||S.key==="ArrowUp")&&(S.preventDefault(),y[(k-1+y.length)%y.length].focus()))});let N=()=>{for(let S of c)S.update();D()};return N(),g(),{update:N,focus:()=>{D(),E?.focus()},destroy:()=>{x?.disconnect(),m(),h(),l.abort(),e.replaceChildren()}}}function Rr(n,e,t){if(t.type==="split")return sk(n,e,t);let{ui:r}=n,o=v("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(X(t.icon));let i=t.type==="menu"&&(t.label||t.text)?v("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=v("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(X(M.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,u=()=>r.closePopover(),d=t.type==="menu"?oi(t.items(n),u,t.tooltip):t.render(n,u);o.setAttribute("aria-expanded","true");let f=r.openPopover({anchor:o,content:d,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:p=>{o.setAttribute("aria-expanded","false"),p==="escape"&&f.focusWasInside&&o.focus()}});t.type==="menu"?ii(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"&&(i.textContent=t.label?.(n)??t.text??""),s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function sk(n,e,t){let r=Rr(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=Rr(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:v("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}var Hl,$l=P(()=>{"use strict";Z();j();Al();dn();Hl="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help"});function Ih(n){return new _({key:new J("nova-context-toolbar"),view(e){let t=v("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(m,g)=>{let b=r.get(m);if(b)return b;let x=v("div",{className:"nova-context-items"}),w=[];return zl(g.items).forEach((E,D)=>{D>0&&x.append(v("span",{className:"nova-bubble-sep",role:"separator"}));for(let C of E){if(!n.isAllowed(C))continue;let N=n.ui.registry.get(C);if(!N)continue;let S=Rr(n,C,N);w.push(S),x.append(S.el)}}),b={el:x,controls:w},r.set(m,b),b},s=()=>{t.hidden=!0,o=null},l=m=>{let{selection:g}=e.state;if((m.position??"node")==="node"&&g instanceof B)return e.nodeDOM(g.from)?.getBoundingClientRect()??null;let b=e.coordsAtPos(g.from),x=e.coordsAtPos(g.to);return new DOMRect(b.left,b.top,Math.max(1,x.right-b.left),x.bottom-b.top)},a=!1,c=m=>{m.pointerType==="mouse"&&m.button===0&&(a=!0)},u=()=>{a&&(a=!1,setTimeout(()=>f(e),0))};e.dom.addEventListener("pointerdown",c),document.addEventListener("pointerup",u);let d=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=m=>{if(!(m.hasFocus()||t.contains(document.activeElement))||!n.isEditable()||n.ui.activeDialog||a)return s();let b=n.ui.registry.getContextToolbars().find(([,N])=>N.predicate(n));if(!b)return s();let[x,w]=b,E=i(x,w);o!==x&&(t.replaceChildren(E.el),t.setAttribute("aria-label",w.label),o=x);for(let N of E.controls)N.update();let D=w.anchor?w.anchor(n):l(w);if(!D)return s();t.hidden=!1;let C=w.placement??(w.position==="selection"?"bottom-start":"top-start");d&&w.position==="selection"&&(C="bottom-start"),kt(t,D,C)};t.addEventListener("mousedown",m=>{m.target.closest("button")&&m.preventDefault()}),t.addEventListener("keydown",m=>{let g=[...t.querySelectorAll("button:not(:disabled)")],b=g.indexOf(document.activeElement);if(m.key==="Escape")m.preventDefault(),n.focus();else if(b>=0&&(m.key==="ArrowRight"||m.key==="ArrowLeft")){m.preventDefault();let x=m.key==="ArrowRight"?1:-1;g[(b+x+g.length)%g.length].focus()}});let p=m=>{let g=m.relatedTarget;!t.contains(g)&&!n.ui.overlayHost.contains(g)&&s()};e.dom.addEventListener("blur",p),t.addEventListener("focusout",m=>{let g=m.relatedTarget;!t.contains(g)&&!e.hasFocus()&&!n.ui.overlayHost.contains(g)&&s()});let h=()=>{t.hidden||f(e)};return window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),{update:f,destroy(){e.dom.removeEventListener("blur",p),e.dom.removeEventListener("pointerdown",c),document.removeEventListener("pointerup",u),window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h),t.remove()}}}})}function Bh(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var Hh=P(()=>{"use strict";K();Z();dn();$l()});var zh,di,Fh=P(()=>{"use strict";K();et();gt();zh=24,di=class{constructor(e,t,r,o){this.view=t;this.getPos=r;this.editor=o;this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}view;getPos;editor;dom;img;node;resizing=!1;render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=Pe(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",Ve(this.node.attrs.class).class??null);let a=Ie(o),c=Ie(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(zh,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,u=s;this.resizing=!0,this.dom.classList.add("is-resizing");let d=p=>{u=Math.round(Math.min(a,Math.max(zh,s+c*(p.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},f=()=>{r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",f),r.removeEventListener("pointercancel",f),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let p=this.getPos();if(p===void 0||Math.abs(u-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(p,void 0,{...this.node.attrs,width:u,height:Math.round(u*l)});h.setSelection(B.create(h.doc,p)),this.view.dispatch(h)};r.addEventListener("pointermove",d),r.addEventListener("pointerup",f),r.addEventListener("pointercancel",f)}}});function ak(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ck(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-lk-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${ak(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=r.parentOffset-c.length-s.trigger.length,d=u>0?r.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function $h(n){let e,t=[],r=0,o=null,i=null,s=0,l=Ce("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.setAttribute("aria-expanded","false")},u=(h,m)=>{let g=t[m];if(!g||!o)return;let{spec:b,from:x,to:w}=o;c(h),b.onSelect(g,{from:x,to:w},n)},d=h=>{if(!o)return;let{spec:m}=o;if(e.replaceChildren(),e.setAttribute("aria-label",m.label),!t.length){if(!m.emptyText)return c(h);e.append(v("div",{className:"nova-ac-empty"},m.emptyText))}t.forEach((b,x)=>{let w=v("div",{id:`${l}-${x}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(x===r)},b.icon?X(b.icon):null,v("span",{className:"nova-menu-label"},b.label),b.shortcut?v("kbd",{className:"nova-menu-shortcut"},Qe(b.shortcut)):b.detail?v("span",{className:"nova-menu-shortcut"},b.detail):null);w.addEventListener("mousedown",E=>{E.preventDefault(),u(h,x)}),w.addEventListener("mousemove",()=>{r!==x&&f(h,x)}),e.append(w)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),h.dom.setAttribute("aria-expanded","true"),f(h,Math.min(r,Math.max(0,t.length-1)));let g=h.coordsAtPos(o.from);kt(e,new DOMRect(g.left,g.top,1,g.bottom-g.top),"bottom-start")},f=(h,m)=>{r=m,e.querySelectorAll('[role="option"]').forEach((b,x)=>b.setAttribute("aria-selected",String(x===m)));let g=e.querySelector(`#${l}-${m}`);g&&(h.dom.setAttribute("aria-activedescendant",g.id),g.scrollIntoView?.({block:"nearest"}))},p=h=>{let m=n.isEditable()&&h.hasFocus()?ck(h,n):null;if(!m||m.from===i){m||(i=null),(a()||o)&&c(h);return}let g=!o||o.query!==m.query||o.from!==m.from;if(o=m,!g&&a())return d(h);let b=++s;Promise.resolve(m.spec.fetch(m.query,n)).then(x=>{b!==s||!o||(t=x.slice(0,m.spec.maxResults??10),r=0,d(h))})};return new _({key:new J("nova-autocompleter"),view(h){e=v("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let m=()=>c(h);return h.dom.addEventListener("blur",m),{update:g=>p(g),destroy(){h.dom.removeEventListener("blur",m),e.remove()}}},props:{handleKeyDown(h,m){if(!a()||!o)return!1;let g=t.length;switch(m.key){case"ArrowDown":return g&&f(h,(r+1)%g),!0;case"ArrowUp":return g&&f(h,(r-1+g)%g),!0;case"Enter":case"Tab":return g?(u(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var lk,_h=P(()=>{"use strict";K();Z();dn();lk=30});function dk(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(u=>u.startsWith(r))?c=2:a.some(u=>u.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function Vh(n,e=[]){let{t}=n.ui,r=[...uk,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>dk(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var wt,uk,qh=P(()=>{"use strict";Sr();Hn();zn();j();wt=n=>e=>e.exec(n),uk=[{name:"paragraph",label:"paragraph",icon:M.paragraph,keywords:["text","p","paragraph"],run:wt("paragraph")},{name:"h1",label:"h1",icon:M.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:wt("h1")},{name:"h2",label:"h2",icon:M.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:wt("h2")},{name:"h3",label:"h3",icon:M.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:wt("h3")},{name:"bullist",label:"bulletList",icon:M.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:wt("bulletList")},{name:"numlist",label:"orderedList",icon:M.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:wt("orderedList")},{name:"blockquote",label:"blockquote",icon:M.blockquote,keywords:["quote","blockquote","citation"],run:wt("blockquote")},{name:"codeblock",label:"codeBlock",icon:M.codeBlock,keywords:["code","pre","snippet"],run:wt("codeBlock")},{name:"hr",label:"horizontalRule",icon:M.horizontalRule,keywords:["hr","divider","line","separator"],run:wt("horizontalRule")},{name:"table",label:"table",icon:M.table,keywords:["table","grid"],run:n=>n.exec(it(3,3))},{name:"image",label:"image",icon:M.image,keywords:["image","picture","photo","img"],run:n=>Wo(n)},{name:"link",label:"link",icon:M.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>ot(n)}]});var fi,Wh=P(()=>{"use strict";Z();j();fi=class{region;closeLabel;constructor(e,t){this.closeLabel=t,this.region=v("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=v("span",{className:"nova-notification-text"},e.text),i=v("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},X(M.close)),s=v("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,i);this.region.append(s);let l=null,a=()=>{l&&clearTimeout(l),s.remove()};return i.addEventListener("click",a),r>0&&(l=setTimeout(a,r)),{close:a,setText:c=>o.textContent=c}}destroy(){this.region.remove()}}});var pi,Uh=P(()=>{"use strict";pi=class{controls=new Map;addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}menuItems=new Map;addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}contextToolbars=new Map;autocompleters=new Map;addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}}});var fk,hi,jh=P(()=>{"use strict";Z();dn();fk=450,hi=class{el;timer=null;target=null;constructor(e){this.el=v("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>this.hide()),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),fk)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(v("span",{},t)),r&&this.el.append(v("kbd",{},Qe(r))),this.el.hidden=!1,kt(this.el,e.getBoundingClientRect(),"bottom")}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}}});var mi,Kh=P(()=>{"use strict";At();Z();Wh();dn();Uh();jh();mi=class{constructor(e,t,r){this.focusEditor=r;this.t=t,this.overlayHost=v("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new hi(this.overlayHost),this.notifications=new fi(e,t("dialog.close"))}focusEditor;registry=new pi;t;overlayHost;tooltip;notifications;popover=null;dialog=null;openPopover(e){this.closePopover(),this.tooltip.hide();let t=new _n({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}dialogListeners=new Set;onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.dialog?.close();let t=ec({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.dialog===t&&(this.dialog=null),e.onClose?.()}});return this.dialog=t,t}get activeDialog(){return this.dialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.closePopover(),this.dialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove()}}});function mk(n){let e=n.match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu);return e?e.length:0}function Jh(n,e){e.className="nova-statusbar";let t=v("div",{className:"nova-path","aria-hidden":"true"}),r=v("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?yk(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:mk(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:u}=n.view.state.selection,d=[];for(let p=1;p<=u.depth;p++){let h=u.node(p),m=pk[h.type.name]?.(h);m&&d.push(m)}n.view.state.selection.node?.type.name==="image"&&d.push("img");for(let p of u.marks()){let h=hk[p.type.name];h&&d.push(h)}t.textContent=d.join(" \u203A "),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}function yk(n,e,t){let r=n.root,o=v("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize")});o.append(X(t?M.resizeHandleBoth:M.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=(d,f)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(gk,Math.round(d))}px`,t&&f!==void 0){let p=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(p,Math.max(bk,Math.round(f)))}px`}o.setAttribute("aria-valuenow",String(r.offsetHeight))},s=null,l=d=>{n.isDisabled()||(d.preventDefault(),o.setPointerCapture(d.pointerId),s={x:d.clientX,y:d.clientY,height:r.offsetHeight,width:r.offsetWidth})},a=d=>{s&&i(s.height+d.clientY-s.y,s.width+d.clientX-s.x)},c=d=>{s&&(s=null,o.hasPointerCapture(d.pointerId)&&o.releasePointerCapture(d.pointerId))},u=d=>{let f=d.key==="ArrowDown"?gi:d.key==="ArrowUp"?-gi:0,p=t?d.key==="ArrowRight"?gi:d.key==="ArrowLeft"?-gi:0:0;!p&&!f||(d.preventDefault(),i(r.offsetHeight+f,r.offsetWidth+p))};return o.addEventListener("pointerdown",l),o.addEventListener("pointermove",a),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),o.addEventListener("keydown",u),()=>{o.remove(),delete r.dataset.resize}}var pk,hk,gk,bk,gi,Gh=P(()=>{"use strict";Z();j();pk={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},hk={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"};gk=100,bk=200,gi=20});function Xe(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function yi(n,e){if(typeof e!="string")return De.fromJSON(n,e);let t=document.createElement("div"),r=document.createElement("template");return r.innerHTML=e,t.appendChild(r.content),Ar(n).parse(t)}function _l(n){return new bi(n)}var vk,kk,wk,bi,Vl=P(()=>{"use strict";kp();Sp();Cp();Tp();Vo();pt();de();K();Rt();Oe();Pp();Sr();Bp();zp();Hn();Qp();zn();eh();oh();sh();uh();Hr();Ll();vh();Dl();et();ai();Dh();Ph();Hh();Fh();_h();qh();Kh();Gh();$l();vk=new yt,kk=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" ")),wk=0,bi=class{view;root;ui;options;listeners=new Map;ready;toolbar;toolbarHost;menubar;mode;pluginsByName=new Map;commandOverrides=new Map;transactionTransforms=[];cleanups=[];contentRules;schema;formatter;statusbar;searchBar;destroyed=!1;editable;disabled;pasteAsText;constructor(e){this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor",e.element.appendChild(this.root);let t=document.createElement("div"),r=document.createElement("div"),o=document.createElement("div");r.className="nova-content";let i=document.createElement("div");i.className="nova-header";let s=document.createElement("div");i.append(s,t),this.root.append(i,r,o),this.toolbarHost=t,this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let l=this.mode==="distraction-free";this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(document.activeElement)||this.root.classList.remove("is-focused")},0)})),this.ui=new mi(this.root,Rp(e.language,e.translations),()=>this.focus());let a=Fe({"Mod-k":()=>(ot(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>Bh(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(Lr(this),!0),"Alt-0":()=>(li(this),!0),Escape:()=>this.searchBar.isOpen()?(this.searchBar.close(),!0):!1}),c=[...e.plugins??[]];l&&!c.includes("quickbars")&&c.push("quickbars");let u=Zl(c);u.errors.forEach(C=>Xe(C));let{ordered:d,errors:f}=Ni(u.plugins);f.forEach(C=>Xe(C));let p=d.flatMap(C=>this.collectPmPlugins(C)),h=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=h?new si(e):null;let m=new Set([...Er(Object.values(e.formats??{}).flat()),...Er(e.styleFormats??[]),...Array.isArray(e.validClasses)?e.validClasses:[],...[...e.tableClassList??[],...e.tableCellClassList??[]].flatMap(C=>C.value.split(/\s+/).filter(Boolean))]);this.schema=this.buildSchema(d,e.validClasses===!0?()=>!0:C=>m.has(C)),this.formatter=new Yo(this,m);for(let[C,N]of Object.entries(e.formats??{}))this.formatter.register(C,N);d.forEach(C=>this.registerCommands(C));let g=yi(this.schema,e.content??""),b=yn.create({doc:this.contentRules?this.contentRules.normalizeDoc(g):g,plugins:[$h(this),Ip(C=>this.isAllowed(C),this.schema),a,...wf(),ph(),...Hp(C=>this.resolveCommand(C)),...d.some(C=>C.replaceHistory)?[]:[of()],Mp({color:"var(--nova-accent)",width:2}),Ap(),bf(this),gf(this),Yp(this),Rh(this),Ih(this),...this.contentRules?[ch(this.contentRules)]:[],...p,...e.prosemirrorPlugins??[]]});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let x=this.handleTransaction.bind(this);this.view=new Qt(r,{state:b,editable:()=>this.isEditable(),attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...e.placeholder?{"data-placeholder":e.placeholder}:{}},dispatchTransaction:function(C){x(C,this)},clipboardParser:Ar(this.schema),nodeViews:{image:(C,N,S)=>new di(C,N,S,this)},handleDOMEvents:{focus:()=>(this.emit("focus"),!1),blur:()=>(this.emit("blur"),!1)}}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),Oh(this),ih(this),e.slashCommands!==!1&&Vh(this,e.slashCommands??[]),d.forEach(C=>this.setupPlugin(C)),e.setup?.(this);let w=e.menubar===!0?nh:typeof e.menubar=="string"?e.menubar:null;this.menubar=w?rh(this,s,w,{...th,...e.menu}):null,this.menubar||s.remove(),this.toolbar=e.toolbar===!1||l&&e.toolbar===void 0?null:Fl(this,t,this.toolbarConfig(),e.toolbarMode??"sliding",{warnUnknown:u.loaders.length===0}),this.toolbar||t.remove(),!this.toolbar&&!this.menubar&&i.remove(),this.searchBar=yh(this,r);let E=e.statusbar??this.mode==="classic";this.statusbar=E?Jh(this,o):null,this.statusbar||o.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let D=this.applyContentStyles();this.ready=Promise.all([u.loaders.length?this.loadLazyPlugins(u.loaders):void 0,D]).then(()=>{})}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++wk}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=xp(this.root,vl([...s,e??""].join(`
|
|
37
|
-
`),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,u)=>
|
|
36
|
+
`).trim()}function Fp(n){let{t:e}=n.ui,t=Cy(n.getHTML()),r=M("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});r.value=t,n.ui.openDialog({title:e("sourceCode"),body:r,size:"large",submitLabel:e("dialog.save"),initialFocus:r,onSubmit:()=>(r.value!==t&&n.setContent(r.value),!0)})}var Ay=[{group:"help.formatting",rows:[{label:"bold",keys:"Mod-b"},{label:"italic",keys:"Mod-i"},{label:"underline",keys:"Mod-u"},{label:"strike",keys:"Mod-Shift-x"},{label:"code",keys:"Mod-e"},{label:"superscript",keys:"Mod-."},{label:"subscript",keys:"Mod-,"},{label:"link",keys:"Mod-k"},{label:"clearFormatting",keys:"Mod-\\"}]},{group:"help.blocks",rows:[{label:"paragraph",keys:"Mod-Alt-0"},{label:"h1",keys:"Mod-Alt-1"},{label:"h2",keys:"Mod-Alt-2"},{label:"h3",keys:"Mod-Alt-3"},{label:"bulletList",keys:"Mod-Shift-8"},{label:"orderedList",keys:"Mod-Shift-7"},{label:"alignCenter",keys:"Mod-Shift-e"},{label:"indent",keys:"Mod-]"},{label:"outdent",keys:"Mod-["}]},{group:"help.editing",rows:[{label:"undo",keys:"Mod-z"},{label:"redo",keys:"Mod-Shift-z"},{label:"search.title",keys:"Mod-f"},{label:"pasteAsText",keys:"Mod-Shift-v"},{label:"fullscreen",keys:"Mod-Shift-f"},{label:"help.slash",keys:"/"}]},{group:"help.navigation",rows:[{label:"help.toMenubar",keys:"Alt-F9"},{label:"help.toToolbar",keys:"Alt-F10"},{label:"help.toContextToolbar",keys:"Ctrl-F9"},{label:"help.toEditor",keys:"Escape"},{label:"help.nextCell",keys:"Tab"},{label:"help",keys:"Alt-0"}]}];function Vo(n){let{t:e}=n.ui,t=M("div",{className:"nova-help"});for(let{group:r,rows:o}of Ay)t.append(M("section",{},M("h3",{},e(r)),M("table",{className:"nova-help-table"},M("tbody",{},o.map(({label:i,keys:s})=>M("tr",{},M("td",{},e(i)),M("td",{},M("kbd",{},s.length===1?s:tt(s)))))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var aa={};Z(aa,{HTMLSerializer:()=>Ot,escapeAttr:()=>$p,escapeText:()=>qo});var Ty=new Set(["href","xlink:href","action","formaction","cite"]),Ny=new Set(["src","poster","data","background"]),Oy=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;function mr(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:Ty.has(t)?Oe(e)?e:null:Ny.has(t)?ce(e)?e:null:t==="srcset"?e.split(",").map(o=>o.trim().split(/\s+/)[0]??"").every(o=>ce(o))?e:null:t==="style"&&Oy.test(e)?null:e}var Dy=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),_p=new RegExp("\xA0","g");function qo(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(_p," ")}var Ly="\xA0";function Ry(n){let e=null,t=!0,r=n.childCount;for(let o=0;o<r;o++){let i=n.child(o);if(!i.isText){t=i.type.name==="hard_break"||!i.isInline;continue}let s=i.text??"";if(!s.includes(" ")){t=!1;continue}let l=o===r-1||!n.child(o+1).isInline,a="";for(let c=0;c<s.length;c++){let u=s[c];u!==" "?(a+=u,t=!1):t||l&&c===s.length-1?(a+=Ly,t=!1):(a+=" ",t=!0)}a!==s&&(e??(e=new Map)).set(o,a)}return e}function $p(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(_p," ")}var Py=/^[a-z][a-z0-9-]*$/i,Iy=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),zp=new Set;function Hy(n){zp.has(n)||(zp.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}var By=/^[a-z_:][a-z0-9_.:-]*$/i;function la(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:qo(n)};if(typeof n=="number"||typeof n=="boolean")return{open:"",close:"",hole:!1,html:qo(String(n))};if(n==null)return{open:"",close:"",hole:!1,html:""};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,r=e.includes(" ")?e.split(" ")[1]:e;if(!Py.test(r))throw new Error(`[nova] invalid tag in toDOM: ${r}`);let o=Iy.has(r.toLowerCase());o&&Hy(r.toLowerCase());let i="",s=t,l=t[0];if(l&&typeof l=="object"&&!Array.isArray(l)){for(let[f,h]of Object.entries(l)){if(h==null)continue;let g=f.includes(" ")?f.split(" ")[1]:f;if(!By.test(g))continue;let m=mr(g,String(h));m!==null&&(i+=` ${g}="${$p(m)}"`)}s=t.slice(1)}let a=o?"":`<${r}${i}>`;if(Dy.has(r.toLowerCase()))return{open:a,close:"",hole:!1,html:a};let c="",u="",d=!1;for(let f of s){if(f===0){if(d)throw new Error("[nova] toDOM spec has more than one content hole");d=!0;continue}let h=la(f);if(d){if(h.hole)throw new Error("[nova] toDOM spec has more than one content hole");u+=h.html}else h.hole?(c+=h.open,u+=h.close,d=!0):c+=h.html}if(o)return{open:"",close:"",hole:d,html:""};let p=`</${r}>`;return{open:a+c,close:u+p,hole:d,html:a+c+u+p}}var Ot=class{constructor(){E(this,"cache",new WeakMap)}serializeFragment(e,{pre:t=!1}={}){let r=t?null:Ry(e),o="",i=[],s=[],l=a=>{for(;i.length>a;)o+=s.pop(),i.pop()};return e.forEach((a,c,u)=>{if(!a.isInline){l(0),o+=this.serializeNode(a);return}let d=0;for(;d<i.length&&d<a.marks.length&&i[d].eq(a.marks[d]);)d++;l(d);for(let p=d;p<a.marks.length;p++){let f=a.marks[p],h=this.renderMark(f,a.isText);o+=h.open,s.push(h.close),i.push(f)}o+=a.isText?qo(r?.get(u)??a.text??""):this.serializeNode(a)}),l(0),i=[],s=[],o}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let r=la(t(e));if(!r.hole)return r.html;let o=!!e.type.spec.code||e.type.spec.whitespace==="pre";return r.open+this.serializeFragment(e.content,{pre:o})+r.close}renderMark(e,t){let r=e.type.spec.toDOM;if(!r)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let o=this.cache.get(e.type);o||this.cache.set(e.type,o=new Map);let i=JSON.stringify(e.attrs),s=o.get(i);return s||(s=la(r(e,t)),o.size>500&&o.clear(),o.set(i,s)),s}};var Fy={color:q.color,background:q.color,font_family:q.fontFamily,font_size:q.length};function ut(n,e){return(t,r)=>{let o=Y(t)[n],i=e===null?null:Fy[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!r)return!0;let l=t.tr;if(s)l.removeStoredMark(o),i&&l.addStoredMark(o.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,o),i&&l.addMark(a.$from.pos,a.$to.pos,o.create({value:i}));return r(l.scrollIntoView()),!0}}function Ye(n,e){let t=Y(n)[e],{$from:r,empty:o}=n.selection,i=o?n.storedMarks??r.marks():r.nodeAfter?.marks??r.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function gr(n){return(e,t)=>{let r=n===null?null:q.lineHeight(n);if(n!==null&&!r)return!1;let{from:o,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(o,i,(a,c)=>{(a.type===$(e).paragraph||a.type===$(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:r}))}),l?(t?.(s),!0):!1}}function ca(n){return n.selection.$from.parent.attrs.lineHeight??null}var Wo=["#000000","#434343","#666666","#999999","#b7b7b7","#d9d9d9","#efefef","#ffffff","#b91c1c","#c2410c","#a16207","#15803d","#0e7490","#1d4ed8","#6d28d9","#be185d","#ef4444","#f97316","#eab308","#22c55e","#06b6d4","#3b82f6","#8b5cf6","#ec4899","#fecaca","#fed7aa","#fef08a","#bbf7d0","#a5f3fc","#bfdbfe","#ddd6fe","#fbcfe8"];function jo(n){let t=[],r=n.current?.toLowerCase()??null,o=M("div",{className:"nova-swatches",role:"grid","aria-label":n.label}),i=null;for(let a of n.colors){let c=r===a.toLowerCase(),u=M("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":a,"aria-selected":String(c),title:a,tabindex:"-1"},c?V(S.check):null);u.style.setProperty("--swatch",a),u.addEventListener("click",()=>n.onPick(a)),t.push(u),(!i||i.childElementCount===8)&&(i=M("div",{className:"nova-swatch-row",role:"row"}),o.append(i)),i.append(u)}(t.find(a=>a.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),o.addEventListener("keydown",a=>{let c=t.indexOf(j(o));if(c<0)return;let d={ArrowRight:1,ArrowLeft:-1,ArrowDown:8,ArrowUp:-8}[Me(a,o)];if(d===void 0)return;a.preventDefault();let p=t[Math.min(t.length-1,Math.max(0,c+d))];t[c].tabIndex=-1,p.tabIndex=0,p.focus()});let s=M("button",{type:"button",className:"nova-panel-action"},V(S.clearFormatting),n.removeLabel);s.addEventListener("click",()=>n.onPick(null));let l=M("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(r??"")?r:"#000000"});return l.addEventListener("change",()=>n.onPick(l.value)),M("div",{className:"nova-color-panel"},o,M("div",{className:"nova-panel-footer"},s,M("label",{className:"nova-panel-action"},l,n.customLabel)))}function Vp(n){let{registry:e,t}=n.ui,r=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:S.table,tooltip:t("table.insert"),isEnabled:i=>i.can(ct(1,1)),render:(i,s)=>Ul((l,a)=>{s(),i.exec(ct(l,a))},r,t("table.insert"))});let o=(i,s,l,a,c)=>e.addButton(i,{icon:l,tooltip:t(s),onAction:u=>u.exec(a),isEnabled:u=>u.can(a),...c?{isActive:c}:{}});o("tableinsertrowbefore","table.rowBefore",S.rowBefore,De.addRowBefore),o("tableinsertrowafter","table.rowAfter",S.rowAfter,De.addRowAfter),o("tabledeleterow","table.rowDelete",S.rowDelete,De.deleteRow),o("tableinsertcolbefore","table.colBefore",S.colBefore,De.addColumnBefore),o("tableinsertcolafter","table.colAfter",S.colAfter,De.addColumnAfter),o("tabledeletecol","table.colDelete",S.colDelete,De.deleteColumn),o("tablemergecells","table.merge",S.merge,De.mergeCells),o("tablesplitcells","table.split",S.split,De.splitCell),o("tablerowheader","table.rowHeader",S.rowHeader,De.toggleHeaderRow,i=>_l(i.view.state)),o("tablecolheader","table.colHeader",S.colHeader,De.toggleHeaderColumn,i=>$l(i.view.state)),o("tabledelete","table.delete",S.tableDelete,De.deleteTable),e.addPanelButton("tablecellbackground",{icon:S.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Et(i.view.state),render:(i,s)=>jo({colors:i.options.colors??Wo,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(zl(l))}})}),e.addMenuButton("advtablesort",{icon:S.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(Bo("asc")),items:i=>["asc","desc"].map(s=>({id:s,label:t(s==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(Bo(s,i.options.language))}))}),e.addButton("tableprops",{icon:S.tableProps,tooltip:t("table.props"),isEnabled:i=>Et(i.view.state),onAction:i=>zy(i)}),e.addButton("tablecellprops",{icon:S.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Et(i.view.state),onAction:i=>_y(i)}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Et(i.view.state),anchor:i=>Kl(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"})}function qp(n,e,t){if(!e?.length)return null;let{t:r}=n.ui,o=[{value:"",label:r("table.styleDefault")}];for(let i of e)i.value&&o.push({value:i.value,label:i.title});return t&&!o.some(i=>i.value===t)&&o.push({value:t,label:t}),qn({label:r("table.style"),value:t??"",options:o})}function zy(n){let{t:e}=n.ui,t=Vl(n.view.state);if(!t)return;let r=ee({label:e("table.width"),hint:e("table.widthHint"),value:t.width??""}),o=qn({label:e("table.align"),value:t.align??"",options:[{value:"",label:e("table.alignDefault")},{value:"center",label:e("table.alignCenter")},{value:"right",label:e("table.alignRight")}]}),i=qp(n,n.options.tableClassList,t.class??null);n.ui.openDialog({title:e("table.props"),body:M("div",{className:"nova-form"},i?.el??null,r.el,o.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l={width:r.input.value.trim().replace(/^(\d+(\.\d+)?)$/,"$1px")||null,align:o.select.value||null,...i?{class:i.select.value||null}:{}};return n.exec(ql(l))||e("table.invalidWidth")}})}function _y(n){let{t:e}=n.ui,t=Wl(n.view.state);if(!t)return;let r=qn({label:e("table.valign"),value:t.valign??"",options:[{value:"",label:e("table.alignDefault")},{value:"top",label:e("table.valignTop")},{value:"middle",label:e("table.valignMiddle")},{value:"bottom",label:e("table.valignBottom")}]}),o=qn({label:e("table.cellType"),value:t.header?"th":"td",options:[{value:"td",label:e("table.cellData")},{value:"th",label:e("table.cellHeader")}]}),i=ee({label:e("table.colWidth"),hint:e("table.colWidthHint"),value:t.width?String(t.width):""}),s=qp(n,n.options.tableCellClassList,t.class??null);n.ui.openDialog({title:e("table.cellProps"),body:M("div",{className:"nova-form"},s?.el??null,r.el,o.el,i.el),submitLabel:e("dialog.save"),onSubmit:()=>{let l=i.input.value.trim(),a=l?Number(l.replace(/px$/i,"")):null;return a!==null&&!(Number.isInteger(a)&&a>=24&&a<=4e3)?e("table.invalidColWidth"):(n.exec(jl({valign:r.select.value||null,header:o.select.value==="th",width:a,...s?{class:s.select.value||null}:{}})),!0)}})}var $y=[{label:"Sans Serif",value:'system-ui, -apple-system, "Segoe UI", Roboto, sans-serif'},{label:"Serif",value:'Georgia, "Times New Roman", serif'},{label:"Monospace",value:"ui-monospace, Menlo, Consolas, monospace"},{label:"Arial",value:"Arial, Helvetica, sans-serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Times New Roman",value:'"Times New Roman", Times, serif'},{label:"Verdana",value:"Verdana, Geneva, sans-serif"},{label:"Courier New",value:'"Courier New", Courier, monospace'}],Vy=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],qy=["1","1.15","1.5","2","2.5","3"],Ve={undo:"Mod-z",redo:"Mod-Shift-z",bold:"Mod-b",italic:"Mod-i",underline:"Mod-u",strike:"Mod-Shift-x",code:"Mod-e",subscript:"Mod-,",superscript:"Mod-.",bulletList:"Mod-Shift-8",orderedList:"Mod-Shift-7",alignLeft:"Mod-Shift-l",alignCenter:"Mod-Shift-e",alignRight:"Mod-Shift-r",alignJustify:"Mod-Shift-j",indent:"Mod-]",outdent:"Mod-[",clearFormatting:"Mod-\\",paragraph:"Mod-Alt-0",h1:"Mod-Alt-1",h2:"Mod-Alt-2",h3:"Mod-Alt-3",h4:"Mod-Alt-4",h5:"Mod-Alt-5",h6:"Mod-Alt-6"};function Wp(n){try{let{node:e}=n.view.domAtPos(n.view.state.selection.from),t=e.nodeType===Node.TEXT_NODE?e.parentElement:e;return t?getComputedStyle(t):null}catch{return null}}var Wy={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};function jp(n){let e=String(n).split(",")[0].trim().replace(/["']/g,"");return Wy[e.toLowerCase()]??e}function jy(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}var Kp=(n,e)=>typeof n=="string"&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase();function Up(n){let{registry:e,t}=n.ui,r=()=>n.view.state,o=(v,x,C,B)=>e.addButton(v,{icon:C,tooltip:t(x),...Ve[x]?{shortcut:Ve[x]}:{},onAction:Q=>Q.exec(x),isEnabled:Q=>Q.can(x),...B?{isActive:B}:{}}),i=(v,x,C,B)=>o(v,x,B,()=>xn(r(),n.schema.marks[C]));o("undo","undo",S.undo),o("redo","redo",S.redo),i("bold","bold","bold",S.bold),i("italic","italic","italic",S.italic),i("underline","underline","underline",S.underline),i("strikethrough","strike","strike",S.strike),i("inlinecode","code","code",S.code),i("subscript","subscript","subscript",S.subscript),i("superscript","superscript","superscript",S.superscript),o("bullist","bulletList",S.bulletList,()=>Be(r(),n.schema.nodes.bullet_list)),o("numlist","orderedList",S.orderedList,()=>Be(r(),n.schema.nodes.ordered_list)),o("indent","indent",S.indent),o("outdent","outdent",S.outdent),o("blockquote","blockquote",S.blockquote,()=>Be(r(),n.schema.nodes.blockquote)),o("codeblock","codeBlock",S.codeBlock,()=>Be(r(),n.schema.nodes.code_block)),o("hr","horizontalRule",S.horizontalRule),o("removeformat","clearFormatting",S.clearFormatting);let s=[["alignLeft","left",S.alignLeft],["alignCenter","center",S.alignCenter],["alignRight","right",S.alignRight],["alignJustify","justify",S.alignJustify]];for(let[v,x,C]of s)o(v.toLowerCase(),v,C,()=>Nt(r())===x);e.addMenuButton("align",{icon:S.alignLeft,tooltip:t("align"),isEnabled:v=>v.can("alignLeft"),items:v=>s.map(([x,C,B])=>({id:x,label:t(x),icon:B,...Ve[x]?{shortcut:Ve[x]}:{},active:Nt(v.view.state)===C,onSelect:()=>v.exec(x)}))});let l=[{command:"paragraph",style:""},{command:"h1",style:"font-size: 1.6em; font-weight: 700"},{command:"h2",style:"font-size: 1.35em; font-weight: 700"},{command:"h3",style:"font-size: 1.15em; font-weight: 700"},{command:"h4",style:"font-size: 1em; font-weight: 700"},{command:"h5",style:"font-size: 0.9em; font-weight: 700"},{command:"h6",style:"font-size: 0.85em; font-weight: 700"},{command:"codeBlock",style:"font-family: ui-monospace, monospace"}],a=()=>{let v=r().selection.$from.parent;return v.type===n.schema.nodes.heading?`h${v.attrs.level}`:v.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let v=1;v<=6;v++){let x=`h${v}`;e.addToggleButton(x,{...v<=3?{icon:S[`h${v}`]}:{text:`H${v}`},tooltip:t(x),...Ve[x]?{shortcut:Ve[x]}:{},isActive:()=>a()===x,isEnabled:C=>C.can(x)||a()===x,onAction:C=>C.exec(a()===x?"paragraph":x)})}let c={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",pre:"codeBlock"},u=()=>{let v=n.options.blockFormats;return v?.length?v.flatMap(({label:x,block:C})=>{let B=c[C],Q=l.find(he=>he.command===B);return Q?[{...Q,label:x}]:[]}):l};e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>u().find(v=>v.command===a())?.label??t(a()),minChars:11,isEnabled:v=>u().some(({command:x})=>v.can(x)),items:v=>u().filter(({command:x})=>v.isAllowed(x)).map(({command:x,style:C,label:B})=>({id:x,label:B??t(x),labelStyle:C,...Ve[x]?{shortcut:Ve[x]}:{},active:a()===x,onSelect:()=>v.exec(x)}))});let d="p,h1,h2,h3,h4,h5,h6",p=()=>[{title:t("styles.headings"),items:[1,2,3,4,5,6].map(v=>({title:t(`h${v}`),block:`h${v}`}))},{title:t("styles.inline"),items:[{title:t("bold"),inline:"strong"},{title:t("italic"),inline:"em"},{title:t("underline"),inline:"u"},{title:t("strike"),inline:"s"},{title:t("superscript"),inline:"sup"},{title:t("subscript"),inline:"sub"},{title:t("code"),inline:"code"}]},{title:t("styles.blocks"),items:[{title:t("paragraph"),block:"p"},{title:t("blockquote"),block:"blockquote"},{title:t("codeBlock"),block:"pre"}]},{title:t("styles.align"),items:["left","center","right","justify"].map(v=>({title:t(`align${v==="justify"?"Justify":v[0].toUpperCase()+v.slice(1)}`),selector:d,styles:{"text-align":v}}))}],f=v=>v.format??v,h=v=>{let x=v.format?n.formatter.get(v.format)?.[0]:v,C=[],B=x?.block;B&&/^h[1-6]$/.test(B)&&C.push("font-weight: 700"),(x?.inline==="strong"||x?.inline==="b")&&C.push("font-weight: 700"),(x?.inline==="em"||x?.inline==="i")&&C.push("font-style: italic"),x?.inline==="u"&&C.push("text-decoration: underline"),(x?.inline==="s"||x?.inline==="strike"||x?.inline==="del")&&C.push("text-decoration: line-through"),(x?.inline==="code"||B==="pre")&&C.push("font-family: ui-monospace, monospace");for(let Q of["color","background-color","font-family"]){let he=x?.styles?.[Q];he&&/^[#\w\s,'"().%-]+$/.test(he)&&C.push(`${Q}: ${he}`)}return C.join("; ")},g=v=>v.flatMap(x=>x.items?g(x.items):[x]),m=()=>{let v=n.options.styleFormats;return v?n.options.styleFormatsMerge?[...p(),...v]:v:p()};e.addMenuButton("styles",{tooltip:t("styles"),minChars:10,label:v=>g(m()).find(x=>v.formatter.match(f(x)))?.title??t("styles"),items:v=>{let x=[],C=(B,Q)=>{B.forEach((he,wr)=>{if(he.items){x.length&&x.push({type:"separator"}),x.push({type:"heading",label:he.title}),C(he.items,`${Q}${wr}-`);return}x.push({id:`style-${Q}${wr}`,label:he.title,labelStyle:h(he),active:v.formatter.match(f(he)),disabled:!v.formatter.canApply(f(he)),onSelect:()=>v.formatter.toggle(f(he))})})};return C(m(),""),x}});let b=n.options.fontFamilies??$y;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:v=>{let x=Ye(r(),"font_family");if(x)return b.find(B=>Kp(x,B.value))?.label??jp(x);let C=Wp(v)?.fontFamily;return C?jp(C):t("fontFamily")},items:v=>{let x=Ye(v.view.state,"font_family");return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(ut("font_family",null))},{type:"separator"},...b.map(C=>({id:C.label,label:C.label,labelStyle:`font-family: ${C.value}`,active:Kp(x,C.value),onSelect:()=>v.exec(ut("font_family",C.value))}))]}});let k=n.options.fontSizes??Vy;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:v=>Ye(r(),"font_size")??jy(Wp(v)?.fontSize??"")??"\u2014",items:v=>{let x=Ye(v.view.state,"font_size");return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(ut("font_size",null))},{type:"separator"},...k.map(C=>({id:C,label:C,active:x===C,onSelect:()=>v.exec(ut("font_size",C))}))]}});let y=n.options.lineHeights??qy;e.addMenuButton("lineheight",{icon:S.lineHeight,tooltip:t("lineHeight"),isEnabled:v=>v.can(gr(null)),items:v=>{let x=ca(v.view.state);return[{id:"default",label:t("default"),active:x===null,onSelect:()=>v.exec(gr(null))},...y.map(C=>({id:C,label:C,active:x===C,onSelect:()=>v.exec(gr(C))}))]}});let w=(v,x,C,B)=>e.addPanelButton(v,{icon:C,tooltip:t(B),indicator:()=>Ye(r(),x),render:(Q,he)=>jo({colors:Q.options.colors??Wo,current:Ye(Q.view.state,x),label:t(B),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:wr=>{he(),Q.exec(ut(x,wr))}})});w("forecolor","color",S.textColor,"textColor"),w("backcolor","background",S.highlight,"backgroundColor");let N=[["superscript","superscript",S.superscript],["subscript","subscript",S.subscript],["code","code",S.code]];e.addMenuButton("moreformats",{icon:S.formatMore,tooltip:t("moreFormats"),isActive:v=>N.some(([,x])=>xn(v.view.state,n.schema.marks[x])),items:v=>[...N.filter(([x])=>v.isAllowed(x)).map(([x,C,B])=>({id:x,label:t(x),icon:B,checkbox:!0,active:xn(v.view.state,n.schema.marks[C]),disabled:!v.can(x),...Ve[x]?{shortcut:Ve[x]}:{},onSelect:()=>v.exec(x)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:S.clearFormatting,disabled:!v.can("clearFormatting"),shortcut:Ve.clearFormatting,onSelect:()=>v.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:S.pasteText,checkbox:!0,active:v.isPasteAsText(),onSelect:()=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}]}),e.addToggleButton("pastetext",{icon:S.pasteText,tooltip:t("pasteAsText"),isActive:v=>v.isPasteAsText(),onAction:v=>{v.setPasteAsText(!v.isPasteAsText()),v.focus()}}),e.addButton("link",{icon:S.link,tooltip:t("link"),shortcut:"Mod-k",onAction:v=>at(v),isActive:()=>!!Kt(r())}),e.addButton("unlink",{icon:S.unlink,tooltip:t("unlink"),onAction:v=>v.exec(wn()),isEnabled:v=>v.can(wn())}),e.addButton("image",{icon:S.image,tooltip:t("image"),onAction:v=>cr(v)});let L=()=>ze(r())?.attrs.align??null,R=(v,x,C,B)=>e.addToggleButton(v,{icon:C,tooltip:t(B),isActive:()=>L()===x,onAction:Q=>Q.exec(Sn({align:L()===x?null:x}))});R("imagealignleft","left",S.imageLeft,"image.alignLeft"),R("imagealigncenter","center",S.imageCenter,"image.alignCenter"),R("imagealignright","right",S.imageRight,"image.alignRight");let O=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:S.resize,tooltip:t("image.size"),items:v=>O.map(([x,C])=>({id:x,label:t(x),onSelect:()=>Ml(v,C)}))}),e.addButton("imagealt",{icon:S.altText,tooltip:t("image.editAlt"),onAction:v=>xl(v)}),e.addToggleButton("imagecaption",{icon:S.imageCaption,tooltip:t("image.caption"),isActive:v=>yl(v.view.state),onAction:v=>v.exec(vl)}),e.addButton("imagedelete",{icon:S.trash,tooltip:t("image.delete"),onAction:v=>v.exec((x,C)=>{let B=ze(x);return B?(C?.(x.tr.delete(B.pos,B.pos+B.node.nodeSize).scrollIntoView()),!0):!1})}),Vp(n),e.addButton("searchreplace",{icon:S.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:v=>v.openSearch()}),e.addToggleButton("fullscreen",{icon:S.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:v=>sa(v),onAction:v=>hr(v)}),e.addButton("preview",{icon:S.preview,tooltip:t("preview"),onAction:v=>Bp(v)}),e.addButton("code",{icon:S.sourceCode,tooltip:t("sourceCode"),onAction:v=>Fp(v)}),e.addButton("help",{icon:S.help,tooltip:t("help"),shortcut:"Alt-0",onAction:v=>Vo(v)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:v=>!!ze(v.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt imagecaption | imagedelete",anchor:v=>{let x=ze(v.view.state);return(x?v.view.nodeDOM(x.pos):null)?.getBoundingClientRect()??null}})}var Ko=6,Uo=8;function dt(n,e,t){let r=window.innerWidth,o=window.innerHeight,i=n.offsetWidth,s=n.offsetHeight,l=o-e.bottom,a=e.top,u=t==="top-start"?a>=s+Ko||a>l:l<s+Ko&&a>l,d=u?e.top-s-Ko:e.bottom+Ko,p=rn(n),h=t==="bottom"?e.left+e.width/2-i/2:t==="bottom-end"!==p?e.right-i:e.left;h=Math.max(Uo,Math.min(h,r-i-Uo)),d=Math.max(Uo,Math.min(d,o-s-Uo)),n.style.left=`${Math.round(h)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.side=u?"top":"bottom"}var br=[],An=class{constructor(e){E(this,"el");E(this,"options");E(this,"closed",!1);E(this,"unlisten",[]);E(this,"reposition",()=>{if(this.closed)return;let{anchor:e,placement:t="bottom-start"}=this.options,r=typeof e=="function"?e():e.getBoundingClientRect();dt(this.el,r,t)});E(this,"focusWasInside",!1);E(this,"onKeyDown",(e,t)=>{e.key!=="Escape"||e.defaultPrevented||br[br.length-1]===this&&(t?.closest?.(".nova-dialog")||(e.preventDefault(),e.stopPropagation(),this.focusWasInside=this.el.contains(j(this.el)),this.close("escape")))});E(this,"onPointerDown",(e,t)=>{this.options.dismissOnOutside!==!1&&(this.el.contains(t)||this.options.ignore?.some(r=>r.contains(t))||this.close("outside"))});this.options=e,this.el=document.createElement("div"),this.el.className=`nova-popover ${e.className??""}`.trim(),this.el.append(e.content),e.host.append(this.el),this.reposition(),this.unlisten=[yt(this.el,"keydown",this.onKeyDown),yt(this.el,"pointerdown",this.onPointerDown)],br.push(this),window.addEventListener("resize",this.reposition),window.addEventListener("scroll",this.reposition,!0)}get isOpen(){return!this.closed}close(e="api"){this.closed||(this.closed=!0,br.splice(br.indexOf(this),1),this.unlisten.forEach(t=>t()),window.removeEventListener("resize",this.reposition),window.removeEventListener("scroll",this.reposition,!0),this.el.remove(),this.options.onClose?.(e))}};function Jp(n){return new z({key:new K("nova-link-bubble"),view(e){let{t}=n.ui,r=M("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),o=(c,u,d)=>{let p=M("button",{type:"button",className:"nova-btn","aria-label":u,"data-tooltip":u},V(c));return p.addEventListener("click",d),n.ui.tooltip.attach(p),p},i=M("div",{className:"nova-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},V(S.externalLink),r,M("span",{className:"nova-bubble-sep"}),o(S.edit,t("link.edit"),()=>at(n)),o(S.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(r.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),o(S.unlink,t("unlink"),()=>n.exec(wn())));i.addEventListener("mousedown",c=>{c.target.closest("button")&&c.preventDefault()}),n.ui.overlayHost.append(i);let s=()=>{i.hidden=!0},l=()=>{let c=e.state,u=Kt(c),d=e.hasFocus()||i.contains(j(i));if(!u||!d||!n.isEditable()||n.ui.activeDialog||!c.selection.empty){s();return}let p=Ut(c,Y(c).link,c.selection.from);if(!p)return s();r.textContent=u.href,r.title=u.href,Oe(u.href)?r.setAttribute("href",u.href):r.removeAttribute("href"),i.hidden=!1;let f=e.coordsAtPos(p.from),h=e.coordsAtPos(p.to),g=new DOMRect(f.left,f.top,Math.max(1,h.right-f.left),h.bottom-f.top);dt(i,g,"bottom-start")},a=c=>{i.contains(c.relatedTarget)||s()};return e.dom.addEventListener("blur",a),i.addEventListener("focusout",c=>{!i.contains(c.relatedTarget)&&!e.hasFocus()&&s()}),{update:l,destroy(){e.dom.removeEventListener("blur",a),i.remove()}}}})}var ua="undo redo | blocks | bold italic underline strikethrough moreformats | forecolor backcolor | link image table | bullist numlist | align lineheight outdent indent | fontfamily fontsize | blockquote codeblock hr | removeformat | searchreplace preview code fullscreen help";function da(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let r of e){let o=r.trim();o&&(o==="|"?t.push([]):t[t.length-1].push(o))}return t.filter(r=>r.length>0)}function pa(n,e,t,r,{warnUnknown:o=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${r}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let O of da(t)){let v=M("div",{className:"nova-tb-group",role:"group"});for(let x of O){if(!n.isAllowed(x))continue;let C=i.registry.get(x);if(!C){o&&console.warn(`[nova] Unknown toolbar item "${x}"`);continue}let B=yr(n,x,C);c.push(B),v.append(B.el)}v.childElementCount&&(u.push(v),e.append(v))}let d=M("div",{className:"nova-toolbar nova-tb-overflow",role:"group"}),p=M("button",{type:"button",className:"nova-btn nova-tb-more","aria-label":s("more"),"aria-haspopup":"true","aria-expanded":"false","data-tooltip":s("more"),hidden:!0},V(S.more));i.tooltip.attach(p);let f=null,h=()=>{f?.close(),f=null},g=i.onDialogOpen(h);p.addEventListener("click",O=>{if(f)return h();p.setAttribute("aria-expanded","true");let v=new An({host:i.overlayHost,anchor:p,placement:"bottom-end",content:d,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,p],onClose:x=>{f=null,p.setAttribute("aria-expanded","false"),x==="escape"&&v.focusWasInside&&p.focus()}});f=v,O.detail===0&&d.querySelector("button:not(:disabled)")?.focus()}),r==="sliding"&&e.append(p);let m=()=>{if(r!=="sliding")return;for(let v of u)e.insertBefore(v,p);if(p.hidden=!0,e.scrollWidth<=e.clientWidth+1){h();return}p.hidden=!1;let O=u.length;for(;O>1&&e.scrollWidth>e.clientWidth+1;)O-=1,d.prepend(u[O]);d.childElementCount||(p.hidden=!0),f?.reposition(),N()},b=-1,k=typeof ResizeObserver<"u"&&r==="sliding"?new ResizeObserver(()=>{e.clientWidth!==b&&(b=e.clientWidth,m())}):null;k?.observe(e);let y=()=>[...e.querySelectorAll("button")].filter(O=>!O.disabled&&!O.hidden),w=null,N=()=>{let O=y();(!w||!O.includes(w))&&(w=O[0]??null);for(let v of e.querySelectorAll("button"))v.tabIndex=v===w?0:-1};e.addEventListener("focusin",O=>{let v=O.target;v instanceof HTMLButtonElement&&e.contains(v)&&(w=v,N())},{signal:a}),e.addEventListener("keydown",O=>{let v=y(),x=v.indexOf(j(e));if(x<0)return;let C=null,B=Me(O,e);if(B==="ArrowRight")C=x+1;else if(B==="ArrowLeft")C=x-1;else if(O.key==="Home")C=0;else if(O.key==="End")C=v.length-1;else if(O.key==="Escape"){O.preventDefault(),n.focus();return}C!==null&&(O.preventDefault(),v[(C+v.length)%v.length].focus())},{signal:a});let L=O=>{O.target.closest("button")&&O.preventDefault()};e.addEventListener("mousedown",L,{signal:a}),d.addEventListener("mousedown",L),d.addEventListener("keydown",O=>{if(O.key==="Escape")return;let v=[...d.querySelectorAll("button")].filter(B=>!B.disabled),x=v.indexOf(j(d));if(x<0)return;let C=Me(O,d);C==="ArrowRight"||C==="ArrowDown"?(O.preventDefault(),v[(x+1)%v.length].focus()):(C==="ArrowLeft"||C==="ArrowUp")&&(O.preventDefault(),v[(x-1+v.length)%v.length].focus())});let R=()=>{for(let O of c)O.update();N()};return R(),m(),{update:R,focus:()=>{N(),w?.focus()},destroy:()=>{k?.disconnect(),g(),h(),l.abort(),e.replaceChildren()}}}function yr(n,e,t){if(t.type==="split")return Ky(n,e,t);let{ui:r}=n,o=M("button",{type:"button",className:`nova-btn nova-tb-${t.type}`,"aria-label":t.tooltip,"data-tooltip":t.tooltip,"data-control":e,...t.shortcut?{"data-shortcut":t.shortcut}:{}});r.tooltip.attach(o),t.icon&&o.append(V(t.icon));let i=t.type==="menu"&&(t.label||t.text)?M("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),o.append(i),o.classList.add("nova-tb-has-label")):!t.icon&&t.text&&o.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=M("span",{className:"nova-color-bar"}),o.append(s)),t.type!=="button"&&(o.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),o.setAttribute("aria-expanded","false"),o.append(V(S.chevronDown)),o.lastElementChild?.classList.add("nova-chevron")),o.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(o.getAttribute("aria-expanded")==="true"){r.closePopover();return}let c=a.detail===0,u=()=>r.closePopover(),d=t.type==="menu"?zo(t.items(n),u,t.tooltip):t.render(n,u);o.setAttribute("aria-expanded","true");let p=r.openPopover({anchor:o,content:d,ignore:[o],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:f=>{o.setAttribute("aria-expanded","false"),f==="escape"&&p.focusWasInside&&o.focus()}});t.type==="menu"?_o(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&o.addEventListener("keydown",a=>{a.key==="ArrowDown"&&o.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),o.click())}),{el:o,update:()=>{let a=n.isEditable();if(o.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);o.classList.toggle("is-active",c),t.type==="button"&&o.setAttribute("aria-pressed",String(c))}if(i&&t.type==="menu"){let c=t.label?.(n)??t.text??"";i.textContent=c,o.setAttribute("aria-label",c&&c!==t.tooltip?`${c}, ${t.tooltip}`:t.tooltip??c)}if(s&&t.type==="panel"&&t.indicator){let c=t.indicator(n);s.style.background=c??"",s.classList.toggle("is-empty",!c)}}}}function Ky(n,e,t){let r=yr(n,e,{type:"button",tooltip:t.tooltip,onAction:t.onAction,...t.icon?{icon:t.icon}:{},...t.text?{text:t.text}:{},...t.shortcut?{shortcut:t.shortcut}:{},...t.isActive?{isActive:t.isActive}:{},...t.isEnabled?{isEnabled:t.isEnabled}:{}}),o=yr(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return o.el.classList.add("nova-tb-split-more"),{el:M("span",{className:"nova-tb-split"},r.el,o.el),update:()=>{r.update(),o.update()}}}function Gp(n){return new z({key:new K("nova-context-toolbar"),view(e){let t=M("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let r=new Map,o=null,i=(m,b)=>{let k=r.get(m);if(k)return k;let y=M("div",{className:"nova-context-items"}),w=[];return da(b.items).forEach((N,L)=>{L>0&&y.append(M("span",{className:"nova-bubble-sep",role:"separator"}));for(let R of N){if(!n.isAllowed(R))continue;let O=n.ui.registry.get(R);if(!O)continue;let v=yr(n,R,O);w.push(v),y.append(v.el)}}),k={el:y,controls:w},r.set(m,k),k},s=()=>{t.hidden=!0,o=null},l=m=>{let{selection:b}=e.state;if((m.position??"node")==="node"&&b instanceof P)return e.nodeDOM(b.from)?.getBoundingClientRect()??null;let k=e.coordsAtPos(b.from),y=e.coordsAtPos(b.to);return new DOMRect(k.left,k.top,Math.max(1,y.right-k.left),y.bottom-k.top)},a=!1,c=m=>{m.pointerType==="mouse"&&m.button===0&&(a=!0)},u=()=>{a&&(a=!1,setTimeout(()=>f(e),0))};e.dom.addEventListener("pointerdown",c);let d=yt(t,"pointerup",u),p=typeof matchMedia=="function"&&matchMedia("(pointer: coarse)").matches,f=m=>{if(!(m.hasFocus()||t.contains(j(t)))||!n.isEditable()||n.ui.activeDialog||a)return s();let k=n.ui.registry.getContextToolbars().find(([,O])=>O.predicate(n));if(!k)return s();let[y,w]=k,N=i(y,w);o!==y&&(t.replaceChildren(N.el),t.setAttribute("aria-label",w.label),o=y);for(let O of N.controls)O.update();let L=w.anchor?w.anchor(n):l(w);if(!L)return s();t.hidden=!1;let R=w.placement??(w.position==="selection"?"bottom-start":"top-start");p&&w.position==="selection"&&(R="bottom-start"),dt(t,L,R)};t.addEventListener("mousedown",m=>{m.target.closest("button")&&m.preventDefault()}),t.addEventListener("keydown",m=>{let b=[...t.querySelectorAll("button:not(:disabled)")],k=b.indexOf(j(t));if(m.key==="Escape")m.preventDefault(),n.focus();else if(k>=0&&(m.key==="ArrowRight"||m.key==="ArrowLeft")){m.preventDefault();let y=Me(m,t)==="ArrowRight"?1:-1;b[(k+y+b.length)%b.length].focus()}});let h=m=>{let b=m.relatedTarget;!t.contains(b)&&!n.ui.overlayHost.contains(b)&&s()};e.dom.addEventListener("blur",h),t.addEventListener("focusout",m=>{let b=m.relatedTarget;!t.contains(b)&&!e.hasFocus()&&!n.ui.overlayHost.contains(b)&&s()});let g=()=>{t.hidden||f(e)};return window.addEventListener("scroll",g,!0),window.addEventListener("resize",g),{update:f,destroy(){e.dom.removeEventListener("blur",h),e.dom.removeEventListener("pointerdown",c),d(),window.removeEventListener("scroll",g,!0),window.removeEventListener("resize",g),t.remove()}}}})}function Yp(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var Xp=24,Jo=class{constructor(e,t,r,o){E(this,"view",t);E(this,"getPos",r);E(this,"editor",o);E(this,"dom");E(this,"img");E(this,"node");E(this,"resizing",!1);this.node=e,this.dom=document.createElement("span"),this.dom.className="nova-image",this.img=document.createElement("img"),this.img.draggable=!1,this.dom.append(this.img);for(let i of["nw","ne","sw","se"]){let s=document.createElement("span");s.className=`nova-image-handle nova-image-handle-${i}`,s.dataset.corner=i,s.addEventListener("pointerdown",l=>this.startResize(l,i)),this.dom.append(s)}this.render()}render(){let{src:e,alt:t,title:r,width:o,height:i,align:s}=this.node.attrs,l=ce(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",r),this.setAttr("class",He(this.node.attrs.class).class??null);let a=ne(o),c=ne(i);this.img.style.width=a?`${a}px`:"",this.img.style.aspectRatio=a&&c?`${a} / ${c}`:"",this.dom.dataset.align=s??""}setAttr(e,t){t?this.img.setAttribute(e,t):this.img.removeAttribute(e)}update(e){return e.type!==this.node.type?!1:(this.node=e,this.resizing||this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(e){return e.target.classList?.contains("nova-image-handle")??!1}ignoreMutation(){return!0}startResize(e,t){if(!this.editor.isEditable())return;e.preventDefault(),e.stopPropagation();let r=e.currentTarget;r.setPointerCapture(e.pointerId);let o=this.img.getBoundingClientRect(),i=e.clientX,s=o.width,l=o.width>0?o.height/o.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(Xp,this.view.dom.clientWidth-40),c=t==="ne"||t==="se"?1:-1,u=s;this.resizing=!0,this.dom.classList.add("is-resizing");let d=f=>{u=Math.round(Math.min(a,Math.max(Xp,s+c*(f.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},p=()=>{r.removeEventListener("pointermove",d),r.removeEventListener("pointerup",p),r.removeEventListener("pointercancel",p),this.resizing=!1,this.dom.classList.remove("is-resizing"),delete this.dom.dataset.size;let f=this.getPos();if(f===void 0||Math.abs(u-s)<1)return this.render();let h=this.view.state.tr.setNodeMarkup(f,void 0,{...this.node.attrs,width:u,height:Math.round(u*l)});h.setSelection(P.create(h.doc,f)),this.view.dispatch(h)};r.addEventListener("pointermove",d),r.addEventListener("pointerup",p),r.addEventListener("pointercancel",p)}};var Uy=30;function Jy(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Gy(n,e){let{selection:t}=n.state;if(!t.empty)return null;let r=t.$from;if(!r.parent.isTextblock||r.parent.type.spec.code)return null;let o=r.parent.textBetween(Math.max(0,r.parentOffset-Uy-1),r.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${Jy(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=o.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=r.parentOffset-c.length-s.trigger.length,d=u>0?r.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:r.pos-c.length-s.trigger.length,to:r.pos,query:c}}return null}function Qp(n){let e,t=[],r=0,o=null,i=null,s=0,l=Te("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,o=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.removeAttribute("aria-expanded")},u=(h,g)=>{let m=t[g];if(!m||!o)return;let{spec:b,from:k,to:y}=o;c(h),b.onSelect(m,{from:k,to:y},n)},d=h=>{if(!o)return;let{spec:g}=o;if(e.replaceChildren(),e.setAttribute("aria-label",g.label),!t.length){if(!g.emptyText)return c(h);e.append(M("div",{className:"nova-ac-empty"},g.emptyText))}t.forEach((b,k)=>{let y=M("div",{id:`${l}-${k}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(k===r)},b.icon?V(b.icon):null,M("span",{className:"nova-menu-label"},b.label),b.shortcut?M("kbd",{className:"nova-menu-shortcut"},tt(b.shortcut)):b.detail?M("span",{className:"nova-menu-shortcut"},b.detail):null);y.addEventListener("mousedown",w=>{w.preventDefault(),u(h,k)}),y.addEventListener("mousemove",()=>{r!==k&&p(h,k)}),e.append(y)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),p(h,Math.min(r,Math.max(0,t.length-1)));let m=h.coordsAtPos(o.from);dt(e,new DOMRect(m.left,m.top,1,m.bottom-m.top),"bottom-start")},p=(h,g)=>{r=g,e.querySelectorAll('[role="option"]').forEach((b,k)=>b.setAttribute("aria-selected",String(k===g)));let m=e.querySelector(`#${l}-${g}`);m&&(h.dom.setAttribute("aria-activedescendant",m.id),m.scrollIntoView?.({block:"nearest"}))},f=h=>{let g=n.isEditable()&&h.hasFocus()?Gy(h,n):null;if(!g||g.from===i){g||(i=null),(a()||o)&&c(h);return}let m=!o||o.query!==g.query||o.from!==g.from;if(o=g,!m&&a())return d(h);let b=++s;Promise.resolve(g.spec.fetch(g.query,n)).then(k=>{b!==s||!o||(t=k.slice(0,g.spec.maxResults??10),r=0,d(h))})};return new z({key:new K("nova-autocompleter"),view(h){e=M("div",{className:"nova-popover nova-ac",id:l,role:"listbox",hidden:!0}),n.ui.overlayHost.append(e),h.dom.setAttribute("aria-autocomplete","list");let g=()=>c(h);return h.dom.addEventListener("blur",g),{update:m=>f(m),destroy(){h.dom.removeEventListener("blur",g),e.remove()}}},props:{handleKeyDown(h,g){if(!a()||!o)return!1;let m=t.length;switch(g.key){case"ArrowDown":return m&&p(h,(r+1)%m),!0;case"ArrowUp":return m&&p(h,(r-1+m)%m),!0;case"Enter":case"Tab":return m?(u(h,r),!0):!1;case"Escape":return i=o.from,c(h),!0;default:return!1}}}})}var pt=n=>e=>e.exec(n),Yy=[{name:"paragraph",label:"paragraph",icon:S.paragraph,keywords:["text","p","paragraph"],run:pt("paragraph")},{name:"h1",label:"h1",icon:S.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:pt("h1")},{name:"h2",label:"h2",icon:S.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:pt("h2")},{name:"h3",label:"h3",icon:S.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:pt("h3")},{name:"bullist",label:"bulletList",icon:S.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:pt("bulletList")},{name:"numlist",label:"orderedList",icon:S.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:pt("orderedList")},{name:"blockquote",label:"blockquote",icon:S.blockquote,keywords:["quote","blockquote","citation"],run:pt("blockquote")},{name:"codeblock",label:"codeBlock",icon:S.codeBlock,keywords:["code","pre","snippet"],run:pt("codeBlock")},{name:"hr",label:"horizontalRule",icon:S.horizontalRule,keywords:["hr","divider","line","separator"],run:pt("horizontalRule")},{name:"table",label:"table",icon:S.table,keywords:["table","grid"],run:n=>n.exec(ct(3,3))},{name:"image",label:"image",icon:S.image,keywords:["image","picture","photo","img"],run:n=>cr(n)},{name:"link",label:"link",icon:S.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>at(n)}];function Xy(n,e,t){let r=e.toLowerCase();if(!r)return n;let o=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(r)?c=3:a.some(u=>u.startsWith(r))?c=2:a.some(u=>u.includes(r))&&(c=1),c>0&&o.push([c,s,i])}),o.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function Zp(n,e=[]){let{t}=n.ui,r=[...Yy,...e].filter(o=>n.isAllowed(o.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:o=>Xy(r,o,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(o,i,s)=>{let l=r.find(a=>a.name===o.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var Go=class{constructor(e,t){E(this,"region");E(this,"closeLabel");this.closeLabel=t,this.region=M("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",r=e.timeout??(t==="error"?0:4e3),o=M("span",{className:"nova-notification-text"},e.text),i=M("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},V(S.close)),s=(e.actions??[]).map(p=>M("button",{type:"button",className:"nova-btn nova-notification-action"},p.label)),l=M("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},o,...s,i);this.region.append(l);let a=null,c=!1,u=()=>{c||(c=!0,a&&clearTimeout(a),l.remove())},d=()=>{c||(u(),e.onClose?.())};return s.forEach((p,f)=>p.addEventListener("click",()=>{u(),e.actions[f].onAction()})),i.addEventListener("click",d),r>0&&(a=setTimeout(d,r)),s[0]?.focus({preventScroll:!0}),{close:u,setText:p=>o.textContent=p}}destroy(){this.region.remove()}};var Qy=S.sidebar,Yo=class{constructor(){E(this,"controls",new Map);E(this,"menuItems",new Map);E(this,"contextToolbars",new Map);E(this,"autocompleters",new Map);E(this,"sidebars",new Map)}addButton(e,t){this.controls.set(e.toLowerCase(),{type:"button",...t})}addToggleButton(e,t){this.addButton(e,t)}addMenuButton(e,t){this.controls.set(e.toLowerCase(),{type:"menu",...t})}addPanelButton(e,t){this.controls.set(e.toLowerCase(),{type:"panel",...t})}addSplitButton(e,t){this.controls.set(e.toLowerCase(),{type:"split",...t})}addMenuItem(e,t){this.menuItems.set(e.toLowerCase(),t)}addToggleMenuItem(e,t){this.addMenuItem(e,t)}getMenuItem(e){let t=this.menuItems.get(e.toLowerCase());if(t)return t;let r=this.get(e);if(!(r?.type!=="button"&&r?.type!=="split"))return{text:r.tooltip,...r.icon?{icon:r.icon}:{},...r.shortcut?{shortcut:r.shortcut}:{},onAction:r.onAction,...r.isActive?{isActive:r.isActive}:{},...r.isEnabled?{isEnabled:r.isEnabled}:{}}}addSidebar(e,t){this.sidebars.set(e,t),!(t.button===!1||this.has(e))&&this.addToggleButton(e,{tooltip:t.tooltip??t.title,icon:t.icon??Qy,isActive:r=>r.ui.sidebar.isOpen(e),onAction:r=>{r.ui.sidebar.toggle(e)}})}getSidebar(e){return this.sidebars.get(e)}addAutocompleter(e,t){this.autocompleters.set(e.toLowerCase(),t)}getAutocompleters(){return[...this.autocompleters]}addContextToolbar(e,t){this.contextToolbars.set(e.toLowerCase(),t)}getContextToolbars(){return[...this.contextToolbars].sort((e,t)=>(t[1].priority??0)-(e[1].priority??0))}get(e){return this.controls.get(e.toLowerCase())}has(e){return this.controls.has(e.toLowerCase())}names(){return[...this.controls.keys()]}};var Xo=class{constructor(e){E(this,"editor",e);E(this,"current",null);E(this,"mounted",new Map);E(this,"column",null);E(this,"opening",Promise.resolve());E(this,"destroyed",!1)}get active(){return this.current}isOpen(e){return this.current===e}async show(e,t={}){let r=this.editor.ui.registry.getSidebar(e);if(!r){console.warn(`[nova] sidebar "${e}" is not registered`);return}if(this.current!==e){this.hide({restoreFocus:!1}),this.editor.ui.closeOverlays(),this.current=e;let o=this.mount(e,r);this.opening=o.ready.then(i=>{if(!i||this.current!==e||this.destroyed){this.current===e&&(this.current=null);return}o.el.hidden=!1,this.editor.root.classList.add("nova-sidebar-open"),r.onShow?.(this.editor),this.editor.updateUI()})}if(await this.opening,t.focus&&this.current===e){let o=this.mounted.get(e).el;(o.querySelector(nn)??o).focus()}}hide(e={}){let t=this.current;if(!t)return;this.current=null;let r=this.mounted.get(t);if(!r)return;let o=r.el.contains(j(r.el));r.el.hidden=!0,this.editor.root.classList.remove("nova-sidebar-open"),this.editor.ui.registry.getSidebar(t)?.onHide?.(this.editor),this.editor.updateUI(),o&&e.restoreFocus!==!1&&this.editor.focus()}toggle(e,t={}){return this.current===e?(this.hide(),Promise.resolve()):this.show(e,t)}destroy(){this.destroyed=!0,this.mounted.forEach(e=>e.cleanup?.()),this.mounted.clear()}host(){if(this.column)return this.column;let e=this.editor.view.dom.parentElement,t=M("div",{className:"nova-body"});return e.before(t),t.append(e),this.column=t,t}mount(e,t){let r=this.mounted.get(e);if(r)return r;let o=Te("nova-sidebar-title"),i=M("div",{className:"nova-sidebar-body"}),s=M("button",{type:"button",className:"nova-btn nova-sidebar-close","aria-label":this.editor.ui.t("dialog.close"),onClick:()=>this.hide()},V(S.close)),l=t.header===!1?null:M("div",{className:"nova-sidebar-head"},M("h2",{id:o,className:"nova-sidebar-title"},t.title),s),a=M("div",{className:`nova-sidebar${l?"":" nova-sidebar-bare"}`,hidden:!0,"data-sidebar":e,...l?{role:"complementary","aria-labelledby":o}:{},onKeydown:(u=>{u.key!=="Escape"||u.defaultPrevented||(u.preventDefault(),this.hide())})},l,i);this.host().append(a);let c={el:a,ready:Promise.resolve(!1)};return c.ready=(async()=>{try{let u=await t.render(i,this.editor);return typeof u=="function"&&(c.cleanup=u),!0}catch(u){return console.error(`[nova] sidebar "${e}" failed to render`,u),a.remove(),this.mounted.delete(e),!1}})(),this.mounted.set(e,c),c}};var Zy=450,Qo=class{constructor(e){E(this,"el");E(this,"timer",null);E(this,"target",null);this.el=M("div",{className:"nova-tooltip",role:"tooltip",hidden:!0}),e.append(this.el)}attach(e){e.addEventListener("pointerenter",t=>{t.pointerType==="mouse"&&this.schedule(e)}),e.addEventListener("pointerleave",()=>this.hide()),e.addEventListener("focus",()=>{e.matches(":focus-visible")&&this.show(e)}),e.addEventListener("blur",()=>this.hide()),e.addEventListener("pointerdown",()=>this.hide())}schedule(e){this.clearTimer(),this.timer=setTimeout(()=>this.show(e),Zy)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let r=e.dataset.shortcut;this.el.replaceChildren(M("span",{},t)),r&&this.el.append(M("kbd",{},tt(r))),this.el.hidden=!1,dt(this.el,e.getBoundingClientRect(),"bottom")}hide(){this.clearTimer(),this.el.hidden=!0,this.target=null}get current(){return this.target}destroy(){this.hide(),this.el.remove()}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}};var Zo=class{constructor(e,t,r,o){E(this,"focusEditor",r);E(this,"registry",new Yo);E(this,"t");E(this,"overlayHost");E(this,"tooltip");E(this,"sidebar");E(this,"notifications");E(this,"popover",null);E(this,"currentDialog",null);E(this,"dialogListeners",new Set);this.t=t,this.overlayHost=M("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new Qo(this.overlayHost),this.notifications=new Go(e,t("dialog.close")),this.sidebar=new Xo(o)}async dialog(e){let{openFormDialog:t}=await import(__novaChunk("tinymce-chunks/form-dialog-9cde0ef7.js") );return t(e,this.t,r=>this.openDialog(r))}openPopover(e){this.closePopover(),this.tooltip.hide();let t=new An({...e,host:this.overlayHost,onClose:r=>{this.popover===t&&(this.popover=null),e.onClose?.(r)}});return this.popover=t,t}closePopover(){this.popover?.close("api"),this.popover=null}get activePopover(){return this.popover}onDialogOpen(e){return this.dialogListeners.add(e),()=>this.dialogListeners.delete(e)}closeOverlays(){this.closePopover(),this.dialogListeners.forEach(e=>e())}openDialog(e){this.closePopover(),this.dialogListeners.forEach(r=>r()),this.currentDialog?.close();let t=Cc({cancelLabel:this.t("dialog.cancel"),closeLabel:this.t("dialog.close"),...e,host:this.overlayHost,returnFocus:this.focusEditor,onClose:()=>{this.currentDialog===t&&(this.currentDialog=null),e.onClose?.()}});return this.currentDialog=t,t}get activeDialog(){return this.currentDialog}notify(e){return this.notifications.open(typeof e=="string"?{text:e}:e)}destroy(){this.sidebar.destroy(),this.closePopover(),this.currentDialog?.close(),this.tooltip.destroy(),this.notifications.destroy(),this.overlayHost.remove()}};var ev={paragraph:()=>"p",heading:n=>`h${n.attrs.level}`,blockquote:()=>"blockquote",code_block:()=>"pre",bullet_list:()=>"ul",ordered_list:()=>"ol",list_item:()=>"li",table:()=>"table",table_row:()=>"tr",table_cell:()=>"td",table_header:()=>"th"},tv={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"},tf=String.raw`\p{sc=Han}\p{sc=Hiragana}\p{sc=Katakana}`,ef=String.raw`(?:(?![${tf}])[\p{L}\p{N}])`,nv=new RegExp(`[${tf}]|${ef}+(?:['\u2019-]${ef}+)*`,"gu");function rv(n){return n.match(nv)?.length??0}function nf(n,e){e.className="nova-statusbar";let t=M("div",{className:"nova-path","aria-hidden":"true"}),r=M("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,r);let o=n.options.resize,i=o?sv(n,e,o==="both"):null,s=null,l=()=>{let c=n.view.state.doc;r.textContent=n.ui.t("status.words",{count:rv(c.textBetween(0,c.content.size," "," "))})},a=c=>{let{$from:u}=n.view.state.selection,d=[];for(let f=1;f<=u.depth;f++){let h=u.node(f),g=ev[h.type.name]?.(h);g&&d.push(g)}n.view.state.selection.node?.type.name==="image"&&d.push("img");for(let f of u.marks()){let h=tv[f.type.name];h&&d.push(h)}t.replaceChildren(...d.flatMap((f,h)=>[...h?[" \u203A "]:[],M("span",{className:"nova-path-item"},f)])),c&&(s&&clearTimeout(s),s=setTimeout(l,250))};return l(),a(!1),{update:a,destroy:()=>{s&&clearTimeout(s),i?.(),e.replaceChildren()}}}var ov=100,iv=200,ei=20;function sv(n,e,t){let r=n.root,o=M("div",{className:"nova-resize-handle",role:"separator",tabIndex:0,"aria-orientation":"horizontal","aria-label":n.ui.t("status.resize")});o.append(V(t?S.resizeHandleBoth:S.resizeHandle)),r.dataset.resize=t?"both":"vertical",e.append(o);let i=(d,p)=>{if(r.style.boxSizing="border-box",r.style.height=`${Math.max(ov,Math.round(d))}px`,t&&p!==void 0){let f=r.parentElement?.clientWidth||1/0;r.style.width=`${Math.min(f,Math.max(iv,Math.round(p)))}px`}o.setAttribute("aria-valuenow",String(r.offsetHeight))},s=null,l=d=>{n.isDisabled()||(d.preventDefault(),o.setPointerCapture(d.pointerId),s={x:d.clientX,y:d.clientY,height:r.offsetHeight,width:r.offsetWidth})},a=d=>{if(!s)return;let p=(d.clientX-s.x)*(rn(r)?-1:1);i(s.height+d.clientY-s.y,s.width+p)},c=d=>{s&&(s=null,o.hasPointerCapture(d.pointerId)&&o.releasePointerCapture(d.pointerId))},u=d=>{let p=d.key==="ArrowDown"?ei:d.key==="ArrowUp"?-ei:0,f=Me(d,r),h=t?f==="ArrowRight"?ei:f==="ArrowLeft"?-ei:0:0;!h&&!p||(d.preventDefault(),i(r.offsetHeight+p,r.offsetWidth+h))};return o.addEventListener("pointerdown",l),o.addEventListener("pointermove",a),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),o.addEventListener("keydown",u),()=>{o.remove(),delete r.dataset.resize}}var lv=new Set(["ar","he","iw","fa","ur","ps","sd","ug","yi","dv","ckb"]);function av(n){return!!n&&lv.has(n.toLowerCase().split(/[-_]/)[0])}var cv=new Ot,ha="nova:remote",vr="nova:api",uv=new Set("P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" ")),dv=0,kr=class{constructor(e){E(this,"view");E(this,"root");E(this,"ui");E(this,"options");E(this,"listeners",new Map);E(this,"ready");E(this,"toolbar");E(this,"toolbarHost");E(this,"menubar");E(this,"mode");E(this,"direction");E(this,"pluginsByName",new Map);E(this,"commandOverrides",new Map);E(this,"transactionTransforms",[]);E(this,"cleanups",[]);E(this,"contentRules");E(this,"schema");E(this,"formatter");E(this,"statusbar");E(this,"searchBar");E(this,"destroyed",!1);E(this,"editable");E(this,"disabled");E(this,"pasteAsText");this.options=e,this.root=document.createElement("div"),this.root.className="nova-editor";let t=e.direction??(av(e.language)?"rtl":void 0);t&&(this.root.dir=t),this.direction=t??(e.element.closest("[dir]")?.getAttribute("dir")==="rtl"?"rtl":"ltr"),e.element.appendChild(this.root);let r=document.createElement("div"),o=document.createElement("div"),i=document.createElement("div");o.className="nova-content";let s=document.createElement("div");s.className="nova-header";let l=document.createElement("div");s.append(l,r),this.root.append(s,o,i),this.toolbarHost=r,this.mode=e.mode??"classic",this.root.classList.add(`nova-mode-${this.mode}`);let a=this.mode==="distraction-free";this.mode!=="classic"&&(this.root.addEventListener("focusin",()=>this.root.classList.add("is-focused")),this.root.addEventListener("focusout",()=>{setTimeout(()=>{this.root.contains(j(this.root))||this.root.classList.remove("is-focused")},0)})),this.ui=new Zo(this.root,Bi(e.language,e.translations),()=>this.focus(),this),this.root.style.setProperty("--nova-caption-placeholder",JSON.stringify(this.ui.t("image.captionPlaceholder")));let c=Ke({"Mod-k":()=>(at(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>Yp(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(hr(this),!0),"Alt-0":()=>(Vo(this),!0),Escape:()=>this.searchBar.isOpen()?(this.searchBar.close(),!0):!1}),u=[...e.plugins??[]];a&&!u.includes("quickbars")&&u.push("quickbars");let d=ui(u);d.errors.forEach(C=>Pe(C));let{ordered:p,errors:f}=Ar(d.plugins);f.forEach(C=>Pe(C));let h=p.flatMap(C=>this.collectPmPlugins(C)),g=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=g?new $o(e):null;let m=new Set([...lr(Object.values(e.formats??{}).flat()),...lr(e.styleFormats??[]),...Array.isArray(e.validClasses)?e.validClasses:[],...[...e.tableClassList??[],...e.tableCellClassList??[]].flatMap(C=>C.value.split(/\s+/).filter(Boolean))]),b=Mp(e),k=e.validClasses===!0||e.validClasses===void 0&&!!b?.classOnBuiltIn;this.schema=this.buildSchema(p,k?()=>!0:C=>m.has(C),b),this.formatter=new Ao(this,m);for(let[C,B]of Object.entries(e.formats??{}))this.formatter.register(C,B);p.forEach(C=>this.registerCommands(C));let y=fa(this.schema,e.content??""),w=Dp(),N=[Qp(this),hp(C=>this.isAllowed(C),this.schema),c,w,...mp(C=>this.resolveCommand(C)),...p.some(C=>C.replaceHistory)?[]:[Xs()],tp({color:"var(--nova-accent)",width:2}),rp(),bl(this),gl(this),bp(this),Jp(this),Gp(this),...this.contentRules?[Tp(this.contentRules)]:[],...h,...e.prosemirrorPlugins??[]];Xl(N);let L=Vn.create({doc:this.contentRules?this.contentRules.normalizeDoc(y):y,plugins:N});this.editable=e.editable??!0,this.disabled=e.disabled??!1,this.pasteAsText=e.pasteAsText??!1;let R=this.handleTransaction.bind(this);this.view=new fn(o,{state:L,editable:()=>this.isEditable(),attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...e.placeholder?{"data-placeholder":e.placeholder}:{}},dispatchTransaction:function(C){R(C,this)},clipboardParser:dr(this.schema),nodeViews:{image:(C,B,Q)=>new Jo(C,B,Q,this)},handleDOMEvents:{focus:(C,B)=>(this.emit("focus",{event:B}),!1),blur:(C,B)=>(this.emit("blur",{event:B}),!1)},handleKeyDown:(C,B)=>(this.emit("keydown",{event:B}),B.defaultPrevented)}),this.root.classList.toggle("nova-readonly",!this.editable),this.applyDisabled(),Up(this),Cp(this),e.slashCommands!==!1&&Zp(this,e.slashCommands??[]),p.forEach(C=>this.setupPlugin(C)),e.setup?.(this);let O=e.menubar===!0?wp:typeof e.menubar=="string"?e.menubar:null;this.menubar=O?Ep(this,l,O,{...Sp,...e.menu}):null,this.menubar||l.remove(),this.toolbar=e.toolbar===!1||a&&e.toolbar===void 0?null:pa(this,r,this.toolbarConfig(),e.toolbarMode??"sliding",{warnUnknown:d.loaders.length===0}),this.toolbar||r.remove(),!this.toolbar&&!this.menubar&&s.remove(),this.searchBar=Hp(this,o);let v=e.statusbar??this.mode==="classic";this.statusbar=v?nf(this,i):null,this.statusbar||i.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder();let x=this.applyContentStyles();this.ready=Promise.all([d.loaders.length?this.loadLazyPlugins(d.loaders):void 0,x,Hl(),this.installTables(w)]).then(()=>{this.destroyed||this.emit("init")})}async installTables(e){let t=await Fl();if(!t||this.destroyed)return;let{state:r}=this.view,o=r.plugins.indexOf(e),i=[...r.plugins];i.splice(o<0?i.length:o,0,...t.tablePlugins()),Ql(this.view,i),this.updateUI()}applyContentStyles(){let{contentStyle:e,contentCss:t}=this.options,r=t===void 0?[]:Array.isArray(t)?t:[t];if(!e&&!r.length)return;let o=`nova-cs-${++dv}`;this.root.classList.add(o);let i=`.nova-editor.${o} .nova-prosemirror`,s=r.map(()=>""),l=null,a=()=>{this.destroyed||(l?.(),l=ep(this.root,cl([...s,e??""].join(`
|
|
37
|
+
`),i)))};if(this.cleanups.push(()=>l?.()),a(),!!r.length)return Promise.all(r.map((c,u)=>ul(c).then(d=>{s[u]=d},d=>console.warn(`[nova] contentCss: could not load ${c}`,d)))).then(a)}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}buildSchema(e,t,r){let o={},i={};for(let s of e){let l=typeof s.nodes=="function"?s.nodes(this):s.nodes;for(let[a,c]of Object.entries(l??{}))a in o?Pe(`Node "${a}" is defined by several plugins`):o[a]=c;for(let[a,c]of Object.entries(s.marks??{}))a in i?Pe(`Mark "${a}" is defined by several plugins`):i[a]=c}try{return po({nodes:o,marks:i},t,r,this.direction)}catch(s){return Pe("Failed to build the document schema from plugins",s),po({},t,r,this.direction)}}collectPmPlugins(e){try{return e.prosemirrorPlugins?.(this)??[]}catch(t){return Pe(`Plugin "${e.name}" failed to create ProseMirror plugins`,t),[]}}setupPlugin(e){try{let t=e.setup?.(this);typeof t=="function"&&this.cleanups.push(t),this.pluginsByName.set(e.name,e)}catch(t){Pe(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>di(l).catch(a=>(Pe("Failed to load plugin",a),null))));if(this.destroyed)return;let r=t.filter(l=>l?l.nodes||l.marks?(Pe(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:o,errors:i}=Ar(r,new Set(this.pluginsByName.keys()));i.forEach(l=>Pe(l));let s=o.flatMap(l=>this.collectPmPlugins(l));s.length&&Ql(this.view,[...this.view.state.plugins,...s]),o.forEach(l=>{this.registerCommands(l),this.setupPlugin(l)}),this.rebuildToolbar()}updateUI(){this.destroyed||this.toolbar?.update()}rebuildToolbar(){!this.toolbar||this.destroyed||(this.toolbar.destroy(),this.toolbar=pa(this,this.toolbarHost,this.toolbarConfig(),this.options.toolbarMode??"sliding"))}toolbarConfig(){if(this.options.toolbar)return this.options.toolbar;let e=[...this.pluginsByName.values()].map(t=>t.toolbar).filter(Boolean);return e.length?`${ua} | ${e.join(" ")}`:ua}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let r of this.transactionTransforms)e=r(e,t.state,this);t.updateState(t.state.apply(e)),this.view&&(this.toolbar?.update(),this.statusbar?.update(e.docChanged),this.searchBar?.update(),this.updatePlaceholder(),e.docChanged&&(this.emit("change",{transaction:e}),!(e.getMeta(vr)||e.getMeta(ha))&&e.getMeta("addToHistory")!==!1&&this.emit("input",{transaction:e})),(e.selectionSet||e.docChanged)&&this.emit("selectionChange",{transaction:e}))}}updatePlaceholder(){let e=this.view.state.doc,t=e.childCount===1&&e.firstChild?.type===this.schema.nodes.paragraph&&e.firstChild.content.size===0;this.view.dom.classList.toggle("nova-empty",t)}getHTML(){return cv.serializeFragment(this.view.state.doc.content)}getJSON(){return this.view.state.doc.toJSON()}getText(){return this.view.state.doc.textBetween(0,this.view.state.doc.content.size,`
|
|
38
38
|
|
|
39
|
-
`)}setContent(e,{addToHistory:t=!0}={}){let r=yi(this.schema,e),o=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,r.content);t||o.setMeta("addToHistory",!1),this.view.dispatch(o)}insertContent(e){if(!this.isEditable())return!1;let t=document.createElement("template");t.innerHTML=e;let r=document.createElement("div");r.append(t.content);let o=Ar(this.schema),i=[...r.children].some(f=>kk.has(f.tagName)),{state:s}=this.view,l=i?new O(o.parse(r).content,0,0):o.parseSlice(r),a=!1;l.content.descendants(f=>(f.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=s.selection,u=0;for(let f=1;f<=c.depth;f++)if(c.node(f).type.spec.tableRole==="table"){u=f;break}let d=a&&u?s.tr.insert(c.after(u),l.content):s.tr.replaceSelection(l);return this.view.dispatch(d.scrollIntoView()),!0}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){return this.commandOverrides.get(e)??Q[e]}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}can(e){return(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,void 0,this.view)}isActive(e){return ff(this.view.state,e)}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}openSearch(){this.searchBar.open()}closeSearch(){this.searchBar.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e){for(let t of this.listeners.get(e)??[])t(this)}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){Xe("Plugin cleanup failed",t)}this.searchBar.destroy(),this.root.classList.contains("nova-fullscreen")&&Lr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}}});function Xh(n){let e=[];return n.descendants((t,r)=>{if(!t.isTextblock)return!0;let o="",i=[];return t.forEach((s,l)=>{let a=r+1+l;if(s.isText){for(let c=0;c<s.text.length;c+=1)i.push(a+c);o+=s.text}else{let c=s.type.spec.leafText?.(s)??" ";for(let u=0;u<c.length;u+=1)i.push(a);o+=c}}),e.push({pos:r,end:r+t.nodeSize-1,depth:n.resolve(r).depth,type:t.type.name,text:o,chars:i}),!1}),e}function Qh(n,e,t){let r=n.length,o=e.length;if((r+1)*(o+1)>2e6)return null;let i=new Uint32Array((r+1)*(o+1)),s=(u,d)=>u*(o+1)+d;for(let u=r-1;u>=0;u-=1)for(let d=o-1;d>=0;d-=1)i[s(u,d)]=t(n[u],e[d])?i[s(u+1,d+1)]+1:Math.max(i[s(u+1,d)],i[s(u,d+1)]);let l=[],a=0,c=0;for(;a<r&&c<o;)t(n[a],e[c])?(l.push([a,c]),a+=1,c+=1):i[s(a+1,c)]>=i[s(a,c+1)]?a+=1:c+=1;return l}function vi(n,e,t){if(e>=t)return;let r=n.added[n.added.length-1];r&&r.to>=e?r.to=Math.max(r.to,t):n.added.push({from:e,to:t})}function xk(n,e,t){if(e.text===t.text){e.text&&vi(n,e.chars[0],e.end);return}let r=Yh(e.text),o=Yh(t.text),i=Qh(r,o,(f,p)=>f===p);if(!i){e.text&&vi(n,e.chars[0],e.end),t.text&&n.removed.push({pos:e.end,text:t.text,block:!1});return}let s=[],l=0;for(let f of r)s.push(l),l+=f.length;let a=f=>f<e.chars.length?e.chars[f]:e.end,c=0,u=0,d=(f,p)=>{let h=o.slice(u,f).join("");if(h.trim()){let m=p<r.length?a(s[p]):e.end;n.removed.push({pos:m,text:h,block:!1})}u=f};for(let[f,p]of[...i,[r.length,o.length]]){for(;c<f;c+=1){if(!r[c].trim())continue;let h=s[c];vi(n,a(h),a(h+r[c].length-1)+1)}d(p,f),c=f+1,u=p+1}}function Sk(n,e,t){return e?t>=e.depth?e.pos:n.resolve(e.pos).before(t+1):n.content.size}function Zh(n,e){let t={added:[],removed:[]},r=Xh(n),o=Xh(e),s=Qh(r,o,(c,u)=>c.type===u.type&&c.text===u.text)??[],l=0,a=0;for(let[c,u]of[...s,[r.length,o.length]]){let d=r.slice(l,c),f=o.slice(a,u),p=Math.min(d.length,f.length);for(let h=0;h<p;h+=1)xk(t,d[h],f[h]);for(let h of d.slice(p))h.text&&vi(t,h.chars[0],h.end);for(let h of f.slice(p))h.text.trim()&&t.removed.push({pos:Sk(n,r[c],h.depth),text:h.text,block:!0});l=c+1,a=u+1}return t}var Yh,em=P(()=>{"use strict";Yh=n=>n.split(/(\s+)/).filter(Boolean)});var rm={};He(rm,{default:()=>Ak});function Ck(n,e){let t=typeof e=="string"?e:Mk.serializeFragment(De.fromJSON(n.schema,e).content);return yi(n.schema,t)}function Ek(n,e){let t=V(n,nm),r=n.options.language??"en",o=new Intl.DateTimeFormat(r,{dateStyle:"medium",timeStyle:"short"}),i=Ce("nova-history-title"),s=[],l=null,a=null,c=!0,u=null,d=0,f=v("ol",{className:"nova-history-list","aria-label":t.versions}),p=v("div",{className:"nova-history-preview"}),h=v("p",{className:"nova-history-status",role:"status"}),m=v("button",{type:"button",className:"nova-button nova-button-primary",disabled:!0},t.restore),g=v("input",{type:"checkbox",checked:!0}),b=v("div",{className:"nova-history-legend"},v("label",{className:"nova-history-toggle"},g,t.highlight),v("span",{className:"nova-history-swatch is-added"},t.onlyHere),v("span",{className:"nova-history-swatch is-removed"},t.onlyNow)),x=e.save?v("button",{type:"button",className:"nova-button"},t.save):null,w=v("button",{type:"button",className:"nova-button"},t.close),E=v("section",{className:"nova-history",role:"region","aria-labelledby":i},v("header",{className:"nova-history-head"},v("h2",{id:i,className:"nova-history-title"},t.title),b,v("span",{className:"nova-history-spacer"}),x,m,w),v("div",{className:"nova-history-body"},p,v("aside",{className:"nova-history-side"},h,f))),D=I=>{if(!c||!l)return Y.empty;let{added:R,removed:z}=Zh(I,n.view.state.doc),te=[...R.map(fe=>re.inline(fe.from,fe.to,{class:"nova-diff-added"})),...z.map(fe=>re.widget(fe.pos,()=>v(fe.block?"div":"span",{className:"nova-diff-removed"},fe.text),{side:-1,ignoreSelection:!0}))];return Y.create(I,te)},C=I=>{a=I;let R=yn.create({doc:I}),z=D(I);if(u){u.setProps({state:R,decorations:()=>z});return}u=new Qt(p,{state:R,editable:()=>!1,decorations:()=>z,attributes:{class:"nova-prosemirror nova-history-doc","aria-label":t.title,"aria-readonly":"true"}})},N=()=>{let I=[{revision:null,title:t.current,detail:""},...[...s].sort((R,z)=>z.createdAt-R.createdAt).map(R=>({revision:R,title:o.format(R.createdAt),detail:(R.authors??[]).join(", "),...R.label?{label:R.label}:{}}))];f.replaceChildren(...I.map(R=>{let z=R.revision?.id===l?.id&&!!R.revision==!!l,te=v("button",{type:"button",className:"nova-history-item","aria-current":z?"true":null,tabindex:z?"0":"-1","data-revision":R.revision?.id??"current"},v("span",{className:"nova-history-time"},R.title),R.label?v("span",{className:"nova-history-label"},R.label):null,R.detail?v("span",{className:"nova-history-authors"},R.detail):null);return te.addEventListener("click",()=>{y(R.revision),S()}),v("li",{},te)}))};function S(){f.querySelector('.nova-history-item[aria-current="true"]')?.focus()}async function y(I){l=I,N(),m.disabled=!0;let R=++d;if(!I){C(n.view.state.doc);return}h.textContent=t.loading;try{let z=await e.load(I,n);if(R!==d)return;C(Ck(n,z)),h.textContent="",m.disabled=!n.isEditable()}catch{R===d&&(h.textContent=t.failed)}}async function k(){h.textContent=t.loading;try{s=(await e.list()).filter(I=>I&&typeof I.id=="string"),h.textContent=s.length?"":t.empty,N()}catch{h.replaceChildren(t.failed," ",v("button",{type:"button",className:"nova-link-btn",onClick:()=>{k()}},t.retry))}}function T(){u?.destroy(),E.remove(),n.root.classList.remove("nova-history-open"),n.focus()}return m.addEventListener("click",()=>{if(!l||!a)return;let I=l,{state:R}=n.view;n.view.dispatch(nf(R.tr.replaceWith(0,R.doc.content.size,a.content))),e.onRestore?.(I),n.ui.notify({text:t.restored.replace("{date}",o.format(I.createdAt)),type:"success"}),T()}),x?.addEventListener("click",async()=>{x.disabled=!0;try{await e.save(),n.ui.notify({text:t.saved,type:"success"}),await k(),S()}finally{x.disabled=!1}}),w.addEventListener("click",T),g.addEventListener("change",()=>{c=g.checked,a&&C(a)}),E.addEventListener("keydown",I=>{if(I.key==="Escape"){I.preventDefault(),T();return}let R=I.target;if(!R.classList.contains("nova-history-item")||I.key!=="ArrowDown"&&I.key!=="ArrowUp")return;I.preventDefault();let z=[...f.querySelectorAll(".nova-history-item")],te=z[z.indexOf(R)+(I.key==="ArrowDown"?1:-1)];te?.click(),f.querySelector(`[data-revision="${te?.dataset.revision}"]`)?.focus()}),n.ui.closeOverlays(),n.root.classList.add("nova-history-open"),n.root.append(E),y(null),k().then(()=>{f.querySelector(".nova-history-item")?.focus()}),{close:T,element:E}}var nm,tm,Mk,Ak,om=P(()=>{"use strict";j();de();Vo();K();Rt();Vl();ai();Z();em();ke();nm={en:{button:"Version history",title:"Version history",current:"Current version",restore:"Restore this version",close:"Close",save:"Save version",saved:"Version saved",highlight:"Highlight changes",onlyHere:"Only in this version",onlyNow:"Only in the current text",loading:"Loading\u2026",failed:"Could not load the version history.",retry:"Try again",empty:"No saved versions yet.",restored:"Restored the version from {date}. Undo with Ctrl+Z.",versions:"Versions"},ru:{button:"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439",title:"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439",current:"\u0422\u0435\u043A\u0443\u0449\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F",restore:"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u044D\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044E",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C",save:"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E",saved:"\u0412\u0435\u0440\u0441\u0438\u044F \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0430",highlight:"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F",onlyHere:"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u044D\u0442\u043E\u0439 \u0432\u0435\u0440\u0441\u0438\u0438",onlyNow:"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u0442\u0435\u043A\u0441\u0442\u0435",loading:"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026",failed:"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0441\u0442\u043E\u0440\u0438\u044E \u0432\u0435\u0440\u0441\u0438\u0439.",retry:"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",empty:"\u0421\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442.",restored:"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u0432\u0435\u0440\u0441\u0438\u044F \u043E\u0442 {date}. \u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u2014 Ctrl+Z.",versions:"\u0412\u0435\u0440\u0441\u0438\u0438"}},tm=M.history,Mk=new yt;Ak={name:"revisionhistory",toolbar:"revisionhistory",setup(n){let e=n.options.pluginOptions?.revisionhistory;if(!e?.list||!e.load){console.warn("[nova] revisionhistory: set pluginOptions.revisionhistory.list and .load");return}let t=V(n,nm),r=null,o=()=>{r?.element.isConnected||(r=Ek(n,e))};return n.ui.registry.addButton("revisionhistory",{icon:tm,tooltip:t.button,onAction:o}),n.ui.registry.addMenuItem("revisionhistory",{text:t.button,icon:tm,onAction:o}),()=>r?.close()}}});Hr();j();K();At();Z();ke();var nc=M.anchor,lg={en:{title:"Anchor",id:"ID",hint:"Letters, digits, \u201C-\u201D, \u201C_\u201D, \u201C.\u201D; must start with a letter. Link to it with #ID.",invalid:"Use letters, digits, \u201C-\u201D, \u201C_\u201D or \u201C.\u201D, starting with a letter",save:"Save"},ru:{title:"\u042F\u043A\u043E\u0440\u044C",id:"\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440",hint:"\u041B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB, \xAB.\xBB; \u043D\u0430\u0447\u0438\u043D\u0430\u0435\u0442\u0441\u044F \u0441 \u0431\u0443\u043A\u0432\u044B. \u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u044F\u043A\u043E\u0440\u044C \u2014 #\u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440.",invalid:"\u0422\u043E\u043B\u044C\u043A\u043E \u043B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB \u0438\u043B\u0438 \xAB.\xBB, \u043F\u0435\u0440\u0432\u0430\u044F \u2014 \u0431\u0443\u043A\u0432\u0430",save:"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C"}},to=/^[A-Za-z][\w.-]{0,63}$/,rc={name:"anchor",toolbar:"anchor",nodes:{anchor:{group:"inline",inline:!0,atom:!0,selectable:!0,attrs:{id:{}},parseDOM:[{tag:"a[id]:not([href])",getAttrs:n=>{let e=n.getAttribute("id")??"";return to.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return to.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:to.test(n.attrs.id)?n.attrs.id:null}]}},setup(n){let e=V(n,lg),t=()=>{let{selection:o}=n.view.state;return o instanceof B&&o.node.type.name==="anchor"?o:null},r=()=>{let o=t(),i=ce({label:e.id,hint:e.hint,value:o?.node.attrs.id??""});n.ui.openDialog({title:e.title,body:v("div",{className:"nova-form"},i.el),submitLabel:e.save,onSubmit:()=>{let s=i.input.value.trim();if(!to.test(s))return e.invalid;let{state:l,dispatch:a}=n.view,c=n.schema.nodes.anchor,u=t();return a(u?l.tr.setNodeMarkup(u.from,void 0,{id:s}):l.tr.replaceSelectionWith(c.create({id:s}),!1).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("anchor",{icon:nc,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("anchor",{text:e.title,icon:nc,onAction:r})}};j();K();Rt();pt();Su();ke();var $b={en:{list:"People",empty:"No matches"},ru:{list:"\u041B\u044E\u0434\u0438",empty:"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E"}},Es=/^[\w.@:+-]{1,128}$/,_b=80,yo=n=>n.replace(/^@/,"").trim().slice(0,_b);async function As(n,e,t=8){let r=await n(e);return Array.isArray(r)?r.filter(o=>o&&typeof o.id=="string"&&Es.test(o.id)&&o.name).slice(0,t).map(o=>({id:o.id,name:yo(String(o.name)),...o.description?{description:String(o.description).slice(0,120)}:{}})):[]}var Mu={name:"mentions",nodes:{mention:{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{id:{},name:{default:""}},parseDOM:[{tag:"span[data-mention]",getAttrs:n=>{let e=n,t=e.getAttribute("data-mention")??"";return Es.test(t)?{id:t,name:yo(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":Es.test(n.attrs.id)?n.attrs.id:null},`@${yo(String(n.attrs.name))}`],leafText:n=>`@${yo(String(n.attrs.name))}`}},setup(n){let e=n.options.pluginOptions?.mentions;if(!e?.fetch){console.warn("[nova] mentions: set pluginOptions.mentions.fetch to search people");return}let t=V(n,$b),r=e.maxResults??8,o=new Map;n.ui.registry.addAutocompleter("mentions",{trigger:"@",label:t.list,emptyText:t.empty,maxResults:r,fetch:async i=>{let s=await As(e.fetch,i,r);return o=new Map(s.map(l=>[l.id,l])),s.map(l=>({value:l.id,label:l.name,...l.description?{detail:l.description}:{}}))},onSelect:(i,s,l)=>{let a=o.get(i.value)??{id:i.value,name:i.label},{state:c,dispatch:u}=l.view,d=l.schema.nodes.mention.create({id:a.id,name:a.name});u(c.tr.replaceWith(s.from,s.to,[d,c.schema.text(" ")]).scrollIntoView()),e.onMention?.(a,l)}})}};ke();var jb={en:{add:"Add comment",show:"Comments",panel:"Comments",guest:"Guest",newComment:"New comment",placeholder:"Add a comment\u2026",replyPlaceholder:"Reply\u2026",comment:"Comment",reply:"Reply",cancel:"Cancel",save:"Save",edit:"Edit",remove:"Delete",resolve:"Resolve",reopen:"Reopen",deleteThread:"Delete thread",close:"Close comments",showResolved:"Show resolved",resolvedBy:"Resolved by {name}",orphan:"The commented text was deleted",empty:"No comments yet. Select text and press \u201CAdd comment\u201D ({shortcut}).",people:"People",noPeople:"No matches",edited:"edited",you:"you",count:"{count} comments"},ru:{add:"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",show:"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438",panel:"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438",guest:"\u0413\u043E\u0441\u0442\u044C",newComment:"\u041D\u043E\u0432\u044B\u0439 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439",placeholder:"\u041D\u0430\u043F\u0438\u0448\u0438\u0442\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\u2026",replyPlaceholder:"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C\u2026",comment:"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C",reply:"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C",cancel:"\u041E\u0442\u043C\u0435\u043D\u0430",save:"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C",edit:"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C",remove:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C",resolve:"\u0420\u0435\u0448\u0435\u043D\u043E",reopen:"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u043D\u043E\u0432\u0430",deleteThread:"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0435",close:"\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438",showResolved:"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0440\u0435\u0448\u0451\u043D\u043D\u044B\u0435",resolvedBy:"\u0420\u0435\u0448\u0435\u043D\u043E: {name}",orphan:"\u041F\u0440\u043E\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442 \u0443\u0434\u0430\u043B\u0451\u043D",empty:"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442. \u0412\u044B\u0434\u0435\u043B\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \xAB\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\xBB ({shortcut}).",people:"\u041B\u044E\u0434\u0438",noPeople:"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",edited:"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u043E",you:"\u0432\u044B",count:"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432: {count}"}},Tu=M.commentAdd,Nu=M.comments,vo="Mod-Alt-m",ht=new J("nova-comments"),Ls=new WeakMap;function Ns(n){return Ls.get(n)}function Lu(n){let e=new Map;return n.descendants((t,r)=>{if(t.isInline)for(let o of t.marks){if(o.type.name!=="comment")continue;let i=o.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===r?l.to=r+t.nodeSize:s.push({from:r,to:r+t.nodeSize}),e.set(i,s)}}),e}function Kb(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(o=>o.type.name==="comment").map(o=>o.attrs.id)}var Ou={name:"comments",toolbar:"addcomment showcomments",marks:{comment:{attrs:{id:{}},inclusive:!1,excludes:"",parseDOM:[{tag:"span[data-comment]",getAttrs:n=>{let e=n.getAttribute("data-comment")??"";return hr.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":hr.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Fe({[vo]:()=>Ns(n)?.startComment()??!1}),new _({key:ht,state:{init:()=>({pending:null,active:null}),apply(t,r){let o=t.getMeta(ht),i=r;if(t.docChanged&&i.pending){let s=t.mapping.map(i.pending.from,1),l=t.mapping.map(i.pending.to,-1);i={...i,pending:s<l?{from:s,to:l}:null}}return o&&("pending"in o||"active"in o)&&(i={...i,...o}),i}},props:{decorations(t){let r=Ns(n),o=ht.getState(t),i=r?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===o)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of Lu(t.doc)){if(!s.has(c))continue;let d=c===o.active?"nova-comment is-active":"nova-comment";for(let{from:f,to:p}of u)l.push(re.inline(f,p,{class:d}))}if(o.pending){let{from:c,to:u}=o.pending;l.push(re.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=Y.create(t.doc,l);return e={doc:t.doc,threads:i,state:o,set:a},a}},view:()=>({update(t,r){if(r.selection.eq(t.state.selection)||r.doc!==t.state.doc)return;let o=Ns(n);if(!o||ht.getState(t.state).pending)return;let i=new Set(o.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=Kb(t.state).find(l=>i.has(l));s&&(s!==o.active()||!o.isPanelOpen())&&queueMicrotask(()=>{o.setActive(s),o.openPanel()})}})})]},setup(n){let e=V(n,jb),t=n.options.pluginOptions?.comments??{},r=t.store??xu(t.threads??[],t.onChange),o={id:String(t.author?.id??"guest").slice(0,128),name:String(t.author?.name||e.guest).slice(0,80)},i=()=>n.schema.marks.comment,s=t.mentions??n.options.pluginOptions?.mentions?.fetch,l=(C,N=[])=>[...new Map(N.map(y=>[y.id,y])).values()].filter(y=>C.includes(`@${y.name}`)),a=(C,N)=>{let S=l(C,N);return{id:Cs(),author:o,text:C,createdAt:Date.now(),...S.length?{mentions:S}:{}}},c=(C,N)=>{N.mentions?.length&&t.onMention?.({threadId:C,comment:N,users:N.mentions})},u=()=>ht.getState(n.view.state),d=C=>n.view.dispatch(n.view.state.tr.setMeta(ht,C)),f=null,p=!1,h=null,m=n.view.dom.parentElement,g=document.createElement("div");g.className="nova-body",m.parentElement.insertBefore(g,m),g.append(m);let b={editor:n,store:r,author:o,labels:e,shortcut:vo,pending:()=>u().pending,active:()=>u().active,setActive(C,N=!1){u().active!==C&&d({active:C}),f?.render();let S=C?b.ranges(C)[0]:void 0;if(N&&S){let{node:y}=n.view.domAtPos(S.from);(y instanceof Element?y:y.parentElement)?.scrollIntoView({block:"nearest"})}},startComment(){let{selection:C}=n.view.state;return C.empty||!n.isEditable()?!1:(d({pending:{from:C.from,to:C.to},active:null}),b.openPanel().then(()=>{f?.render(),f?.focusComposer()}),!0)},cancelPending(){d({pending:null}),f?.render(),n.focus()},findUsers:s?C=>As(s,C):null,submitPending(C,N){let S=u().pending,y=C.trim().slice(0,5e3);if(!S||!y)return null;let k=Cs("t"),T=a(y,N);r.createThread({id:k,createdAt:T.createdAt,comments:[T],resolved:null});let{state:I}=n.view;return n.view.dispatch(I.tr.addMark(S.from,S.to,i().create({id:k})).setMeta(ht,{pending:null,active:k}).setMeta("addToHistory",!1)),f?.render(),c(k,T),k},reply(C,N,S){let y=N.trim().slice(0,5e3);if(!y)return;let k=a(y,S);r.reply(C,k),c(C,k)},ranges:C=>Lu(n.view.state.doc).get(C)??[],quote(C){let{doc:N}=n.view.state;return b.ranges(C).map(({from:S,to:y})=>N.textBetween(S,y," ")).join(" \u2026 ")},positionOf:C=>b.ranges(C)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(C){let{state:N}=n.view,S=N.tr;for(let{from:y,to:k}of b.ranges(C))S.removeMark(y,k,i().create({id:C}));u().active===C&&S.setMeta(ht,{active:null}),(S.docChanged||S.getMeta(ht))&&n.view.dispatch(S.setMeta("addToHistory",!1)),r.deleteThread(C)},setResolved(C,N){r.setResolved(C,N?{by:o,at:Date.now()}:null),N&&u().active===C&&d({active:null})},canEdit:C=>t.canEdit?t.canEdit(C,o):C.author.id===o.id,isPanelOpen:()=>p,async openPanel(){f||(h??=Promise.resolve().then(()=>(Au(),Eu)).then(({createCommentsPanel:C})=>{n.view.isDestroyed||(f=C(b),g.append(f.el))}),await h),!(!f||p)&&(n.ui.closeOverlays(),p=!0,f.el.hidden=!1,n.root.classList.add("nova-comments-open"),f.render(),n.updateUI())},closePanel(){!f||!p||(p=!1,f.el.hidden=!0,n.root.classList.remove("nova-comments-open"),u().pending&&d({pending:null}),n.updateUI(),n.focus())}};Ls.set(n,b);let x=r.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),f?.render())}),w=()=>b.startComment(),E=()=>b.isPanelOpen()?b.closePanel():void b.openPanel(),D=C=>C.isEditable()&&!C.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:Tu,tooltip:e.add,shortcut:vo,isEnabled:D,onAction:w}),n.ui.registry.addToggleButton("showcomments",{icon:Nu,tooltip:e.show,isActive:()=>p,onAction:E}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:Tu,shortcut:vo,isEnabled:D,onAction:w}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:Nu,isActive:()=>p,onAction:E}),()=>{x(),f?.destroy(),Ls.delete(n)}}};K();j();ke();var Du={en:{insert:"Insert variable",search:"Variables",empty:"No variables found",unknown:"Unknown variable"},ru:{insert:"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0443\u044E",search:"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435",empty:"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B",unknown:"\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F"}},Ru=/^[\w.:-]{1,100}$/,Jb=/^data-[a-z0-9-]{1,40}$/;function wo(n){return n.options.pluginOptions?.mergetags??{}}function Gb(n){let e=wo(n).attribute??"data-mergetag";return Jb.test(e)?e:(console.warn(`[nova] mergetags: attribute "${e}" must look like data-name; using data-mergetag`),"data-mergetag")}var Iu=n=>Array.isArray(n.items);function ko(n){return(wo(n).list??[]).flatMap(e=>Iu(e)?e.items:[e])}function Bu(n,e){return ko(n).find(t=>t.key===e)?.label}function Xb(n){let e=Gb(n);return{mergetag:{group:"inline",inline:!0,atom:!0,selectable:!0,draggable:!0,ignoreStyles:!0,attrs:{key:{},label:{default:""}},parseDOM:[{tag:`span[${e}]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute(e)??"";return Ru.test(o)?{key:o,label:Bu(n,o)??r.textContent?.trim()??o}:!1}}],toDOM:t=>{let r=Ru.test(t.attrs.key)?t.attrs.key:"",o=t.attrs.label||r;return["span",{[e]:r,contenteditable:"false"},o]}}}}var Os=class{constructor(e,t,r){this.node=e;this.editor=t;this.unknownTitle=r;this.dom=document.createElement("span"),this.dom.className="nova-mergetag",this.dom.contentEditable="false",this.render()}node;editor;unknownTitle;dom;render(){let e=this.node.attrs.key,t=Bu(this.editor,e);this.dom.textContent=t??(this.node.attrs.label||e),this.dom.dataset.key=e;let o=!!wo(this.editor).list?.length&&t===void 0;this.dom.classList.toggle("is-unknown",o),this.dom.title=o?`${this.unknownTitle}: ${e}`:e}update(e){return e.type!==this.node.type?!1:(this.node=e,this.render(),!0)}selectNode(){this.dom.classList.add("is-selected")}deselectNode(){this.dom.classList.remove("is-selected")}stopEvent(){return!1}ignoreMutation(){return!0}};function Pu(n,e,t){let{state:r,dispatch:o}=n.view,i=n.schema.nodes.mergetag.create({key:e.key,label:e.label}),s=t?r.tr.replaceWith(t.from,t.to,i):r.tr.replaceSelectionWith(i,!1);o(s.scrollIntoView()),n.focus()}var Hu={name:"mergetags",toolbar:"mergetags",nodes:Xb,prosemirrorPlugins:n=>{let e=V(n,Du);return[new _({props:{nodeViews:{mergetag:(t,r)=>new Os(t,n,e.unknown)}}})]},setup(n){let e=V(n,Du);n.ui.registry.addMenuButton("mergetags",{icon:M.mergeTags,tooltip:e.insert,isEnabled:t=>t.isEditable()&&ko(t).length>0,items:t=>{let r=[],o=(i,s)=>({id:s,label:i.label,onSelect:()=>Pu(t,i)});return(wo(t).list??[]).forEach((i,s)=>{Iu(i)?(r.length&&r.push({type:"separator"}),r.push({type:"heading",label:i.title}),i.items.forEach((l,a)=>r.push(o(l,`mergetag-${s}-${a}`)))):r.push(o(i,`mergetag-${s}`))}),r}}),n.ui.registry.addAutocompleter("mergetags",{trigger:"{{",label:e.search,emptyText:e.empty,maxResults:12,fetch:(t,r)=>{let o=t.toLowerCase();return ko(r).filter(i=>i.label.toLowerCase().includes(o)||i.key.toLowerCase().includes(o)).map(i=>({value:i.key,label:i.label,detail:i.key}))},onSelect:(t,r,o)=>{let i=ko(o).find(s=>s.key===t.value);i&&Pu(o,i,r)}})}};j();de();K();Ye();Rt();pt();ke();var zu=/^[A-Za-z0-9_-]{1,64}$/,Bs=/^[\w.@:+-]{1,128}$/,Ds={en:{toggle:"Suggest edits",review:"Review suggestions",accept:"Accept",reject:"Reject",acceptAll:"Accept all suggestions",rejectAll:"Reject all suggestions",next:"Next suggestion",previous:"Previous suggestion",inserted:"Inserted by {name}",deleted:"Deleted by {name}",toolbar:"Suggestion",guest:"Guest",none:"No suggestions"},ru:{toggle:"\u041F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0442\u044C \u043F\u0440\u0430\u0432\u043A\u0438",review:"\u041F\u0440\u0430\u0432\u043A\u0438",accept:"\u041F\u0440\u0438\u043D\u044F\u0442\u044C",reject:"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C",acceptAll:"\u041F\u0440\u0438\u043D\u044F\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438",rejectAll:"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438",next:"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430",previous:"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430",inserted:"\u0412\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E: {name}",deleted:"\u0423\u0434\u0430\u043B\u0435\u043D\u043E: {name}",toolbar:"\u041F\u0440\u0430\u0432\u043A\u0430",guest:"\u0413\u043E\u0441\u0442\u044C",none:"\u041F\u0440\u0430\u0432\u043E\u043A \u043D\u0435\u0442"}},Fu=M.suggest,Yb=M.review,Qb=M.check,Zb=M.close,mr=new J("nova-suggestions"),Hs="nova-suggestions-own",$u=["#1a7f37","#8250df","#bf3989","#0969da","#bc4c00","#1b7c83"];function ey(n){let e=0;for(let t of n)e=e*31+t.charCodeAt(0)|0;return $u[Math.abs(e)%$u.length]}function _u(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function Vu(n){let e=n==="insert"?"ins":"del";return{attrs:{id:{},author:{default:""},name:{default:""},time:{default:0}},inclusive:!1,excludes:"",parseDOM:[{tag:`${e}[data-suggestion]`,priority:60,getAttrs:t=>{let r=t,o=r.getAttribute("data-suggestion")??"";if(!zu.test(o))return!1;let i=r.getAttribute("data-author")??"";return{id:o,author:Bs.test(i)?i:"",name:(r.getAttribute("data-name")??"").slice(0,80),time:Number(r.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":zu.test(t.attrs.id)?t.attrs.id:null,"data-author":Bs.test(t.attrs.author)?t.attrs.author:null,"data-name":String(t.attrs.name??"").slice(0,80)||null,"data-time":Number(t.attrs.time)||null},0]}}var zs=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete});function ty(n){return!n.docChanged||n.getMeta(Hs)||n.getMeta("addToHistory")===!1||n.getMeta("history$")||n.getMeta("y-sync$")?.isChangeOrigin?!1:n.steps.every(t=>t instanceof ve)}function Rs(n,e,t,r){let o=n.resolve(e);for(let i of[o.nodeBefore,o.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===r);if(s)return s}return null}function Wu(n,e,t){let r=[];return n.forEach(o=>{o.isInline?r.push(t&&!t.allowsMarkType(e.type)?o:o.mark(e.addToSet(o.marks))):r.push(o.copy(Wu(o.content,e,o.type)))}),A.from(r)}function ny(n,e,t){if(!ty(n))return n;let r=zs(e.schema),o=e.tr,i=Date.now(),s=c=>c,l=null,a=null;if(n.steps.forEach(c=>{let u=c,d=o.steps.length,f=s,p=f(u.from),h=Math.max(p,f(u.to));if(h>p){let b=[],x=[];if(o.doc.nodesBetween(p,h,(D,C)=>{if(!D.isInline)return!0;let N=Math.max(C,p),S=Math.min(C+D.nodeSize,h);return N>=S||(D.marks.some(k=>k.type===r.insert&&k.attrs.author===t.id)?b.push({from:N,to:S}):r.delete.isInSet(D.marks)||x.push({from:N,to:S})),!1}),x.length){let D=x[0],C=Rs(o.doc,D.from,r.delete,t.id)??Rs(o.doc,x[x.length-1].to,r.delete,t.id)??r.delete.create({id:_u(),author:t.id,name:t.name,time:i});for(let N of x)o.addMark(N.from,N.to,C)}for(let D of b.reverse())o.delete(D.from,D.to);let w=o.mapping.slice(d);p=w.map(p,1),h=w.map(h,-1);let E=e.selection;n.steps.length===1&&u.slice.size===0&&E.empty&&E.from===u.from&&n.selection.head===u.from&&(l=h)}if(u.slice.size>0){let b=h;if(!u.slice.openStart)for(let D=o.doc.resolve(b).nodeAfter;D&&r.delete.isInSet(D.marks);)b+=D.nodeSize,D=o.doc.resolve(b).nodeAfter;let x=Rs(o.doc,b,r.insert,t.id)??r.insert.create({id:_u(),author:t.id,name:t.name,time:i}),w=o.doc.resolve(b),E=Wu(u.slice.content,x,u.slice.openStart?null:w.parent.type);o.replace(b,b,new O(E,u.slice.openStart,u.slice.openEnd)),n.steps.length===1&&(a=b+u.slice.size)}let m=u.getMap().invert(),g=o.mapping.slice(d);s=b=>g.map(f(m.map(b,-1)),1)}),l!==null)o.setSelection(H.create(o.doc,l));else if(a!==null&&n.selection.empty)o.setSelection(H.create(o.doc,a));else{let c=s(n.selection.anchor),u=s(n.selection.head);try{o.setSelection(H.create(o.doc,c,u))}catch{}}for(let c of["addToHistory","uiEvent","paste","scrollIntoView"]){let u=n.getMeta(c);u!==void 0&&o.setMeta(c,u)}return n.scrolledIntoView&&o.scrollIntoView(),o}function gr(n){let e=zs(n.type.schema),t=[];return n.descendants((r,o)=>{if(!r.isInline)return!0;for(let i of r.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":null;if(!s)continue;let l=t[t.length-1],a=r.isText?r.text:"";l&&l.id===i.attrs.id&&l.kind===s&&l.to===o?(l.to=o+r.nodeSize,l.text+=a):t.push({id:i.attrs.id,kind:s,author:{id:i.attrs.author,name:i.attrs.name},time:Number(i.attrs.time)||0,from:o,to:o+r.nodeSize,text:a})}return!1}),t}function Ps(n,e,t){let r=zs(n.schema),o=n.tr.setMeta(Hs,!0),i=gr(n.doc).filter(s=>!t||t.includes(s.id));for(let s of[...i].sort((l,a)=>a.from-l.from))s.kind==="insert"==(e==="reject")?o.delete(s.from,s.to):o.removeMark(s.from,s.to,s.kind==="insert"?r.insert:r.delete);return o}function qu(n){let{from:e}=n.selection;return gr(n.doc).find(t=>e>=t.from&&e<=t.to&&(t.to>e||t.from<e))??null}function Tn(n){return mr.getState(n)?.enabled??!1}function Is(n,e){let{state:t,dispatch:r}=n.view;r(t.tr.setMeta(mr,{enabled:e}).setMeta(Hs,!0)),n.updateUI()}var Uu={name:"suggestions",toolbar:"suggestions reviewsuggestions",marks:{suggestion_insert:Vu("insert"),suggestion_delete:Vu("delete")},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new _({key:mr,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(r,o){let i=r.getMeta(mr);return i?{enabled:e.force?!0:i.enabled}:o}},props:{attributes:r=>mr.getState(r)?.enabled?{class:"nova-suggesting"}:{},decorations(r){if(t?.doc===r.doc)return t.set;let o=V(n,Ds),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=Y.create(r.doc,gr(r.doc).map(l=>re.inline(l.from,l.to,{title:(l.kind==="insert"?o.inserted:o.deleted).replace("{name}",l.author.name||o.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.kind==="insert"?"nova-sugg-insert":"nova-sugg-delete",style:`--nova-suggestion: ${ey(l.author.id||l.author.name)}`})));return t={doc:r.doc,set:s},s}}}),Fe({"Mod-Alt-Shift-e":()=>e.force?!1:(Is(n,!Tn(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!Tn(e))return n;let r=t.options.pluginOptions?.suggestions??{},o=V(t,Ds),i={id:Bs.test(r.author?.id??"")?r.author.id:"guest",name:String(r.author?.name||o.guest).slice(0,80)};return ny(n,e,i)},setup(n){let e=n.options.pluginOptions?.suggestions??{},t=V(n,Ds),r=e.canReview!==!1,o=c=>n.view.dispatch(c),i=()=>qu(n.view.state),s=c=>{let u=i();u&&o(Ps(n.view.state,c,[u.id])),n.focus()},l=c=>{let{state:u}=n.view,d=gr(u.doc),f=u.selection.from,p=c===1?d.find(h=>h.from>f)??d[0]:[...d].reverse().find(h=>h.to<f)??d[d.length-1];if(!p){n.ui.notify(t.none);return}o(u.tr.setSelection(H.create(u.doc,p.from)).scrollIntoView()),n.focus()},a=()=>gr(n.view.state.doc).length>0;n.ui.registry.addToggleButton("suggestions",{icon:Fu,tooltip:t.toggle,shortcut:"Mod-Alt-Shift-e",isActive:c=>Tn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Is(c,!Tn(c.view.state))}),n.ui.registry.addMenuButton("reviewsuggestions",{icon:Yb,tooltip:t.review,isEnabled:a,items:()=>[{id:"next",label:t.next,onSelect:()=>l(1)},{id:"previous",label:t.previous,onSelect:()=>l(-1)},...r?[{type:"separator"},{id:"accept-all",label:t.acceptAll,onSelect:()=>o(Ps(n.view.state,"accept"))},{id:"reject-all",label:t.rejectAll,onSelect:()=>o(Ps(n.view.state,"reject"))}]:[]]}),r&&(n.ui.registry.addButton("acceptsuggestion",{icon:Qb,text:t.accept,tooltip:t.accept,onAction:()=>s("accept")}),n.ui.registry.addButton("rejectsuggestion",{icon:Zb,text:t.reject,tooltip:t.reject,onAction:()=>s("reject")}),n.ui.registry.addContextToolbar("suggestion",{label:t.toolbar,predicate:c=>qu(c.view.state)!==null,items:"acceptsuggestion rejectsuggestion",position:"selection",placement:"bottom-start",priority:20})),n.ui.registry.addMenuItem("suggestions",{text:t.toggle,icon:Fu,isActive:c=>Tn(c.view.state),isEnabled:()=>!e.force,onAction:c=>Is(c,!Tn(c.view.state))})}};j();xo();K();et();At();Z();ke();var sv=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,lv=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,av=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function Io(n){let e=n.trim(),t=e.match(sv);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let r=e.match(lv);return r?{kind:"vimeo",src:`https://player.vimeo.com/video/${r[1]}`}:av.test(e)?{kind:"video",src:e}:null}var Pd=M.media,cv={en:{title:"Video",url:"Video URL",hint:"YouTube, Vimeo or a link to an .mp4 / .webm file",name:"Title (for screen readers)",invalid:"This video address is not supported",save:"Insert"},ru:{title:"\u0412\u0438\u0434\u0435\u043E",url:"\u0410\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E",hint:"YouTube, Vimeo \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0444\u0430\u0439\u043B .mp4 / .webm",name:"\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 (\u0434\u043B\u044F \u044D\u043A\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0434\u0438\u043A\u0442\u043E\u0440\u0430)",invalid:"\u042D\u0442\u043E\u0442 \u0430\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F",save:"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C"}};function Id(n,e){let t=e?Io(e):null;return t?{...t,width:Ie(n.getAttribute("width"))??560,height:Ie(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function uv(n){let e=Io(n.attrs.src);if(!e)return null;let t=String(Ie(n.attrs.width)??560),r=String(Ie(n.attrs.height)??315);return e.kind==="video"?v("video",{src:e.src,controls:!0,width:t,height:r,preload:"metadata"}):v("iframe",{src:e.src,width:t,height:r,title:n.attrs.title||"Video",allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:!0,loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"})}var Bd={name:"media",toolbar:"media",nodes:{media:{group:"block",atom:!0,selectable:!0,draggable:!0,attrs:{kind:{default:"youtube"},src:{},width:{default:560},height:{default:315},title:{default:""}},parseDOM:[{tag:"iframe[src]",getAttrs:n=>Id(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Id(e,t)}}],toDOM:n=>{let e=Io(n.attrs.src),t=String(Ie(n.attrs.width)??560),r=String(Ie(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:r}]:["iframe",{src:e.src,width:t,height:r,title:n.attrs.title||null,allow:"accelerometer; encrypted-media; gyroscope; picture-in-picture; fullscreen",allowfullscreen:"",loading:"lazy",referrerpolicy:"strict-origin-when-cross-origin"}]:["p"]}}},prosemirrorPlugins:()=>[new _({props:{nodeViews:{media:n=>{let e=uv(n);return{dom:v("div",{className:"nova-media",contenteditable:"false"},e,v("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],setup(n){let e=V(n,cv),t=()=>{let{selection:o}=n.view.state;return o instanceof B&&o.node.type.name==="media"?o:null},r=()=>{let o=t(),i=ce({label:e.url,type:"url",placeholder:"https://",hint:e.hint,value:o?.node.attrs.src??""}),s=ce({label:e.name,value:o?.node.attrs.title??""});Nn(n,i,"media",l=>{l.title&&(s.input.value=l.title)}),n.ui.openDialog({title:e.title,body:v("div",{className:"nova-form"},i.el,s.el),submitLabel:e.save,onSubmit:()=>{let l=Io(i.input.value);if(!l)return e.invalid;let{state:a,dispatch:c}=n.view,u={...l,title:s.input.value.trim()},d=t();return c(d?a.tr.setNodeMarkup(d.from,void 0,{...d.node.attrs,...u}):a.tr.replaceSelectionWith(n.schema.nodes.media.create(u)).scrollIntoView()),!0}})};n.ui.registry.addToggleButton("media",{icon:Pd,tooltip:e.title,isActive:()=>t()!==null,isEnabled:o=>o.isEditable(),onAction:r}),n.ui.registry.addMenuItem("media",{text:e.title,icon:Pd,onAction:r})}};j();ke();var Hd=M.pageBreak,dv={en:{title:"Page break"},ru:{title:"\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B"}},zd={name:"pagebreak",toolbar:"pagebreak",nodes:{pagebreak:{group:"block",atom:!0,selectable:!0,parseDOM:[{tag:"div.nova-pagebreak"},{tag:"div",getAttrs:n=>{let e=n;return(e.style.breakAfter==="page"||e.style.pageBreakAfter==="always")&&!e.textContent?.trim()?null:!1}}],toDOM:()=>["div",{class:"nova-pagebreak",style:"break-after: page;"}]}},setup(n){let{title:e}=V(n,dv),t=()=>{let{state:r,dispatch:o}=n.view,i=n.schema.nodes.pagebreak;o(r.tr.replaceSelectionWith(i.create()).scrollIntoView()),n.focus()};n.ui.registry.addButton("pagebreak",{icon:Hd,tooltip:e,isEnabled:r=>r.isEditable(),onAction:t}),n.ui.registry.addMenuItem("pagebreak",{text:e,icon:Hd,onAction:t})}};se("insertdatetime",()=>Promise.resolve().then(()=>(qd(),Vd)));se("quickbars",()=>Promise.resolve().then(()=>(Hf(),Bf)));se("charmap",()=>Promise.resolve().then(()=>($f(),Ff)));se("emoticons",()=>Promise.resolve().then(()=>(Wf(),qf)));se("nonbreaking",()=>Promise.resolve().then(()=>(Jf(),Kf)));se("autolink",()=>Promise.resolve().then(()=>(tp(),ep)));se("autosave",()=>Promise.resolve().then(()=>(op(),rp)));se("autoresize",()=>Promise.resolve().then(()=>(sp(),ip)));se("visualblocks",()=>Promise.resolve().then(()=>(cp(),ap)));se("anchor",rc);se("pagebreak",zd);se("media",Bd);se("comments",Ou);se("mentions",Mu);se("mergetags",Hu);se("suggestions",Uu);se("directionality",()=>Promise.resolve().then(()=>(pp(),fp)));se("advlist",()=>Promise.resolve().then(()=>(mp(),hp)));se("revisionhistory",()=>Promise.resolve().then(()=>(om(),rm)));Vl();Il();Hr();j();ai();var Tk=new Set(["lists","link","image","table","code","codesample","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste","importcss","accordion"]),Nk={tinycomments:"comments"},Lk=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","valid_styles","toolbar_mode","toolbar_sticky","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name"]),ki=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function wi(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function Ok(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||=URL.createObjectURL(n),uri:()=>{}}}}var Dk=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Rk=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function xi(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&Dk.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&Rk.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function im(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:im(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=xi(t);return o?[{title:r,...o}]:[]}):[]}function sm(n){let e=Object.keys(n).filter(p=>!Lk.has(p)),t=[],r=[];for(let p of ki(n.plugins)){let h=Nk[p]??p;Tk.has(p)||(Ti(h)?t.push(h):r.push(p))}let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=p=>Array.isArray(p)?p.filter(h=>!!h&&typeof h.title=="string"&&typeof h.value=="string").map(({title:h,value:m})=>({title:h,value:m})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([p,h])=>[p,xi(h)]).filter(([,p])=>p.length))),Array.isArray(n.style_formats)&&(o.styleFormats=im(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=ki(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(p=>ki(p)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let p=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),h=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(m=>String(m).trim()).filter(m=>m&&!p.has(m));h.length&&(o.contentCss=h)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=wi(n.block_formats);if(a){let p=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:h,value:m})=>({label:h,block:m.toLowerCase()})).filter(h=>p.includes(h.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),n.toolbar_mode==="sliding"||n.toolbar_mode==="wrap"?o.toolbarMode=n.toolbar_mode:(n.toolbar_mode==="floating"||n.toolbar_mode==="scrolling")&&(o.toolbarMode="sliding"),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let p=n.paste_preprocess;o.pastePreprocess=(h,m)=>{let g={content:h};return p(m,g),g.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),n.valid_styles&&(o.validStyles=n.valid_styles);let c=wi(n.font_family_formats);c&&(o.fontFamilies=c);let u=wi(n.font_size_formats);u&&(o.fontSizes=u.map(p=>p.value));let d=wi(n.line_height_formats);if(d&&(o.lineHeights=d.map(p=>p.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((p,h)=>h%2===0).map(p=>p.startsWith("#")?p:`#${p}`)),typeof n.images_upload_handler=="function"){let p=n.images_upload_handler,h=async(m,g)=>{let{ready:b,info:x}=Ok(m);return await b,p(x,g)};o.uploadImage=h}if(typeof n.file_picker_callback=="function"){let p=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=ki(n.file_picker_types).filter(h=>h==="file"||h==="image"||h==="media")),o.filePicker=({type:h,value:m})=>new Promise(g=>p((b,x={})=>g({url:b,...x}),m,{filetype:h,fieldname:"src"}))}let f={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let p=h=>parseInt(String(h),10);f.autosave={...n.autosave_interval?{delay:p(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:p(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(f.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let p=n.mentions_fetch;f.mentions={fetch:h=>new Promise(m=>p({term:h},m))}}return n.tinycomments_author&&(f.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Object.keys(f).length&&(o.pluginOptions=f),{options:o,unknown:e,missingPlugins:r}}var Pk=0,lm=()=>`nova-compat-field-${++Pk}`;function ae(n,e,t){let r=document.createElement(n);return e&&(r.className=e),t!==void 0&&(r.textContent=t),r}function Ik(n){let e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach(t=>t.remove()),e.content.querySelectorAll("*").forEach(t=>{for(let r of[...t.attributes]){let o=r.value.trim().toLowerCase();(r.name.startsWith("on")||/^(javascript|vbscript|data):/.test(o))&&t.removeAttribute(r.name)}}),e.content}function am(n,e,t){let r=new Map,o=new Map,i="",s=!1,l=null,a=g=>e.onChange?.(m,{name:g});function c(g,b){let x=lm();b.id=x;let w=ae("div","nova-field");if(g.label){let E=ae("label","nova-label",g.label);E.htmlFor=x,w.append(E)}return w.append(b),w}function u(g){let b=g.name??"",x=g.enabled!==!1&&g.disabled!==!0;switch(g.type){case"input":case"urlinput":case"colorinput":{let w=ae("input","nova-input");return w.type=g.type==="colorinput"?"color":g.type==="urlinput"?"url":"text",g.inputMode&&(w.inputMode=g.inputMode),g.placeholder&&(w.placeholder=g.placeholder),w.disabled=!x,w.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>g.type==="urlinput"?{value:w.value}:w.value,set:E=>{w.value=String(g.type==="urlinput"&&E&&typeof E=="object"?E.value??"":E??"")},focus:()=>w.focus(),setEnabled:E=>w.disabled=!E}),c(g,w)}case"textarea":{let w=ae("textarea","nova-input");return w.rows=g.maximized?10:4,g.placeholder&&(w.placeholder=g.placeholder),w.disabled=!x,w.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>w.value,set:E=>w.value=String(E??""),focus:()=>w.focus(),setEnabled:E=>w.disabled=!E}),c(g,w)}case"checkbox":{let w=ae("input","nova-checkbox");w.type="checkbox",w.id=lm(),w.disabled=!x,w.addEventListener("change",()=>a(b));let E=ae("label",void 0,g.label??"");E.htmlFor=w.id,b&&r.set(b,{get:()=>w.checked,set:C=>w.checked=!!C,focus:()=>w.focus(),setEnabled:C=>w.disabled=!C});let D=ae("div","nova-field nova-field-inline");return D.append(w,E),D}case"selectbox":case"listbox":{let w=ae("select","nova-input nova-select");for(let E of g.items??[]){let D=ae("option",void 0,E.text);D.value=E.value,w.append(D)}return w.disabled=!x,w.addEventListener("change",()=>a(b)),b&&r.set(b,{get:()=>w.value,set:E=>w.value=String(E??""),focus:()=>w.focus(),setEnabled:E=>w.disabled=!E}),c(g,w)}case"button":{let w=ae("button",g.primary||g.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",g.text??"");return w.type="button",w.disabled=!x,w.addEventListener("click",()=>e.onAction?.(m,{name:b})),b&&r.set(b,{get:()=>{},set:()=>{},focus:()=>w.focus(),setEnabled:E=>w.disabled=!E}),w}case"htmlpanel":{let w=ae("div","nova-compat-html");return w.append(Ik(g.html??"")),w}case"alertbanner":{let w=ae("p",`nova-compat-alert is-${g.level??"info"}`,g.text??"");return w.setAttribute("role",g.level==="error"?"alert":"status"),w}case"label":{let w=ae("div","nova-compat-group");w.append(ae("p","nova-label",g.label??""));for(let E of g.items??[]){let D=u(E);D&&w.append(D)}return w}case"grid":case"bar":{let w=ae("div","nova-compat-grid"),E=g.type==="bar"?g.items?.length??1:g.columns==="auto"?2:g.columns??2;w.style.gridTemplateColumns=`repeat(${Number(E)||2}, minmax(0, 1fr))`;for(let D of g.items??[]){let C=u(D);C&&w.append(C)}return w}default:return console.warn(`[nova] tinymce-compat: dialog component "${g.type}" is not supported yet`),null}}let d=ae("div","nova-compat-dialog nova-form");if(e.body.type==="tabpanel"){let g=ae("div","nova-compat-tabs");g.setAttribute("role","tablist"),d.append(g),e.body.tabs.forEach((b,x)=>{let w=b.name??b.title,E=ae("button","nova-compat-tab",b.title);E.type="button",E.setAttribute("role","tab");let D=ae("div","nova-compat-tabpanel");D.setAttribute("role","tabpanel");for(let C of b.items){let N=u(C);N&&D.append(N)}E.addEventListener("click",()=>m.showTab(w)),o.set(w,{button:E,panel:D}),g.append(E),d.append(D),x===0&&(i=w)})}else for(let g of e.body.items){let b=u(g);b&&d.append(b)}let f=e.buttons??[],p=f.find(g=>g.type==="submit"),h=f.filter(g=>g.type==="custom");if(h.length){let g=ae("div","nova-compat-actions");for(let b of h){let x=ae("button",b.primary?"nova-button nova-button-primary":"nova-button",b.text);x.type="button",x.disabled=b.enabled===!1,x.addEventListener("click",()=>e.onAction?.(m,{name:b.name??b.text})),b.name&&r.set(b.name,{get:()=>{},set:()=>{},focus:()=>x.focus(),setEnabled:w=>x.disabled=!w}),g.append(x)}d.append(g)}let m={getData:()=>{let g={};return r.forEach((b,x)=>{let w=b.get();w!==void 0&&(g[x]=w)}),g},setData:g=>{for(let[b,x]of Object.entries(g))r.get(b)?.set(x)},close:()=>{s=!0,l?.close()},block:()=>l?.setBusy(!0),unblock:()=>l?.setBusy(!1),focus:g=>r.get(g)?.focus(),disable:g=>r.get(g)?.setEnabled(!1),enable:g=>r.get(g)?.setEnabled(!0),showTab:g=>{if(!o.has(g))return;let b=i;i=g,o.forEach(({button:x,panel:w},E)=>{let D=E===g;x.setAttribute("aria-selected",String(D)),x.tabIndex=D?0:-1,w.hidden=!D}),b&&b!==g&&e.onTabChange?.(m,{newTabName:g,oldTabName:b})},redial:g=>{m.close(),Object.assign(m,t(g))}};return e.initialData&&m.setData(e.initialData),i&&m.showTab(i),l=n.ui.openDialog({title:e.title,body:d,...p?{submitLabel:p.text}:{},...e.size==="large"?{size:"large"}:{},onSubmit:()=>(e.onSubmit?.(m),s),onClose:()=>{s||e.onCancel?.(m),e.onClose?.()}}),m}K();var Bk=new yt,Si={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},Hk={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},zk={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},ql={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},Fk=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),$k=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),Wl={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function Pr(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var Mi=new Map;function Ul(n){if(typeof n!="string"||!n)return;if(Mi.has(n))return Mi.get(n);let e=zk[n]??(n in M?n:void 0);return e?M[e]:void 0}function _k(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var Ir=class{id;core;targetElm;settings;initialized=!1;removed=!1;handlers=new Map;dirty=!1;teardowns=[];constructor(e,t,r,o){this.core=e,this.targetElm=t,this.id=r,this.settings=o}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML(),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(Si[o])i=this.core.exec(Si[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=Hk[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new me(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}queryCommandState(e){let t=Si[e.toLowerCase()];return t?this.core.isActive(t):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in Si||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||this.commands.has(t)}commands=new Map;addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){Mi.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}options={get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}};mode={get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()};undoManager={undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()};selection={getContent:(e={})=>{let{state:t}=this.core.view,{from:r,to:o}=t.selection;return e.format==="text"?t.doc.textBetween(r,o,`
|
|
40
|
-
`):Bk.serializeFragment(t.selection.content().content)},setContent:e=>this.insertContent(e),getNode:()=>{let{from:e}=this.core.view.state.selection,{node:t}=this.core.view.domAtPos(e);return t instanceof Element?t:t.parentElement},getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.view.state.selection.empty,collapse:(e=!1)=>{let{state:t,dispatch:r}=this.core.view,o=e?t.selection.from:t.selection.to;r(t.tr.setSelection(H.near(t.doc.resolve(o))))},setCursorLocation:(e,t=0)=>{let{view:r}=this.core;if(!e||!r.dom.contains(e))return;let o=r.posAtDOM(e,t);r.dispatch(r.state.tr.setSelection(H.near(r.state.doc.resolve(o))))},select:(e,t=!1)=>{let{view:r}=this.core;if(!r.dom.contains(e))return;let o=r.posAtDOM(e,0),i=r.posAtDOM(e,e.childNodes.length),{doc:s}=r.state,l=!t&&e instanceof HTMLImageElement?B.create(s,Math.max(0,o-(s.resolve(o).nodeAfter?0:1))):H.between(s.resolve(o),s.resolve(i));r.dispatch(r.state.tr.setSelection(l))}};notificationManager={open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}};windowManager={alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>am(this.core,e,t=>this.windowManager.open(t))};ui={registry:{addIcon:(e,t)=>{Mi.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=Ul(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=Ul(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}};addButton(e,t,r){let{api:o,state:i}=_k(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=Ul(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}dom={select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>Pr("setAttrib"),addClass:()=>Pr("addClass"),removeClass:()=>Pr("removeClass"),setStyle:()=>Pr("setStyle"),remove:()=>Pr("remove")};formatter={apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(Fk.has(t))return this.blockMatches(t);let r=ql[t];if(r)return this.core.isActive(r);let o=Wl[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?st(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in ql||e.toLowerCase()in Wl,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=xi(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)};blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=ql[o];if(i){let l=this.formatter.match(o);$k.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=Wl[o];if(s){this.core.exec(vt(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var cm=new Set;function jl(n){cm.has(n)||(cm.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var Vk=0,Ci=n=>typeof n=="number"?`${n}px`:String(n);function qk(){let n=[],e=new Map,t=null;async function r(i,s){let l=n.find(C=>C.targetElm===i&&!C.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=sm(s);c.length&&jl(`options not supported yet: ${c.join(", ")}`);let d=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter(C=>e.has(C)),f=u.filter(C=>!e.has(C));f.length&&jl(`plugins not available: ${f.join(", ")}`);let p=i.id||`mce_${++Vk}`;i.id||(i.id=p);let h=i instanceof HTMLTextAreaElement,m=h?i.value:i.innerHTML,g={...s,__initialContent:m},b;s.inline===!0&&!h?(i.replaceChildren(),b=i):(b=document.createElement("div"),b.className="nova-compat",i.after(b),i.hidden=!0,g.__wrapper=b);let x,w=_l({...a,element:b,content:m,setup:C=>{x=new Ir(C,i,p,g);for(let N of d)try{e.get(N)(x,"")}catch(S){console.error(`[nova] tinymce-compat: plugin "${N}" failed`,S)}s.setup?.(x)}});s.height!==void 0&&(w.root.style.height=Ci(s.height)),s.min_height!==void 0&&(w.root.style.minHeight=Ci(s.min_height)),s.max_height!==void 0&&(w.root.style.maxHeight=Ci(s.max_height)),s.width!==void 0&&(w.root.style.width=Ci(s.width));let E=!1;w.on("change",()=>{x.setDirty(!0),E=!0,x.fire("input")}),w.on("selectionChange",()=>{x.fire("NodeChange",{element:x.selection.getNode(),selectionChange:!0})}),w.on("focus",()=>{t=x,E=!1,x.fire("focus")}),w.on("blur",()=>{E&&x.fire("change",{level:{content:x.getContent()}}),E=!1,x.fire("blur")});for(let C of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])w.view.dom.addEventListener(C,N=>x.fireNative(C,N));return(h?i.form:i.closest("form"))?.addEventListener("submit",()=>x.save()),x.on("remove",()=>{let C=n.indexOf(x);C>=0&&n.splice(C,1),t===x&&(t=n[0]??null)}),n.push(x),t??=x,await w.ready,x.removed||(x.initialized=!0,x.fire("init"),s.init_instance_callback?.(x)),x}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0}));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||jl(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))Ir.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var um=qk();var dm=document.currentScript;if(dm?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=dm.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=um;})();
|
|
41
|
-
//# sourceMappingURL=tinymce.global.js.map
|
|
39
|
+
`)}setContent(e,{addToHistory:t=!0}={}){let r={content:e};this.emit("beforeSetContent",r);let o=fa(this.schema,r.content),i=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,o.content);i.setMeta(vr,!0),t||i.setMeta("addToHistory",!1),this.view.dispatch(i),this.emit("setContent",{content:r.content})}insertContent(e){if(!this.isEditable())return!1;let t=document.createElement("template");t.innerHTML=e;let r=document.createElement("div");r.append(t.content);let o=dr(this.schema),i=[...r.children].some(p=>uv.has(p.tagName)),{state:s}=this.view,l=i?new D(o.parse(r).content,0,0):o.parseSlice(r),a=!1;l.content.descendants(p=>(p.type.spec.tableRole==="table"&&(a=!0),!a));let{$from:c}=s.selection,u=0;for(let p=1;p<=c.depth;p++)if(c.node(p).type.spec.tableRole==="table"){u=p;break}let d=a&&u?s.tr.insert(c.after(u),l.content):s.tr.replaceSelection(l);return this.view.dispatch(d.setMeta(vr,!0).scrollIntoView()),!0}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){return this.commandOverrides.get(e)??W[e]}registerCommands(e){for(let[t,r]of Object.entries(e.commands??{}))r&&this.commandOverrides.set(t,r);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let r=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return r&&this.view.focus(),r}can(e){return(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,void 0,this.view)}isActive(e){return rl(this.view.state,e)}getCommandState(e){return{active:this.isActive(e),enabled:this.isEditable()&&this.can(e)}}focus(){this.destroyed||this.view.focus()}isPasteAsText(){return this.pasteAsText}setPasteAsText(e){this.pasteAsText=e,this.toolbar?.update()}openSearch(){this.searchBar.open()}closeSearch(){this.searchBar.close()}isEditable(){return this.editable&&!this.disabled}isDisabled(){return this.disabled}setDisabled(e){this.disabled!==e&&(this.disabled=e,this.view.setProps({}),this.applyDisabled(),e&&(this.ui.closePopover(),this.view.dom.blur()),this.toolbar?.update(),this.emit("editableChange"))}applyDisabled(){this.root.classList.toggle("nova-disabled",this.disabled),this.disabled?this.root.setAttribute("aria-disabled","true"):this.root.removeAttribute("aria-disabled"),this.disabled?this.view.dom.setAttribute("tabindex","-1"):this.view.dom.removeAttribute("tabindex")}setEditable(e){this.editable!==e&&(this.editable=e,this.view.setProps({}),this.root.classList.toggle("nova-readonly",!e),e||this.ui.closePopover(),this.toolbar?.update(),this.emit("editableChange"))}on(e,t){let r=this.listeners.get(e);return r||this.listeners.set(e,r=new Set),r.add(t),()=>this.off(e,t)}off(e,t){this.listeners.get(e)?.delete(t)}emit(e,...[t]){for(let r of this.listeners.get(e)??[])try{r(this,t)}catch(o){Pe(`Listener for "${e}" failed`,o)}}destroy(){if(!this.destroyed){this.emit("destroy"),this.destroyed=!0,this.menubar?.destroy(),this.ui.destroy(),this.toolbar?.destroy(),this.statusbar?.destroy();for(let e of this.cleanups.splice(0))try{e()}catch(t){Pe("Plugin cleanup failed",t)}this.searchBar.destroy(),this.root.classList.contains("nova-fullscreen")&&hr(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}};function Pe(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function pv(n,e){let t=n?.validate;if(!t)return!0;if(typeof t=="function")try{return t(e),!0}catch{return!1}let r=e===null?"null":typeof e;return t.split("|").includes(r)}function rf(n,e){return!e||typeof e!="object"||!n?e:Object.fromEntries(Object.entries(e).filter(([t,r])=>pv(n[t],r)))}function of(n,e){let t=n.nodes[e.type],r={...e};return t&&(r.attrs=rf(t.spec.attrs,e.attrs)),Array.isArray(e.marks)&&(r.marks=e.marks.map(o=>{let i=o&&n.marks[o.type];return i?{...o,attrs:rf(i.spec.attrs,o.attrs)}:o})),Array.isArray(e.content)&&(r.content=e.content.map(o=>o&&typeof o=="object"?of(n,o):o)),r}function fa(n,e){if(typeof e!="string")return Ae.fromJSON(n,of(n,e));let t=document.createElement("div"),r=document.createElement("template");return r.innerHTML=e,t.appendChild(r.content),dr(n).parse(t)}function ti(n){return new kr(n)}var fv={"toolbar.label":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","toolbar.options":"\u0432\u0430\u0440\u0438\u0430\u043D\u0442\u044B","editor.label":"\u0422\u0435\u043A\u0441\u0442\u043E\u0432\u044B\u0439 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440","editor.required":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u044D\u0442\u043E \u043F\u043E\u043B\u0435.",undo:"\u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C",redo:"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C",bold:"\u0416\u0438\u0440\u043D\u044B\u0439",italic:"\u041A\u0443\u0440\u0441\u0438\u0432",underline:"\u041F\u043E\u0434\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",strike:"\u0417\u0430\u0447\u0451\u0440\u043A\u043D\u0443\u0442\u044B\u0439",code:"\u041A\u043E\u0434 \u0432 \u0441\u0442\u0440\u043E\u043A\u0435",subscript:"\u041F\u043E\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",superscript:"\u041D\u0430\u0434\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439",link:"\u0421\u0441\u044B\u043B\u043A\u0430",unlink:"\u0423\u0431\u0440\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443",image:"\u0418\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",bulletList:"\u041C\u0430\u0440\u043A\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",orderedList:"\u041D\u0443\u043C\u0435\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A",indent:"\u0423\u0432\u0435\u043B\u0438\u0447\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",outdent:"\u0423\u043C\u0435\u043D\u044C\u0448\u0438\u0442\u044C \u043E\u0442\u0441\u0442\u0443\u043F",align:"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",alignLeft:"\u041F\u043E \u043B\u0435\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignCenter:"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443",alignRight:"\u041F\u043E \u043F\u0440\u0430\u0432\u043E\u043C\u0443 \u043A\u0440\u0430\u044E",alignJustify:"\u041F\u043E \u0448\u0438\u0440\u0438\u043D\u0435",blockquote:"\u0426\u0438\u0442\u0430\u0442\u0430",codeBlock:"\u0411\u043B\u043E\u043A \u043A\u043E\u0434\u0430",horizontalRule:"\u0413\u043E\u0440\u0438\u0437\u043E\u043D\u0442\u0430\u043B\u044C\u043D\u0430\u044F \u043B\u0438\u043D\u0438\u044F",clearFormatting:"\u041E\u0447\u0438\u0441\u0442\u0438\u0442\u044C \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",more:"\u0415\u0449\u0451",moreFormats:"\u0415\u0449\u0451 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",blocks:"\u0421\u0442\u0438\u043B\u044C \u0442\u0435\u043A\u0441\u0442\u0430",styles:"\u0424\u043E\u0440\u043C\u0430\u0442\u044B","styles.headings":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438","styles.inline":"\u0422\u0435\u043A\u0441\u0442","styles.blocks":"\u0411\u043B\u043E\u043A\u0438","styles.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",paragraph:"\u041E\u0431\u044B\u0447\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442",h1:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1",h2:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2",h3:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 3",h4:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 4",h5:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 5",h6:"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 6",fontFamily:"\u0428\u0440\u0438\u0444\u0442",fontSize:"\u0420\u0430\u0437\u043C\u0435\u0440 \u0448\u0440\u0438\u0444\u0442\u0430",lineHeight:"\u041C\u0435\u0436\u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0439 \u0438\u043D\u0442\u0435\u0440\u0432\u0430\u043B",default:"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E",textColor:"\u0426\u0432\u0435\u0442 \u0442\u0435\u043A\u0441\u0442\u0430",backgroundColor:"\u0426\u0432\u0435\u0442 \u0432\u044B\u0434\u0435\u043B\u0435\u043D\u0438\u044F",removeColor:"\u0423\u0431\u0440\u0430\u0442\u044C \u0446\u0432\u0435\u0442",customColor:"\u0421\u0432\u043E\u0439 \u0446\u0432\u0435\u0442","dialog.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","dialog.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","dialog.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C","dialog.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","dialog.required":"\u0417\u0430\u043F\u043E\u043B\u043D\u0438\u0442\u0435 \u044D\u0442\u043E \u043F\u043E\u043B\u0435","dialog.invalid":"\u041F\u0440\u043E\u0432\u0435\u0440\u044C\u0442\u0435 \u0444\u043E\u0440\u043C\u0430\u0442","link.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.editTitle":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.url":"\u0410\u0434\u0440\u0435\u0441","link.text":"\u0422\u0435\u043A\u0441\u0442 \u0441\u0441\u044B\u043B\u043A\u0438","link.tooltip":"\u041F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430 (title)","link.newTab":"\u041E\u0442\u043A\u0440\u044B\u0432\u0430\u0442\u044C \u0432 \u043D\u043E\u0432\u043E\u0439 \u0432\u043A\u043B\u0430\u0434\u043A\u0435","link.open":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.edit":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copy":"\u041A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0441\u044B\u043B\u043A\u0443","link.copied":"\u0421\u0441\u044B\u043B\u043A\u0430 \u0441\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u0430","link.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.url":"\u0410\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.altHint":"\u041E\u043F\u0438\u0448\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u043B\u044E\u0434\u0435\u0439, \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u0443\u044E\u0449\u0438\u0445 \u044D\u043A\u0440\u0430\u043D\u043D\u044B\u0439 \u0434\u0438\u043A\u0442\u043E\u0440","image.upload":"\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C","image.drop":"\u041F\u0435\u0440\u0435\u0442\u0430\u0449\u0438\u0442\u0435 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435 \u0441\u044E\u0434\u0430 \u0438\u043B\u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435, \u0447\u0442\u043E\u0431\u044B \u0432\u044B\u0431\u0440\u0430\u0442\u044C","image.uploading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F\u2026","image.uploadFailed":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.retry":"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C","image.retrying":"\u041F\u0440\u043E\u0431\u043B\u0435\u043C\u0430 \u0441\u043E \u0441\u0432\u044F\u0437\u044C\u044E \u2014 \u043F\u043E\u0432\u0442\u043E\u0440\u044F\u0435\u043C \u0437\u0430\u0433\u0440\u0443\u0437\u043A\u0443\u2026","image.invalid":"\u0422\u0430\u043A\u043E\u0439 \u0430\u0434\u0440\u0435\u0441 \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F \u043D\u0435 \u0440\u0430\u0437\u0440\u0435\u0448\u0451\u043D","image.or":"\u0438\u043B\u0438","image.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u044F","image.alignLeft":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043B\u0435\u0432\u0430","image.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","image.alignRight":"\u041E\u0431\u0442\u0435\u043A\u0430\u043D\u0438\u0435, \u0441\u043F\u0440\u0430\u0432\u0430","image.editAlt":"\u0410\u043B\u044C\u0442\u0435\u0440\u043D\u0430\u0442\u0438\u0432\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442","image.size":"\u0420\u0430\u0437\u043C\u0435\u0440","image.sizeSmall":"\u041C\u0430\u043B\u0435\u043D\u044C\u043A\u0438\u0439 (25%)","image.sizeMedium":"\u0421\u0440\u0435\u0434\u043D\u0438\u0439 (50%)","image.sizeLarge":"\u0411\u043E\u043B\u044C\u0448\u043E\u0439 (75%)","image.sizeFull":"\u0412\u043E \u0432\u0441\u044E \u0448\u0438\u0440\u0438\u043D\u0443","image.sizeOriginal":"\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440","image.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435","image.caption":"\u041F\u043E\u0434\u043F\u0438\u0441\u044C","image.captionPlaceholder":"\u0414\u043E\u0431\u0430\u0432\u044C\u0442\u0435 \u043F\u043E\u0434\u043F\u0438\u0441\u044C\u2026","status.words":"\u0421\u043B\u043E\u0432: {count}","status.resize":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0440\u0430\u0437\u043C\u0435\u0440 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0430","dialog.browse":"\u041E\u0431\u0437\u043E\u0440",pasteAsText:"\u0412\u0441\u0442\u0430\u0432\u043B\u044F\u0442\u044C \u043A\u0430\u043A \u0442\u0435\u043A\u0441\u0442","menu.label":"\u041C\u0435\u043D\u044E","menu.file":"\u0424\u0430\u0439\u043B","menu.edit":"\u041F\u0440\u0430\u0432\u043A\u0430","menu.view":"\u0412\u0438\u0434","menu.insert":"\u0412\u0441\u0442\u0430\u0432\u043A\u0430","menu.format":"\u0424\u043E\u0440\u043C\u0430\u0442","menu.table":"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","menu.help":"\u0421\u043F\u0440\u0430\u0432\u043A\u0430",selectAll:"\u0412\u044B\u0434\u0435\u043B\u0438\u0442\u044C \u0432\u0441\u0451",print:"\u041F\u0435\u0447\u0430\u0442\u044C","table.rows":"\u0421\u0442\u0440\u043E\u043A\u0438","table.cols":"\u0421\u0442\u043E\u043B\u0431\u0446\u044B","table.invalidSize":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 1 \u0434\u043E 50","quickbars.selection":"\u0411\u044B\u0441\u0442\u0440\u043E\u0435 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","quickbars.insert":"\u0411\u044B\u0441\u0442\u0440\u0430\u044F \u0432\u0441\u0442\u0430\u0432\u043A\u0430","search.title":"\u041D\u0430\u0439\u0442\u0438 \u0438 \u0437\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.find":"\u041D\u0430\u0439\u0442\u0438","search.replace":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u043D\u0430","search.next":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.prev":"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0435\u0435 \u0441\u043E\u0432\u043F\u0430\u0434\u0435\u043D\u0438\u0435","search.replaceOne":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C","search.replaceAll":"\u0417\u0430\u043C\u0435\u043D\u0438\u0442\u044C \u0432\u0441\u0435","search.matchCase":"\u0423\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u0440\u0435\u0433\u0438\u0441\u0442\u0440","search.wholeWord":"\u0422\u043E\u043B\u044C\u043A\u043E \u0441\u043B\u043E\u0432\u043E \u0446\u0435\u043B\u0438\u043A\u043E\u043C","search.count":"{current} \u0438\u0437 {total}","search.none":"\u041D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E",fullscreen:"\u041D\u0430 \u0432\u0435\u0441\u044C \u044D\u043A\u0440\u0430\u043D",preview:"\u041F\u0440\u0435\u0434\u043F\u0440\u043E\u0441\u043C\u043E\u0442\u0440",sourceCode:"HTML-\u043A\u043E\u0434",help:"\u0413\u043E\u0440\u044F\u0447\u0438\u0435 \u043A\u043B\u0430\u0432\u0438\u0448\u0438","help.formatting":"\u0424\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435 \u0442\u0435\u043A\u0441\u0442\u0430","help.blocks":"\u0410\u0431\u0437\u0430\u0446\u044B \u0438 \u0441\u043F\u0438\u0441\u043A\u0438","help.editing":"\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435","help.navigation":"\u041D\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044F","help.slash":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0431\u043B\u043E\u043A (\u0441\u043B\u044D\u0448-\u043A\u043E\u043C\u0430\u043D\u0434\u044B)","help.toMenubar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u0432 \u0433\u043B\u0430\u0432\u043D\u043E\u0435 \u043C\u0435\u043D\u044E","help.toToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u0438\u043D\u0441\u0442\u0440\u0443\u043C\u0435\u043D\u0442\u043E\u0432","help.toContextToolbar":"\u041F\u0435\u0440\u0435\u0439\u0442\u0438 \u043D\u0430 \u043F\u0430\u043D\u0435\u043B\u044C \u043A\u0430\u0440\u0442\u0438\u043D\u043A\u0438/\u0442\u0430\u0431\u043B\u0438\u0446\u044B","help.toEditor":"\u0412\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F \u0432 \u0442\u0435\u043A\u0441\u0442","help.nextCell":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u044F\u0447\u0435\u0439\u043A\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B",table:"\u0422\u0430\u0431\u043B\u0438\u0446\u0430","table.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.size":"{rows} \xD7 {cols}","table.toolbar":"\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.rowBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u0432\u044B\u0448\u0435","table.rowAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443 \u043D\u0438\u0436\u0435","table.rowDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u0440\u043E\u043A\u0443","table.colBefore":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043B\u0435\u0432\u0430","table.colAfter":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446 \u0441\u043F\u0440\u0430\u0432\u0430","table.colDelete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0441\u0442\u043E\u043B\u0431\u0435\u0446","table.merge":"\u041E\u0431\u044A\u0435\u0434\u0438\u043D\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0438","table.split":"\u0420\u0430\u0437\u0434\u0435\u043B\u0438\u0442\u044C \u044F\u0447\u0435\u0439\u043A\u0443","table.rowHeader":"\u0421\u0442\u0440\u043E\u043A\u0430 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.colHeader":"\u0421\u0442\u043E\u043B\u0431\u0435\u0446 \u0437\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u043E\u0432","table.cellBackground":"\u0424\u043E\u043D \u044F\u0447\u0435\u0439\u043A\u0438","table.delete":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0442\u0430\u0431\u043B\u0438\u0446\u0443","table.sort":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u043A\u0430","table.sortAsc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0410 \u2192 \u042F, 1 \u2192 9","table.sortDesc":"\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u042F \u2192 \u0410, 9 \u2192 1","table.props":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B","table.style":"\u0421\u0442\u0438\u043B\u044C","table.styleDefault":"\u041E\u0431\u044B\u0447\u043D\u044B\u0439","table.width":"\u0428\u0438\u0440\u0438\u043D\u0430","table.widthHint":"\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 100% \u0438\u043B\u0438 600px. \u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidWidth":"\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0448\u0438\u0440\u0438\u043D\u0443, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 100% \u0438\u043B\u0438 600px","table.align":"\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435 \u043D\u0430 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435","table.alignDefault":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","table.alignCenter":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.alignRight":"\u0421\u043F\u0440\u0430\u0432\u0430","table.cellProps":"\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u044F\u0447\u0435\u0439\u043A\u0438","table.valign":"\u0412\u0435\u0440\u0442\u0438\u043A\u0430\u043B\u044C\u043D\u043E\u0435 \u0432\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435","table.valignTop":"\u0421\u0432\u0435\u0440\u0445\u0443","table.valignMiddle":"\u041F\u043E \u0446\u0435\u043D\u0442\u0440\u0443","table.valignBottom":"\u0421\u043D\u0438\u0437\u0443","table.cellType":"\u0422\u0438\u043F \u044F\u0447\u0435\u0439\u043A\u0438","table.cellData":"\u041E\u0431\u044B\u0447\u043D\u0430\u044F","table.cellHeader":"\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A","table.colWidth":"\u0428\u0438\u0440\u0438\u043D\u0430 \u0441\u0442\u043E\u043B\u0431\u0446\u0430, px","table.colWidthHint":"\u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.","table.invalidColWidth":"\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0447\u0438\u0441\u043B\u043E \u043E\u0442 24 \u0434\u043E 4000","slash.label":"\u041A\u043E\u043C\u0430\u043D\u0434\u044B","slash.empty":"\u041D\u0435\u0442 \u043F\u043E\u0434\u0445\u043E\u0434\u044F\u0449\u0438\u0445 \u043A\u043E\u043C\u0430\u043D\u0434","advlist.disc":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E","advlist.circle":"\u041A\u0440\u0443\u0436\u043E\u043A","advlist.square":"\u041A\u0432\u0430\u0434\u0440\u0430\u0442","advlist.decimal":"\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E (1, 2, 3)","advlist.lower-alpha":"\u0421\u0442\u0440\u043E\u0447\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (a, b, c)","advlist.upper-alpha":"\u041F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 \u0431\u0443\u043A\u0432\u044B (A, B, C)","advlist.lower-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u0441\u0442\u0440\u043E\u0447\u043D\u044B\u0435 (i, ii, iii)","advlist.upper-roman":"\u0420\u0438\u043C\u0441\u043A\u0438\u0435 \u043F\u0440\u043E\u043F\u0438\u0441\u043D\u044B\u0435 (I, II, III)","advlist.lower-greek":"\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435 (\u03B1, \u03B2, \u03B3)","anchor.title":"\u042F\u043A\u043E\u0440\u044C","anchor.id":"\u0418\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440","anchor.hint":"\u041B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB, \xAB.\xBB; \u043D\u0430\u0447\u0438\u043D\u0430\u0435\u0442\u0441\u044F \u0441 \u0431\u0443\u043A\u0432\u044B. \u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u044F\u043A\u043E\u0440\u044C \u2014 #\u0438\u0434\u0435\u043D\u0442\u0438\u0444\u0438\u043A\u0430\u0442\u043E\u0440.","anchor.invalid":"\u0422\u043E\u043B\u044C\u043A\u043E \u043B\u0430\u0442\u0438\u043D\u0441\u043A\u0438\u0435 \u0431\u0443\u043A\u0432\u044B, \u0446\u0438\u0444\u0440\u044B, \xAB-\xBB, \xAB_\xBB \u0438\u043B\u0438 \xAB.\xBB, \u043F\u0435\u0440\u0432\u0430\u044F \u2014 \u0431\u0443\u043A\u0432\u0430","anchor.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","autosave.restore":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A","autosave.found":"\u041D\u0430\u0439\u0434\u0435\u043D \u043D\u0435\u0441\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0439 \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A. \u0415\u0433\u043E \u043C\u043E\u0436\u043D\u043E \u0432\u0435\u0440\u043D\u0443\u0442\u044C \u043A\u043D\u043E\u043F\u043A\u043E\u0439 \xAB\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u0447\u0435\u0440\u043D\u043E\u0432\u0438\u043A\xBB.","autosave.restored":"\u0427\u0435\u0440\u043D\u043E\u0432\u0438\u043A \u0432\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D","charmap.title":"\u0421\u043F\u0435\u0446\u0438\u0430\u043B\u044C\u043D\u044B\u0439 \u0441\u0438\u043C\u0432\u043E\u043B","charmap.search":"\u041F\u043E\u0438\u0441\u043A \u0441\u0438\u043C\u0432\u043E\u043B\u0430","charmap.empty":"\u041D\u0438\u0447\u0435\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","charmap.groups.0":"\u0412\u0430\u043B\u044E\u0442\u044B","charmap.groups.1":"\u0422\u0438\u043F\u043E\u0433\u0440\u0430\u0444\u0438\u043A\u0430","charmap.groups.2":"\u041C\u0430\u0442\u0435\u043C\u0430\u0442\u0438\u043A\u0430","charmap.groups.3":"\u0421\u0442\u0440\u0435\u043B\u043A\u0438","charmap.groups.4":"\u041B\u0430\u0442\u0438\u043D\u0438\u0446\u0430","charmap.groups.5":"\u0413\u0440\u0435\u0447\u0435\u0441\u043A\u0438\u0435","comments.add":"\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439","comments.show":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.panel":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.guest":"\u0413\u043E\u0441\u0442\u044C","comments.newComment":"\u041D\u043E\u0432\u044B\u0439 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439","comments.placeholder":"\u041D\u0430\u043F\u0438\u0448\u0438\u0442\u0435 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\u2026","comments.replyPlaceholder":"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C\u2026","comments.comment":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C","comments.reply":"\u041E\u0442\u0432\u0435\u0442\u0438\u0442\u044C","comments.cancel":"\u041E\u0442\u043C\u0435\u043D\u0430","comments.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C","comments.edit":"\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C","comments.remove":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C","comments.resolve":"\u0420\u0435\u0448\u0435\u043D\u043E","comments.reopen":"\u041E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u043D\u043E\u0432\u0430","comments.deleteThread":"\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u043E\u0431\u0441\u0443\u0436\u0434\u0435\u043D\u0438\u0435","comments.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0438","comments.showResolved":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0440\u0435\u0448\u0451\u043D\u043D\u044B\u0435","comments.resolvedBy":"\u0420\u0435\u0448\u0435\u043D\u043E: {name}","comments.orphan":"\u041F\u0440\u043E\u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442 \u0443\u0434\u0430\u043B\u0451\u043D","comments.empty":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442. \u0412\u044B\u0434\u0435\u043B\u0438\u0442\u0435 \u0442\u0435\u043A\u0441\u0442 \u0438 \u043D\u0430\u0436\u043C\u0438\u0442\u0435 \xAB\u0414\u043E\u0431\u0430\u0432\u0438\u0442\u044C \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0439\xBB ({shortcut}).","comments.people":"\u041B\u044E\u0434\u0438","comments.noPeople":"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","comments.edited":"\u0438\u0437\u043C\u0435\u043D\u0435\u043D\u043E","comments.you":"\u0432\u044B","comments.count":"\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432: {count}","directionality.ltr":"\u0421\u043B\u0435\u0432\u0430 \u043D\u0430\u043F\u0440\u0430\u0432\u043E","directionality.rtl":"\u0421\u043F\u0440\u0430\u0432\u0430 \u043D\u0430\u043B\u0435\u0432\u043E","emoticons.title":"\u042D\u043C\u043E\u0434\u0437\u0438","emoticons.search":"\u041F\u043E\u0438\u0441\u043A \u044D\u043C\u043E\u0434\u0437\u0438","emoticons.empty":"\u042D\u043C\u043E\u0434\u0437\u0438 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B","emoticons.groups.0":"\u0421\u043C\u0430\u0439\u043B\u044B","emoticons.groups.1":"\u0416\u0435\u0441\u0442\u044B","emoticons.groups.2":"\u0421\u0435\u0440\u0434\u0446\u0430","emoticons.groups.3":"\u041F\u0440\u0438\u0440\u043E\u0434\u0430","emoticons.groups.4":"\u0415\u0434\u0430","emoticons.groups.5":"\u0417\u0430\u043D\u044F\u0442\u0438\u044F","emoticons.groups.6":"\u041F\u0440\u0435\u0434\u043C\u0435\u0442\u044B","emoticons.groups.7":"\u0421\u0438\u043C\u0432\u043E\u043B\u044B","insertdatetime.title":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u0434\u0430\u0442\u0443/\u0432\u0440\u0435\u043C\u044F","insertdatetime.date":"\u0414\u0430\u0442\u0430","insertdatetime.time":"\u0412\u0440\u0435\u043C\u044F","insertdatetime.dateTime":"\u0414\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043C\u044F","insertdatetime.long":"\u0414\u0430\u0442\u0430 \u043F\u0440\u043E\u043F\u0438\u0441\u044C\u044E","media.title":"\u0412\u0438\u0434\u0435\u043E","media.url":"\u0410\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E","media.hint":"YouTube, Vimeo \u0438\u043B\u0438 \u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0444\u0430\u0439\u043B .mp4 / .webm","media.name":"\u041D\u0430\u0437\u0432\u0430\u043D\u0438\u0435 (\u0434\u043B\u044F \u044D\u043A\u0440\u0430\u043D\u043D\u043E\u0433\u043E \u0434\u0438\u043A\u0442\u043E\u0440\u0430)","media.invalid":"\u042D\u0442\u043E\u0442 \u0430\u0434\u0440\u0435\u0441 \u0432\u0438\u0434\u0435\u043E \u043D\u0435 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F","media.save":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C","mentions.list":"\u041B\u044E\u0434\u0438","mentions.empty":"\u041D\u0438\u043A\u043E\u0433\u043E \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u043E","mergetags.insert":"\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0443\u044E","mergetags.search":"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435","mergetags.empty":"\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B","mergetags.unknown":"\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F","nonbreaking.title":"\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B","pagebreak.title":"\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B","revisionhistory.button":"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439","revisionhistory.title":"\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0432\u0435\u0440\u0441\u0438\u0439","revisionhistory.current":"\u0422\u0435\u043A\u0443\u0449\u0430\u044F \u0432\u0435\u0440\u0441\u0438\u044F","revisionhistory.restore":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u0438\u0442\u044C \u044D\u0442\u0443 \u0432\u0435\u0440\u0441\u0438\u044E","revisionhistory.close":"\u0417\u0430\u043A\u0440\u044B\u0442\u044C","revisionhistory.save":"\u0421\u043E\u0445\u0440\u0430\u043D\u0438\u0442\u044C \u0432\u0435\u0440\u0441\u0438\u044E","revisionhistory.saved":"\u0412\u0435\u0440\u0441\u0438\u044F \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0430","revisionhistory.highlight":"\u041F\u043E\u043A\u0430\u0437\u044B\u0432\u0430\u0442\u044C \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F","revisionhistory.onlyHere":"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u044D\u0442\u043E\u0439 \u0432\u0435\u0440\u0441\u0438\u0438","revisionhistory.onlyNow":"\u0422\u043E\u043B\u044C\u043A\u043E \u0432 \u0442\u0435\u043A\u0443\u0449\u0435\u043C \u0442\u0435\u043A\u0441\u0442\u0435","revisionhistory.loading":"\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430\u2026","revisionhistory.failed":"\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438\u0441\u0442\u043E\u0440\u0438\u044E \u0432\u0435\u0440\u0441\u0438\u0439.","revisionhistory.retry":"\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C","revisionhistory.empty":"\u0421\u043E\u0445\u0440\u0430\u043D\u0451\u043D\u043D\u044B\u0445 \u0432\u0435\u0440\u0441\u0438\u0439 \u043F\u043E\u043A\u0430 \u043D\u0435\u0442.","revisionhistory.restored":"\u0412\u043E\u0441\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D\u0430 \u0432\u0435\u0440\u0441\u0438\u044F \u043E\u0442 {date}. \u041E\u0442\u043C\u0435\u043D\u0438\u0442\u044C \u2014 Ctrl+Z.","revisionhistory.versions":"\u0412\u0435\u0440\u0441\u0438\u0438","suggestions.toggle":"\u041F\u0440\u0435\u0434\u043B\u0430\u0433\u0430\u0442\u044C \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.review":"\u041F\u0440\u0430\u0432\u043A\u0438","suggestions.accept":"\u041F\u0440\u0438\u043D\u044F\u0442\u044C","suggestions.reject":"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C","suggestions.acceptAll":"\u041F\u0440\u0438\u043D\u044F\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.rejectAll":"\u041E\u0442\u043A\u043B\u043E\u043D\u0438\u0442\u044C \u0432\u0441\u0435 \u043F\u0440\u0430\u0432\u043A\u0438","suggestions.next":"\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430","suggestions.previous":"\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F \u043F\u0440\u0430\u0432\u043A\u0430","suggestions.inserted":"\u0412\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043E: {name}","suggestions.deleted":"\u0423\u0434\u0430\u043B\u0435\u043D\u043E: {name}","suggestions.toolbar":"\u041F\u0440\u0430\u0432\u043A\u0430","suggestions.guest":"\u0413\u043E\u0441\u0442\u044C","suggestions.none":"\u041F\u0440\u0430\u0432\u043E\u043A \u043D\u0435\u0442","visualblocks.title":"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438"},sf=fv;var lf=new Set("script,style,iframe,frame,frameset,object,embed,applet,base,link,meta,title,head,html,body,template,slot,noscript,form,input,button,select,option,optgroup,textarea,fieldset,legend,datalist,output,progress,meter,svg,math,canvas,audio,video,source,track,picture,map,area,portal,dialog,param,xmp,plaintext,listing,noembed,noframes,image".split(",")),hv=/^(on|xmlns)|^(srcdoc|formaction|action|contenteditable|autofocus|is|slot|nonce)$/,mv=/^[a-z_:][a-z0-9_.:-]*$/,af=/^[a-z][a-z0-9._-]*$/,Tn=new Set("p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,img,figure,figcaption,br,table,tr,td,th,strong,em,u,s,code,a,sub,sup".split(",")),Mr=new Set(["span","i","b","del","strike","mark"]),gv=new Set("abbr,acronym,bdi,bdo,big,cite,data,dfn,ins,kbd,q,samp,small,time,tt,var,label,ruby,rt,rp,wbr".split(",")),hf=new Set("div,section,article,aside,header,footer,nav,main,address,details,summary,dl,dt,dd,center,hgroup,search".split(",")),bv=new Set([...hf,..."p,h1,h2,h3,h4,h5,h6,blockquote,pre,hr,ul,ol,li,table,figure".split(",")]),yv={a:["href"],img:["src"],td:["colspan","rowspan"],th:["colspan","rowspan"]};function cf(n){let e=[],t=0,r="";for(let o of n)o==="["?t++:o==="]"&&(t=Math.max(0,t-1)),o===","&&!t?(e.push(r),r=""):r+=o;return e.push(r),e.map(o=>o.trim()).filter(Boolean)}function vv(n){let e=n.trim(),t=e.startsWith("!");t&&(e=e.slice(1));let r=/^([^=:<]+)(?:([=:<])(.*))?$/s.exec(e);if(!r)return null;let o=r[1].trim().toLowerCase();if(!o)return null;let i={name:o,required:t},s=r[3]??"";return r[2]==="="?i.def=s:r[2]===":"?i.forced=s:r[2]==="<"&&(i.values=s.split("?")),i}function ga(n,e){return n==="*"?!0:n.endsWith("*")?e.startsWith(n.slice(0,-1)):n===e}var uf=new Set;function ba(n,e){uf.has(n)||(uf.add(n),console.warn(`[nova] <${n}> in content rules is ignored: ${e}`))}var ya=class{constructor(e){E(this,"elements",new Map);E(this,"globals",[]);E(this,"blockTags",new Map);E(this,"inlineTags",new Map);let t=new Set((e.invalidElements??"").split(",").map(s=>s.trim().toLowerCase()).filter(Boolean)),r=new Set,o=new Set;for(let s of(e.customElements??"").split(",")){let l=s.trim().toLowerCase(),a=l.replace(/^~/,"");if(af.test(a)){if(lf.has(a)||Tn.has(a)){ba(a,"it cannot be a custom element");continue}o.add(a),l.startsWith("~")&&r.add(a)}}let i=(s,l)=>{let[a,...c]=s;if(a){if(a==="@"||a==="*"){this.globals.push(...l??[]);return}for(let u of s){if(!af.test(u)||t.has(u))continue;if(lf.has(u)){ba(u,"not allowed for security reasons (iframes and video: use the media plugin)");continue}this.elements.set(u,l);let d=Tn.has(u)||Mr.has(u)?u:a;if(Tn.has(u))continue;if(Mr.has(u)){u===a&&l?.length&&this.inlineTags.set(u,u);continue}let p=o.has(u)||o.has(a)||u.includes("-");gv.has(a)||r.has(a)?this.inlineTags.set(u,d):hf.has(a)||p?this.blockTags.set(u,d):(!c.includes(u)||u===a)&&ba(u,"unknown element")}}};for(let s of cf(e.validElements??"")){let{names:l,attrs:a}=df(s);a?i(l,a):l.every(c=>Tn.has(c)||Mr.has(c))||i(l,null)}for(let s of cf(e.extendedValidElements??"")){let{names:l,attrs:a}=df(s);i(l,a)}for(let s of o)t.has(s)||(this.elements.has(s)||this.elements.set(s,[{name:"*",required:!1}]),r.has(s)?this.inlineTags.set(s,s):this.inlineTags.has(s)||this.blockTags.set(s,s))}apply(e,t){return wv(e.nodes,e.marks,this,t)}get active(){return this.elements.size>0||this.globals.length>0}touches(e){return this.globals.length>0||this.elements.has(e)}rulesFor(e){return[...this.elements.get(e)??[],...this.globals]}allows(e,t){return hv.test(t)||!mv.test(t)?!1:this.rulesFor(e).some(r=>ga(r.name,t))}extends(e){return this.rulesFor(e).some(t=>t.name!=="class"&&t.name!=="style")}get classOnBuiltIn(){if(this.globals.some(e=>ga(e.name,"class")))return!0;for(let[e,t]of this.elements)if(Tn.has(e)&&t?.some(r=>ga(r.name,"class")))return!0;return!1}hasRequired(e,t){return this.rulesFor(e).every(r=>!r.required||t.hasAttribute(r.name))}readAttrs(e,t,r){let o=null;for(let i of Array.from(t.attributes)){let s=i.name.toLowerCase();if(s===Fo&&(s="style"),r.includes(s)||!this.allows(e,s))continue;let l=mr(s,i.value);l!==null&&((o??(o={}))[s]=l)}return o}outputAttrs(e,t,r){let o={...t};if(r&&typeof r=="object"&&!Array.isArray(r))for(let[s,l]of Object.entries(r)){let a=s.toLowerCase();if(o[a]!=null||!this.allows(e,a)||!["string","number","boolean"].includes(typeof l))continue;let c=mr(a,String(l));c!==null&&(o[a]=c)}if(this.elements.get(e))for(let s of Object.keys(o))this.allows(e,s)||yv[e]?.includes(s)||s.startsWith("data-nova-")||delete o[s];for(let s of this.rulesFor(e)){if(s.name.includes("*"))continue;s.forced!==void 0?o[s.name]=s.forced:s.def!==void 0&&o[s.name]==null&&(o[s.name]=s.def);let l=o[s.name];s.values&&l!=null&&!s.values.includes(String(l))&&delete o[s.name]}return e==="a"&&o.target!=null&&o.rel==null&&(o.rel="noopener noreferrer"),o}decorate(e,t){if(!Array.isArray(e)||typeof e[0]!="string")return e;let r=e[0],o=(r.includes(" ")?r.split(" ")[1]:r).toLowerCase();if(!this.touches(o))return e;let i=e[1],s=!!i&&typeof i=="object"&&!Array.isArray(i)&&i.nodeType===void 0,l=this.outputAttrs(o,s?i:{},t);return[r,l,...e.slice(s?2:1)]}};function df(n){let e=/^([^[]*)(?:\[(.*)\])?$/s.exec(n.trim()),t=(e?.[1]??"").trim().replace(/^[-#+!]+/,"").split("/").map(i=>i.trim().toLowerCase()).filter(Boolean),r=e?.[2],o=r===void 0?null:r.split("|").map(vv).filter(i=>i!==null);return{names:t,attrs:o}}function kv(n){if(!n.validElements&&!n.extendedValidElements&&!n.customElements)return null;let e=new ya(n);return e.active?e:null}var pf=n=>(/^[a-z][a-z0-9-]*/i.exec(n)?.[0]??"").toLowerCase();function Mv(n,e,t,r,o){try{let i=n.schema,s=e==="node"?o(i.nodes[t].create(r)):o(i.marks[t].create(r),!0),l=Array.isArray(s)?s[1]:null;return l&&typeof l=="object"&&!Array.isArray(l)?Object.keys(l):[]}catch{return[]}}function xv(n,e,t,r,o){let i=(e.parseDOM??[]).map(a=>a.tag?pf(a.tag):"").filter(a=>Tn.has(a)&&r.touches(a));if(!i.length||!e.toDOM)return e;let s=i.some(a=>r.extends(a)),l=e.toDOM;return{...e,...s?{attrs:{...e.attrs,htmlAttrs:{default:null}}}:{},parseDOM:e.parseDOM.map(a=>{let c=a.tag?pf(a.tag):"";if(!i.includes(c))return a;let u=a.getAttrs;return{...a,getAttrs:d=>{let p=u?u(d):a.attrs??null;if(p===!1||!r.hasRequired(c,d))return!1;if(!s)return p;let f=r.readAttrs(c,d,["class","style"]);if(!f)return p;for(let h of Mv(o,t,n,{...p},l))delete f[h];return Object.keys(f).length?{...p,htmlAttrs:f}:p}}}),toDOM:((a,c)=>r.decorate(l(a,c),a.attrs.htmlAttrs))}}function ff(n,e){return Array.from(n.children).some(t=>{let r=t.localName;return bv.has(r)||e.blockTags.has(r)})}function Sv(n){let e={},t={},r=(a,c,u)=>{if(!n.hasRequired(a,c))return!1;let d=Mr.has(a),p=d?u&&a==="span"?["class","style"]:["style"]:[],f=n.readAttrs(a,c,p);return d&&!f?!1:{tag:a,htmlAttrs:f}},o=a=>[...a].filter(([,c])=>!Mr.has(c)).map(([c])=>c),i=(a,c,u)=>{let d=typeof u.tag=="string"&&a.has(u.tag)?u.tag:c;return{tag:d,attrs:n.outputAttrs(d,{},u.htmlAttrs)}},s=[...n.blockTags];if(s.length){let a=new Set(n.blockTags.values()),c=a.has("div")?"div":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_block={ownStyleTags:o(n.blockTags),group:"block",content:"block+",defining:!0,attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ff(f,n)?r(p,f,!1):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}},e.html_textblock={group:"block",content:"inline*",attrs:u,parseDOM:s.map(([d,p])=>({tag:d,getAttrs:f=>ff(f,n)?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}let l=[...n.inlineTags];if(l.length){let a=new Set(n.inlineTags.values()),c=a.has("span")?"span":[...a][0],u={tag:{default:c},htmlAttrs:{default:null}};e.html_inline_atom={ownStyleTags:o(n.inlineTags),group:"inline",inline:!0,atom:!0,attrs:u,parseDOM:l.map(([d,p])=>({tag:d,priority:65,getAttrs:f=>f.firstChild?!1:r(p,f,!1)})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f]}},t.html_inline={attrs:u,excludes:"",parseDOM:l.map(([d,p])=>({tag:d,priority:p==="span"?40:60,getAttrs:f=>f.firstChild?r(p,f,!0):!1})),toDOM:d=>{let{tag:p,attrs:f}=i(a,c,d.attrs);return[p,f,0]}}}return{nodes:e,marks:t}}function wv(n,e,t,r){let o=(s,l)=>Object.fromEntries(Object.entries(s).map(([a,c])=>[a,xv(a,c,l,t,r)])),i=Sv(t);return{nodes:{...o(n,"node"),...i.nodes},marks:{...o(e,"mark"),...i.marks}}}var mf={create:kv};var Ev=new Set(["lists","link","image","table","code","codesample","preview","searchreplace","fullscreen","help","wordcount","paste","hr","print","textcolor","colorpicker","contextmenu","tabfocus","textpattern","imagetools","powerpaste","importcss","accordion"]),Cv={tinycomments:"comments"},Av=new Set(["selector","target","license_key","api_key","branding","promotion","skin","skin_url","content_css","icons","icons_url","theme","theme_url","base_url","suffix","referrer_policy","convert_urls","relative_urls","remove_script_host","document_base_url","entity_encoding","height","min_height","max_height","width","resize","content_style","setup","init_instance_callback","inline","plugins","toolbar","menubar","statusbar","placeholder","readonly","disabled","block_formats","file_picker_callback","formats","style_formats","style_formats_merge","valid_classes","table_class_list","table_cell_class_list","file_picker_types","language","images_upload_handler","paste_as_text","paste_preprocess","paste_postprocess","invalid_elements","valid_elements","directionality","extended_valid_elements","custom_elements","valid_styles","toolbar_mode","toolbar_sticky","font_family_formats","font_size_formats","line_height_formats","color_map","autosave_interval","autosave_retention","autosave_prefix","quickbars_selection_toolbar","quickbars_insert_toolbar","mentions_fetch","tinycomments_author","tinycomments_author_name"]),ni=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function ri(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,r]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(r??t).trim()}})}function Tv(n){let e="",t=new Promise(o=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),o()},i.onerror=()=>o(),i.readAsDataURL(n)}),r="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>r||(r=URL.createObjectURL(n)),uri:()=>{}}}}var Nv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Ov=new Set(["span","strong","b","em","i","u","s","strike","del","code","sub","sup"]);function oi(n){let e=Array.isArray(n)?n:[n],t=[];for(let r of e){if(!r||typeof r!="object")continue;let o=r,i={};typeof o.block=="string"&&Nv.has(o.block.toLowerCase())&&(i.block=o.block.toLowerCase()),typeof o.inline=="string"&&Ov.has(o.inline.toLowerCase())&&(i.inline=o.inline.toLowerCase()),typeof o.selector=="string"&&(i.selector=o.selector),(typeof o.classes=="string"||Array.isArray(o.classes))&&(i.classes=o.classes),o.styles&&typeof o.styles=="object"&&(i.styles=Object.fromEntries(Object.entries(o.styles).filter(([,s])=>typeof s=="string"&&!s.includes("%")).map(([s,l])=>[s.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`),l]))),(i.block||i.inline||i.selector)&&t.push(i)}return t}function gf(n){return Array.isArray(n)?n.flatMap(e=>{if(!e||typeof e!="object")return[];let t=e,r=String(t.title??"");if(!r)return[];if(Array.isArray(t.items))return[{title:r,items:gf(t.items)}];if(typeof t.format=="string")return[{title:r,format:t.format}];let[o]=oi(t);return o?[{title:r,...o}]:[]}):[]}function bf(n){let e=Object.keys(n).filter(f=>!Av.has(f)),t=[],r=[];for(let f of ni(n.plugins)){let h=Cv[f]??f;Ev.has(f)||(Cr(h)?t.push(h):r.push(f))}let o={plugins:t};n.toolbar===!1?o.toolbar=!1:Array.isArray(n.toolbar)?o.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(o.toolbar=n.toolbar),n.menubar!==void 0&&(o.menubar=n.menubar),typeof n.statusbar=="boolean"&&(o.statusbar=n.statusbar),typeof n.placeholder=="string"&&(o.placeholder=n.placeholder),n.readonly===!0&&(o.editable=!1),typeof n.content_style=="string"&&(o.contentStyle=n.content_style);let i=f=>Array.isArray(f)?f.filter(h=>!!h&&typeof h.title=="string"&&typeof h.value=="string").map(({title:h,value:g})=>({title:h,value:g})):void 0,s=i(n.table_class_list);s&&(o.tableClassList=s);let l=i(n.table_cell_class_list);if(l&&(o.tableCellClassList=l),n.formats&&typeof n.formats=="object"&&(o.formats=Object.fromEntries(Object.entries(n.formats).map(([f,h])=>[f,oi(h)]).filter(([,f])=>f.length))),Array.isArray(n.style_formats)&&(o.styleFormats=gf(n.style_formats),n.style_formats_merge===!0&&(o.styleFormatsMerge=!0)),typeof n.valid_classes=="string"?o.validClasses=ni(n.valid_classes):n.valid_classes&&typeof n.valid_classes=="object"?o.validClasses=Object.values(n.valid_classes).flatMap(f=>ni(f)):o.validClasses=!0,n.content_css!==void 0&&n.content_css!==!1){let f=new Set(["default","dark","document","writer","tinymce-5","tinymce-5-dark"]),h=(Array.isArray(n.content_css)?n.content_css:String(n.content_css).split(",")).map(g=>String(g).trim()).filter(g=>g&&!f.has(g));h.length&&(o.contentCss=h)}n.disabled===!0&&(o.disabled=!0),n.resize!==!1&&(o.resize=n.resize==="both"?"both":!0);let a=ri(n.block_formats);if(a){let f=["p","h1","h2","h3","h4","h5","h6","pre"];o.blockFormats=a.map(({label:h,value:g})=>({label:h,block:g.toLowerCase()})).filter(h=>f.includes(h.block))}if(typeof n.language=="string"&&(o.language=n.language.replace("_","-")),n.toolbar_mode==="sliding"||n.toolbar_mode==="wrap"?o.toolbarMode=n.toolbar_mode:(n.toolbar_mode==="floating"||n.toolbar_mode==="scrolling")&&(o.toolbarMode="sliding"),n.inline===!0&&(o.mode="inline"),n.paste_as_text===!0&&(o.pasteAsText=!0),typeof n.paste_preprocess=="function"){let f=n.paste_preprocess;o.pastePreprocess=(h,g)=>{let m={content:h};return f(g,m),m.content}}typeof n.invalid_elements=="string"&&(o.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(o.validElements=n.valid_elements),typeof n.extended_valid_elements=="string"&&(o.extendedValidElements=n.extended_valid_elements),typeof n.custom_elements=="string"&&(o.customElements=n.custom_elements),(n.directionality==="rtl"||n.directionality==="ltr")&&(o.direction=n.directionality),n.valid_styles&&(o.validStyles=n.valid_styles);let c=ri(n.font_family_formats);c&&(o.fontFamilies=c);let u=ri(n.font_size_formats);u&&(o.fontSizes=u.map(f=>f.value));let d=ri(n.line_height_formats);if(d&&(o.lineHeights=d.map(f=>f.value)),Array.isArray(n.color_map)&&(o.colors=n.color_map.filter((f,h)=>h%2===0).map(f=>f.startsWith("#")?f:`#${f}`)),typeof n.images_upload_handler=="function"){let f=n.images_upload_handler,h=async(g,m)=>{let{ready:b,info:k}=Tv(g);return await b,f(k,m)};o.uploadImage=h}if(typeof n.file_picker_callback=="function"){let f=n.file_picker_callback;typeof n.file_picker_types=="string"&&(o.filePickerTypes=ni(n.file_picker_types).filter(h=>h==="file"||h==="image"||h==="media")),o.filePicker=({type:h,value:g})=>new Promise(m=>f((b,k={})=>m({url:b,...k}),g,{filetype:h,fieldname:"src"}))}let p={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let f=h=>parseInt(String(h),10);p.autosave={...n.autosave_interval?{delay:f(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:f(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(p.quickbars={...n.quickbars_selection_toolbar!==void 0?{selection:n.quickbars_selection_toolbar}:{},...n.quickbars_insert_toolbar!==void 0?{insert:n.quickbars_insert_toolbar}:{}}),typeof n.mentions_fetch=="function"){let f=n.mentions_fetch;p.mentions={fetch:h=>new Promise(g=>f({term:h},g))}}return n.tinycomments_author&&(p.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Object.keys(p).length&&(o.pluginOptions=p),{options:o,unknown:e,missingPlugins:r}}var Dv=0,yf=()=>`nova-compat-field-${++Dv}`;function X(n,e,t){let r=document.createElement(n);return e&&(r.className=e),t!==void 0&&(r.textContent=t),r}function Lv(n){let e=document.createElement("template");return e.innerHTML=n,e.content.querySelectorAll("script, style, iframe, object, embed, link, meta, base, form").forEach(t=>t.remove()),e.content.querySelectorAll("*").forEach(t=>{for(let r of[...t.attributes]){let o=r.value.trim().toLowerCase();(r.name.startsWith("on")||/^(javascript|vbscript|data):/.test(o))&&t.removeAttribute(r.name)}}),e.content}function vf(n,e,t){let r=new Map,o=new Map,i="",s=!1,l=null,a=m=>e.onChange?.(g,{name:m});function c(m,b){let k=yf();b.id=k;let y=X("div","nova-field");if(m.label){let w=X("label","nova-label",m.label);w.htmlFor=k,y.append(w)}return y.append(b),y}function u(m){let b=m.name??"",k=m.enabled!==!1&&m.disabled!==!0;switch(m.type){case"input":case"urlinput":case"colorinput":{let y=X("input","nova-input");return y.type=m.type==="colorinput"?"color":m.type==="urlinput"?"url":"text",m.inputMode&&(y.inputMode=m.inputMode),m.placeholder&&(y.placeholder=m.placeholder),y.disabled=!k,y.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>m.type==="urlinput"?{value:y.value}:y.value,set:w=>{y.value=String(m.type==="urlinput"&&w&&typeof w=="object"?w.value??"":w??"")},focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"textarea":{let y=X("textarea","nova-input");return y.rows=m.maximized?10:4,m.placeholder&&(y.placeholder=m.placeholder),y.disabled=!k,y.addEventListener("input",()=>a(b)),b&&r.set(b,{get:()=>y.value,set:w=>y.value=String(w??""),focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"checkbox":{let y=X("input","nova-checkbox");y.type="checkbox",y.id=yf(),y.disabled=!k,y.addEventListener("change",()=>a(b));let w=X("label",void 0,m.label??"");w.htmlFor=y.id,b&&r.set(b,{get:()=>y.checked,set:L=>y.checked=!!L,focus:()=>y.focus(),setEnabled:L=>y.disabled=!L});let N=X("div","nova-field nova-field-inline");return N.append(y,w),N}case"selectbox":case"listbox":{let y=X("select","nova-input nova-select");for(let w of m.items??[]){let N=X("option",void 0,w.text);N.value=w.value,y.append(N)}return y.disabled=!k,y.addEventListener("change",()=>a(b)),b&&r.set(b,{get:()=>y.value,set:w=>y.value=String(w??""),focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),c(m,y)}case"button":{let y=X("button",m.primary||m.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",m.text??"");return y.type="button",y.disabled=!k,y.addEventListener("click",()=>e.onAction?.(g,{name:b})),b&&r.set(b,{get:()=>{},set:()=>{},focus:()=>y.focus(),setEnabled:w=>y.disabled=!w}),y}case"htmlpanel":{let y=X("div","nova-compat-html");return y.append(Lv(m.html??"")),y}case"alertbanner":{let y=X("p",`nova-compat-alert is-${m.level??"info"}`,m.text??"");return y.setAttribute("role",m.level==="error"?"alert":"status"),y}case"label":{let y=X("div","nova-compat-group");y.append(X("p","nova-label",m.label??""));for(let w of m.items??[]){let N=u(w);N&&y.append(N)}return y}case"grid":case"bar":{let y=X("div","nova-compat-grid"),w=m.type==="bar"?m.items?.length??1:m.columns==="auto"?2:m.columns??2;y.style.gridTemplateColumns=`repeat(${Number(w)||2}, minmax(0, 1fr))`;for(let N of m.items??[]){let L=u(N);L&&y.append(L)}return y}default:return console.warn(`[nova] tinymce-compat: dialog component "${m.type}" is not supported yet`),null}}let d=X("div","nova-compat-dialog nova-form");if(e.body.type==="tabpanel"){let m=X("div","nova-compat-tabs");m.setAttribute("role","tablist"),d.append(m),e.body.tabs.forEach((b,k)=>{let y=b.name??b.title,w=X("button","nova-compat-tab",b.title);w.type="button",w.setAttribute("role","tab");let N=X("div","nova-compat-tabpanel");N.setAttribute("role","tabpanel");for(let L of b.items){let R=u(L);R&&N.append(R)}w.addEventListener("click",()=>g.showTab(y)),o.set(y,{button:w,panel:N}),m.append(w),d.append(N),k===0&&(i=y)})}else for(let m of e.body.items){let b=u(m);b&&d.append(b)}let p=e.buttons??[],f=p.find(m=>m.type==="submit"),h=p.filter(m=>m.type==="custom");if(h.length){let m=X("div","nova-compat-actions");for(let b of h){let k=X("button",b.primary?"nova-button nova-button-primary":"nova-button",b.text);k.type="button",k.disabled=b.enabled===!1,k.addEventListener("click",()=>e.onAction?.(g,{name:b.name??b.text})),b.name&&r.set(b.name,{get:()=>{},set:()=>{},focus:()=>k.focus(),setEnabled:y=>k.disabled=!y}),m.append(k)}d.append(m)}let g={getData:()=>{let m={};return r.forEach((b,k)=>{let y=b.get();y!==void 0&&(m[k]=y)}),m},setData:m=>{for(let[b,k]of Object.entries(m))r.get(b)?.set(k)},close:()=>{s=!0,l?.close()},block:()=>l?.setBusy(!0),unblock:()=>l?.setBusy(!1),focus:m=>r.get(m)?.focus(),disable:m=>r.get(m)?.setEnabled(!1),enable:m=>r.get(m)?.setEnabled(!0),showTab:m=>{if(!o.has(m))return;let b=i;i=m,o.forEach(({button:k,panel:y},w)=>{let N=w===m;k.setAttribute("aria-selected",String(N)),k.tabIndex=N?0:-1,y.hidden=!N}),b&&b!==m&&e.onTabChange?.(g,{newTabName:m,oldTabName:b})},redial:m=>{g.close(),Object.assign(g,t(m))}};return e.initialData&&g.setData(e.initialData),i&&g.showTab(i),l=n.ui.openDialog({title:e.title,body:d,...f?{submitLabel:f.text}:{},...e.size==="large"?{size:"large"}:{},onSubmit:()=>(e.onSubmit?.(g),s),onClose:()=>{s||e.onCancel?.(g),e.onClose?.()}}),g}var Rv=new Ot,ii={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",justifyleft:"alignLeft",justifycenter:"alignCenter",justifyright:"alignRight",justifyfull:"alignJustify",insertunorderedlist:"bulletList",insertorderedlist:"orderedList",indent:"indent",outdent:"outdent",undo:"undo",redo:"redo",removeformat:"clearFormatting",unlink:"unlink",inserthorizontalrule:"horizontalRule",mceblockquote:"blockquote"},Pv={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},Iv={bold:"bold",italic:"italic",underline:"underline","strike-through":"strike",link:"link",unlink:"unlink",image:"image",table:"table",undo:"undo",redo:"redo","align-left":"alignLeft","align-center":"alignCenter","align-right":"alignRight","align-justify":"alignJustify","unordered-list":"bulletList","ordered-list":"orderedList",indent:"indent",outdent:"outdent",quote:"blockquote","code-sample":"codeBlock","horizontal-rule":"horizontalRule","remove-formatting":"clearFormatting",fullscreen:"fullscreen",preview:"preview",sourcecode:"sourceCode",help:"help",print:"print",search:"search",copy:"copy","edit-block":"edit",checkmark:"check",close:"close",upload:"upload",subscript:"subscript",superscript:"superscript","paste-text":"pasteText","text-color":"textColor","highlight-bg-color":"highlight","line-height":"lineHeight"},va={bold:"bold",italic:"italic",underline:"underline",strikethrough:"strike",superscript:"superscript",subscript:"subscript",code:"code",p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock",alignleft:"alignLeft",aligncenter:"alignCenter",alignright:"alignRight",alignjustify:"alignJustify"},Hv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),Bv=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),ka={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function xr(n){console.warn(`[nova] tinymce-compat: editor.dom.${n} changes the editor DOM directly, which NovaProse redraws from its document model. Use setContent, insertContent or editor.formatter instead.`)}var li=new Map;function si(n){if(typeof n!="string"||!n)return;if(li.has(n))return li.get(n);let e=Iv[n]??(n in S?n:void 0);return e?S[e]:void 0}function Fv(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:r=>{e=r,n.core.updateUI()},isEnabled:()=>t,setEnabled:r=>{t=r,n.core.updateUI()},isDisabled:()=>!t,setDisabled:r=>{t=!r,n.core.updateUI()}}}}var Sr=class{constructor(e,t,r,o){E(this,"id");E(this,"core");E(this,"targetElm");E(this,"settings");E(this,"initialized",!1);E(this,"removed",!1);E(this,"handlers",new Map);E(this,"dirty",!1);E(this,"teardowns",[]);E(this,"commands",new Map);E(this,"options",{get:e=>this.settings[e],set:(e,t)=>(this.settings[e]=t,e==="disabled"&&this.core.setDisabled(t===!0),!0),isSet:e=>e in this.settings,isRegistered:()=>!0,register:()=>{}});E(this,"mode",{get:()=>this.core.isEditable()?"design":"readonly",set:e=>this.core.setEditable(e!=="readonly"),isReadOnly:()=>!this.core.isEditable()});E(this,"undoManager",{undo:()=>this.core.exec("undo"),redo:()=>this.core.exec("redo"),hasUndo:()=>this.core.can("undo"),hasRedo:()=>this.core.can("redo"),add:()=>null,clear:()=>{},transact:e=>(e(),null),ignore:e=>e()});E(this,"selection",{getContent:(e={})=>{let{state:t}=this.core.view,{from:r,to:o}=t.selection;return e.format==="text"?t.doc.textBetween(r,o,`
|
|
40
|
+
`):Rv.serializeFragment(t.selection.content().content)},setContent:e=>this.insertContent(e),getNode:()=>{let{from:e}=this.core.view.state.selection,{node:t}=this.core.view.domAtPos(e);return t instanceof Element?t:t.parentElement},getStart:()=>this.selection.getNode(),getEnd:()=>this.selection.getNode(),isCollapsed:()=>this.core.view.state.selection.empty,collapse:(e=!1)=>{let{state:t,dispatch:r}=this.core.view,o=e?t.selection.from:t.selection.to;r(t.tr.setSelection(I.near(t.doc.resolve(o))))},setCursorLocation:(e,t=0)=>{let{view:r}=this.core;if(!e||!r.dom.contains(e))return;let o=r.posAtDOM(e,t);r.dispatch(r.state.tr.setSelection(I.near(r.state.doc.resolve(o))))},select:(e,t=!1)=>{let{view:r}=this.core;if(!r.dom.contains(e))return;let o=r.posAtDOM(e,0),i=r.posAtDOM(e,e.childNodes.length),{doc:s}=r.state,l=!t&&e instanceof HTMLImageElement?P.create(s,Math.max(0,o-(s.resolve(o).nodeAfter?0:1))):I.between(s.resolve(o),s.resolve(i));r.dispatch(r.state.tr.setSelection(l))}});E(this,"notificationManager",{open:e=>this.core.ui.notify({text:e.text,...e.type?{type:e.type}:{},...e.timeout!==void 0?{timeout:e.timeout}:{}}),close:()=>{}});E(this,"windowManager",{alert:(e,t)=>{let r=document.createElement("p");r.textContent=e,this.core.ui.openDialog({title:"",body:r,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let r=document.createElement("p");r.textContent=e;let o=!1;this.core.ui.openDialog({title:"",body:r,submitLabel:"OK",onSubmit:()=>(o=!0,!0),onClose:()=>t?.(o)})},open:e=>vf(this.core,e,t=>this.windowManager.open(t))});E(this,"ui",{registry:{addIcon:(e,t)=>{li.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let r=[];t.fetch(i=>r=i);let o=si(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...o?{icon:o}:{text:t.text??e},items:()=>(t.fetch(i=>r=i),r.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let r=si(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...r?{icon:r}:{},onAction:()=>t.onAction?.({})})},addContextToolbar:(e,t)=>{this.core.ui.registry.addContextToolbar(e,{label:t.label??e,items:t.items,position:t.position==="node"?"node":"selection",predicate:()=>{let r=this.selection.getNode();return!!r&&this.getBody().contains(r)&&t.predicate(r)}})},addSidebar:(e,t)=>{let r=null,o={element:()=>r},i=si(t.icon);this.core.ui.registry.addSidebar(e,{title:t.tooltip??e,...i?{icon:i}:{},render:s=>{r=s;let l=t.onSetup?.(o);return typeof l=="function"?l:void 0},onShow:()=>t.onShow?.(o),onHide:()=>t.onHide?.(o)})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}});E(this,"dom",{select:(e,t)=>[...(t??this.getBody()).querySelectorAll(e)],get:e=>typeof e=="string"?this.getBody().querySelector(`#${CSS.escape(e)}`):e,getParent:(e,t)=>{let r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();){if(typeof t=="string"?r.matches(t):t(r))return r;r=r.parentElement}return null},getParents:(e,t)=>{let r=[],o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();)(!t||o.matches(t))&&r.push(o),o=o.parentElement;return r},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,r="")=>e?.getAttribute(t)??r,hasClass:(e,t)=>!!e?.classList.contains(t),getStyle:(e,t)=>e instanceof HTMLElement?e.style.getPropertyValue(t):"",getRoot:()=>this.getBody(),encode:e=>e.replace(/[&<>"']/g,t=>`&#${t.charCodeAt(0)};`),decode:e=>{let t=document.createElement("textarea");return t.innerHTML=e,t.value},create:(e,t={},r)=>{let o=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||o.setAttribute(i,s);return r!==void 0&&(o.textContent=r),o},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>xr("setAttrib"),addClass:()=>xr("addClass"),removeClass:()=>xr("removeClass"),setStyle:()=>xr("setStyle"),remove:()=>xr("remove")});E(this,"formatter",{apply:(e,t={})=>this.applyFormat(e,t,"apply"),remove:e=>this.applyFormat(e,{},"remove"),toggle:(e,t={})=>this.applyFormat(e,t,this.formatter.match(e)?"remove":"apply"),match:e=>{if(this.core.formatter.has(e))return this.core.formatter.match(e);let t=e.toLowerCase();if(Hv.has(t))return this.blockMatches(t);let r=va[t];if(r)return this.core.isActive(r);let o=ka[t];if(!o)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[o];return a||!c?Ye(i,o)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>this.core.formatter.has(e)||e.toLowerCase()in va||e.toLowerCase()in ka,register:(e,t)=>{let r=typeof e=="string"?[[e,t]]:Object.entries(e);for(let[o,i]of r){let s=oi(i);s.length?this.core.formatter.register(o,s):console.warn(`[nova] tinymce-compat: format "${o}" is not supported yet`)}},unregister:e=>this.core.formatter.unregister(e),get:e=>this.core.formatter.get(e)});this.core=e,this.targetElm=t,this.id=r,this.settings=o}getContent(e={}){let t={format:e.format??"html",content:""};return t.content=t.format==="text"?this.core.getText():this.core.getHTML(),this.fire("GetContent",t),t.content}setContent(e,t={}){let r={content:e,...t};return this.fire("BeforeSetContent",r),this.core.setContent(r.content),this.fire("SetContent",r),r.content}insertContent(e){this.core.insertContent(e)}resetContent(e){this.core.setContent(e??this.settings.__initialContent??"",{addToHistory:!1}),this.setDirty(!1)}getBody(){return this.core.view.dom}getElement(){return this.targetElm}getContainer(){return this.core.root}getContentAreaContainer(){return this.core.view.dom.parentElement??this.core.root}getDoc(){return this.core.root.ownerDocument}getWin(){return this.core.root.ownerDocument.defaultView}queryCommandValue(e){return e.toLowerCase()==="togglesidebar"?this.core.ui.sidebar.active??"":""}execCommand(e,t,r){let o=e.toLowerCase(),i=!1;if(ii[o])i=this.core.exec(ii[o]);else if(o==="formatblock"||o==="mcetoggleformat"){let s=Pv[String(r??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(o==="mceinsertcontent"||o==="inserthtml")this.insertContent(String(r??"")),i=!0;else if(o==="togglesidebar")this.core.ui.sidebar.toggle(String(r??"")),i=!0;else if(o==="mcesetcontent")this.setContent(String(r??"")),i=!0;else if(o==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new se(s.doc))),i=!0}else if(o==="mcecleanup")i=!0;else{let s=this.commands.get(o);s&&(s(t,r),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:r}),i}queryCommandState(e){let t=ii[e.toLowerCase()];return t?this.core.isActive(t):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in ii||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||this.commands.has(t)}addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,r=!1){for(let o of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(o)??new Set;r?this.handlers.set(o,new Set([t,...i])):this.handlers.set(o,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let r of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(r)?.delete(t):this.handlers.delete(r);return this}once(e,t){let r=o=>(this.off(e,r),t(o));return this.on(e,r)}fire(e,t={}){let r=Object.assign(t,{type:e.toLowerCase(),target:this});for(let o of[...this.handlers.get(e.toLowerCase())??[]])try{o(r)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return r}fireNative(e,t){for(let r of[...this.handlers.get(e)??[]])try{r(t)}catch(o){console.error(`[nova] tinymce-compat: "${e}" handler failed`,o)}}static registerIcon(e,t){li.set(e,t)}dispatch(e,t){return this.fire(e,t)}hasEventListeners(e){return(this.handlers.get(e.toLowerCase())?.size??0)>0}isDirty(){return this.dirty}setDirty(e){let t=this.dirty!==e;this.dirty=e,t&&e&&this.fire("Dirty")}save(){let e=this.getContent(),t=this.fire("SaveContent",{content:e});return this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.value=String(t.content)),this.setDirty(!1),String(t.content)}focus(){this.core.focus()}hasFocus(){return this.core.view.hasFocus()}hide(){this.core.root.hidden=!0,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!1)}show(){this.core.root.hidden=!1,this.targetElm instanceof HTMLTextAreaElement&&(this.targetElm.hidden=!0)}isHidden(){return this.core.root.hidden===!0}getParam(e,t){return e in this.settings?this.settings[e]:t}addButton(e,t,r){let{api:o,state:i}=Fv(this);t.enabled===!1&&o.setEnabled(!1),t.active&&o.setActive(!0);let s=si(t.icon);if(this.core.ui.registry.addButton(e,{tooltip:t.tooltip??t.text??e,...s?{icon:s}:{text:t.text??e},isEnabled:()=>i.enabled,...r?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(o)}),t.onSetup){let l=()=>{let a=t.onSetup(o);typeof a=="function"&&this.teardowns.push(a)};this.initialized?l():this.once("init",l)}}blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let o=t.depth;o>0;o-=1){let i=t.node(o),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(o===t.depth){if(e==="p")return s==="paragraph";if(e==="pre")return s==="code_block";if(/^h[1-6]$/.test(e))return s==="heading"&&i.attrs.level===Number(e[1])}}let r=null;if(this.core.view.state.doc.descendants(o=>r||!o.isTextblock?!r:(r={name:o.type.name,level:o.attrs.level},!1)),!t.depth&&r){let o=r;if(e==="p")return o.name==="paragraph";if(e==="pre")return o.name==="code_block";if(/^h[1-6]$/.test(e))return o.name==="heading"&&o.level===Number(e[1])}return!1}applyFormat(e,t,r){if(this.core.formatter.has(e)){r==="apply"?this.core.formatter.apply(e):this.core.formatter.remove(e);return}let o=e.toLowerCase(),i=va[o];if(i){let l=this.formatter.match(o);Bv.has(o)?r==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):r==="apply"!==l&&this.core.exec(i);return}let s=ka[o];if(s){this.core.exec(ut(s,r==="apply"?t.value??null:null));return}console.warn(`[nova] tinymce-compat: format "${e}" is not supported yet`)}remove(){if(this.removed)return;this.fire("remove"),this.save(),this.teardowns.splice(0).forEach(t=>t()),this.removed=!0,this.core.destroy(),this.core.root.remove(),this.settings.__wrapper?.remove(),this.targetElm.hidden=!1,this.off()}destroy(){this.remove()}};var kf=new Set;function Ma(n){kf.has(n)||(kf.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var zv=0,ai=n=>typeof n=="number"?`${n}px`:String(n);function _v(){ea(mf);let n=[],e=new Map,t=null;async function r(i,s){let l=n.find(L=>L.targetElm===i&&!L.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=bf(s);c.length&&Ma(`options not supported yet: ${c.join(", ")}`);let d=String(Array.isArray(s.plugins)?s.plugins.join(" "):s.plugins??"").split(/[\s,]+/).filter(L=>e.has(L)),p=u.filter(L=>!e.has(L));p.length&&Ma(`plugins not available: ${p.join(", ")}`);let f=i.id||`mce_${++zv}`;i.id||(i.id=f);let h=i instanceof HTMLTextAreaElement,g=h?i.value:i.innerHTML,m={...s,__initialContent:g},b;s.inline===!0&&!h?(i.replaceChildren(),b=i):(b=document.createElement("div"),b.className="nova-compat",i.after(b),i.hidden=!0,m.__wrapper=b);let k,y=ti({...a,element:b,content:g,setup:L=>{k=new Sr(L,i,f,m);for(let R of d)try{e.get(R)(k,"")}catch(O){console.error(`[nova] tinymce-compat: plugin "${R}" failed`,O)}s.setup?.(k)}});s.height!==void 0&&(y.root.style.height=ai(s.height)),s.min_height!==void 0&&(y.root.style.minHeight=ai(s.min_height)),s.max_height!==void 0&&(y.root.style.maxHeight=ai(s.max_height)),s.width!==void 0&&(y.root.style.width=ai(s.width));let w=!1;y.on("change",()=>{k.setDirty(!0),w=!0,k.fire("input")}),y.on("selectionChange",()=>{k.fire("NodeChange",{element:k.selection.getNode(),selectionChange:!0})}),y.on("focus",()=>{t=k,w=!1,k.fire("focus")}),y.on("blur",()=>{w&&k.fire("change",{level:{content:k.getContent()}}),w=!1,k.fire("blur")});for(let L of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])y.view.dom.addEventListener(L,R=>k.fireNative(L,R));return(h?i.form:i.closest("form"))?.addEventListener("submit",()=>k.save()),k.on("remove",()=>{let L=n.indexOf(k);L>=0&&n.splice(L,1),t===k&&(t=n[0]??null)}),n.push(k),t??(t=k),await y.ready,k.removed||(k.initialized=!0,k.fire("init"),s.init_instance_callback?.(k)),k}return{majorVersion:"7",minorVersion:"0.0",novaprose:!0,get activeEditor(){return t},get editors(){return[...n]},async init(i){document.readyState==="loading"&&await new Promise(a=>document.addEventListener("DOMContentLoaded",a,{once:!0}));let s=i.target?[i.target]:i.selector?[...document.querySelectorAll(i.selector)]:[];s.length||Ma(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await r(a,i));return l},get:(i=>i===void 0?[...n]:typeof i=="number"?n[i]??null:n.find(s=>s.id===i)??null),remove(i){(i===void 0?[...n]:typeof i=="string"?n.filter(l=>l.id===i.replace(/^#/,"")||l.targetElm.matches(i)):[i]).forEach(l=>l.remove())},triggerSave(){n.forEach(i=>i.save())},execCommand(i,s,l){return t?.execCommand(i,s,l)??!1},PluginManager:{add:(i,s)=>{e.set(i,s)},get:i=>e.get(i),requireLangPack:()=>{},urls:{}},IconManager:{add:(i,s)=>{for(let[l,a]of Object.entries(s.icons??{}))Sr.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var Mf=_v();Hi("ru",sf);var xf=document.currentScript;if(xf?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=xf.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=Mf;var re=globalThis.__novaprose_tinymce={};re["node_modules/.pnpm/prosemirror-history@1.5.2/node_modules/prosemirror-history/dist/index.js"]=Qs;re["node_modules/.pnpm/prosemirror-inputrules@1.7.0/node_modules/prosemirror-inputrules/dist/index.js"]=Al;re["node_modules/.pnpm/prosemirror-keymap@1.2.3/node_modules/prosemirror-keymap/dist/index.js"]=gs;re["node_modules/.pnpm/prosemirror-model@1.25.13/node_modules/prosemirror-model/dist/index.js"]=xi;re["node_modules/.pnpm/prosemirror-state@1.4.4/node_modules/prosemirror-state/dist/index.js"]=Ri;re["node_modules/.pnpm/prosemirror-transform@1.12.7/node_modules/prosemirror-transform/dist/index.js"]=Ni;re["node_modules/.pnpm/prosemirror-view@1.43.1/node_modules/prosemirror-view/dist/index.js"]=hs;re["packages/core/src/commands.ts"]=ol;re["packages/core/src/comments.ts"]=Ms;re["packages/core/src/editor.ts"]=ma;re["packages/core/src/image.ts"]=Sl;re["packages/core/src/link.ts"]=Dl;re["packages/core/src/plugins.ts"]=pi;re["packages/core/src/plugins/shared.ts"]=Fi;re["packages/core/src/schema.ts"]=qs;re["packages/core/src/serializer.ts"]=aa;re["packages/core/src/tables.ts"]=Jl;re["packages/core/src/ui/dom.ts"]=Ii;re["packages/core/src/ui/icons.ts"]=fi;re["packages/core/src/url.ts"]=Ps;})();
|
|
41
|
+
//# sourceMappingURL=tinymce.global.js.map
|