@novaprose/tinymce-compat 0.5.3 → 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 +20 -8
- package/dist/index.cjs +401 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -8
- package/dist/index.d.ts +29 -8
- package/dist/index.js +399 -255
- package/dist/index.js.map +1 -1
- package/dist/novaprose.css +291 -29
- 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 +27 -24
- package/dist/tinymce.global.js.map +7 -1
- package/package.json +11 -6
package/dist/tinymce.global.js
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
"use strict";(()=>{var Mh=Object.defineProperty;var D=(n,e)=>()=>(n&&(e=n(n=0)),e);var He=(n,e)=>{for(var t in e)Mh(n,t,{get:e[t],enumerable:!0})};function ae(n,e){ti.set(n,e)}function ni(n){return ti.has(n)}function kl(n){return typeof n=="function"}function Ml(n){let e=[],t=[],o=[];for(let r of n)if(typeof r=="string"){let i=ti.get(r);i?kl(i)?t.push(i):e.push(i):o.push(`Plugin "${r}" is not registered`)}else kl(r)?t.push(r):e.push(r);return{plugins:e,loaders:t,errors:o}}function oi(n,e=new Set){let t=new Map(n.map(l=>[l.name,l])),o=[],r=[],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 r.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 r.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"),o.push(l),!0};for(let l of n)s(l,[]);return{ordered:o,errors:r}}async function Sl(n){let e=await n();return"default"in e&&e.default?e.default:e}var ti,Do=D(()=>{"use strict";ti=new Map});var O,k,j=D(()=>{"use strict";O=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>`,k={undo:O('<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:O('<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:O('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),italic:O('<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:O('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),strike:O('<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:O('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),subscript:O('<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:O('<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:O('<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:O('<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:O('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'),outdent:O('<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'),blockquote:O('<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'),codeBlock:O('<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:O('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),alignCenter:O('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),alignRight:O('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),alignJustify:O('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),horizontalRule:O('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),link:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'),trash:O('<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:O('<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'),h1:O('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),h2:O('<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:O('<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:O('<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:O('<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'),rowBefore:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'),rowHeader:O('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),colHeader:O('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),sort:O('<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:O('<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'),cellProps:O('<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:O('<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:O('<path d="m18 15-6-6-6 6" />'),search:O('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),fullscreen:O('<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:O('<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:O('<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:O('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),help:O('<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:O('<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:O('<path d="M20 6 9 17l-5-5" />'),close:O('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),chevronDown:O('<path d="m6 9 6 6 6-6" />'),more:O('<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'),textColor:O('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),highlight:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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" />'),anchor:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),pageBreak:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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:O('<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 ri,Cl=D(()=>{"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 o=t&&t!=n?this.remove(t):this,r=o.find(n),i=o.content.slice();return r==-1?i.push(t||n,e):(i[r+1]=e,t&&(i[r]=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 o=this.remove(e),r=o.content.slice(),i=o.find(n);return r.splice(i==-1?r.length:i,0,e,t),new ye(r)},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)};ri=ye});function Hl(n,e,t){for(let o=0;;o++){if(o==n.childCount||o==e.childCount)return n.childCount==e.childCount?null:t;let r=n.child(o),i=e.child(o);if(r==i){t+=r.nodeSize;continue}if(!r.sameMarkup(i))return t;if(r.isText&&r.text!=i.text){let s=r.text,l=i.text,a=0;for(;s[a]==l[a];a++)t++;return a&&a<s.length&&a<l.length&&$l(s.charCodeAt(a-1))&&Fl(s.charCodeAt(a))&&t--,t}if(r.content.size||i.content.size){let s=Hl(r.content,i.content,t+1);if(s!=null)return s}t+=r.nodeSize}}function zl(n,e,t,o){for(let r=n.childCount,i=e.childCount;;){if(r==0||i==0)return r==i?null:{a:t,b:o};let s=n.child(--r),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,o-=a;continue}if(!s.sameMarkup(l))return{a:t,b:o};if(s.isText&&s.text!=l.text){let c=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--,o--;return d&&f&&d<c.length&&$l(c.charCodeAt(d-1))&&Fl(c.charCodeAt(d))&&(t++,o++),{a:t,b:o}}if(s.content.size||l.content.size){let c=zl(s.content,l.content,t-1,o-1);if(c)return c}t-=a,o-=a}}function Fl(n){return n>=56320&&n<57344}function $l(n){return n>=55296&&n<56320}function Ro(n,e){return ii.index=n,ii.offset=e,ii}function Bo(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let o=0;o<n.length;o++)if(!Bo(n[o],e[o]))return!1}else{for(let o in n)if(!(o in e)||!Bo(n[o],e[o]))return!1;for(let o in e)if(!(o in n))return!1}return!0}function _l(n,e,t){let{index:o,offset:r}=n.findIndex(e),i=n.maybeChild(o),{index:s,offset:l}=n.findIndex(t);if(r==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(o!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(o,i.copy(_l(i.content,e-r-1,t-r-1)))}function Vl(n,e,t,o,r,i){let{index:s,offset:l}=n.findIndex(e),a=n.maybeChild(s);if(l==e||a.isText)return i&&o<=0&&r<=0&&!i.canReplace(s,s,t)?null:n.cut(0,e).append(t).append(n.cut(e));let c=Vl(a.content,e-l-1,t,s==0?o-1:0,s==n.childCount-1?r-1:0,a);return c&&n.replaceChild(s,a.copy(c))}function Sh(n,e,t){if(t.openStart>n.depth)throw new wt("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new wt("Inconsistent open depths");return ql(n,e,t,0)}function ql(n,e,t,o){let r=n.index(o),i=n.node(o);if(r==e.index(o)&&o<n.depth-t.openStart){let s=ql(n,e,t,o+1);return i.copy(i.content.replaceChild(r,s))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==o&&e.depth==o){let s=n.parent,l=s.content;return Ht(s,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:s,end:l}=Ch(t,n);return Ht(i,Ul(n,s,l,e,o))}else return Ht(i,Ho(n,e,o))}function Wl(n,e){if(!e.type.compatibleContent(n.type))throw new wt("Cannot join "+e.type.name+" onto "+n.type.name)}function si(n,e,t){let o=n.node(t);return Wl(o,e.node(t)),o}function Bt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function $n(n,e,t,o){let r=(e||n).node(t),i=0,s=e?e.index(t):r.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(Bt(n.nodeAfter,o),i++));for(let l=i;l<s;l++)Bt(r.child(l),o);e&&e.depth==t&&e.textOffset&&Bt(e.nodeBefore,o)}function Ht(n,e){if(!n.type.validContent(e))throw new wt("Invalid content for node "+n.type.name);return n.copy(e)}function Ul(n,e,t,o,r){let i=n.depth>r&&si(n,e,r+1),s=o.depth>r&&si(t,o,r+1),l=[];return $n(null,n,r,l),i&&s&&e.index(r)==t.index(r)?(Wl(i,s),Bt(Ht(i,Ul(n,e,t,o,r+1)),l)):(i&&Bt(Ht(i,Ho(n,e,r+1)),l),$n(e,t,r,l),s&&Bt(Ht(s,Ho(t,o,r+1)),l)),$n(o,null,r,l),new A(l)}function Ho(n,e,t){let o=[];if($n(null,n,t,o),n.depth>t){let r=si(n,e,t+1);Bt(Ht(r,Ho(n,e,t+1)),o)}return $n(e,null,t,o),new A(o)}function Ch(n,e){let t=e.depth-n.openStart,r=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)r=e.node(i).copy(A.from(r));return{start:r.resolveNoCache(n.openStart+t),end:r.resolveNoCache(r.content.size-n.openEnd-t)}}function jl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}function Tl(n,e,t,o){for(let r in e)if(!(r in n))throw new RangeError(`Unsupported attribute ${r} for ${t} of type ${o}`);for(let r in n)n[r].validate&&n[r].validate(e[r])}function Kl(n){let e=[];do e.push(Th(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Th(n){let e=[];do e.push(Nh(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Nh(n){let e=Dh(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=Oh(n,e);else break;return e}function Nl(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Oh(n,e){let t=Nl(n),o=t;return n.eat(",")&&(n.next!="}"?o=Nl(n):o=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:o,expr:e}}function Lh(n,e){let t=n.nodeTypes,o=t[e];if(o)return[o];let r=[];for(let i in t){let s=t[i];s.isInGroup(e)&&r.push(s)}return r.length==0&&n.err("No node type or group '"+e+"' found"),r}function Dh(n){if(n.eat("(")){let e=Kl(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=Lh(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 Rh(n){let e=[[]];return r(i(n,0),t()),e;function t(){return e.push([])-1}function o(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function r(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;r(c,l=t())}else if(s.type=="star"){let a=t();return o(l,a),r(i(s.expr,a),a),[o(a)]}else if(s.type=="plus"){let a=t();return r(i(s.expr,l),a),r(i(s.expr,a),a),[o(a)]}else{if(s.type=="opt")return[o(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c<s.min;c++){let u=t();r(i(s.expr,a),u),a=u}if(s.max==-1)r(i(s.expr,a),a);else for(let c=s.min;c<s.max;c++){let u=t();o(a,u),r(i(s.expr,a),u),a=u}return[o(a)]}else{if(s.type=="name")return[o(l,void 0,s.value)];throw new Error("Unknown expr type")}}}}function Jl(n,e){return e-n}function Ol(n,e){let t=[];return o(e),t.sort(Jl);function o(r){let i=n[r];if(i.length==1&&!i[0].term)return o(i[0].to);t.push(r);for(let s=0;s<i.length;s++){let{term:l,to:a}=i[s];!l&&t.indexOf(a)==-1&&o(a)}}}function Ih(n){let e=Object.create(null);return t(Ol(n,0));function t(o){let r=[];o.forEach(s=>{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<r.length;u++)r[u][0]==l&&(c=r[u][1]);Ol(n,a).forEach(u=>{c||r.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=e[o.join(",")]=new Ft(o.indexOf(n.length-1)>-1);for(let s=0;s<r.length;s++){let l=r[s][1].sort(Jl);i.next.push({type:r[s][0],next:e[l.join(",")]||t(l)})}return i}}function Ph(n,e){for(let t=0,o=[n];t<o.length;t++){let r=o[t],i=!r.validEnd,s=[];for(let l=0;l<r.next.length;l++){let{type:a,next:c}=r.next[l];s.push(a.name),i&&!(a.isText||a.hasRequiredAttrs())&&(i=!1),o.indexOf(c)==-1&&o.push(c)}i&&e.err("Only non-generatable nodes ("+s.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Gl(n){let e=Object.create(null);for(let t in n){let o=n[t];if(!o.hasDefault)return null;e[t]=o.default}return e}function Xl(n,e){let t=Object.create(null);for(let o in n){let r=n[o],i=e&&e[o];if(i===void 0)if(r.hasDefault)i=r.default;else throw new RangeError("No value supplied for attribute "+o);else r.validate&&r.validate(i);t[o]=i}return t}function Yl(n,e){let t=Object.create(null);if(e)for(let o in e)t[o]=new ui(n,o,e[o]);return t}function Bh(n,e,t){let o=t.split("|");return r=>{let i=r===null?"null":typeof r;if(o.indexOf(i)<0)throw new RangeError(`Expected value of type ${o} for attribute ${e} on type ${n}, got ${i}`)}}function Ll(n,e){let t=[];for(let o=0;o<e.length;o++){let r=e[o],i=n.marks[r],s=i;if(i)t.push(i);else for(let l in n.marks){let a=n.marks[l];(r=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(r)>-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[o]+"'")}return t}function Hh(n){return n.tag!=null}function zh(n){return n.style!=null}function Dl(n,e,t){return e!=null?(e?Wn:0)|(e==="full"?di:0):n&&n.whitespace=="pre"?Wn|di:t&~_n}function $h(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let o=e.nodeType==1?e.nodeName.toLowerCase():null;o&&Zl.hasOwnProperty(o)&&t?(t.appendChild(e),e=t):o=="li"?t=e:o&&(t=null)}}function _h(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Rl(n){let e={};for(let t in n)e[t]=n[t];return e}function Il(n,e){let t=e.schema.nodes;for(let o in t){let r=t[o];if(!r.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(r.contentMatch))return!0}}function Pl(n){let e={};for(let t in n){let o=n[t].spec.toDOM;o&&(e[t]=o)}return e}function Io(n){return n.document||window.document}function Vh(n){let e=Bl.get(n);return e===void 0&&Bl.set(n,e=qh(n)),e}function qh(n){let e=null;function t(o){if(o&&typeof o=="object")if(Array.isArray(o))if(typeof o[0]=="string")e||(e=[]),e.push(o);else for(let r=0;r<o.length;r++)t(o[r]);else for(let r in o)t(o[r])}return t(n),e}function Po(n,e,t,o){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let r=e[0],i;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(o&&(i=Vh(o))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s=r.indexOf(" ");s>0&&(t=r.slice(0,s),r=r.slice(s+1));let l,a=t?n.createElementNS(t,r):n.createElement(r),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}=Po(n,f,t,o);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var A,ii,q,wt,L,zo,li,Eh,El,zt,Ah,Le,Al,ai,Ft,ci,rt,ui,Vn,qn,xt,Ql,Fh,Zl,Wn,di,_n,un,Fo,Ue,Bl,ce=D(()=>{"use strict";Cl();A=class n{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let o=0;o<e.length;o++)this.size+=e[o].nodeSize}nodesBetween(e,t,o,r=0,i){for(let s=0,l=0;l<t;s++){let a=this.content[s],c=l+a.nodeSize;if(c>e&&o(a,r+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),o,r+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,o,r){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?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&o&&(s?s=!1:i+=o),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,o=e.firstChild,r=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(o)&&(r[r.length-1]=t.withText(t.text+o.text),i=1);i<e.content.length;i++)r.push(e.content[i]);return new n(r,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let o=[],r=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))),o.push(l),r+=l.nodeSize),s=a}return new n(o,r)}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 o=this.content[e];if(o==t)return this;let r=this.content.slice(),i=this.size+t.nodeSize-o.nodeSize;return r[e]=t,new n(r,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,o=0;t<this.content.length;t++){let r=this.content[t];e(r,o,t),o+=r.nodeSize}}findDiffStart(e,t=0){return Hl(this,e,t)}findDiffEnd(e,t=this.size,o=e.size){return zl(this,e,t,o)}findIndex(e){if(e==0)return Ro(0,e);if(e==this.size)return Ro(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,o=0;;t++){let r=this.child(t),i=o+r.nodeSize;if(i>=e)return i==e?Ro(t+1,i):Ro(t,o);o=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,o=0;for(let r=0;r<e.length;r++){let i=e[r];o+=i.nodeSize,r&&i.isText&&e[r-1].sameMarkup(i)?(t||(t=e.slice(0,r)),t[t.length-1]=i.withText(t[t.length-1].text+i.text)):t&&t.push(i)}return new n(t||e,o)}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);ii={index:0,offset:0};q=class n{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,o=!1;for(let r=0;r<e.length;r++){let i=e[r];if(this.eq(i))return e;if(this.type.excludes(i.type))t||(t=e.slice(0,r));else{if(i.type.excludes(this.type))return e;!o&&i.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),o=!0),t&&t.push(i)}}return t||(t=e.slice()),o||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&Bo(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let o=e.marks[t.type];if(!o)throw new RangeError(`There is no mark type ${t.type} in this schema`);return o.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let o=0;o<e.length;o++)if(!e[o].eq(t[o]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return n.none;if(e instanceof n)return[e];let t=e.slice();return t.sort((o,r)=>o.type.rank-r.type.rank),t}};q.none=[];wt=class extends Error{},L=class n{constructor(e,t,o){this.content=e,this.openStart=t,this.openEnd=o}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let o=Vl(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return o&&new n(o,this.openStart,this.openEnd)}removeBetween(e,t){return new n(_l(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return n.empty;let o=t.openStart||0,r=t.openEnd||0;if(typeof o!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(A.fromJSON(e,t.content),o,r)}static maxOpen(e,t=!0){let o=0,r=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)o++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)r++;return new n(e,o,r)}};L.empty=new L(A.empty,0,0);zo=class n{constructor(e,t,o){this.pos=e,this.path=t,this.parentOffset=o,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let o=this.pos-this.path[this.path.length-1],r=e.child(t);return o?e.child(t).cut(o):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let o=this.path[t*3],r=t==0?0:this.path[t*3-1]+1;for(let i=0;i<e;i++)r+=o.child(i).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return q.none;if(this.textOffset)return e.child(t).marks;let o=e.maybeChild(t-1),r=e.maybeChild(t);if(!o){let l=o;o=r,r=l}let i=o.marks;for(var s=0;s<i.length;s++)i[s].type.spec.inclusive===!1&&(!r||!i[s].isInSet(r.marks))&&(i=i[s--].removeFromSet(i));return i}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let o=t.marks,r=e.parent.maybeChild(e.index());for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!r||!o[i].isInSet(r.marks))&&(o=o[i--].removeFromSet(o));return o}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let o=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);o>=0;o--)if(e.pos<=this.end(o)&&(!t||t(this.node(o))))return new zt(this,e,o);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let o=[],r=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(o.push(s,l,r+a),!c||(s=s.child(l),s.isText))break;i=c-1,r+=a+1}return new n(t,o,i)}static resolveCached(e,t){let o=El.get(e);if(o)for(let i=0;i<o.elts.length;i++){let s=o.elts[i];if(s.pos==t)return s}else El.set(e,o=new li);let r=o.elts[o.i]=n.resolve(e,t);return o.i=(o.i+1)%Eh,r}},li=class{constructor(){this.elts=[],this.i=0}},Eh=12,El=new WeakMap,zt=class{constructor(e,t,o){this.$from=e,this.$to=t,this.depth=o}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}},Ah=Object.create(null),Le=class n{constructor(e,t,o,r=q.none){this.type=e,this.attrs=t,this.marks=r,this.content=o||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,o,r=0){this.content.nodesBetween(e,t,o,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,o,r){return this.content.textBetween(e,t,o,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,o){return this.type==e&&Bo(this.attrs,t||e.defaultAttrs||Ah)&&q.sameSet(this.marks,o||q.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,o=!1){if(e==t)return L.empty;let r=this.resolve(e),i=this.resolve(t),s=o?0:r.sharedDepth(t),l=r.start(s),c=r.node(s).content.cut(r.pos-l,i.pos-l);return new L(c,r.depth-s,i.depth-s)}replace(e,t,o){return Sh(this.resolve(e),this.resolve(t),o)}nodeAt(e){for(let t=this;;){let{index:o,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(o),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:o}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:o}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:o}=this.content.findIndex(e);if(o<e)return{node:this.content.child(t),index:t,offset:o};let r=this.content.child(t-1);return{node:r,index:t-1,offset:o-r.nodeSize}}resolve(e){return zo.resolveCached(this,e)}resolveNoCache(e){return zo.resolve(this,e)}rangeHasMark(e,t,o){let r=!1;return t>e&&this.nodesBetween(e,t,i=>(o.isInSet(i.marks)&&(r=!0),!r)),r}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()+")"),jl(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,o=A.empty,r=0,i=o.childCount){let s=this.contentMatchAt(e).matchFragment(o,r,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=r;a<i;a++)if(!this.type.allowsMarks(o.child(a).marks))return!1;return!0}canReplaceWith(e,t,o,r){if(r&&!this.type.allowsMarks(r))return!1;let i=this.contentMatchAt(e).matchType(o),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),Tl(this.type.attrs,this.attrs,"node",this.type.name);let e=q.none;for(let t=0;t<this.marks.length;t++){let o=this.marks[t];Tl(o.type.attrs,o.attrs,"mark",o.type.name),e=o.addToSet(e)}if(!q.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let o;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");o=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,o)}let r=A.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,o)}};Le.prototype.text=void 0;Al=(()=>{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)})(),ai=class n extends Le{constructor(e,t,o,r){if(super(e,t,null,r),!o)throw new RangeError("Empty text nodes are not allowed");this.text=o}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jl(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return Al(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(Al(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}};Ft=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let o=new ci(e,t);if(o.next==null)return n.empty;let r=Kl(o);o.next&&o.err("Unexpected trailing text");let i=Ih(Rh(r));return Ph(i,o),i}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,o=e.childCount){let r=this;for(let i=t;r&&i<o;i++)r=r.matchType(e.child(i).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let o=0;o<e.next.length;o++)if(this.next[t].type==e.next[o].type)return!0;return!1}fillBefore(e,t=!1,o=0){let r=[this];function i(s,l){let a=s.matchFragment(e,o);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())&&r.indexOf(d)==-1){r.push(d);let f=i(d,l.concat(u));if(f)return f}}return null}return i(this,[])}findWrapping(e){for(let o=0;o<this.wrapCache.length;o+=2)if(this.wrapCache[o]==e)return this.wrapCache[o+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),o=[{match:this,type:null,via:null}];for(;o.length;){let r=o.shift(),i=r.match;if(i.matchType(e)){let s=[];for(let l=r;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)&&(!r.type||a.validEnd)&&(o.push({match:l.contentMatch,type:l,via:r}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(o){e.push(o);for(let r=0;r<o.next.length;r++)e.indexOf(o.next[r].next)==-1&&t(o.next[r].next)}return t(this),e.map((o,r)=>{let i=r+(o.validEnd?"*":" ")+" ";for(let s=0;s<o.next.length;s++)i+=(s?", ":"")+o.next[s].type.name+"->"+e.indexOf(o.next[s].next);return i}).join(`
|
|
2
|
-
`)}};Ft.empty=new Ft(!0);ci=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+"')")}};rt=class n{constructor(e,t,o){this.name=e,this.schema=t,this.spec=o,this.markSet=null,this.groups=o.group?o.group.split(" "):[],this.attrs=Yl(e,o.attrs),this.defaultAttrs=Gl(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(o.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ft.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:Xl(this.attrs,e)}create(e=null,t,o){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Le(this,this.computeAttrs(e),A.from(t),q.setFrom(o))}createChecked(e=null,t,o){return t=A.from(t),this.checkContent(t),new Le(this,this.computeAttrs(e),t,q.setFrom(o))}createAndFill(e=null,t,o){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 r=this.contentMatch.matchFragment(t),i=r&&r.fillBefore(A.empty,!0);return i?new Le(this,e,t.append(i),q.setFrom(o)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let o=0;o<e.childCount;o++)if(!this.allowsMarks(e.child(o).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let o=0;o<e.length;o++)this.allowsMarkType(e[o].type)?t&&t.push(e[o]):t||(t=e.slice(0,o));return t?t.length?t:q.none:e}static compile(e,t){let o=Object.create(null);e.forEach((i,s)=>o[i]=new n(i,t,s));let r=t.spec.topNode||"doc";if(!o[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!o.text)throw new RangeError("Every schema needs a 'text' type");for(let i in o.text.attrs)throw new RangeError("The text node type should not have attributes");return o}};ui=class{constructor(e,t,o){this.hasDefault=Object.prototype.hasOwnProperty.call(o,"default"),this.default=o.default,this.validate=typeof o.validate=="string"?Bh(e,t,o.validate):o.validate}get isRequired(){return!this.hasDefault}},Vn=class n{constructor(e,t,o,r){this.name=e,this.rank=t,this.schema=o,this.spec=r,this.attrs=Yl(e,r.attrs),this.excluded=null;let i=Gl(this.attrs);this.instance=i?new q(this,i):null}create(e=null){return!e&&this.instance?this.instance:new q(this,Xl(this.attrs,e))}static compile(e,t){let o=Object.create(null),r=0;return e.forEach((i,s)=>o[i]=new n(i,r++,t,s)),o}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}},qn=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let r in e)t[r]=e[r];t.nodes=ri.from(e.nodes),t.marks=ri.from(e.marks||{}),this.nodes=rt.compile(this.spec.nodes,this),this.marks=Vn.compile(this.spec.marks,this);let o=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let i=this.nodes[r],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=o[s]||(o[s]=Ft.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?Ll(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let r in this.marks){let i=this.marks[r],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Ll(this,s.split(" "))}this.nodeFromJSON=r=>Le.fromJSON(this,r),this.markFromJSON=r=>q.fromJSON(this,r),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,o,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof rt){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,o,r)}text(e,t){let o=this.nodes.text;return new ai(o,o.defaultAttrs,e,q.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}};xt=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let o=this.matchedStyles=[];t.forEach(r=>{if(Hh(r))this.tags.push(r);else if(zh(r)){let i=/[^=]*/.exec(r.style)[0];o.indexOf(i)<0&&o.push(i),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let o=new Fo(this,t,!1);return o.addAll(e,q.none,t.from,t.to),o.finish()}parseSlice(e,t={}){let o=new Fo(this,t,!0);return o.addAll(e,q.none,t.from,t.to),L.maxOpen(o.finish())}matchTag(e,t,o){for(let r=o?this.tags.indexOf(o)+1:0;r<this.tags.length;r++){let i=this.tags[r];if(_h(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,o,r){for(let i=r?this.styles.indexOf(r)+1:0;i<this.styles.length;i++){let s=this.styles[i],l=s.style;if(!(l.indexOf(e)!=0||s.context&&!o.matchesContext(s.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function o(r){let i=r.priority==null?50:r.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,r)}for(let r in e.marks){let i=e.marks[r].spec.parseDOM;i&&i.forEach(s=>{o(s=Rl(s)),s.mark||s.ignore||s.clearMark||(s.mark=r)})}for(let r in e.nodes){let i=e.nodes[r].spec.parseDOM;i&&i.forEach(s=>{o(s=Rl(s)),s.node||s.ignore||s.mark||(s.node=r)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Ql={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},Fh={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Zl={ol:!0,ul:!0},Wn=1,di=2,_n=4;un=class{constructor(e,t,o,r,i,s){this.type=e,this.attrs=t,this.marks=o,this.solid=r,this.options=s,this.content=[],this.activeMarks=q.none,this.match=i||(s&_n?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 o=this.type.contentMatch,r;return(r=o.findWrapping(e.type))?(this.match=o,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Wn)){let o=this.content[this.content.length-1],r;if(o&&o.isText&&(r=/[ \t\r\n\u000c]+$/.exec(o.text))){let i=o;o.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-r[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&&!Ql.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},Fo=class{constructor(e,t,o){this.parser=e,this.options=t,this.isOpen=o,this.open=0,this.localPreserveWS=!1;let r=t.topNode,i,s=Dl(null,t.preserveWhitespace,0)|(o?_n:0);r?i=new un(r.type,r.attrs,q.none,!0,t.topMatch||r.type.contentMatch,s):o?i=new un(null,null,q.none,!0,null,s):i=new un(e.schema.topNodeType,null,q.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 o=e.nodeValue,r=this.top,i=r.options&di?"full":this.localPreserveWS||(r.options&Wn)>0,{schema:s}=this.parser;if(i==="full"||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(o)){if(i)if(i==="full")o=o.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(s.linebreakReplacement&&/[\r\n]/.test(o)&&this.top.findWrapping(s.linebreakReplacement.create())){let l=o.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]));o=""}else o=o.replace(/\r?\n|\r/g," ");else if(o=o.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(o)&&this.open==this.nodes.length-1){let l=r.content[r.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(o=o.slice(1))}o&&this.insertNode(s.text(o),t,!/\S/.test(o)),this.findInText(e)}else this.findInside(e)}addElement(e,t,o){let r=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Zl.hasOwnProperty(s)&&this.parser.normalizeLists&&$h(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,o));e:if(a?a.ignore:Fh.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(Ql.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=r}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 o=e.style;if(o&&o.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let i=this.parser.matchedStyles[r],s=o.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,o,r){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),o,e.nodeName=="BR")||this.leafFallback(e,o);else{let a=this.enter(s,t.attrs||null,o,t.preserveWhitespace);a&&(i=!0,o=a)}else{let a=this.parser.schema.marks[t.mark];o=o.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,o,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,o,!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,o),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,o,r){let i=o||0;for(let s=o?e.childNodes[o]:e.firstChild,l=r==null?null:e.childNodes[r];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t,o){let r,i;for(let s=this.open,l=0;s>=0;s--){let a=this.nodes[s],c=a.findWrapping(e);if(c&&(!r||r.length>c.length+l)&&(r=c,i=a,!c.length))break;if(a.solid){if(o)break;l+=2}}if(!r)return null;this.sync(i);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t,o){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(t=this.enterInner(i,null,t))}let r=this.findPlace(e,t,o);if(r){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let s=q.none;for(let l of r.concat(e.marks))(i.type?i.type.allowsMarkType(l.type):Il(l.type,e.type))&&(s=l.addToSet(s));return i.content.push(e.mark(s)),!0}return!1}enter(e,t,o,r){let i=this.findPlace(e.create(t),o,!1);return i&&(i=this.enterInner(e,t,o,!0,r)),i}enterInner(e,t,o,r=!1,i){this.closeExtra();let s=this.top;s.match=s.match&&s.match.matchType(e);let l=Dl(e,i,s.options);s.options&_n&&s.content.length==0&&(l|=_n);let a=q.none;return o=o.filter(c=>(s.type?s.type.allowsMarkType(c.type):Il(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new un(e,t,a,r,null,l)),this.open++,o}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=Wn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let o=this.nodes[t].content;for(let r=o.length-1;r>=0;r--)e+=o[r].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let o=0;o<this.find.length;o++)this.find[o].node==e&&this.find[o].offset==t&&(this.find[o].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,o){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&t.compareDocumentPosition(this.find[r].node)&(o?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),o=this.options.context,r=!this.isOpen&&(!o||o.parent.type==this.nodes[0].type),i=-(o?o.depth+1:0)+(r?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&&r?this.nodes[a].type:o&&a>=i?o.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 o=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(o&&o.isTextblock&&o.defaultAttrs)return o}for(let t in this.parser.schema.nodes){let o=this.parser.schema.nodes[t];if(o.isTextblock&&o.defaultAttrs)return o}}};Ue=class n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},o){o||(o=Io(t).createDocumentFragment());let r=o,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;)r=i.pop()[1];for(;a<s.marks.length;){let c=s.marks[a++],u=this.serializeMark(c,s.isInline,t);u&&(i.push([c,r]),r.appendChild(u.dom),r=u.contentDOM||u.dom)}}r.appendChild(this.serializeNodeInner(s,t))}),o}serializeNodeInner(e,t){if(e.isText)return Io(t).createTextNode(e.text);let{dom:o,contentDOM:r}=Po(Io(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return o}serializeNode(e,t={}){let o=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let i=this.serializeMark(e.marks[r],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(o),o=i.dom)}return o}serializeMark(e,t,o={}){let r=this.marks[e.type.name];return r&&Po(Io(o),r(e,t),null,e.attrs)}static renderSpec(e,t,o=null,r){return typeof t=="string"?{dom:e.createTextNode(t)}:Po(e,t,o,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Pl(e.nodes);return t.text||(t.text=o=>o.text),t}static marksFromSchema(e){return Pl(e.marks)}};Bl=new WeakMap});function Wh(n,e){return n+e*ia}function ea(n){return n&ra}function Uh(n){return(n-(n&ra))/ia}function gi(n,e,t){let o=[];for(let r=0;r<n.childCount;r++){let i=n.child(r);i.content.size&&(i=i.copy(gi(i.content,e,i))),i.isInline&&(i=e(i,t,r)),o.push(i)}return A.fromArray(o)}function _o(n,e,t,o,r){let i=r.length?r[r.length-1]:null;i&&i instanceof n&&i.to==e&&i.mark.eq(o)?r[r.length-1]=new n(i.from,t,o):r.push(new n(e,t,o))}function hi(n,e,t){let o=n.resolve(e),r=t-e,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let s=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,r--}}return!1}function jh(n,e,t,o){let r=[];n.doc.nodesBetween(e,t,(i,s,l)=>{if(!i.isInline)return;let a=i.marks;if(!o.isInSet(a)&&l.type.allowsMarkType(o.type)){let c=Math.max(s,e),u=Math.min(s+i.nodeSize,t);_o($t,c,u,o,r)}}),r.forEach(i=>n.step(i))}function Kh(n,e,t,o){let r=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline||!s.isAtom)return;i++;let a=null;if(o instanceof Vn){let c=s.marks,u;for(;u=o.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else o?o.isInSet(s.marks)&&(a=[o]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let p=0;p<r.length;p++){let h=r[p];h.step==i-1&&d.eq(r[p].style)&&(f=h)}f?(f.to=c,f.step=i):r.push({style:d,from:Math.max(l,e),to:c,step:i})}}}),r.forEach(s=>n.step(new kt(s.from,s.to,s.style)))}function bi(n,e,t,o=t.contentMatch,r=!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=o.matchType(c.type);if(!d)s.push(new ve(l,u,L.empty));else{o=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new kt(l,u,c.marks[f]));if(r&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,h;for(;f=p.exec(c.text);)h||(h=new L(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(!o.validEnd){let a=o.fillBefore(A.empty,!0);n.replace(l,l,new L(a,0,0))}for(let a=s.length-1;a>=0;a--)n.step(s[a])}function Jh(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function _t(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let o=n.depth,r=0,i=0;;--o){let s=n.$from.node(o),l=n.$from.index(o)+r,a=n.$to.indexAfter(o)-i;if(o<n.depth&&s.canReplace(l,a,t))return o;if(o==0||s.type.spec.isolating||!Jh(s,l,a))break;l&&(r=1),a<s.childCount&&(i=1)}return null}function Gh(n,e,t){let{$from:o,$to:r,depth:i}=e,s=o.before(i+1),l=r.after(i+1),a=s,c=l,u=A.empty,d=0;for(let h=i,g=!1;h>t;h--)g||o.index(h)>0?(g=!0,u=A.from(o.node(h).copy(u)),d++):a--;let f=A.empty,p=0;for(let h=i,g=!1;h>t;h--)g||r.after(h+1)<r.end(h)?(g=!0,f=A.from(r.node(h).copy(f)),p++):c++;n.step(new he(a,c,s,l,new L(u.append(f),d,p),u.size-d,!0))}function hn(n,e,t=null,o=n){let r=Xh(n,e),i=r&&Yh(o,e);return i?r.map(ta).concat({type:e,attrs:t}).concat(i.map(ta)):null}function ta(n){return{type:n,attrs:null}}function Xh(n,e){let{parent:t,startIndex:o,endIndex:r}=n,i=t.contentMatchAt(o).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return t.canReplaceWith(o,r,s)?i:null}function Yh(n,e){let{parent:t,startIndex:o,endIndex:r}=n,i=t.child(o),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let c=o;a&&c<r;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:s}function Qh(n,e,t){let o=A.empty;for(let s=t.length-1;s>=0;s--){if(o.size){let l=t[s].type.contentMatch.matchFragment(o);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=A.from(t[s].type.create(t[s].attrs,o))}let r=e.start,i=e.end;n.step(new he(r,i,r,i,new L(o,0,0),t.length,!0))}function Zh(n,e,t,o,r){if(!o.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 r=="function"?r(s):r;if(s.isTextblock&&!s.hasMarkup(o,a)&&em(n.doc,n.mapping.slice(i).map(l),o)){let c=null;if(o.schema.linebreakReplacement){let p=o.whitespace=="pre",h=!!o.contentMatch.matchType(o.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&ua(n,s,l,i),bi(n,n.mapping.slice(i).map(l,1),o,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 L(A.from(o.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ca(n,s,l,i),!1}})}function ca(n,e,t,o){e.forEach((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let a=n.mapping.slice(o).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ua(n,e,t,o){e.forEach((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let s=n.mapping.slice(o).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function em(n,e,t){let o=n.resolve(e),r=o.index();return o.parent.canReplaceWith(r,r+1,t)}function tm(n,e,t,o,r){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(o,null,r||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 L(A.from(s),0,0),1,!0))}function Mt(n,e,t=1,o){let r=n.resolve(e),i=r.depth-t,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let c=r.depth-1,u=t-2;c>i;c--,u--){let d=r.node(c),f=r.index(c);if(d.type.spec.isolating)return!1;let p=d.content.cutByIndex(f,d.childCount),h=o&&o[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let g=o&&o[u]||d;if(!d.canReplace(f+1,d.childCount)||!g.type.validContent(p))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function nm(n,e,t=1,o){let r=n.doc.resolve(e),i=A.empty,s=A.empty;for(let l=r.depth,a=r.depth-t,c=t-1;l>a;l--,c--){i=A.from(r.node(l).copy(i));let u=o&&o[c];s=A.from(u?u.type.create(u.attrs,s):r.node(l).copy(s))}n.step(new ve(e,e,new L(i.append(s),t,t),!0))}function Vt(n,e){let t=n.resolve(e),o=t.index();return rm(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(o,o+1)}function om(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:o}=n.type.schema;for(let r=0;r<e.childCount;r++){let i=e.child(r),s=i.type==o?n.type.schema.nodes.text:i.type;if(t=t.matchType(s),!t||!n.type.allowsMarks(i.marks))return!1}return t.validEnd}function rm(n,e){return!!(n&&e&&!n.isLeaf&&om(n,e))}function im(n,e,t){let o=null,{linebreakReplacement:r}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(r&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(r);u&&!d?o=!1:!u&&d&&(o=!0)}let l=n.steps.length;if(o===!1){let u=n.doc.resolve(e+t);ua(n,u.node(),u.before(),l)}s.inlineContent&&bi(n,e+t-1,s,i.node().contentMatchAt(i.index()),o==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new ve(c,a.map(e+t,-1),L.empty,!0)),o===!0){let u=n.doc.resolve(c);ca(n,u.node(),u.before(),n.steps.length)}return n}function sm(n,e,t){let o=n.resolve(e);if(o.parent.canReplaceWith(o.index(),o.index(),t))return e;if(o.parentOffset==0)for(let r=o.depth-1;r>=0;r--){let i=o.index(r);if(o.node(r).canReplaceWith(i,i,t))return o.before(r+1);if(i>0)return null}if(o.parentOffset==o.parent.content.size)for(let r=o.depth-1;r>=0;r--){let i=o.indexAfter(r);if(o.node(r).canReplaceWith(i,i,t))return o.after(r+1);if(i<o.node(r).childCount)return null}return null}function Wo(n,e,t){let o=n.resolve(e);if(!t.content.size)return e;let r=t.content;for(let i=0;i<t.openStart;i++)r=r.firstChild.content;for(let i=1;i<=(t.openStart==0&&t.size?2:1);i++)for(let s=o.depth;s>=0;s--){let l=s==o.depth?0:o.pos<=(o.start(s+1)+o.end(s+1))/2?-1:1;for(let a=0;a<2;a++){if(a){if(!l)break;l=-l}let c=o.index(s)+(l>0?1:0),u=o.node(s),d=!1;if(i==1)d=u.canReplace(c,c,r);else{let f=u.contentMatchAt(c).findWrapping(r.firstChild.type);d=f&&u.canReplaceWith(c,c,f[0])}if(d)return l==0?o.pos:l<0?o.before(s+1):o.after(s+1)}}return null}function Uo(n,e,t=e,o=L.empty){if(e==t&&!o.size)return null;let r=n.resolve(e),i=n.resolve(t);return da(r,i,o)?new ve(e,t,o):new mi(r,i,o).fit()}function da(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}function Un(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Un(n.firstChild.content,e-1,t)))}function jn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(jn(n.lastChild.content,e-1,t)))}function na(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function fa(n,e,t){if(e<=0)return n;let o=n.content;return e>1&&(o=o.replaceChild(0,fa(o.firstChild,e-1,o.childCount==1?t-1:0))),e>0&&(o=n.type.contentMatch.fillBefore(o).append(o),t<=0&&(o=o.append(n.type.contentMatch.matchFragment(o).fillBefore(A.empty,!0)))),n.copy(o)}function pi(n,e,t,o,r){let i=n.node(e),s=r?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!lm(t,i.content,s)?l:null}function lm(n,e,t){for(let o=t;o<e.childCount;o++)if(!n.allowsMarks(e.child(o).marks))return!0;return!1}function am(n){return n.spec.defining||n.spec.definingForContent}function oa(n,e){for(let t=0;;t++){let o=e<0?n.firstChild:n.lastChild;if(!o||o.isAtom)return t;n=o.content}}function cm(n,e,t,o){if(!o.size)return n.deleteRange(e,t);let r=n.doc.resolve(e),i=n.doc.resolve(t);if(da(r,i,o))return n.step(new ve(e,t,o));let s=ha(r,i);s[s.length-1]==0&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let f=r.depth,p=r.pos-1;f>0;f--,p--){let h=r.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?l=f:r.before(f)==p&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=o.openStart;for(let f=o.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==o.openStart)break;f=h.content}for(let f=u-1;f>=0;f--){let p=c[f],h=am(p.type);if(h&&!p.sameMarkup(r.node(Math.abs(l)-1)))u=f;else if(h||!p.type.isTextblock)break}for(let f=o.openStart;f>=0;f--){let p=(f+u+1)%(o.openStart+1),h=c[p];if(h)for(let g=0;g<s.length;g++){let b=s[(g+a)%s.length],m=!0;b<0&&(m=!1,b=-b);let y=r.node(b-1),v=r.index(b-1);if(y.canReplaceWith(v,v,h.type,h.marks))return n.replace(r.before(b),m?i.after(b):t,new L(pa(o.content,0,o.openStart,p),p,o.openEnd))}}let d=n.steps.length;for(let f=s.length-1;f>=0&&(n.replace(e,t,o),!(n.steps.length>d));f--){let p=s[f];p<0||(e=r.before(p),t=i.after(p))}}function pa(n,e,t,o,r){if(e<t){let i=n.firstChild;n=n.replaceChild(0,i.copy(pa(i.content,e+1,t,o,i)))}if(e>o){let i=r.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(A.empty,!0))}return n}function um(n,e,t,o){if(!o.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let r=sm(n.doc,e,o.type);r!=null&&(e=t=r)}n.replaceRange(e,t,new L(A.from(o),0,0))}function dm(n,e,t){let o=n.doc.resolve(e),r=n.doc.resolve(t);if(o.parent.isTextblock&&r.parent.isTextblock&&o.start()!=r.start()&&o.parentOffset==0&&r.parentOffset==0){let s=o.sharedDepth(t),l=!1;for(let a=o.depth;a>s;a--)o.node(a).type.spec.isolating&&(l=!0);for(let a=r.depth;a>s;a--)r.node(a).type.spec.isolating&&(l=!0);if(!l){for(let a=o.depth;a>0&&e==o.start(a);a--)e=o.before(a);for(let a=r.depth;a>0&&t==r.start(a);a--)t=r.before(a);o=n.doc.resolve(e),r=n.doc.resolve(t)}}let i=ha(o,r);for(let s=0;s<i.length;s++){let l=i[s],a=s==i.length-1;if(a&&l==0||o.node(l).type.contentMatch.validEnd)return n.delete(o.start(l),r.end(l));if(l>0&&(a||o.node(l-1).canReplace(o.index(l-1),r.indexAfter(l-1))))return n.delete(o.before(l),r.after(l))}for(let s=1;s<=o.depth&&s<=r.depth;s++)if(e-o.start(s)==o.depth-s&&t>o.end(s)&&r.end(s)-t!=r.depth-s&&o.start(s-1)==r.start(s-1)&&o.node(s-1).canReplace(o.index(s-1),r.index(s-1)))return n.delete(o.before(s),t);n.delete(e,t)}function ha(n,e){let t=[],o=Math.min(n.depth,e.depth);for(let r=o;r>=0;r--){let i=n.start(r);if(i<n.pos-(n.depth-r)||e.end(r)>e.pos+(e.depth-r)||n.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(i==e.start(r)||r==n.depth&&r==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==i-1)&&t.push(r)}return t}var ra,ia,sa,la,$o,aa,Kn,it,Jn,fi,re,pe,$t,kt,Gn,Xn,dn,ve,he,mi,Vo,qo,fn,pn,Ge=D(()=>{"use strict";ce();ra=65535,ia=Math.pow(2,16);sa=1,la=2,$o=4,aa=8,Kn=class{constructor(e,t,o){this.pos=e,this.delInfo=t,this.recover=o}get deleted(){return(this.delInfo&aa)>0}get deletedBefore(){return(this.delInfo&(sa|$o))>0}get deletedAfter(){return(this.delInfo&(la|$o))>0}get deletedAcross(){return(this.delInfo&$o)>0}},it=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,o=ea(e);if(!this.inverted)for(let r=0;r<o;r++)t+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[o*3]+t+Uh(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,o){let r=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?r: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+r+(f<0?0:u);if(o)return p;let h=e==(t<0?a:d)?null:Wh(l/3,e-a),g=0;return c&&(g|=e==a?la:e==d?sa:$o,(t<0?e!=a:e!=d)&&(g|=aa)),new Kn(p,g,h)}r+=u-c}return o?e+r:new Kn(e+r,0,null)}touches(e,t){let o=0,r=ea(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?o:0);if(a>e)break;let c=this.ranges[l+i],u=a+c;if(e<=u&&l==r*3)return!0;o+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,o=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let s=this.ranges[r],l=s-(this.inverted?i:0),a=s+(this.inverted?0:i),c=this.ranges[r+t],u=this.ranges[r+o];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])}};it.empty=new it([]);Jn=class n{constructor(e,t,o=0,r=e?e.length:0){this.mirror=t,this.from=o,this.to=r,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,o=this._maps.length;t<e.to;t++){let r=e.getMirror(t);r!=null&&(r=r<t&&r>=e.from?o+(r-e.from):void 0),this.appendMap(e._maps[t],r)}}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,o=this._maps.length+e._maps.length;t>=e.from;t--){let r=e.getMirror(t);r!=null&&(r=r>t&&r<e.to?o-(r-e.from)-1:void 0),this.appendMap(e._maps[t].invert(),r)}}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 o=this.from;o<this.to;o++)e=this._maps[o].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,o){let r=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}}r|=l.delInfo,e=l.pos}return o?e:new Kn(e,r,null)}},fi=Object.create(null),re=class{getMap(){return it.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let o=fi[t.stepType];if(!o)throw new RangeError(`No step type ${t.stepType} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in fi)throw new RangeError("Duplicate use of step JSON ID "+e);return fi[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,o,r){try{return n.ok(e.replace(t,o,r))}catch(i){if(i instanceof wt)return n.fail(i.message);throw i}}};$t=class n extends re{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=e.resolve(this.from),r=o.node(o.sharedDepth(this.to)),i=new L(gi(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),r),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,i)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(o,r)=>{if(o.isInline&&o.isAtom){let i=this.mark.addToSet(o.marks);if(!q.sameSet(i,o.marks)){let s=Math.max(this.from,r),l=Math.min(this.to,r+o.nodeSize);_o(kt,s,l,this.mark,t);for(let a of o.marks)a.isInSet(i)||_o(n,s,l,a,t)}}}),t.length==1?t[0]:new Gn(t)}map(e){let t=e.map(this.from,1),o=e.map(this.to,-1);return t>=o?null:new n(t,o,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))}};re.jsonID("addMark",$t);kt=class n extends re{constructor(e,t,o){super(),this.from=e,this.to=t,this.mark=o}apply(e){let t=e.slice(this.from,this.to),o=new L(gi(t.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),t.openStart,t.openEnd);return pe.fromReplace(e,this.from,this.to,o)}invert(e){let t=[];return e.nodesBetween(this.from,this.to,(o,r)=>{o.isInline&&o.isAtom&&this.mark.isInSet(o.marks)&&_o($t,Math.max(this.from,r),Math.min(this.to,r+o.nodeSize),this.mark,t)}),t.length==1?t[0]:new Gn(t)}map(e){let t=e.map(this.from,1),o=e.map(this.to,-1);return t>=o?null:new n(t,o,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))}};re.jsonID("removeMark",kt);Gn=class n extends re{constructor(e){super(),this.steps=e}apply(e){for(let t of this.steps){let o=t.apply(e);if(!o.doc)return o;e=o.doc}return new pe(e,null)}invert(e){return new n(this.steps.map(t=>t.invert(e)))}map(e){let t=[];for(let o of this.steps){let r=o.map(e);r&&t.push(r)}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(o=>o.stepType=="addMark"||o.stepType=="removeMark"))throw new RangeError("Invalid JSON for MarkSetStep");return new n(t.steps.map(o=>re.fromJSON(e,o)))}};re.jsonID("markSet",Gn);Xn=class n extends re{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 o=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new L(A.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let o=this.mark.addToSet(t.marks);if(o.length==t.marks.length){for(let r=0;r<t.marks.length;r++)if(!t.marks[r].isInSet(o))return new n(this.pos,t.marks[r]);return new n(this.pos,this.mark)}}return new dn(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new 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))}};re.jsonID("addNodeMark",Xn);dn=class n extends re{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 o=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return pe.fromReplace(e,this.pos,this.pos+1,new L(A.from(o),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Xn(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))}};re.jsonID("removeNodeMark",dn);ve=class n extends re{constructor(e,t,o,r=!1){super(),this.from=e,this.to=t,this.slice=o,this.structure=r}apply(e){return this.structure&&hi(e,this.from,this.to)?pe.fail("Structure replace would overwrite content"):pe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new it([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),o=this.from==this.to&&n.MAP_BIAS<0?t:e.mapResult(this.from,1);return o.deletedAcross&&t.deletedAcross?null:new n(o.pos,Math.max(o.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?L.empty:new L(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?L.empty:new L(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,L.fromJSON(e,t.slice),!!t.structure)}};ve.MAP_BIAS=1;re.jsonID("replace",ve);he=class n extends re{constructor(e,t,o,r,i,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=o,this.gapTo=r,this.slice=i,this.insert=s,this.structure=l}apply(e){if(this.structure&&(hi(e,this.from,this.gapFrom)||hi(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 o=this.slice.insertAt(this.insert,t.content);return o?pe.fromReplace(e,this.from,this.to,o):pe.fail("Content does not fit in gap")}getMap(){return new it([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),o=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),i=this.to==this.gapTo?o.pos:e.map(this.gapTo,1);return t.deletedAcross&&o.deletedAcross||r<t.pos||i>o.pos||r>i?null:new n(t.pos,o.pos,r,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,L.fromJSON(e,t.slice),t.insert,!!t.structure)}};re.jsonID("replaceAround",he);mi=class{constructor(e,t,o){this.$from=e,this.$to=t,this.unplaced=o,this.frontier=[],this.placed=A.empty;for(let r=0;r<=e.depth;r++){let i=e.node(r);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=A.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,o=this.$from,r=this.close(e<0?this.$to:o.doc.resolve(e));if(!r)return null;let i=this.placed,s=o.depth,l=r.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new L(i,s,l);return e>-1?new he(o.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||o.pos!=this.$to.pos?new ve(o.pos,r.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,o=0,r=this.unplaced.openEnd;o<e;o++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=o){e=o;break}t=i.content}for(let t=1;t<=2;t++)for(let o=t==1?e:this.unplaced.openStart;o>=0;o--){let r,i=null;o?(i=na(this.unplaced.content,o-1).firstChild,r=i.content):r=this.unplaced.content;let s=r.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:o,frontierDepth:l,parent:i,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:o,frontierDepth:l,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:o}=this.unplaced;return oa(e,-1)<=t?!1:(this.unplaced.size>1&&oa(e,1)>o&&o++,this.unplaced=new L(e,t+1,o),!0)}dropNode(){let{content:e,openStart:t,openEnd:o}=this.unplaced,r=na(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new L(Un(e,t-1,1),t-1,i?t-1:o)}else this.unplaced=new L(Un(e,t,1),t,o)}placeNodes({sliceDepth:e,frontierDepth:t,parent:o,inject:r,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=o?o.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(r){for(let g=0;g<r.childCount;g++)u.push(r.child(g));d=d.matchFragment(r)}let p=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let g=l.child(c),b=d.matchType(g.type);if(!b)break;c++,(c>1||a==0||g.content.size)&&(d=b,u.push(fa(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=jn(this.placed,t,A.from(u)),this.frontier[t].match=d,h&&p<0&&o&&o.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,b=u[u.length-1];b&&g<p;g++)this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),b=b.lastChild;this.unplaced=h?e==0?L.empty:new L(Un(s.content,e-1,1),e-1,p<0?s.openEnd:e-1):new L(Un(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||!pi(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:o}=this.$to,r=this.$to.after(o);for(;o>1&&r==this.$to.end(--o);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:o,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=pi(e,t,r,o,i);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=pi(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=jn(this.placed,t.depth,t.fit)),e=t.move;for(let o=t.depth+1;o<=e.depth;o++){let r=e.node(o),i=r.type.contentMatch.fillBefore(r.content,!0,e.index(o));this.openFrontierNode(r.type,r.attrs,i)}return e}openFrontierNode(e,t=null,o){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=jn(this.placed,this.depth,A.from(e.create(t,o))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(A.empty,!0);t.childCount&&(this.placed=jn(this.placed,this.frontier.length,t))}};Vo=class n extends re{constructor(e,t,o){super(),this.pos=e,this.attr=t,this.value=o}apply(e){let t=e.nodeAt(this.pos);if(!t)return pe.fail("No node at attribute step's position");let o=Object.create(null);for(let i in t.attrs)o[i]=t.attrs[i];o[this.attr]=this.value;let r=t.type.create(o,null,t.marks);return pe.fromReplace(e,this.pos,this.pos+1,new L(A.from(r),0,t.isLeaf?0:1))}getMap(){return it.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)}};re.jsonID("attr",Vo);qo=class n extends re{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let r in e.attrs)t[r]=e.attrs[r];t[this.attr]=this.value;let o=e.type.create(t,e.content,e.marks);return pe.ok(o)}getMap(){return it.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};re.jsonID("docAttr",qo);fn=class extends Error{};fn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};fn.prototype=Object.create(Error.prototype);fn.prototype.constructor=fn;fn.prototype.name="TransformError";pn=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new fn(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 o=0;o<this.mapping.maps.length;o++){let r=this.mapping.maps[o];o&&(e=r.map(e,1),t=r.map(t,-1)),r.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,o=L.empty){let r=Uo(this.doc,e,t,o);return r&&this.step(r),this}replaceWith(e,t,o){return this.replace(e,t,new L(A.from(o),0,0))}delete(e,t){return this.replace(e,t,L.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,o){return cm(this,e,t,o),this}replaceRangeWith(e,t,o){return um(this,e,t,o),this}deleteRange(e,t){return dm(this,e,t),this}lift(e,t){return Gh(this,e,t),this}join(e,t=1){return im(this,e,t),this}wrap(e,t){return Qh(this,e,t),this}setBlockType(e,t=e,o,r=null){return Zh(this,e,t,o,r),this}setNodeMarkup(e,t,o=null,r){return tm(this,e,t,o,r),this}setNodeAttribute(e,t,o){return this.step(new Vo(e,t,o)),this}setDocAttribute(e,t){return this.step(new qo(e,t)),this}addNodeMark(e,t){return this.step(new Xn(e,t)),this}removeNodeMark(e,t){let o=this.doc.nodeAt(e);if(!o)throw new RangeError("No node at position "+e);if(t instanceof q)t.isInSet(o.marks)&&this.step(new dn(e,t));else{let r=o.marks,i,s=[];for(;i=t.isInSet(r);)s.push(new dn(e,i)),r=i.removeFromSet(r);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,o){return nm(this,e,t,o),this}addMark(e,t,o){return jh(this,e,t,o),this}removeMark(e,t,o){return Kh(this,e,t,o),this}clearIncompatible(e,t,o){return bi(this,e,t,o),this}}});function ga(n){!ma&&!n.parent.inlineContent&&(ma=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}function mn(n,e,t,o,r,i=!1){if(e.inlineContent)return P.create(n,t);for(let s=o-(r>0?0:1);r>0?s<e.childCount:s>=0;s+=r){let l=e.child(s);if(l.isAtom){if(!i&&R.isSelectable(l))return R.create(n,t-(r<0?l.nodeSize:0))}else{let a=mn(n,l,t+r,r<0?l.childCount:0,r,i);if(a)return a}t+=l.nodeSize*r}return null}function ba(n,e,t){let o=n.steps.length-1;if(o<e)return;let r=n.steps[o];if(!(r instanceof ve||r instanceof he))return;let i=n.mapping.maps[o],s;i.forEach((l,a,c,u)=>{s==null&&(s=u)}),n.setSelection(B.near(n.doc.resolve(s),t))}function wa(n,e){return!e||!n?n:n.bind(e)}function xa(n,e,t){for(let o in n){let r=n[o];r instanceof Function?r=r.bind(e):o=="handleDOMEvents"&&(r=xa(r,e,{})),t[o]=r}return t}function ka(n){return n in vi?n+"$"+ ++vi[n]:(vi[n]=0,n+"$")}var yi,B,St,ma,P,Ko,R,wi,me,fm,ya,jo,va,xi,qt,pm,Yn,gn,_,vi,K,U=D(()=>{"use strict";ce();Ge();yi=Object.create(null),B=class{constructor(e,t,o){this.$anchor=e,this.$head=t,this.ranges=o||[new St(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=L.empty){let o=t.content.lastChild,r=null;for(let l=0;l<t.openEnd;l++)r=o,o=o.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?L.empty:t),l==0&&ba(e,i,(o?o.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let o=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:s,$to:l}=r[i],a=e.mapping.slice(o),c=a.map(s.pos),u=a.map(l.pos);i?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ba(e,o,t.isInline?-1:1))}}static findFrom(e,t,o=!1){let r=e.parent.inlineContent?new P(e):mn(e.node(0),e.parent,e.pos,e.index(),t,o);if(r)return r;for(let i=e.depth-1;i>=0;i--){let s=t<0?mn(e.node(0),e.node(i),e.before(i+1),e.index(i),t,o):mn(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,o);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 mn(e,e,0,0,1)||new me(e)}static atEnd(e){return mn(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 o=yi[t.type];if(!o)throw new RangeError(`No selection type ${t.type} defined`);return o.fromJSON(e,t)}static jsonID(e,t){if(e in yi)throw new RangeError("Duplicate use of selection JSON ID "+e);return yi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}};B.prototype.visible=!0;St=class{constructor(e,t){this.$from=e,this.$to=t}},ma=!1;P=class n extends B{constructor(e,t=e){ga(e),ga(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let o=e.resolve(t.map(this.head));if(!o.parent.inlineContent)return B.near(o);let r=e.resolve(t.map(this.anchor));return new n(r.parent.inlineContent?r:o,o)}replace(e,t=L.empty){if(super.replace(e,t),t==L.empty){let o=this.$from.marksAcross(this.$to);o&&e.ensureMarks(o)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Ko(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,o=t){let r=e.resolve(t);return new this(r,o==t?r:e.resolve(o))}static between(e,t,o){let r=e.pos-t.pos;if((!o||r)&&(o=r>=0?1:-1),!t.parent.inlineContent){let i=B.findFrom(t,o,!0)||B.findFrom(t,-o,!0);if(i)t=i.$head;else return B.near(t,o)}return e.parent.inlineContent||(r==0?e=t:(e=(B.findFrom(e,-o,!0)||B.findFrom(e,o,!0)).$anchor,e.pos<t.pos!=r<0&&(e=t))),new n(e,t)}};B.jsonID("text",P);Ko=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 P.between(e.resolve(this.anchor),e.resolve(this.head))}},R=class n extends B{constructor(e){let t=e.nodeAfter,o=e.node(0).resolve(e.pos+t.nodeSize);super(e,o),this.node=t}map(e,t){let{deleted:o,pos:r}=t.mapResult(this.anchor),i=e.resolve(r);return o?B.near(i):new n(i)}content(){return new L(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 wi(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}};R.prototype.visible=!1;B.jsonID("node",R);wi=class n{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:o}=e.mapResult(this.anchor);return t?new Ko(o,o):new n(o)}resolve(e){let t=e.resolve(this.anchor),o=t.nodeAfter;return o&&R.isSelectable(o)?new R(t):B.near(t)}},me=class n extends B{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=L.empty){if(t==L.empty){e.delete(0,e.doc.content.size);let o=B.atStart(e.doc);o.eq(e.selection)||e.setSelection(o)}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 fm}};B.jsonID("all",me);fm={map(){return this},resolve(n){return new me(n)}};ya=1,jo=2,va=4,xi=class extends pn{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|ya)&~jo,this.storedMarks=null,this}get selectionSet(){return(this.updated&ya)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=jo,this}ensureMarks(e){return q.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&jo)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~jo,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let o=this.selection;return t&&(e=e.mark(this.storedMarks||(o.empty?o.$from.marks():o.$from.marksAcross(o.$to)||q.none))),o.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,o){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(o==null&&(o=t),!e)return this.deleteRange(t,o);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=o==t?s.marks():s.marksAcross(this.doc.resolve(o))}return this.replaceRangeWith(t,o,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(B.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|=va,this}get scrolledIntoView(){return(this.updated&va)>0}};qt=class{constructor(e,t,o){this.name=e,this.init=wa(t.init,o),this.apply=wa(t.apply,o)}},pm=[new qt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new qt("selection",{init(n,e){return n.selection||B.atStart(e.doc)},apply(n){return n.selection}}),new qt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,o){return o.selection.$cursor?n.storedMarks:null}}),new qt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Yn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pm.slice(),t&&t.forEach(o=>{if(this.pluginsByKey[o.key])throw new RangeError("Adding different instances of a keyed plugin ("+o.key+")");this.plugins.push(o),this.pluginsByKey[o.key]=o,o.spec.state&&this.fields.push(new qt(o.key,o.spec.state,o))})}},gn=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 o=0;o<this.config.plugins.length;o++)if(o!=t){let r=this.config.plugins[o];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],o=this.applyInner(e),r=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=r?r[s].n:0,c=r?r[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,o);if(u&&o.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!r){r=[];for(let d=0;d<this.config.plugins.length;d++)r.push(d<s?{state:o,n:t.length}:{state:this,n:0})}t.push(u),o=o.applyInner(u),i=!0}r&&(r[s]={state:o,n:t.length})}}if(!i)return{state:o,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new n(this.config),o=this.config.fields;for(let r=0;r<o.length;r++){let i=o[r];t[i.name]=i.apply(e,this[i.name],this,t)}return t}get tr(){return new xi(this)}static create(e){let t=new Yn(e.doc?e.doc.type.schema:e.schema,e.plugins),o=new n(t);for(let r=0;r<t.fields.length;r++)o[t.fields[r].name]=t.fields[r].init(e,o);return o}reconfigure(e){let t=new Yn(this.schema,e.plugins),o=t.fields,r=new n(t);for(let i=0;i<o.length;i++){let s=o[i].name;r[s]=this.hasOwnProperty(s)?this[s]:o[i].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(o=>o.toJSON())),e&&typeof e=="object")for(let o in e){if(o=="doc"||o=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[o],i=r.spec.state;i&&i.toJSON&&(t[o]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,o){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Yn(e.schema,e.plugins),i=new n(r);return r.fields.forEach(s=>{if(s.name=="doc")i.doc=Le.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=B.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(o)for(let l in o){let a=o[l],c=a.spec.state;if(a.key==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&&xa(e.props,this,this.props),this.key=e.key?e.key.key:ka("plugin")}getState(e){return e[this.key]}},vi=Object.create(null);K=class{constructor(e="key"){this.key=ka(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}});function w(n,e={},...t){let o=document.createElement(n);for(let[r,i]of Object.entries(e))i==null||i===!1||(typeof i=="function"?o.addEventListener(r.replace(/^on/,"").toLowerCase(),i):r==="className"?o.className=String(i):o.setAttribute(r,i===!0?"":String(i)));for(let r of t.flat())r==null||r===!1||o.append(r);return o}function ne(n){let e=document.createElement("span");return e.className="nova-icon",e.innerHTML=n,e}function Se(n="nova"){return Ma+=1,`${n}-${Ma}`}function Xe(n){let e=n.split("-"),t=e.pop(),o=t.length===1?t.toUpperCase():t;if(hm){let i={Mod:"\u2318",Shift:"\u21E7",Alt:"\u2325",Ctrl:"\u2303"};return e.map(s=>i[s]??s).join("")+o}let r={Mod:"Ctrl",Shift:"Shift",Alt:"Alt",Ctrl:"Ctrl"};return[...e.map(i=>r[i]??i),o].join("+")}var Ma,hm,ki,Y=D(()=>{"use strict";Ma=0;hm=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);ki='a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'});function Sa(n){let e=Se("nova-dialog-title"),t=w("p",{className:"nova-dialog-error",role:"alert",hidden:!0}),o=w("button",{type:"submit",className:"nova-button nova-button-primary",hidden:!n.submitLabel},n.submitLabel??""),r=w("button",{type:"button",className:"nova-button"},n.cancelLabel),i=w("button",{type:"button",className:"nova-btn nova-dialog-close","aria-label":n.closeLabel},ne(k.close)),s=w("form",{className:n.size==="large"?"nova-dialog nova-dialog-large":"nova-dialog",role:"dialog","aria-modal":"true","aria-labelledby":e,novalidate:!0},w("header",{className:"nova-dialog-header"},w("h2",{id:e},n.title),i),w("div",{className:"nova-dialog-body"},n.body,t),w("footer",{className:"nova-dialog-footer"},r,o)),l=w("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=>{o.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)}}),r.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(ki)].filter(y=>!y.hidden),b=g[0],m=g[g.length-1];if(!b||!m)return;h.shiftKey&&document.activeElement===b?(h.preventDefault(),m.focus()):!h.shiftKey&&document.activeElement===m&&(h.preventDefault(),b.focus())}});let f=h=>{s.contains(h.target)||(s.querySelector(ki)??s).focus()};return document.addEventListener("focusin",f,!0),(n.initialFocus??s.querySelector(".nova-dialog-body input, .nova-dialog-body textarea")??(n.submitLabel?o:r)).focus(),{el:s,close:c,setError:u,setBusy:d}}function ue(n){let e=Se("nova-field"),t=n.hint?`${e}-hint`:void 0,o=w("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 o.value=n.value??"",{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),o,n.hint?w("p",{id:t,className:"nova-hint"},n.hint):null),input:o}}function Ca(n,e=!1){let t=Se("nova-check"),o=w("input",{id:t,type:"checkbox",className:"nova-checkbox"});return o.checked=e,{el:w("div",{className:"nova-field nova-field-inline"},o,w("label",{for:t},n)),input:o}}function Jo(n){let e=Se("nova-field"),t=w("select",{id:e,className:"nova-input nova-select"},...n.options.map(r=>w("option",{value:r.value},r.label)));return t.value=n.value,{el:w("div",{className:"nova-field"},w("label",{for:e,className:"nova-label"},n.label),t),select:t}}var Ct=D(()=>{"use strict";Y();j()});function W(n,e){let t=(n.options.language??"en").toLowerCase();return e[t]??e[t.split("-")[0]]??e.en}function bn(n,e){let{state:t,dispatch:o}=n.view;o(t.tr.insertText(e).scrollIntoView()),n.focus()}function Go(n){let e=w("input",{type:"search",className:"nova-input nova-symbols-search",placeholder:n.searchLabel,"aria-label":n.searchLabel}),t=w("div",{className:"nova-symbols-list"}),o=w("div",{className:`nova-symbols ${n.className}`},e,t),r=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(w("div",{className:"nova-symbols-empty"},n.emptyText));return}t.replaceChildren(...l.map(a=>w("div",{className:"nova-symbols-group",role:"group","aria-label":a.title},w("div",{className:"nova-symbols-title"},a.title),w("div",{className:"nova-symbols-grid"},...a.items.map(([c,u])=>w("button",{type:"button",className:"nova-symbols-cell",title:u,"aria-label":u,onclick:()=>n.onPick(c)},c))))))};return e.addEventListener("input",()=>r(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()}),r(""),queueMicrotask(()=>e.focus()),o}function Xo(n,e,t){let o=null,r=t(()=>o?.close());o=n.ui.openDialog({title:e,body:r,cancelLabel:n.ui.t("dialog.close")})}var Ce=D(()=>{"use strict";Y()});function xn(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e}function lt(n,e,t){let o=Ai||(Ai=document.createRange());return o.setEnd(n,t??n.nodeValue.length),o.setStart(n,e||0),o}function gm(){Ai=null}function Qo(n,e,t,o){return t&&(Na(n,e,t,o,-1)||Na(n,e,t,o,1))}function Na(n,e,t,o,r){for(var i;;){if(n==t&&e==o)return!0;if(e==(r<0?0:xe(n))){let s=n.parentNode;if(!s||!H(s)||Zo(n)||Ta.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ee(n)+(r<0?0:1),n=s}else if(H(n)){let s=n.childNodes[e+(r<0?-1:0)];if(H(s)&&s.contentEditable=="false")if(!((i=s.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=r;else return!1;else{if(Zo(s)||Ta.test(s.nodeName))return!1;n=s,e=r<0?xe(n):0}}else return!1}}function xe(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function H(n){return n.nodeType==1}function ge(n){return n.nodeType==3}function kn(n,e){return e?n.contains(H(e)?e:e.parentNode):!1}function lc(n,e){for(;;){if(ge(n)&&e)return n;if(H(n)&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=xe(n)}else if(n.parentNode&&!Zo(n,!0))e=Ee(n),n=n.parentNode;else return null}}function ac(n,e){for(;;){if(ge(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&&!Zo(n,!0))e=Ee(n)+1,n=n.parentNode;else return null}}function bm(n,e,t){for(let o=e==0,r=e==xe(n);o||r;){if(n==t)return!0;let i=Ee(n);if(n=n.parentNode,!n)return!1;o=o&&i==0,r=r&&i==xe(n)}}function Zo(n,e=!1){let t;for(let o=n;o&&!(t=o.pmViewDesc);o=o.parentNode);return t&&t.node&&(!e||t.node.isBlock)&&(t.dom==n||t.contentDOM==n)}function ar(n){return n.focusNode&&Qo(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)}function cc(n,e){n.collapse(e.anchorNode,e.anchorOffset),(e.focusNode!=e.anchorNode||e.focusOffset!=e.anchorOffset)&&n.extend(e.focusNode,e.focusOffset)}function ym(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function vm(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function wm(n,e,t){if(n.caretPositionFromPoint)try{let o=n.caretPositionFromPoint(e,t);if(o)return{node:o.offsetNode,offset:Math.min(xe(o.offsetNode),o.offset)}}catch{}if(n.caretRangeFromPoint){let o=n.caretRangeFromPoint(e,t);if(o)return{node:o.startContainer,offset:Math.min(xe(o.startContainer),o.startOffset)}}}function km(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 st(n,e){return typeof n=="number"?n:n[e]}function Mm(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,o=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*o}}function La(n,e,t){if(!Ni(e)&&e.left==0)return;let o=n.someProp("scrollThreshold")||0,r=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(!H(s)){s=xn(s);continue}let l=s==i.body,a=l?km(i):Mm(s),c=0,u=0;if(e.top<a.top+st(o,"top")?u=-(a.top-e.top+st(r,"top")):e.bottom>a.bottom-st(o,"bottom")&&(u=e.bottom-e.top>a.bottom-a.top?e.top+st(r,"top")-a.top:e.bottom-a.bottom+st(r,"bottom")),e.left<a.left+st(o,"left")?c=-(a.left-e.left+st(r,"left")):e.right>a.right-st(o,"right")&&(c=e.right-a.right+st(r,"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,g=s.scrollTop-p;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:xn(s)}}function Sm(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),o,r;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){o=l,r=a.top;break}}return{refDOM:o,refTop:r,stack:fc(n.dom)}}function fc(n){let e=[],t=n.ownerDocument;for(let o=n;o&&(e.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),n!=t);o=xn(o));return e}function Cm({refDOM:n,refTop:e,stack:t}){let o=n?n.getBoundingClientRect().top:0;pc(t,o==0?0:o-e)}function pc(n,e){for(let t=0;t<n.length;t++){let{dom:o,top:r,left:i}=n[t];o.scrollTop!=r+e&&(o.scrollTop=r+e),o.scrollLeft!=i&&(o.scrollLeft=i)}}function hc(n){if(n.setActive)return n.setActive();if(yn)return n.focus(yn);let e=fc(n);n.focus(yn==null?{get preventScroll(){return yn={preventScroll:!0},!0}}:void 0),yn||(yn=!1,pc(e,0))}function mc(n,e){let t,o=2e8,r,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(H(u))f=u.getClientRects();else if(ge(u))f=lt(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 g=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(g<o){t=u,o=g,r=g&&ge(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,r=c,o=0),t&&ge(t)?Em(t,r):!t||o?{node:n,offset:i}:mc(t,r)}function Em(n,e){let t=n.nodeValue.length,o=document.createRange(),r;for(let i=0;i<t;i++){o.setEnd(n,i+1),o.setStart(n,i);let s=Et(o,1);if(s.top!=s.bottom&&qi(e,s)){r={node:n,offset:i+(e.left>=(s.left+s.right)/2?1:0)};break}}return o.detach(),r||{node:n,offset:0}}function qi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Am(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function Tm(n,e,t){let{node:o,offset:r}=mc(e,t),i=-1;if(H(o)&&!o.firstChild){let s=o.getBoundingClientRect();i=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(o,r,i)}function Nm(n,e,t,o){let r=-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>o.left||a.top>o.top?r=l.posBefore:(!s&&a.right<o.left||a.bottom<o.top)&&(r=l.posAfter),s=!0),!l.contentDOM&&r<0&&!l.node.isText))return(l.node.isBlock?o.top<(a.top+a.bottom)/2:o.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;i=l.dom.parentNode}return r>-1?r:n.docView.posFromDOM(e,t,-1)}function gc(n,e,t){let o=n.childNodes.length;if(o&&t.top<t.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(e.top-t.top)/(t.bottom-t.top))-2)),i=r;;){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(qi(e,c))return gc(s,e,c)}}if((i=(i+1)%o)==r)break}return n}function Om(n,e){let t=n.dom.ownerDocument,o,r=0,i=wm(t,e.left,e.top);i&&({node:o,offset:r}=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(!qi(e,c)||(s=gc(n.dom,e,c),!s))return null}if(Te)for(let c=s;o&&c;c=xn(c))c.draggable&&(o=void 0);if(s=Am(s,e),o){if(je&&H(o)&&(r=Math.min(r,o.childNodes.length),r<o.childNodes.length)){let u=o.childNodes[r],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&r++}let c;cr&&r&&H(o)&&H(c=o.childNodes[r-1])&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&r--,o==n.dom&&r==o.childNodes.length-1&&H(o.lastChild)&&e.top>o.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(r==0||!H(o)||o.childNodes[r-1].nodeName!="BR")&&(l=Nm(n,o,r,e))}l==null&&(l=Tm(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ni(n){return n.top<n.bottom||n.left<n.right}function Et(n,e){let t=n.getClientRects();if(t.length){let o=t[e<0?0:t.length-1];if(Ni(o))return o}return Array.prototype.find.call(t,Ni)||n.getBoundingClientRect()}function bc(n,e,t){let{node:o,offset:r,atom:i}=n.docView.domFromPos(e,t<0?-1:1),s=cr||je;if(ge(o))if(s&&(Lm.test(o.nodeValue)||(t<0?!r:r==o.nodeValue.length))){let a=Et(lt(o,r,r),t);if(je&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let c=Et(lt(o,r-1,r-1),-1);if(c.top==a.top){let u=Et(lt(o,r,r+1),-1);if(u.top!=a.top)return Qn(u,u.left<c.left)}}return a}else{let a=r,c=r,u=t<0?1:-1;return t<0&&!r?(c++,u=-1):t>=0&&r==o.nodeValue.length?(a--,u=1):t<0?a--:c++,Qn(Et(lt(o,a,c),u),u<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&r&&(t<0||r==xe(o))){let a=o.childNodes[r-1];if(H(a))return Mi(a.getBoundingClientRect(),!1)}if(i==null&&r<xe(o)){let a=o.childNodes[r];if(H(a))return Mi(a.getBoundingClientRect(),!0)}return Mi(o.getBoundingClientRect(),t>=0)}if(i==null&&r&&(t<0||r==xe(o))){let a=o.childNodes[r-1],c=ge(a)?lt(a,xe(a)-(s?0:1)):H(a)&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Qn(Et(c,1),!1)}if(i==null&&r<xe(o)){let a=o.childNodes[r];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?ge(a)?lt(a,0,s?0:1):H(a)?a:null:null;if(c)return Qn(Et(c,-1),!0)}return Qn(Et(ge(o)?lt(o):o,-t),t>=0)}function Qn(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 Mi(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 yc(n,e,t){let o=n.state,r=n.root.activeElement;o!=e&&n.updateState(e),r!=n.dom&&n.focus();try{return t()}finally{o!=e&&n.updateState(o),r!=n.dom&&r&&r.focus()}}function Dm(n,e,t){let o=e.selection,r=t=="up"?o.$from:o.$to;return yc(n,e,()=>{let{node:i}=n.docView.domFromPos(r.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=bc(n,r.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(H(l))a=l.getClientRects();else if(ge(l))a=lt(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 Im(n,e,t){let{$head:o}=e.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=n.domSelection();return l?!Rm.test(o.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:yc(n,e,()=>{let a=n.domSel.readRange(),c=l.caretBidiLevel;l.modify("move",t,"character");let u=o.depth?n.docView.domAfterPos(o.before()):n.dom,{focusNode:d,focusOffset:f}=n.domSel.readRange(),p=d&&!kn(u,d)||a.focusNode==d&&a.focusOffset==f;return cc(l,a),c!=null&&(l.caretBidiLevel=c),p}):o.pos==o.start()||o.pos==o.end()}function Pm(n,e,t){return Da==e&&Ra==t?Ia:(Da=e,Ra=t,Ia=t=="up"||t=="down"?Dm(n,e,t):Im(n,e,t))}function Pa(n,e,t,o,r,i){i?Wi(o,o,oo(i,n,!1),oo(e,n,!1)):wc(o,e,n);let s=new Ot(void 0,n,e,t,o,o,o);return s.contentDOM&&s.updateChildren(r,0),s}function vc(n,e,t){let o=n.firstChild,r=!1;for(let i=0;i<e.length;i++){let s=e[i],l=s.dom;if(l.parentNode==n){for(;l!=o;)o=Ba(o),r=!0;o=o.nextSibling}else r=!0,n.insertBefore(l,o);if(s instanceof Ut){let a=o?o.previousSibling:n.lastChild;vc(s.contentDOM,s.children,t),o=a?a.nextSibling:n.firstChild}}for(;o;)o=Ba(o),r=!0;r&&t.trackWrites==n&&(t.trackWrites=null)}function oo(n,e,t){if(n.length==0)return Wt;let o=t?Wt[0]:new eo,r=[o];for(let i=0;i<n.length;i++){let s=n[i].type.attrs;if(s){s.nodeName&&r.push(o=new eo(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&r.length==1&&r.push(o=new eo(e.isInline?"span":"div")),l=="class"?o.class=(o.class?o.class+" ":"")+a:l=="style"?o.style=(o.style?o.style+";":"")+a:l!="nodeName"&&(o[l]=a))}}}return r}function Wi(n,e,t,o){if(t==Wt&&o==Wt)return e;let r=e;for(let i=0;i<o.length;i++){let s=o[i],l=t[i];if(i){let a;l&&l.nodeName==s.nodeName&&r!=n&&(a=r.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(r),l=Wt[0]),r=a}Bm(r,l||Wt[0],s)}return r}function Bm(n,e,t){for(let o in e)o!="class"&&o!="style"&&o!="nodeName"&&!(o in t)&&n.removeAttribute(o);for(let o in t)o!="class"&&o!="style"&&o!="nodeName"&&t[o]!=e[o]&&n.setAttribute(o,t[o]);if(e.class!=t.class){let o=e.class?e.class.split(" ").filter(Boolean):[],r=t.class?t.class.split(" ").filter(Boolean):[];for(let i=0;i<o.length;i++)r.indexOf(o[i])==-1&&n.classList.remove(o[i]);for(let i=0;i<r.length;i++)o.indexOf(r[i])==-1&&n.classList.add(r[i]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=o.exec(e.style);)n.style.removeProperty(r[1])}t.style&&(n.style.cssText+=t.style)}}function wc(n,e,t){return Wi(n,n,Wt,oo(e,t,!H(n)))}function or(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 Ba(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}function Hm(n,e){let t=e,o=t.children.length,r=[],i=n.childCount,s=new Map,l=[];e:for(;i>0;){let a;for(;;)if(o){let u=t.children[o-1];if(u instanceof Ut)r.push(o-1),t=u,o=u.children.length;else{a=u,o--;break}}else{if(t==e)break e;o=r.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 zm(n,e){return n.type.side-e.type.side}function Fm(n,e,t,o){let r=e.locals(n),i=0;if(r.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);o(u,r,e.forChild(i,u),c),i+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<r.length&&r[s].to==i;){let b=r[s++];b.widget&&(u?(d||(d=[u])).push(b):u=b)}if(u)if(d){d.sort(zm);for(let b=0;b<d.length;b++)t(d[b],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 b=0;b<l.length;b++)l[b].to<=i&&l.splice(b--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let h=i+f.nodeSize;if(f.isText){let b=h;s<r.length&&r[s].from<b&&(b=r[s].from);for(let m=0;m<l.length;m++)l[m].to<b&&(b=l[m].to);b<h&&(a=f.cut(b-i),f=f.cut(0,b-i),h=b,p=-1)}else for(;s<r.length&&r[s].to<h;)s++;let g=f.isInline&&!f.isLeaf?l.filter(b=>!b.inline):l.slice();o(f,g,e.forChild(i,f),p),i=h}}function $m(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 _m(n,e,t,o){for(let r=0,i=0;r<n.childCount&&i<=o;){let s=n.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<n.childCount;){let c=n.child(r++);if(i+=c.nodeSize,!c.isText)break;a+=c.text}if(i>=t){if(i>=o&&a.slice(o-e.length-l,o-l)==e)return o-e.length;let c=l<o?a.lastIndexOf(e,o-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==o&&a.length>=o+e.length-l&&a.slice(o-l,o-l+e.length)==e)return o}}return-1}function Di(n,e,t,o,r){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,o)),r&&(i.push(r),r=void 0),u>t&&i.push(a.slice(t-c,a.size,o)))}return i}function Ri(n,e){let{$anchor:t,$head:o}=n.selection,r=e>0?t.max(o):t.min(o),i=r.parent.inlineContent?r.depth?n.doc.resolve(e>0?r.after():r.before()):null:r;return i&&B.findFrom(i,e)}function At(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ha(n,e,t){let o=n.state.selection;if(o instanceof P)if(t.indexOf("s")>-1){let{$head:r}=o,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(r.pos+i.nodeSize*(e<0?-1:1));return At(n,new P(o.$anchor,s))}else if(o.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let r=Ri(n.state,e);return r&&r instanceof R?At(n,r):!1}else if(!Ve||t.indexOf("m")<0){let r=o.$head,i=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?r.pos-i.nodeSize:r.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?R.isSelectable(i)?At(n,new R(e<0?n.state.doc.resolve(r.pos-i.nodeSize):r)):At(n,new P(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1}}else return!1;else{if(o instanceof R&&o.node.isInline)return At(n,new P(e>0?o.$to:o.$from));{let r=Ri(n.state,e);return r?At(n,r):!1}}}function to(n,e){let t=n.pmViewDesc;return t?t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR"):H(n)&&n.contentEditable=="false"}function vn(n,e){return e<0?Vm(n):qm(n)}function Vm(n){let e=n.domSel.readRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r,i,s=!1;for(je&&H(t)&&o<xe(t)&&to(t.childNodes[o],-1)&&(s=!0);;)if(o>0){if(!H(t))break;let l=t.childNodes[o-1];if(to(l,-1))r=t,i=--o;else if(ge(l))t=l,o=t.nodeValue.length;else break}else{if(xc(t))break;{let l=t.previousSibling;for(;l&&to(l,-1);)r=t.parentNode,i=Ee(l),l=l.previousSibling;if(l)t=l,o=xe(t);else{if(t=t.parentNode,t==n.dom)break;o=0}}}s?Ii(n,t,o):r&&Ii(n,r,i)}function qm(n){let e=n.domSel.readRange(),t=e.focusNode,o=e.focusOffset;if(!t)return;let r=xe(t),i,s;for(;;)if(o<r){if(!H(t))break;let l=t.childNodes[o];if(to(l,1))i=t,s=++o;else break}else{if(xc(t))break;{let l=t.nextSibling;for(;l&&to(l,1);)i=l.parentNode,s=Ee(l)+1,l=l.nextSibling;if(l)t=l,o=0,r=xe(t);else{if(t=t.parentNode,t==n.dom)break;o=r=0}}}i&&Ii(n,i,s)}function xc(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 Ii(n,e,t){if(!ge(e)){let s,l;(l=ac(e,t))?(e=l,t=0):(s=lc(e,t))&&(e=s,t=s.nodeValue.length)}let o=n.domSelection(),r=n.domSel.readRange();if(!o)return;ar(r)?o.collapse(e,t):o.extend&&(o.collapse(r.anchorNode,r.anchorOffset),o.extend(e,t)),n.domSel.ignore();let{state:i}=n;setTimeout(()=>{n.state==i&&n.domSel.sync()},50)}function za(n,e){let t=n.state.doc.resolve(e);if(!(Ae||dc)&&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 o=n.dom;for(let i=t.depth;i>0;i--)if(t.node(i).isBlock){o=n.nodeDOM(t.before(i))||o;break}return getComputedStyle(o).direction=="rtl"?"rtl":"ltr"}function Fa(n,e,t){let o=n.state.selection;if(o instanceof P&&!o.empty||t.indexOf("s")>-1||Ve&&t.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Ri(n.state,e);if(s&&s instanceof R)return At(n,s)}if(!r.parent.inlineContent){let s=e<0?r:i,l=o instanceof me?B.near(s,e):B.findFrom(s,e);return l?At(n,l):!1}return!1}function $a(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:o,empty:r}=n.state.selection;if(!t.sameParent(o))return!0;if(!r)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 _a(n,e,t){n.domObserver.stopped(()=>e.contentEditable=t)}function Wm(n){if(!Te||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 o=e.firstChild;_a(n,o,"true"),setTimeout(()=>_a(n,o,"false"),20)}return!1}function Um(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function jm(n,e){let t=e.keyCode,o=Um(e);if(t==8||Ve&&t==72&&o=="c")return $a(n,-1)||vn(n,-1);if(t==46&&!e.shiftKey||Ve&&t==68&&o=="c")return $a(n,1)||vn(n,1);if(t==13||t==27)return!0;if(t==37||Ve&&t==66&&o=="c"){let r=t==37?za(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ha(n,r,o)||vn(n,r)}else if(t==39||Ve&&t==70&&o=="c"){let r=t==39?za(n,n.state.selection.from)=="ltr"?1:-1:1;return Ha(n,r,o)||vn(n,r)}else{if(t==38||Ve&&t==80&&o=="c")return Fa(n,-1,o)||vn(n,-1);if(t==40||Ve&&t==78&&o=="c")return Wm(n)||Fa(n,1,o)||vn(n,1);if(o==(Ve?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ui(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:o,openStart:r,openEnd:i}=e;for(;r>1&&i>1&&o.childCount==1&&o.firstChild.childCount==1;){r--,i--;let p=o.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),o=p.content}let s=n.someProp("clipboardSerializer")||Ue.fromSchema(n.state.schema),l=Ac(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c=a.firstChild,u,d=0;for(;c&&H(c)&&(u=Ec[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&&H(c)&&c.setAttribute("data-pm-slice",`${r} ${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=o={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=r.domSel.readRange();if(je&&l.focusNode&&l.focusNode!=o.node&&H(l.focusNode)){let a=l.focusNode.childNodes[l.focusOffset];a&&a.contentEditable=="false"&&(i=!0)}!(i||s&&Te)&&Qo(t.node,t.offset,l.anchorNode,l.anchorOffset)&&Qo(o.node,o.offset,l.focusNode,l.focusOffset)||cc(r.domSelection(),{focusNode:o.node,focusOffset:o.offset,anchorNode:t.node,anchorOffset:t.offset})}function Ua(n,e){let{node:t,offset:o}=n.docView.domFromPos(e,0),r=o<t.childNodes.length?t.childNodes[o]:null,i=o?t.childNodes[o-1]:null;if(Te&&r&&r.contentEditable=="false")return Si(r);if((!r||r.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(r)return Si(r);if(i)return Si(i)}}function Si(n){return n.contentEditable="true",Te&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ja(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function ng(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSel.readRange(),o=t.anchorNode,r=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=o||t.anchorOffset!=r)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Tc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function og(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 rg(n,e){if(e instanceof R){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Ka(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Ka(n)}function Ka(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Cn(n,e,t,o){let r=n.someProp("createSelectionBetween",i=>i(n,e,t))||P.between(e,t,o);return n.someProp("adjustSelectionFromDOM",i=>{r=i(n,r)}),r}function Oc(n){if(n.editable&&!n.hasFocus())return null;let e=n.domSel.readRange();return e&&Lc(n,e)?e:null}function Lc(n,e){if(!e.anchorNode)return!1;try{return kn(n.dom,e.anchorNode)&&(n.editable||kn(n.dom,e.focusNode))}catch{return!1}}function sg(n){for(let e in Ne){let t=Ne[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=o=>{ag(n,o)&&(n.input.composing&&(o.type=="keydown"||o.type=="beforeinput")&&o.isComposing===!1&&Ic(n,!0),!Ki(n,o)&&(n.editable||!(o.type in Oe))&&t(n,o))},ig[e]?{passive:!0}:void 0)}Te&&n.dom.addEventListener("input",()=>null),zi(n)}function ur(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function lg(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 zi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=o=>Ki(n,o))})}function Ki(n,e){return n.someProp("handleDOMEvents",t=>{let o=t[e.type];return o?o(n,e)||e.defaultPrevented:!1})}function ag(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 cg(n,e){!Ki(n,e)&&Ne[e.type]&&(n.editable||!(e.type in Oe))&&Ne[e.type](n,e)}function Tt(n,e){let{input:t}=n;return t.lastKeyDispatched||n.composing?!1:(t.lastKeyDispatched=!0,typeof e=="string"&&(e=ym(e=="Backspace"?8:13,e)),n.someProp("handleKeyDown",o=>o(n,e)))}function ro(n){return{left:n.clientX,top:n.clientY}}function ug(n,e){let t=e.x-n.clientX,o=e.y-n.clientY;return t*t+o*o<100}function Ji(n,e,t,o,r){if(o==-1)return!1;let i=n.state.doc.resolve(o);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),r,!0):l(n,t,i.node(s),i.before(s),r,!1)))return!0;return!1}function Dc(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let o=n.state.tr.setSelection(e);o.setMeta("pointer",!0),n.dispatch(o)}function dg(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),o=t.nodeAfter;return o&&o.isAtom&&R.isSelectable(o)?(Dc(n,new R(t)),!0):!1}function fg(n,e){if(e==-1)return!1;let t=n.state.selection,o,r;t instanceof R&&(o=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(R.isSelectable(l)){o&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?r=i.before(t.$from.depth):r=i.before(s);break}}return r!=null?(Dc(n,R.create(n.state.doc,r)),!0):!1}function pg(n,e,t,o,r){return Ji(n,"handleClickOn",e,t,o)||n.someProp("handleClick",i=>i(n,e,o))||(r?fg(n,t):dg(n,t))}function hg(n,e,t,o){return Ji(n,"handleDoubleClickOn",e,t,o)||n.someProp("handleDoubleClick",r=>r(n,e,o))}function mg(n,e,t,o){return Ji(n,"handleTripleClickOn",e,t,o)||n.someProp("handleTripleClick",r=>r(n,e,o))}function Ja(n,e,t){if(e==-1)return n.inlineContent?P.create(n,0,n.content.size):null;let o=n.resolve(e);for(let r=o.depth+1;r>0;r--){let i=r>o.depth?o.nodeAfter:o.node(r),s=o.before(r);if(i.inlineContent)return P.create(n,s+1,s+1+i.content.size);if(t&&R.isSelectable(i))return R.create(n,s)}return null}function Ga(n,e){let t=n.resolve(e),o=t.node(),r="",i=e,s=e;for(let g=t.indexAfter(),b=!1;g>0;g--){let m=o.child(g-1);if(!m.text)break;let y=i==e?e-t.posAtIndex(g-1):m.text.length,v=y;for(;v>0;v--)if(/\S/.test(m.text[v-1]))b=!0;else if(b)break;if(r=m.text.slice(v,y)+r,i-=y-v,v||i<e-50)break}for(let g=t.index(),b=!1;g<o.childCount;g++){let m=o.child(g);if(!m.text)break;let y=s==e?e-t.posAtIndex(g):0,v=y;for(;v<m.text.length;v++)if(/\S/.test(m.text[v]))b=!0;else if(b)break;if(r+=m.text.slice(y,v),s+=v-y,v<m.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(r))if(g.isWordLike){let b=g.index+i,m=b+g.segment.length;if(m<e)l=m;else if(b>e){a=b;break}else return P.create(n,b,m)}}else{Fi.lastIndex=0;for(let g;g=Fi.exec(r);){let b=g.index+i,m=b+g[0].length;if(m<e)l=m;else if(b>e){a=b;break}else return P.create(n,b,m)}}let c=r.slice(l-i,e-i),u=r.slice(e-i,a-i),d=/\S*$/.exec(c)[0].length,f=/^\S*/.exec(u)[0].length;if(d||f)return P.create(n,e-d,e+f);let p=/\s*$/.exec(c)[0].length,h=/^\s*/.exec(u)[0].length;return P.create(n,e-p,e+h)}function Xa(n){let e=n.dom.getBoundingClientRect();return{x:e.left-n.dom.scrollLeft,y:e.top-n.dom.scrollTop}}function Ya(n,e,t){if(t.inside>-1){let r=e.nodeAt(t.inside);if(r.isAtom&&R.isSelectable(r))return R.create(e,t.inside)}let o=e.resolve(t.pos);return Cn(n,o,o)}function gg(n,e){let{selection:t}=n.state;if(t.empty)return!1;let o=n.domSelection();if(!o||o.rangeCount==0)return!0;let r=o.getRangeAt(0).getClientRects();for(let i=0;i<r.length;i++){let s=r[i];if(s.left<=e.clientX&&s.right>=e.clientX&&s.top<=e.clientY&&s.bottom>=e.clientY)return!0}return!1}function bg(n,e){return n.composing?!0:Te&&Math.abs(Date.now()-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}function vg(n){let{focusNode:e,focusOffset:t}=n.domSel.range;if(!e||!H(e)||t>=e.childNodes.length)return!1;let o=e.childNodes[t];return H(o)&&o.contentEditable=="false"}function Ic(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?Gt(n):Pc(n,20)}function Pc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Gt(n),e))}function Bc(n){n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Date.now());for(let e;e=n.input.compositionNodes.pop();)e.markParentDamage()}function wg(n){let e=n.domSel.range;if(!n.domSel.active||!e.focusNode)return null;let t=lc(e.focusNode,e.focusOffset),o=ac(e.focusNode,e.focusOffset);if(t&&o&&t!=o){let r=o.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||o==i)return i;if(!r||!r.isText(o.nodeValue))return o;if(n.input.compositionNode==o){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return o}}return t||o}function Gt(n,e=!1){if(!(at&&n.domObserver.flushingSoon>=0)&&(n.domObserver.forceFlush(),Bc(n),e||n.docView&&n.docView.damage)){let t=ji(n,n.domSel.readRange()),o=n.state.selection;t&&!t.eq(o)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state)}}function xg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(e),n.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}function kg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Mg(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,o=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),o.parentNode&&o.parentNode.removeChild(o),t?so(n,o.value,null,r,e):so(n,o.textContent,o.innerHTML,r,e)},50)}function so(n,e,t,o,r){let i=kc(n,e,t,o,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,r,i||L.empty)))return!0;if(!i)return!1;let s=kg(i),l=s?n.state.tr.replaceSelectionWith(s,o):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hc(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 zc(n,e){let t;return n.someProp("dragCopies",o=>{t=t||o(e)}),t!=null?!t:!e[Sg]}function Cg(n,e,t){if(!e.dataTransfer)return;let o=n.posAtCoords(ro(e));if(!o)return;let r=n.state.doc.resolve(o.pos),i=t&&t.slice;i?n.someProp("transformPasted",p=>{i=p(i,n,!1)}):i=kc(n,Hc(e.dataTransfer),io?null:e.dataTransfer.getData("text/html"),!1,r);let s=!!(t&&zc(n,e));if(n.someProp("handleDrop",p=>p(n,e,i||L.empty,s))){e.preventDefault();return}if(!i)return;e.preventDefault();let l=i?Wo(n.state.doc,r.pos,i):r.pos;l==null&&(l=r.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&&R.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new R(f));else{let p=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((h,g,b,m)=>p=m),a.setSelection(Cn(n,f,a.doc.resolve(p)))}n.focus(),n.dispatch(a.setMeta("uiEvent","drop"))}function lo(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 Eg(n,e,t,o,r,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,g)=>{let b=g-h-(p-f);for(let m=0;m<l.length;m+=3){let y=l[m+1];if(y<0||f>y+u-d)continue;let v=l[m]+u-d;p>=v?l[m+1]=f<=v?-2:-1:f>=u&&b&&(l[m]+=b,l[m+1]+=b)}d+=b}),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-r;if(d<0||d>=o.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),p=f-r,{index:h,offset:g}=o.content.findIndex(d),b=o.maybeChild(h);if(b&&g==d&&g+b.nodeSize==p){let m=l[c+2].mapInner(t,b,u+1,n[c]+i+1,s);m!=we?(l[c]=d,l[c+1]=p,l[c+2]=m):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Ag(l,n,e,t,r,i,s),u=lr(c,o,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 J(e.sort(Nt),l)}function Fc(n,e){if(!e||!n.length)return n;let t=[];for(let o=0;o<n.length;o++){let r=n[o];t.push(new te(r.from+e,r.to+e,r.type))}return t}function Ag(n,e,t,o,r,i,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(o,r,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 $c(n,e,t){if(e.isLeaf)return null;let o=t+e.nodeSize,r=null;for(let i=0,s;i<n.length;i++)(s=n[i])&&s.from>t&&s.to<o&&((r||(r=[])).push(s),n[i]=null);return r}function _c(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function lr(n,e,t,o){let r=[],i=!1;e.forEach((l,a)=>{let c=$c(n,l,a+t);if(c){i=!0;let u=lr(c,l,t+a+1,o);u!=we&&r.push(a,a+l.nodeSize,u)}});let s=Fc(i?_c(n):n,-t).sort(Nt);if(s.length){let l=new ao(e.content);for(let a=0;a<s.length;a++)s[a].type.valid(e,s[a],l)||(o.onRemove&&o.onRemove(s[a].spec),s.splice(a--,1))}return s.length||r.length?new J(s,r):we}function Nt(n,e){return n.from-e.from||n.to-e.to}function Gi(n){let e=n;for(let t=0;t<e.length-1;t++){let o=e[t];if(o.from!=o.to)for(let r=t+1;r<e.length;r++){let i=e[r];if(i.from==o.from){i.to!=o.to&&(e==n&&(e=n.slice()),e[r]=i.copy(i.from,o.to),Qa(e,r+1,i.copy(o.to,i.to)));continue}else{i.from<o.to&&(e==n&&(e=n.slice()),e[t]=o.copy(o.from,i.from),Qa(e,r,o.copy(i.from,o.to)));break}}}return e}function Qa(n,e,t){for(;e<n.length&&Nt(t,n[e])>0;)e++;n.splice(e,0,t)}function Ci(n){let e=[];return n.someProp("decorations",t=>{let o=t(n.state);o&&o!=we&&e.push(o)}),n.cursorWrapper&&e.push(J.create(n.state.doc,[n.cursorWrapper.deco])),sr.from(e)}function Tg(n,e,t,o){let{node:r,fromOffset:i,toOffset:s,from:l,to:a}=n.docView.parseRange(e,t),c=n.domSel.range,u,d=c.anchorNode;if(d&&kn(n.dom,d)&&(u=[{node:d,offset:c.anchorOffset}],ar(c)||u.push({node:c.focusNode,offset:c.focusOffset})),Ae&&n.input.lastKeyCode===8)for(let m=s;m>i;m--){let y=r.childNodes[m-1],v=y.pmViewDesc;if(y.nodeName=="BR"&&!v){s=m;break}if(!v||v.size)break}let f=n.state.doc,p=n.someProp("domParser")||xt.fromSchema(n.state.schema),h=f.resolve(l),g=null,b=p.parse(r,{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:Ng(o),context:h});if(u&&u[0].pos!=null){let m=u[0].pos,y=u[1]&&u[1].pos;y==null&&(y=m),g={anchor:m+l,head:y+l}}return{doc:b,sel:g,from:l,to:a}}function Lg(n,e,t,o,r,i){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let x=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,S=ji(n,n.domSel.range,x);if(S&&!n.state.selection.eq(S)&&n.domSel.active){if(Ae&&at&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&Tt(n,"Enter"))return;let E=n.state.tr.setSelection(S);x=="pointer"?E.setMeta("pointer",!0):x=="key"&&E.scrollIntoView(),s&&E.setMeta("composition",s),n.dispatch(E)}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=Tg(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 g=Pg(f.content,u.doc.content,u.from,p,h);if(g&&n.input.domChangeCount++,(Sn&&n.input.lastIOSEnter>Date.now()-225||at)&&i.some(x=>H(x)&&!Og.test(x.nodeName))&&(!g||g.endA>=g.endB)&&Tt(n,"Enter")){n.input.lastIOSEnter=0;return}if(!g)if(r&&c instanceof P&&!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 x=Za(n,n.state.doc,u.sel);if(x&&!x.eq(n.state.selection)){let S=n.state.tr.setSelection(x);s&&S.setMeta("composition",s),n.dispatch(S)}}return}n.state.selection.from<n.state.selection.to&&g.start==g.endB&&n.state.selection instanceof P&&(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 b=u.doc.resolveNoCache(g.start-u.from),m=u.doc.resolveNoCache(g.endB-u.from),y=d.resolve(g.start),v=b.sameParent(m)&&b.parent.inlineContent&&y.end()>=g.endA;if((Sn&&n.input.lastIOSEnter>Date.now()-225&&(!v||i.some(x=>x.nodeName=="DIV"||x.nodeName=="P"))||!v&&Ig(u.doc,b.pos,m.pos))&&Tt(n,"Enter")){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>g.start&&(v?g.endA>g.start&&g.endB==g.start:Rg(d,g.start,g.endA,b,m))&&Tt(n,"Backspace")){at&&Ae&&n.domSel.suppressChanges();return}Ae&&g.endB==g.start&&(n.input.lastChromeDelete=Date.now()),at&&!v&&b.start()!=m.start()&&m.parentOffset==0&&b.depth==m.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==g.endA&&(g.endB-=2,m=u.doc.resolveNoCache(g.endB-u.from),setTimeout(()=>Tt(n,"Enter"),20));let M=g.start,T=g.endA,C=x=>{let S=x||n.state.tr.replace(M,T,u.doc.slice(g.start-u.from,g.endB-u.from));if(u.sel){let E=Za(n,S.doc,u.sel);E&&!(Ae&&n.composing&&E.empty&&(g.start!=g.endB||n.input.lastChromeDelete<Date.now()-100)&&(E.head==M||E.head==S.mapping.map(T)-1))&&S.setSelection(E)}return s&&S.setMeta("composition",s),S.scrollIntoView()},N;if(v)if(b.pos==m.pos){let x=C(n.state.tr.delete(M,T)),S=d.resolve(g.start).marksAcross(d.resolve(g.endA));S&&x.ensureMarks(S),n.dispatch(x)}else if(g.endA==g.endB&&(N=Dg(b.parent.content.cut(b.parentOffset,m.parentOffset),y.parent.content.cut(y.parentOffset,g.endA-y.start())))){let x=C(n.state.tr);N.type=="add"?x.addMark(M,T,N.mark):x.removeMark(M,T,N.mark),n.dispatch(x)}else if(b.parent.child(b.index()).isText&&b.index()==m.index()-(m.textOffset?0:1)){let x=b.parent.textBetween(b.parentOffset,m.parentOffset),S=()=>C(n.state.tr.insertText(x,M,T));n.someProp("handleTextInput",E=>E(n,M,T,x,S))||n.dispatch(S())}else n.dispatch(C());else n.dispatch(C())}function Za(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Cn(n,e.resolve(t.anchor),e.resolve(t.head))}function Dg(n,e){let t=n.firstChild.marks,o=e.firstChild.marks,r=t,i=o,s,l,a;for(let u=0;u<o.length;u++)r=o[u].removeFromSet(r);for(let u=0;u<t.length;u++)i=t[u].removeFromSet(i);if(r.length==1&&i.length==0)l=r[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(r.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 Rg(n,e,t,o,r){if(t-e<=r.pos-o.pos||Ei(o,!0,!1)<r.pos)return!1;let i=n.resolve(e);if(!o.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(Ei(i,!0,!0));return!s.parent.isTextblock||s.pos>t||Ei(s,!0,!1)<t?!1:o.parent.content.cut(o.parentOffset).eq(s.parent.content)}function Ig(n,e,t){let o=0,r=0;return n.nodesBetween(e,t,(i,s)=>{i.isTextblock&&s>=e&&s<t?o++:(i.isText?/\S/.test(i.text.slice(Math.max(0,e-s),Math.min(i.nodeSize,t-s))):i.isLeaf)&&r++}),r==0&&o==1}function Ei(n,e,t){let o=n.depth,r=e?n.end():n.pos;for(;o>0&&(e||n.indexAfter(o)==n.node(o).childCount);)o--,r++,e=!1;if(t){let i=n.node(o).maybeChild(n.indexAfter(o));for(;i&&!i.isLeaf;)i=i.firstChild,r++}return r}function Pg(n,e,t,o,r){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(r=="end"){let u=Math.max(0,i-Math.min(a,c));o-=a+u-i}if(a<i&&s<l){let u=o<=i&&o>=a?i-o:0;i-=u,c=i+(c-a),a=i}else if(c<i){let u=o<=i&&o>=c?i-o:0;i-=u,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}function Hg(n){if(!ec.has(n)&&(ec.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=je,tc)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."),tc=!0}}function zg(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let o=n.docView.nearestDesc(t,!0);if(o&&o.node.isBlock)return t}return null}function Fg(n,e){var t;let{focusNode:o,focusOffset:r}=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),o==i&&n.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function nc(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let o in t)o=="class"?e.class+=" "+t[o]:o=="style"?e.style=(e.style?e.style+";":"")+t[o]:!e[o]&&o!="contenteditable"&&o!="nodeName"&&(e[o]=String(t[o]))}),e.translate||(e.translate="no"),[te.node(0,n.state.doc.content.size,e)]}function oc(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:te.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function rc(n){return!n.someProp("editable",e=>e(n.state)===!1)}function $g(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(o){for(let r in o)Object.prototype.hasOwnProperty.call(e,r)||(e[r]=o[r])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function _g(n,e){let t=0,o=0;for(let r in n){if(n[r]!=e[r])return!0;t++}for(let r in e)o++;return t!=o}function sc(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,Ai,Ta,Ye,Oa,Mn,je,Ti,Ae,uc,Te,Sn,Ve,dc,at,cr,xm,yn,Lm,Rm,Da,Ra,Ia,Jt,er,Oi,Ut,Ot,no,tr,nr,eo,Wt,Li,Km,Ec,Zn,ze,Bi,Wa,Ne,Oe,ig,Hi,Fi,Rc,$i,yg,io,rr,Sg,ao,ir,jt,_i,te,wn,Kt,J,we,sr,Ng,Og,Bg,Vi,ec,tc,Xt,Lt=D(()=>{"use strict";U();ce();Ge();Ee=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e};Ai=null;Ta=/^(img|br|input|textarea|hr)$/i;Ye=typeof navigator<"u"?navigator:null,Oa=typeof document<"u"?document:null,Mn=Ye&&Ye.userAgent||"",je=/gecko\/(\d+)/i.test(Mn)&&!/edge?\//i.test(Mn);je&&+(/Firefox\/(\d+)/.exec(Mn)||[0,0])[1];Ti=/Chrome\/(\d+)/.exec(Mn),Ae=!!Ti,uc=Ti?+Ti[1]:0,Te=!!Ye&&/Apple Computer/.test(Ye.vendor),Sn=Te&&(/Mobile\/\w+/.test(Mn)||!!Ye&&Ye.maxTouchPoints>2),Ve=Sn||(Ye?/Mac/.test(Ye.platform):!1),dc=Ye?/Win/.test(Ye.platform):!1,at=/Android \d/.test(Mn),cr=!!Oa&&"webkitFontSmoothing"in Oa.documentElement.style,xm=cr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;yn=null;Lm=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;Rm=/[\u0590-\u08ac]/;Da=null,Ra=null,Ia=!1;Jt=class{constructor(e,t,o,r){this.parent=e,this.children=t,this.dom=o,this.contentDOM=r,this.damage=0,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,o){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,o=this.posAtStart;;t++){let r=this.children[t];if(r==e)return o;o+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,o){if(this.contentDOM&&kn(this.contentDOM,e))if(o<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 r;if(e==this.dom&&this.contentDOM)r=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?r=t>Array.from(e.childNodes).findIndex(s=>s.contains(this.contentDOM)):r=!(i&4)}else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!1;break}if(i.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){r=!0;break}if(i.nextSibling)break}}return r??o>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let o=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),s;if(i&&(!t||i.node))if(o&&(s=i.nodeDOM)&&!(H(s)?kn(s,e):s==e))o=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let o=t;o;o=o.parent)if(o==this)return t}posFromDOM(e,t,o){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,o)}return-1}descAt(e){for(let t=0,o=0;t<this.children.length;t++){let r=this.children[t],i=o+r.size;if(o==e&&i!=o){for(;!r.border&&r.children.length;)for(let s=0;s<r.children.length;s++){let l=r.children[s];if(l.size){r=l;break}}return r}if(e<i)return r.descAt(e-o-r.border);o=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let o=0,r=0;for(let i=0;o<this.children.length;o++){let s=this.children[o],l=i+s.size;if(l>e){r=e-i;break}i=l}if(r)return this.children[o].domFromPos(r-this.children[o].border,t);for(;o>0;o--){let i=this.children[o-1];if(i.size||!(i instanceof tr||i instanceof er&&i.side>=0))break}if(t<=0){let i,s=!0;for(;i=o?this.children[o-1]:null,!(!i||i.dom.parentNode==this.contentDOM);o--,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=o<this.children.length?this.children[o]:null,!(!i||i.dom.parentNode==this.contentDOM);o++,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,o=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let s=o,l=0;;l++){let a=this.children[l],c=s+a.size;if(r==-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)){r=Ee(f.dom)+1;break}e-=f.size}r==-1&&(r=0)}if(r>-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:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:o}=this.domFromPos(e,0);if(!H(t)||o==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[o]}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}},er=class extends Jt{constructor(e,t,o,r){let i,s=t.type.toDOM;if(typeof s=="function"&&(s=s(o,()=>{if(!i)return r;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}},Oi=class extends Jt{constructor(e,t,o,r){super(e,[],t,null),this.textDOM=o,this.text=r}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}},Ut=class n extends Jt{constructor(e,t,o,r,i){super(e,[],o,r),this.mark=t,this.spec=i}static create(e,t,o,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,o);return(!s||!s.dom)&&(s=Ue.renderSpec(document,t.type.spec.toDOM(t,o),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,o){let r=n.create(this.parent,this.mark,!0,o),i=this.children,s=this.size;t<s&&(i=Di(i,t,s,o)),e>0&&(i=Di(i,0,e,o));for(let l=0;l<i.length;l++)i[l].parent=r;return r.children=i,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Ot=class n extends Jt{constructor(e,t,o,r,i,s,l){super(e,[],i,s),this.node=t,this.outerDeco=o,this.innerDeco=r,this.nodeDOM=l}static create(e,t,o,r,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)},o,r),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}=Ue.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=wc(u,o,t),c?a=new nr(e,t,o,r,u,d||null,f,c):t.isText?new no(e,t,o,r,u,f):new n(e,t,o,r,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 o=this.children.length-1;o>=0;o--){let r=this.children[o];if(this.dom.contains(r.dom.parentNode)){t.contentElement=r.dom.parentNode;break}}if(!t.contentElement){let o=e&&e.find(r=>H(r)&&e.indexOf(r.parentNode)<0&&this.dom.contains(r));o?t.contentElement=o:t.getContent=()=>A.empty}}return t}matchesNode(e,t,o){return!this.damage&&e.eq(this.node)&&or(t,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let o=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Li(this,s&&s.node,e),c=this.node.inlineContent,u=c&&this.node.isBlock;Fm(this.node,this.innerDeco,(d,f,p)=>{d.spec.marks?a.syncToMarks(d.spec.marks,o,e,f):d.type.side>=0&&!p&&a.syncToMarks(f==this.node.childCount?q.none:this.node.child(f).marks,o,e,f),a.placeWidget(d,e,r)},(d,f,p,h)=>{a.syncToMarks(d.marks,o,e,h),u&&d.isAtom&&!d.isText&&a.addHackNode("IMG",a.top);let g;a.findNodeMatch(d,f,p,h)||l&&e.state.selection.from>r&&e.state.selection.to<r+d.nodeSize&&(g=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(d,f,p,g,e,r)||a.updateNextNode(d,f,p,e,h,r)||a.addNode(d,f,p,e,r),r+=d.nodeSize,c&&(u=d.isAtom&&!d.isText)}),a.syncToMarks([],o,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.damage&2)&&(s&&this.protectLocalComposition(e,s),vc(this.contentDOM,this.children,e),Sn&&$m(this.dom))}localCompositionInfo(e,t){let{from:o,to:r}=e.state.selection;if(!(e.state.selection instanceof P)||o<t||r>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=_m(this.node.content,s,o-t,r-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:o,text:r}){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 Oi(this,i,t,r);e.input.compositionNodes.push(s),this.children=Di(this.children,o,o+r.length,e,s)}update(e,t,o,r,i){return this.damage&4||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,o,r,i),!0)}updateInner(e,t,o,r,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=o,this.contentDOM&&this.updateChildren(r,i+1),this.damage=0}updateOuterDeco(e){if(or(e,this.outerDeco))return;let t=!H(this.nodeDOM),o=this.dom;this.dom=Wi(this.dom,this.nodeDOM,oo(this.outerDeco,this.node,t),oo(e,this.node,t)),this.dom!=o&&(o.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}};no=class n extends Ot{constructor(e,t,o,r,i,s){super(e,t,o,r,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,o,r){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,r.trackWrites==this.nodeDOM&&(r.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,o){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,o)}ignoreMutation(e){return!1}slice(e,t,o){let r=this.node.cut(e,t),i=document.createTextNode(r.text);return new n(this.parent,r,this.outerDeco,this.innerDeco,i,i)}get domAtom(){return!1}isText(e){return this.node.text==e}},tr=class extends Jt{parseRule(){return{ignore:!0}}matchesHack(e){return!this.damage&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},nr=class extends Ot{constructor(e,t,o,r,i,s,l,a){super(e,t,o,r,i,s,l),this.spec=a}update(e,t,o,r,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,o);return s&&this.updateInner(e,t,o,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,o,r,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)}};eo=function(n){n&&(this.nodeName=n)};eo.prototype=Object.create(null);Wt=[new eo];Li=class{constructor(e,t,o){this.lock=t,this.view=o,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Hm(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let o=e;o<t;o++)this.top.children[o].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,o,r){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;r<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 Ut&&!(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=Ut.create(this.top,e[s],t,o);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,o,r){let i=-1,s;if(r>=this.preMatch.index&&(s=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,o))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,o)&&!this.preMatch.matched.has(c)){i=l;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,o,r,i,s){let l=this.top.children[r];return l.damage&4&&l.dom==l.contentDOM&&(l.damage=2),l.update(e,t,o,i,s)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let o=e.pmViewDesc;if(o){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==o)return r}return-1}e=t}}updateNextNode(e,t,o,r,i,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ot){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)&&or(t,a.outerDeco));if(!f&&a.update(e,t,o,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,o,r,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.damage|=2,d.updateChildren(r,s+1),d.damage=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,o,r,i,s){if(e.damage&3||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!or(o,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=Ot.create(this.top,t,o,r,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,o,r,i){let s=Ot.create(this.top,e,t,o,r,i);s.contentDOM&&s.updateChildren(r,i+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,o){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let i=new er(this.top,e,t,o);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ut;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof no)||/\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 o=document.createElement(e);e=="IMG"&&(o.className="ProseMirror-separator",o.alt=""),e=="BR"&&(o.className="ProseMirror-trailingBreak");let r=new tr(this.top,[],o,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||H(e)&&e.contains(this.lock.parentNode))}};Km=/^(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;Ec={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};Zn=null;ze=class n{constructor(e,t,o,r){this.anchorNode=e,this.anchorOffset=t,this.focusNode=o,this.focusOffset=r}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);Bi=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&&vm(e.dom.ownerDocument)==e.dom?ze.from(Zm(e,t)||t):ze.from(t):ze.null}read(){this.ensureListener();let e=Oc(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(()=>{rg(t,t.state.selection);let o=t.state.selection;if(t.input.mouseDown||Tc(t)){let{desc:r,start:i}=Nc(t.docView,o.from,o.to,0);t.cursorWrapper?og(t):r instanceof nr&&r.spec.setSelection?r.spec.setSelection(o.anchor-i,o.head-i,t.root):eg(t,e,r,i),this.synced=this.active=!0}o.visible==t.dom.classList.contains("ProseMirror-hideselection")&&(o.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),ng(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}};Wa=Te||Ae&&uc<63;Ne={},Oe={},ig={touchstart:!0,touchmove:!0},Hi=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}};Oe.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,!(at&&Ae&&t.keyCode==13)){if(Sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let o=Date.now();n.input.lastIOSEnter=o,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==o&&(Tt(n,"Enter"),n.input.lastIOSEnter=0)},200);return}t.keyCode!=229&&n.domObserver.forceFlush(!0),Tt(n,t)||jm(n,t)?t.preventDefault():ur(n,"key")}};Oe.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Oe.keypress=(n,e)=>{let t=e;if(bg(n)||!t.charCode||t.ctrlKey&&!t.altKey||Ve&&t.metaKey)return;if(n.someProp("handleKeyPress",r=>r(n,t))){t.preventDefault();return}let o=n.state.selection;if(!(o instanceof P)||!o.$from.sameParent(o.$to)){let r=String.fromCharCode(t.charCode),i=()=>n.state.tr.insertText(r).scrollIntoView();!/[\r\n]/.test(r)&&!n.someProp("handleTextInput",s=>s(n,o.$from.pos,o.$to.pos,r,i))&&n.dispatch(i()),t.preventDefault()}};Fi=/[\w_\u00a1-\uffff]+/g;try{Fi=new RegExp("[\\p{L}\\p{N}_]+","gu")}catch{}Rc=Ve?"metaKey":"ctrlKey";Ne.mousedown=(n,e)=>{let t=e,o=Date.now();if(n.input.shiftKey=t.shiftKey,n.input.lastTouch>o-500)return!1;Gt(n);let r="singleClick";o-n.input.lastClick.time<500&&ug(t,n.input.lastClick)&&!t[Rc]&&n.input.lastClick.button==t.button&&(n.input.lastClick.type=="singleClick"?r="doubleClick":n.input.lastClick.type=="doubleClick"&&(r="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:r,button:t.button},n.input.mouseDown&&n.input.mouseDown.done();let i=n.posAtCoords(ro(t));if(i)if(t.button==0){if(!n.hasFocus()){hc(n.dom);let l=n.root.activeElement;l&&!l.contains(n.dom)&&l.blur()}(n.input.mouseDown=new $i(n,i,t,r)).mightDrag||t.preventDefault()}else ur(n,"pointer")};$i=class{constructor(e,t,o,r){var i;this.view=e,this.startPos=t,this.event=o,this.type=r,this.didMove=!1,this.lastPos=-1,this.anchorRange=null,this.startDoc=e.state.doc,this.selectNode=!!o[Rc],this.extend=o.shiftKey,this.anchorDoc=this.startDoc;let s=Xa(e);if(this.extend){let l=e.state.selection;this.anchorRange=l instanceof R?{from:l.from,to:l.to}:{from:l.anchor,to:l.anchor};let a=l instanceof R?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:o.clientX-s.x,y:o.clientY-s.y};if(r=="singleClick"){let{selection:l}=e.state,a,c,u=!1;if(l instanceof R&&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=gg(e,o)}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"?pg:this.type=="doubleClick"?hg:mg)(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(ro(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(ro(e));t&&this.select(t,!1)}e.preventDefault()}select(e,t){if(e.pos==this.lastPos)return;this.lastPos=e.pos;let{view:o}=this,{doc:r}=o.state,i=this.type=="singleClick"?Ya(o,r,e):this.type=="doubleClick"?Ga(r,e.pos):Ja(r,e.inside,t);i&&(t&&!this.extend?this.anchorRange=i:(!t||this.extend)&&(r.eq(this.anchorDoc)||this.restoreAnchor(),this.anchorRange&&this.anchorRange.from<i.from?i=Cn(o,r.resolve(this.anchorRange.from),r.resolve(i.to)):this.anchorRange&&this.anchorRange.to>i.to&&(i=Cn(o,r.resolve(this.anchorRange.to),r.resolve(i.from)))),i.eq(o.state.selection)||o.dispatch(o.state.tr.setSelection(i).setMeta("pointer",!0).scrollIntoView()))}restoreAnchor(){let e=Xa(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:o}=this.view.state;this.anchorRange=this.type=="singleClick"?Ya(this.view,o,t):this.type=="doubleClick"?Ga(o,t.pos):Ja(o,t.inside,!1),this.anchorDoc=this.view.state.doc}}};Ne.touchstart=n=>{n.input.lastTouch=Date.now(),Gt(n),ur(n,"pointer")};Ne.touchmove=n=>{n.input.lastTouch=Date.now(),ur(n,"pointer")};Ne.contextmenu=n=>Gt(n);yg=at?5e3:-1;Oe.compositionstart=Oe.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(o=>o.type.spec.inclusive===!1)||Ae&&dc&&vg(n)))n.markCursor=n.state.storedMarks||t.marks(),Gt(n,!0),n.markCursor=null;else if(Gt(n,!e.selection.empty),je&&n.domSel.active&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length)for(let{focusNode:o,focusOffset:r}=n.domSel.range;o&&H(o)&&r!=0;){let i=r<0?o.lastChild:o.childNodes[r-1];if(!i)break;if(ge(i)){let s=n.domSelection();s&&s.collapse(i,i.nodeValue.length);break}else o=i,r=-1}n.input.composing=!0}Pc(n,yg)};Oe.compositionend=(n,e)=>{n.composing&&Ic(n)};io=Sn&&xm<604;Ne.copy=Oe.cut=(n,e)=>{let t=e,o=n.state.selection,r=t.type=="cut";if(o.empty)return;let i=io?null:t.clipboardData,s=o.content(),{dom:l,text:a}=Ui(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):xg(n,l),r&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};Oe.paste=(n,e)=>{let t=e;if(n.composing&&!at)return;let o=io?null:t.clipboardData,r=n.input.shiftKey&&n.input.lastKeyCode!=45;o&&so(n,Hc(o),o.getData("text/html"),r,t)?t.preventDefault():Mg(n,t)};rr=class{constructor(e,t,o){this.slice=e,this.move=t,this.node=o}},Sg=Ve?"altKey":"ctrlKey";Ne.dragstart=(n,e)=>{let t=e,o=n.input.mouseDown;if(o&&o.done(),!t.dataTransfer)return;let r=n.state.selection,i=r.empty?null:n.posAtCoords(ro(t)),s;if(!(i&&i.pos>=r.from&&i.pos<=(r instanceof R?r.to-1:r.to))){if(o&&typeof o.mightDrag=="object")s=R.create(n.state.doc,o.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=R.create(n.state.doc,d.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:u}=Ui(n,l);(!t.dataTransfer.files.length||!Ae||uc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(io?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",io||t.dataTransfer.setData("text/plain",c),n.dragging=new rr(u,zc(n,t),s)};Ne.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Oe.dragover=Oe.dragenter=(n,e)=>e.preventDefault();Oe.drop=(n,e)=>{try{Cg(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(at&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:o}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=o||n.domObserver.pendingRecords().length||(n.dom.blur(),n.focus(),Tt(n,"Backspace")))return;let{$cursor:r}=n.state.selection;r&&r.pos>0&&n.dispatch(n.state.tr.delete(r.pos-1,r.pos).scrollIntoView())},50)}};for(let n in Oe)Ne[n]=Oe[n];ao=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}},ir=class n{constructor(e,t){this.toDOM=e,this.spec=t||Kt,this.side=this.spec.side||0}map(e,t,o,r){let{pos:i,deleted:s}=e.mapResult(t.from+r,this.side<0?-1:1);return s?null:new te(i-o,i-o,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&&lo(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||Kt}map(e,t,o,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-o,s=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-o;return i>=s?null:new te(i,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof n&&lo(this.attrs,e.attrs)&&lo(this.spec,e.spec)}static is(e){return e.type instanceof n}destroy(){}},_i=class n{constructor(e,t){this.attrs=e,this.spec=t||Kt}map(e,t,o,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let s=e.mapResult(t.to+r,-1);return s.deleted||s.pos<=i.pos?null:new te(i.pos-o,s.pos-o,this)}valid(e,t,o){let r=o.nodeAt(t.from);return!!r&&!r.isText&&t.from+r.nodeSize==t.to}eq(e){return this==e||e instanceof n&&lo(this.attrs,e.attrs)&&lo(this.spec,e.spec)}destroy(){}},te=class n{constructor(e,t,o){this.from=e,this.to=t,this.type=o}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,o){return this.type.map(e,this,t,o)}static widget(e,t,o){return new n(e,e,new ir(t,o))}static inline(e,t,o,r){return new n(e,t,new jt(o,r))}static node(e,t,o,r){return new n(e,t,new _i(o,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof jt}get widget(){return this.type instanceof ir}},wn=[],Kt={},J=class n{constructor(e,t){this.local=e.length?e:wn,this.children=t.length?t:wn}static create(e,t){return t.length?lr(t,e,0,Kt):we}find(e,t,o){let r=[];return this.findInner(e??0,t??1e9,r,0,o),r}findInner(e,t,o,r,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))&&o.push(l.copy(l.from+r,l.to+r))}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,o,r+l,i)}}map(e,t,o){return this==we||e.maps.length==0?this:this.mapInner(e,t,0,0,o||Kt)}mapInner(e,t,o,r,i){let s;if(this.local.length){let l=new ao(t.content);for(let a=0;a<this.local.length;a++){let c=this.local[a].map(e,o,r);c&&c.type.valid(t,c,l)?(s||(s=[])).push(c):i.onRemove&&i.onRemove(this.local[a].spec)}}return this.children.length?Eg(this.children,s||[],e,t,o,r,i):s?new n(s.sort(Nt),wn):we}add(e,t){return t.length?this==we?n.create(e,t):this.addInner(e,t,0):this}addInner(e,t,o){let r,i=0;e.forEach((l,a)=>{let c=a+o,u;if(u=$c(t,l,c)){for(r||(r=this.children.slice());i<r.length&&r[i]<a;)i+=3;r[i]==a?r[i+2]=r[i+2].addInner(l,u,c+1):r.splice(i,0,a,a+l.nodeSize,lr(u,l,c+1,Kt)),i+=3}});let s=Fc(i?_c(t):t,-o).sort(Nt);if(s.length){let l=new ao(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(Nt):this.local,r||this.children)}remove(e){return e.length==0||this==we?this:this.removeInner(e,0)}removeInner(e,t){let o=this.children,r=this.local;for(let i=0;i<o.length;i+=3){let s,l=o[i]+t,a=o[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;o==this.children&&(o=this.children.slice());let c=o[i+2].removeInner(s,l+1);c!=we?o[i+2]=c:(o.splice(i,3),i-=3)}if(r.length){for(let i=0,s;i<e.length;i++)if(s=e[i])for(let l=0;l<r.length;l++)r[l].eq(s,t)&&(r==this.local&&(r=this.local.slice()),r.splice(l--,1))}return o==this.children&&r==this.local?this:r.length||o.length?new n(r,o):we}forChild(e,t){if(this==we)return this;if(t.isLeaf)return n.empty;let o,r,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{o=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&&(r||(r=[])).push(u.copy(d,f))}}if(r){let c=new n(r.sort(Nt),wn);return o?new sr([c,o]):c}return o||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 Gi(this.localsInner(e))}localsInner(e){if(this==we)return wn;if(e.inlineContent||!this.local.some(jt.is))return this.local;let t=[];for(let o=0;o<this.local.length;o++)this.local[o].type instanceof jt||t.push(this.local[o]);return t}forEachSet(e){e(this)}};J.empty=new J([],[]);J.removeOverlap=Gi;we=J.empty,sr=class n{constructor(e){this.members=e}map(e,t){let o=this.members.map(r=>r.map(e,t,Kt));return n.from(o)}forChild(e,t){if(t.isLeaf)return J.empty;let o=[];for(let r=0;r<this.members.length;r++){let i=this.members[r].forChild(e,t);i!=we&&(i instanceof n?o=o.concat(i.members):o.push(i))}return n.from(o)}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,o=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{o&&(t=t.slice(),o=!1);for(let s=0;s<i.length;s++)t.push(i[s])}}return t?Gi(o?t:t.sort(Nt)):wn}static from(e){switch(e.length){case 0:return we;case 1:return e[0];default:return new n(e.every(t=>t instanceof J)?e:e.reduce((t,o)=>t.concat(o instanceof J?o:o.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};Ng=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 o=document.createElement("div");return o.appendChild(document.createElement("li")),{skip:o}}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},Og=/^(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;Bg={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Vi=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 o=0;o<t.length;o++)this.queue.push(t[o]);Te&&e.composing&&t.some(o=>o.type=="childList"&&o.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,Bg),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,o;for(let i=e.focusNode;i;i=xn(i))t.add(i);for(let i=e.anchorNode;i;i=xn(i))if(t.has(i)){o=i;break}let r=o&&this.view.docView.nearestDesc(o);if(r&&r.ignoreMutation({type:"selection",target:ge(o)?o.parentNode:o}))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 o=this.pendingRecords();o.length&&(this.queue=[]),e&&t.domSel.read();let r=!t.domSel.suppress&&!t.domSel.synced&&!!Oc(t)&&!this.ignoreSelectionChange(t.domSel.range),i=-1,s=-1,l=!1,a=[];if(t.editable)for(let u=0;u<o.length;u++){let d=this.registerMutation(o[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)&&o.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(je&&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||zg(t,d)!=p)&&f.remove()}}}let c=null;i<0&&r&&t.domSel.active&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&ar(t.domSel.range)&&(c=ji(t,t.domSel.range))&&c.eq(B.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,t.domSel.sync(),t.scrollToSelection()):(i>-1||r)&&(i>-1&&Hg(t),t.input.badSafariComposition&&(t.input.badSafariComposition=!1,Fg(t,a)),Lg(this.view,i,s,r,l,a),t.docView&&t.docView.damage?t.updateState(t.state):r&&t.domSel.sync())}registerMutation(e,t){var o;if(t.indexOf(e.target)>-1)return null;let r;for(let i=e.target;i&&!(r=this.view.docView.getDesc(i));i=i.parentNode);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.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(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return r.markDamage(4),{from:r.posBefore,to:r.posAfter};let i=e.previousSibling,s=e.nextSibling,l=i&&i.parentNode==e.target?Ee(i)+1:0,a=r.localPosFromDOM(e.target,l,-1),c=s&&s.parentNode==e.target?Ee(s):e.target.childNodes.length,u=r.localPosFromDOM(e.target,c,1);return r.markDamage(!((o=r.contentDOM)===null||o===void 0)&&o.contains(e.target)?2:4),{from:a,to:u}}else return e.type=="attributes"?(r.markDamage(4),{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}):(this.lastChangedTextNode=e.target,r.markDamage(r instanceof no&&e.target==r.nodeDOM?8:4),{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}},ec=new WeakMap,tc=!1;Xt=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 Hi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(sc),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=rc(this),oc(this),this.nodeViews=ic(this),this.docView=Pa(this.state.doc,nc(this),Ci(this),this.dom,this),this.domObserver=new Vi(this),this.domSel=new Bi(this),this.domObserver.start(),this.domSel.read(),sg(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&&zi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(sc),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let o in this._props)t[o]=this._props[o];t.state=this.state;for(let o in e)t[o]=e[o];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var o;let r=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Bc(this),s=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=ic(this);_g(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&zi(this),this.editable=rc(this),oc(this);let a=Ci(this),c=nc(this),u=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",d=i||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(r.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Sm(this);s&&this.domObserver.stopped(()=>{let p=d&&Ae&&!this.composing&&!r.selection.empty&&!e.selection.empty&&$g(r.selection,e.selection);if(d){let h=Ae?this.trackWrites=this.domSel.range.focusNode:null;if(this.composing&&(this.input.compositionNode=wg(this)),i||!this.docView.update(e.doc,c,a,this,-1)){let g=this.docView.outerDeco;this.docView.destroy(),this.docView=Pa(e.doc,c,a,this.dom,this,g)}h&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(p=!0)}this.domSel.sync(p)}),this.updatePluginViews(r),!((o=this.dragging)===null||o===void 0)&&o.node&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&Cm(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 R){let t=this.docView.domAfterPos(this.state.selection.from);H(t)&&La(this,t.getBoundingClientRect(),e)}else La(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let o=this.directPlugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let o=this.state.plugins[t];o.spec.view&&this.pluginViews.push(o.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let o=this.pluginViews[t];o.update&&o.update(this,e)}}updateDraggedNode(e,t){let o=e.node,r=-1;if(o.from<this.state.doc.content.size&&this.state.doc.nodeAt(o.from)==o.node)r=o.from;else{let i=o.from+(this.state.doc.content.size-t.doc.content.size);(i>0&&i<this.state.doc.content.size&&this.state.doc.nodeAt(i))==o.node&&(r=i)}this.dragging=new rr(e.slice,e.move,r<0?void 0:R.create(this.state.doc,r))}someProp(e,t){let o=this._props&&this._props[e],r;if(o!=null&&(r=t?t(o):o))return r;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(r=t?t(l):l))return r}let i=this.state.plugins;if(i)for(let s=0;s<i.length;s++){let l=i[s].props[e];if(l!=null&&(r=t?t(l):l))return r}}hasFocus(){return this.root.activeElement==this.dom}focus(){this.editable&&hc(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 o=this.dom.parentNode;o;o=o.parentNode)if(o.nodeType==9||o.nodeType==11&&o.host)return o.getSelection||(Object.getPrototypeOf(o).getSelection=()=>o.ownerDocument.getSelection()),this._root=o}return t||document}updateRoot(){this._root=null}posAtCoords(e){return Om(this,e)}coordsAtPos(e,t=1){return bc(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,o=-1){let r=this.docView.posFromDOM(e,t,o);if(r==null)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Pm(this,t||this.state,e)}pasteHTML(e,t){return so(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return so(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ui(this,e)}destroy(){this.docView&&(lg(this),this.domSel.destroy(),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ci(this),this,-1),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,gm())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return cg(this,e)}domSelection(){return this.root.getSelection()}};Xt.prototype.dispatch=function(n){let e=this._props.dispatchTransaction;e?e.call(this,n):this.updateState(this.state.apply(n))}});function Vc(n){var e=Vg&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||qg&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?fr:ct)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var ct,fr,Vg,qg,de,de,de,dr,qc=D(()=>{"use strict";ct={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},fr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Vg=typeof navigator<"u"&&/Mac/.test(navigator.platform),qg=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(de=0;de<10;de++)ct[48+de]=ct[96+de]=String(de);for(de=1;de<=24;de++)ct[de+111]="F"+de;for(de=65;de<=90;de++)ct[de]=String.fromCharCode(de+32),fr[de]=String.fromCharCode(de);for(dr in ct)fr.hasOwnProperty(dr)||(fr[dr]=ct[dr])});function jg(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let o,r,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))o=!0;else if(/^(c|ctrl|control)$/i.test(a))r=!0;else if(/^s(hift)?$/i.test(a))i=!0;else if(/^mod$/i.test(a))Wg?s=!0:r=!0;else throw new Error("Unrecognized modifier name: "+a)}return o&&(t="Alt-"+t),r&&(t="Ctrl-"+t),s&&(t="Meta-"+t),i&&(t="Shift-"+t),t}function Kg(n){let e=Object.create(null);for(let t in n)e[jg(t)]=n[t];return e}function Xi(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:co(n)}})}function co(n){let e=Kg(n);return function(t,o){let r=Vc(o),i,s=e[Xi(r,o)];if(s&&s(t.state,t.dispatch,t))return!0;if(r.length==1&&r!=" "){if(o.shiftKey){let l=e[Xi(r,o,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((o.altKey||o.metaKey||o.ctrlKey)&&!(Ug&&o.ctrlKey&&o.altKey)&&(i=ct[o.keyCode])&&i!=r){let l=e[Xi(i,o)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Wg,Ug,ut=D(()=>{"use strict";qc();U();Wg=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ug=typeof navigator<"u"&&/Win/.test(navigator.platform)});function Qi(n="c"){let e=new Uint8Array(9);return globalThis.crypto.getRandomValues(e),n+Array.from(e,t=>(t%36).toString(36)).join("")}function Wc(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!uo.test(e.id))return null;let t=Array.isArray(e.comments)?e.comments.map(Uc).filter(r=>r!==null):[],o=e.resolved;return{id:e.id,createdAt:Number(e.createdAt)||0,comments:t,resolved:o&&typeof o=="object"?{by:Yi(o.by),at:Number(o.at)||0}:null}}function Yi(n){let e=n&&typeof n=="object"?n:{};return{id:String(e.id??"").slice(0,128),name:String(e.name??"").slice(0,80)}}function Uc(n){if(!n||typeof n!="object")return null;let e=n;if(typeof e.id!="string"||!uo.test(e.id))return null;let t={id:e.id,author:Yi(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 o=e.mentions.slice(0,20).map(Yi).filter(r=>/^[\w.@:+-]{1,128}$/.test(r.id)&&r.name);o.length&&(t.mentions=o)}return t}function jc(n=[],e){let t=n.map(Wc).filter(s=>s!==null),o=new Set,r=s=>{t=s,e?.(t),o.forEach(l=>l())},i=(s,l)=>r(t.map(a=>a.id===s?l(a):a));return{threads:()=>t,subscribe(s){return o.add(s),()=>o.delete(s)},createThread(s){let l=Wc(s);!l||t.some(a=>a.id===l.id)||r([...t,l])},reply(s,l){let a=Uc(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){r(t.filter(l=>l.id!==s))}}}var uo,Kc=D(()=>{"use strict";uo=/^[A-Za-z0-9_-]{1,64}$/});var Xc={};He(Xc,{createCommentsPanel:()=>Qg});function Xg(n){let e=0;for(let t of n)e=e*31+t.charCodeAt(0)|0;return Gc[Math.abs(e)%Gc.length]}function Yg(n){return n.trim().split(/\s+/).filter(Boolean).slice(0,2).map(t=>[...t][0].toUpperCase()).join("")||"?"}function Qg(n){let{editor:e,store:t,labels:o}=n,r=e.options.language??"en",i=new Intl.RelativeTimeFormat(r,{numeric:"auto"}),s=new Intl.DateTimeFormat(r,{dateStyle:"medium",timeStyle:"short"}),l=Se("nova-comments-title"),a=new Map,c=new Map,u=null,d=!1,f=w("div",{className:"nova-comments-list"}),p=w("span",{className:"nova-comments-count"}),h=w("input",{type:"checkbox"});h.addEventListener("change",()=>{d=h.checked,N()});let g=w("aside",{className:"nova-comments","aria-labelledby":l,hidden:!0,onKeydown:(x=>{x.key==="Escape"&&(x.stopPropagation(),n.pending()?n.cancelPending():n.closePanel())})},w("div",{className:"nova-comments-head"},w("h2",{id:l,className:"nova-comments-title"},o.panel),p,w("button",{type:"button",className:"nova-btn nova-comments-close","aria-label":o.close,title:o.close,onClick:()=>n.closePanel()},"\xD7")),w("label",{className:"nova-comments-filter"},h,o.showResolved),f);function b(x){let S=Math.round((x-Date.now())/1e3),E=Math.abs(S),F=E<45?i.format(0,"second"):E<3600?i.format(Math.round(S/60),"minute"):E<86400?i.format(Math.round(S/3600),"hour"):E<86400*7?i.format(Math.round(S/86400),"day"):s.format(x);return w("time",{dateTime:new Date(x).toISOString(),title:s.format(x)},F)}function m(x,S){let E=w("span",{className:"nova-comment-avatar","aria-hidden":"true"},Yg(S));return E.style.backgroundColor=Xg(x||S),E}function y(x){let S=Se("nova-mention-list"),E=w("textarea",{className:"nova-input nova-comment-input",rows:2,maxlength:5e3,placeholder:x.placeholder,"aria-label":x.placeholder,"data-draft":x.key});E.value=a.get(x.key)??x.initial??"";let F=c.get(x.key)??new Map((x.initialMentions??[]).map(V=>[V.id,V]));c.set(x.key,F);let z=w("button",{type:"button",className:"nova-button nova-button-primary"},x.submitLabel),I=w("ul",{id:S,className:"nova-mention-list",role:"listbox","aria-label":o.people,hidden:!0}),$=[],le=0,fe=null,Lo=0;n.findUsers&&(E.setAttribute("role","combobox"),E.setAttribute("aria-autocomplete","list"),E.setAttribute("aria-controls",S),E.setAttribute("aria-expanded","false"));let Fn=()=>{fe=null,$=[],I.hidden=!0,I.replaceChildren(),E.setAttribute("aria-expanded","false"),E.removeAttribute("aria-activedescendant")},bl=()=>{if(!fe)return Fn();I.replaceChildren(...$.length?$.map((V,Be)=>{let It=w("li",{id:`${S}-${Be}`,role:"option",className:"nova-mention-option","aria-selected":String(Be===le)},m(V.id,V.name),w("span",{className:"nova-mention-name"},V.name),V.description?w("span",{className:"nova-mention-detail"},V.description):null);return It.addEventListener("mousedown",Pt=>{Pt.preventDefault(),vl(Be)}),It}):[w("li",{className:"nova-mention-empty",role:"presentation"},o.noPeople)]),I.hidden=!1,E.setAttribute("aria-expanded","true"),$.length?E.setAttribute("aria-activedescendant",`${S}-${le}`):E.removeAttribute("aria-activedescendant")},yl=()=>{let V=n.findUsers;if(!V)return;let Be=E.selectionStart??0,It=E.value.slice(0,Be),Pt=/(?:^|\s)@([\p{L}\p{N}_.-]{0,30})$/u.exec(It);if(!Pt)return Fn();let xl=Pt[1]??"";fe={start:Be-xl.length-1,end:Be};let xh=++Lo;V(xl).then(kh=>{xh!==Lo||!fe||($=kh,le=0,bl())})},vl=V=>{let Be=$[V];if(!Be||!fe)return;let It=`@${Be.name} `;E.value=E.value.slice(0,fe.start)+It+E.value.slice(fe.end);let Pt=fe.start+It.length;E.setSelectionRange(Pt,Pt),F.set(Be.id,{id:Be.id,name:Be.name}),Fn(),ei(),E.focus()},ei=()=>{a.set(x.key,E.value),z.disabled=E.value.trim()===""},wl=()=>{let V=E.value;V.trim()&&(a.delete(x.key),c.delete(x.key),x.onSubmit(V,[...F.values()]))};E.addEventListener("input",()=>{ei(),yl()}),E.addEventListener("click",yl),E.addEventListener("blur",()=>setTimeout(Fn,0)),E.addEventListener("keydown",V=>{if(fe&&!I.hidden){if(V.key==="ArrowDown"||V.key==="ArrowUp"){if(V.preventDefault(),!$.length)return;le=(le+(V.key==="ArrowDown"?1:-1)+$.length)%$.length,bl();return}if((V.key==="Enter"&&!V.ctrlKey&&!V.metaKey||V.key==="Tab")&&$.length){V.preventDefault(),vl(le);return}if(V.key==="Escape"){V.preventDefault(),V.stopPropagation(),Fn();return}}V.key==="Enter"&&(V.ctrlKey||V.metaKey)&&(V.preventDefault(),wl())}),z.addEventListener("click",wl),ei();let wh=x.onCancel?w("button",{type:"button",className:"nova-button",onClick:()=>{a.delete(x.key),c.delete(x.key),x.onCancel()}},o.cancel):null;return w("div",{className:"nova-comment-composer"},w("div",{className:"nova-mention-wrap"},E,I),w("div",{className:"nova-comment-actions"},wh,z))}function v(x){let S=w("p",{className:"nova-comment-text"}),E=(x.mentions??[]).map(I=>`@${I.name}`).sort((I,$)=>$.length-I.length);if(!E.length)return S.textContent=x.text,S;let F=E.map(I=>I.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")),z=x.text.split(new RegExp(`(${F.join("|")})`,"g"));return S.append(...z.map(I=>E.includes(I)?w("span",{className:"nova-comment-mention"},I):I)),S}function M(x,S,E){let F=n.canEdit(S),z=u?.threadId===x.id&&u.commentId===S.id&&F,I=S.author.id===n.author.id,$=w("div",{className:"nova-comment-head"},m(S.author.id,S.author.name),w("span",{className:"nova-comment-author"},S.author.name||o.guest,I?w("span",{className:"nova-comment-you"},` (${o.you})`):null),b(S.createdAt),S.editedAt?w("span",{className:"nova-comment-edited"},o.edited):null),le=z?y({key:`edit:${x.id}:${S.id}`,placeholder:o.placeholder,submitLabel:o.save,initial:S.text,initialMentions:S.mentions??[],onSubmit:Lo=>{u=null,t.editComment(x.id,S.id,Lo.trim())},onCancel:()=>{u=null,N()}}):v(S),fe=F&&!z?w("div",{className:"nova-comment-tools"},w("button",{type:"button",className:"nova-link-btn",onClick:()=>{u={threadId:x.id,commentId:S.id},N(),C(`edit:${x.id}:${S.id}`)}},o.edit),E>0?w("button",{type:"button",className:"nova-link-btn",onClick:()=>t.deleteComment(x.id,S.id)},o.remove):null):null;return w("div",{className:"nova-comment-item"},$,le,fe)}function T(x){let S=n.active()===x.id,E=n.quote(x.id),F=x.comments[0],z=F?n.canEdit(F):!0,I=w("article",{className:["nova-thread",S?"is-active":"",x.resolved?"is-resolved":"",E?"":"is-orphan"].filter(Boolean).join(" "),"data-thread":x.id,tabindex:"-1","aria-current":S?"true":null},E?w("blockquote",{className:"nova-thread-quote"},E.slice(0,140)):w("p",{className:"nova-thread-orphan"},o.orphan),x.comments.map(($,le)=>M(x,$,le)),x.resolved?w("p",{className:"nova-thread-resolved"},o.resolvedBy.replace("{name}",x.resolved.by.name||o.guest)):null,S&&!x.resolved?y({key:`reply:${x.id}`,placeholder:o.replyPlaceholder,submitLabel:o.reply,onSubmit:($,le)=>n.reply(x.id,$,le)}):null,w("div",{className:"nova-thread-tools"},w("button",{type:"button",className:"nova-button",onClick:()=>n.setResolved(x.id,!x.resolved)},x.resolved?o.reopen:o.resolve),z?w("button",{type:"button",className:"nova-button nova-button-danger",onClick:()=>n.deleteThread(x.id)},o.deleteThread):null));return I.addEventListener("click",$=>{$.target.closest("button, textarea, input, a")||n.active()!==x.id&&n.setActive(x.id,!0)}),I}function C(x){let S=f.querySelector(`textarea[data-draft="${x}"]`);S&&(S.focus(),S.setSelectionRange(S.value.length,S.value.length))}function N(){let x=f.contains(document.activeElement)?document.activeElement.getAttribute("data-draft"):null,S=[...t.threads()].sort((I,$)=>n.positionOf(I.id)-n.positionOf($.id)||I.createdAt-$.createdAt),E=S.filter(I=>!I.resolved),F=d?S:E;p.textContent=E.length?String(E.length):"",p.setAttribute("aria-label",o.count.replace("{count}",String(E.length)));let z=[];n.pending()&&z.push(w("article",{className:"nova-thread is-active is-new"},w("div",{className:"nova-comment-head"},m(n.author.id,n.author.name),w("span",{className:"nova-comment-author"},n.author.name)),y({key:"new",placeholder:o.placeholder,submitLabel:o.comment,onSubmit:(I,$)=>n.submitPending(I,$),onCancel:()=>n.cancelPending()}))),z.push(...F.map(T)),z.length===0&&z.push(w("p",{className:"nova-comments-empty"},o.empty.replace("{shortcut}",Xe(n.shortcut)))),f.replaceChildren(...z),x&&C(x),f.querySelector(".nova-thread.is-active")?.scrollIntoView?.({block:"nearest"})}return{el:g,render:N,focusComposer:()=>C("new"),destroy:()=>g.remove()}}var Gc,Yc=D(()=>{"use strict";Y();Gc=["#2563eb","#db2777","#16a34a","#ea580c","#7c3aed","#0891b2","#ca8a04","#dc2626"]});function ab(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=cb(n),t=n.childCount,o=[],r=0,i=null,s=[];for(let c=0,u=e*t;c<u;c++)o[c]=0;for(let c=0,u=0;c<t;c++){let d=n.child(c);u++;for(let h=0;;h++){for(;r<o.length&&o[r]!=0;)r++;if(h==d.childCount)break;let g=d.child(h),{colspan:b,rowspan:m,colwidth:y}=g.attrs;for(let v=0;v<m;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:m-v});break}let M=r+v*e;for(let T=0;T<b;T++){o[M+T]==0?o[M+T]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:b-T});let C=y&&y[T];if(C){let N=(M+T)%e*2,x=s[N];x==null||x!=C&&s[N+1]==1?(s[N]=C,s[N+1]=1):x==C&&s[N+1]++}}}r+=b,u+=g.nodeSize}let f=(c+1)*e,p=0;for(;r<f;)o[r++]==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 oe(e,t,o,i),a=!1;for(let c=0;!a&&c<s.length;c+=2)s[c]!=null&&s[c+1]<t&&(a=!0);return a&&ub(l,s,n),l}function cb(n){let e=-1,t=!1;for(let o=0;o<n.childCount;o++){let r=n.child(o),i=0;if(t)for(let s=0;s<o;s++){let l=n.child(s);for(let a=0;a<l.childCount;a++){let c=l.child(a);s+c.attrs.rowspan>o&&(i+=c.attrs.colspan)}}for(let s=0;s<r.childCount;s++){let l=r.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 ub(n,e,t){n.problems||(n.problems=[]);let o={};for(let r=0;r<n.map.length;r++){let i=n.map[r];if(o[i])continue;o[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[(r+c)%n.width*2];u!=null&&(!a.colwidth||a.colwidth[c]!=u)&&((l||(l=db(a)))[c]=u)}l&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}function db(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function uu(n,e){if(typeof n=="string")return{};let t=n.getAttribute("data-colwidth"),o=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(s=>Number(s)):null,r=Number(n.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(let s in e){let l=e[s].getFromDOM,a=l&&l(n);a!=null&&(i[s]=a)}return i}function du(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 o in e){let r=e[o].setDOMAttr;r&&r(n.attrs[o],t)}return t}function fb(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 xu(n){let e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:fb}};for(let o in e)t[o]={default:e[o].default,validate:e[o].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:o=>uu(o,e)}],toDOM(o){return["td",du(o,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:o=>uu(o,e)}],toDOM(o){return["th",du(o,e),0]}}}}function ke(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let o=n.nodes[t],r=o.spec.tableRole;r&&(e[r]=o)}}return e}function Yt(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 pb(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 Q(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 wr(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=Yt(e.$head)||hb(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function hb(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let o=e.type.spec.tableRole;if(o=="cell"||o=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function ms(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function mb(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ys(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function ku(n,e,t){let o=n.node(-1),r=oe.get(o),i=n.start(-1),s=r.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function Qt(n,e,t=1){let o={...n,colspan:n.colspan-t};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(e,t),o.colwidth.some(r=>r>0)||(o.colwidth=null)),o}function Mu(n,e,t=1){let o={...n,colspan:n.colspan+t};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let r=0;r<t;r++)o.colwidth.splice(e,0,0)}return o}function gb(n,e,t){let o=ke(e.type.schema).header_cell;for(let r=0;r<n.height;r++)if(e.nodeAt(n.map[t+r*n.width]).type!=o)return!1;return!0}function yb(n){if(!(n.selection instanceof X))return null;let e=[];return n.selection.forEachCell((t,o)=>{e.push(te.node(o,o+t.nodeSize,{class:"selectedCell"}))}),J.create(n.doc,e)}function vb({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,o=e.pos,r=n.depth;for(;r>=0&&!(n.after(r+1)<n.end(r));r--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,o--);return t==o&&/row|table/.test(n.node(r).type.spec.tableRole)}function wb({$from:n,$to:e}){let t,o;for(let r=n.depth;r>0;r--){let i=n.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let r=e.depth;r>0;r--){let i=e.node(r);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){o=i;break}}return t!==o&&e.parentOffset===0}function xb(n,e,t){let o=(e||n).selection,r=(e||n).doc,i,s;if(o instanceof R&&(s=o.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=X.create(r,o.from);else if(s=="row"){let l=r.resolve(o.from+1);i=X.rowSelection(l,l)}else if(!t){let l=oe.get(o.node),a=o.from+1,c=a+l.map[l.width*l.height-1];i=X.create(r,a+1,c)}}else o instanceof P&&vb(o)?i=P.create(r,o.from):o instanceof P&&wb(o)&&(i=P.create(r,o.$from.start(),o.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function Cu(n,e,t,o){let r=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(r,s+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}o(a,t),l<r&&n.child(l).sameMarkup(a)?Cu(n.child(l),a,t+1,o):a.nodesBetween(0,a.content.size,o,t+1),t+=a.nodeSize}}function Mb(n,e){let t,o=(r,i)=>{r.type.spec.tableRole=="table"&&(t=Sb(n,r,i,t))};return e?e.doc!=n.doc&&Cu(e.doc,n.doc,0,o):n.doc.descendants(o),t}function Sb(n,e,t,o){let r=oe.get(e);if(!r.problems)return o;o||(o=n.tr);let i=[];for(let a=0;a<r.height;a++)i.push(0);for(let a=0;a<r.problems.length;a++){let c=r.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;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,Qt(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;o.setNodeMarkup(o.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;o.setNodeMarkup(o.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){let u=o.mapping.map(t);o.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<r.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 b=0;b<f;b++){let m=ke(n.schema)[p].createAndFill();m&&h.push(m)}let g=(a==0||s==a-1)&&l==a?c+1:d-1;o.insert(o.mapping.map(g),h)}c=d}return o.setMeta(kb,{fixTables:!0})}function An(n){return Cb(e=>e.type.spec.tableRole==="table",n)}function Cb(n,e){for(let t=e.depth;t>=0;t-=1){let o=e.node(t);if(n(o))return{node:o,pos:t===0?0:e.before(t),start:e.start(t),depth:t}}return null}function _e(n){let e=n.selection,t=wr(n),o=t.node(-1),r=t.start(-1),i=oe.get(o);return{...e instanceof X?i.rectBetween(e.$anchorCell.pos-r,e.$headCell.pos-r):i.findCell(t.pos-r),tableStart:r,map:i,table:o}}function Eu(n,{map:e,tableStart:t,table:o},r){let i=r>0?-1:0;gb(e,o,r+i)&&(i=r==0||r==e.width?null:0);for(let s=0;s<e.height;s++){let l=s*e.width+r;if(r>0&&r<e.width&&e.map[l-1]==e.map[l]){let a=e.map[l],c=o.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Mu(c.attrs,r-e.colCount(a))),s+=c.attrs.rowspan-1}else{let a=i==null?ke(o.type.schema).cell:o.nodeAt(e.map[l+i]).type,c=e.positionAt(s,r,o);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Au(n,e){if(!Q(n))return!1;if(e){let t=_e(n);e(Eu(n.tr,t,t.left))}return!0}function Tu(n,e){if(!Q(n))return!1;if(e){let t=_e(n);e(Eu(n.tr,t,t.right))}return!0}function Eb(n,{map:e,table:t,tableStart:o},r){let i=n.mapping.maps.length;for(let s=0;s<e.height;){let l=s*e.width+r,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(r>0&&e.map[l-1]==a||r<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(i).map(o+a),null,Qt(u,r-e.colCount(a)));else{let d=n.mapping.slice(i).map(o+a);n.delete(d,d+c.nodeSize)}s+=u.rowspan}}function Nu(n,e){if(!Q(n))return!1;if(e){let t=_e(n),o=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let r=t.right-1;Eb(o,t,r),r!=t.left;r--){let i=t.tableStart?o.doc.nodeAt(t.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=oe.get(i)}e(o)}return!0}function Ab(n,e,t){var o;let r=ke(e.type.schema).header_cell;for(let i=0;i<n.width;i++)if(((o=e.nodeAt(n.map[i+t*n.width]))===null||o===void 0?void 0:o.type)!=r)return!1;return!0}function Ou(n,{map:e,tableStart:t,table:o},r){let i=t;for(let c=0;c<r;c++)i+=o.child(c).nodeSize;let s=[],l=r>0?-1:0;Ab(e,o,r+l)&&(l=r==0||r==e.height?null:0);for(let c=0,u=e.width*r;c<e.width;c++,u++)if(r>0&&r<e.height&&e.map[u]==e.map[u-e.width]){let d=e.map[u],f=o.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{var a;let d=l==null?ke(o.type.schema).cell:(a=o.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,ke(o.type.schema).row.create(null,s)),n}function Lu(n,e){if(!Q(n))return!1;if(e){let t=_e(n);e(Ou(n.tr,t,t.top))}return!0}function vs(n,e){if(!Q(n))return!1;if(e){let t=_e(n);e(Ou(n.tr,t,t.bottom))}return!0}function Tb(n,{map:e,table:t,tableStart:o},r){let i=0;for(let c=0;c<r;c++)i+=t.child(c).nodeSize;let s=i+t.child(r).nodeSize,l=n.mapping.maps.length;n.delete(i+o,s+o);let a=new Set;for(let c=0,u=r*e.width;c<e.width;c++,u++){let d=e.map[u];if(!a.has(d)){if(a.add(d),r>0&&d==e.map[u-e.width]){let f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+o),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(r<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),g=e.positionAt(r+1,c,t);n.insert(n.mapping.slice(l).map(o+g),h),c+=p.colspan-1}}}}function Du(n,e){if(!Q(n))return!1;if(e){let t=_e(n),o=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let r=t.bottom-1;Tb(o,t,r),r!=t.top;r--){let i=t.tableStart?o.doc.nodeAt(t.tableStart-1):o.doc;if(!i)throw new RangeError("No table found");t.table=i,t.map=oe.get(t.table)}e(o)}return!0}function fu(n){let e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Nb({width:n,height:e,map:t},o){let r=o.top*n+o.left,i=r,s=(o.bottom-1)*n+o.left,l=r+(o.right-o.left-1);for(let a=o.top;a<o.bottom;a++){if(o.left>0&&t[i]==t[i-1]||o.right<n&&t[l]==t[l+1])return!0;i+=n,l+=n}for(let a=o.left;a<o.right;a++){if(o.top>0&&t[r]==t[r-n]||o.bottom<e&&t[s]==t[s+n])return!0;r++,s++}return!1}function Ru(n,e){let t=n.selection;if(!(t instanceof X)||t.$anchorCell.pos==t.$headCell.pos)return!1;let o=_e(n),{map:r}=o;if(Nb(r,o))return!1;if(e){let i=n.tr,s={},l=A.empty,a,c;for(let u=o.top;u<o.bottom;u++)for(let d=o.left;d<o.right;d++){let f=r.map[u*r.width+d],p=o.table.nodeAt(f);if(!(s[f]||!p))if(s[f]=!0,a==null)a=f,c=p;else{fu(p)||(l=l.append(p.content));let h=i.mapping.map(f+o.tableStart);i.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(i.setNodeMarkup(a+o.tableStart,null,{...Mu(c.attrs,c.attrs.colspan,o.right-o.left-c.attrs.colspan),rowspan:o.bottom-o.top}),l.size>0){let u=a+1+c.content.size,d=fu(c)?a+1:u;i.replaceWith(d+o.tableStart,u+o.tableStart,l)}i.setSelection(new X(i.doc.resolve(a+o.tableStart))),e(i)}return!0}function Iu(n,e){let t=ke(n.schema);return Ob(({node:o})=>t[o.type.spec.tableRole])(n,e)}function Ob(n){return(e,t)=>{let o=e.selection,r,i;if(o instanceof X){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;r=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{var s;if(r=pb(o.$from),!r)return!1;i=(s=Yt(o.$from))===null||s===void 0?void 0:s.pos}if(r==null||i==null||r.attrs.colspan==1&&r.attrs.rowspan==1)return!1;if(t){let l=r.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+=r.nodeSize);for(let g=u.left,b=0;g<u.right;g++,b++)g==u.left&&p==u.top||d.insert(f=d.mapping.map(h+u.tableStart,1),n({node:r,row:p,col:g}).createAndFill(a[b]))}d.setNodeMarkup(i,n({node:r,row:u.top,col:u.left}),a[0]),o instanceof X&&d.setSelection(new X(d.doc.resolve(o.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Pu(n,e){return function(t,o){if(!Q(t))return!1;let r=wr(t);if(r.nodeAfter.attrs[n]===e)return!1;if(o){let i=t.tr;t.selection instanceof X?t.selection.forEachCell((s,l)=>{s.attrs[n]!==e&&i.setNodeMarkup(l,null,{...s.attrs,[n]:e})}):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[n]:e}),o(i)}return!0}}function Lb(n){return function(e,t){if(!Q(e))return!1;if(t){let o=ke(e.schema),r=_e(e),i=e.tr,s=r.map.cellsInRect(n=="column"?{left:r.left,top:0,right:r.right,bottom:r.map.height}:n=="row"?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map(a=>r.table.nodeAt(a));for(let a=0;a<s.length;a++)l[a].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[a],o.cell,l[a].attrs);if(i.steps.length===0)for(let a=0;a<s.length;a++)i.setNodeMarkup(r.tableStart+s[a],o.header_cell,l[a].attrs);t(i)}return!0}}function pu(n,e,t){let o=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let r=0;r<o.length;r++){let i=e.table.nodeAt(o[r]);if(i&&i.type!==t.header_cell)return!1}return!0}function Tn(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Lb(n):function(t,o){if(!Q(t))return!1;if(o){let r=ke(t.schema),i=_e(t),s=t.tr,l=pu("row",i,r),a=pu("column",i,r),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?r.cell:r.header_cell:n=="row"?l?r.cell:r.header_cell:r.cell;i.map.cellsInRect(u).forEach(f=>{let p=f+i.tableStart,h=s.doc.nodeAt(p);h&&s.setNodeMarkup(p,d,h.attrs)}),o(s)}return!0}}function Db(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let o=n.index(-1)-1,r=n.before();o>=0;o--){let i=n.node(-1).child(o),s=i.lastChild;if(s)return r-1-s.nodeSize;r-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let o=n.indexAfter(-1),r=n.after();o<t.childCount;o++){let i=t.child(o);if(i.childCount)return r+1;r+=i.nodeSize}}return null}function xr(n){return function(e,t){if(!Q(e))return!1;let o=Db(wr(e),n);if(o==null)return!1;if(t){let r=e.doc.resolve(o);t(e.tr.setSelection(P.between(r,mb(r))).scrollIntoView())}return!0}}function Bu(n,e){let t=n.selection.$anchor;for(let o=t.depth;o>0;o--)if(t.node(o).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(o),t.after(o)).scrollIntoView()),!0;return!1}function mr(n,e){let t=n.selection;if(!(t instanceof X))return!1;if(e){let o=n.tr,r=ke(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(r)||o.replace(o.mapping.map(s+1),o.mapping.map(s+i.nodeSize-1),new L(r,0,0))}),o.docChanged&&e(o)}return!0}function Rb(n){if(n.size===0)return null;let{content:e,openStart:t,openEnd:o}=n;for(;e.childCount==1&&(t>0&&o>0||e.child(0).type.spec.tableRole=="table");)t--,o--,e=e.child(0).content;let r=e.child(0),i=r.type.spec.tableRole,s=r.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,o-1);(u||d)&&(c=gs(ke(s).row,new L(c,u,d)).content),l.push(c)}else if(i=="cell"||i=="header_cell")l.push(t||o?gs(ke(s).row,new L(e,t,o)).content:e);else return null;return Ib(s,l)}function Ib(n,e){let t=[];for(let r=0;r<e.length;r++){let i=e[r];for(let s=i.childCount-1;s>=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=r;c<r+l;c++)t[c]=(t[c]||0)+a}}let o=0;for(let r=0;r<t.length;r++)o=Math.max(o,t[r]);for(let r=0;r<t.length;r++)if(r>=e.length&&e.push(A.empty),t[r]<o){let i=ke(n).cell.createAndFill(),s=[];for(let l=t[r];l<o;l++)s.push(i);e[r]=e[r].append(A.from(s))}return{height:e.length,width:o,rows:e}}function gs(n,e){let t=n.createAndFill();return new pn(t).replace(0,t.content.size,e).doc}function Pb({width:n,height:e,rows:t},o,r){if(n!=o){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<o;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>o&&(f=f.type.createChecked(Qt(f.attrs,f.attrs.colspan,u+f.attrs.colspan-o),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=o}if(e!=r){let i=[];for(let s=0,l=0;s<r;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>r&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,r-d.attrs.rowspan)},d.content)),a.push(d)}i.push(A.from(a))}t=i,e=r}return{width:n,height:e,rows:t}}function Bb(n,e,t,o,r,i,s){let l=n.doc.type.schema,a=ke(l),c,u;if(r>e.width)for(let d=0,f=0;d<e.height;d++){let p=t.child(d);f+=p.nodeSize;let h=[],g;p.lastChild==null||p.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let b=e.width;b<r;b++)h.push(g);n.insert(n.mapping.slice(s).map(f-1+o),h)}if(i>e.height){let d=[];for(let h=0,g=(e.height-1)*e.width;h<Math.max(e.width,r);h++){let b=h>=e.width?!1:t.nodeAt(e.map[g+h]).type==a.header_cell;d.push(b?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(o+t.nodeSize-2),p)}return!!(c||u)}function hu(n,e,t,o,r,i,s,l){if(s==0||s==e.height)return!1;let a=!1;for(let c=r;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+o),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 mu(n,e,t,o,r,i,s,l){if(s==0||s==e.width)return!1;let a=!1;for(let c=r;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+o);n.setNodeMarkup(h,null,Qt(f.attrs,s-p,f.attrs.colspan-(s-p))),n.insert(h+f.nodeSize,f.type.createAndFill(Qt(f.attrs,0,s-p))),c+=f.attrs.rowspan-1}}return a}function gu(n,e,t,o,r){let i=t?n.doc.nodeAt(t-1):n.doc;if(!i)throw new Error("No table found");let s=oe.get(i),{top:l,left:a}=o,c=a+r.width,u=l+r.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=oe.get(i),f=d.mapping.maps.length}Bb(d,s,i,t,c,u,f)&&p(),hu(d,s,i,t,a,c,l,f)&&p(),hu(d,s,i,t,a,c,u,f)&&p(),mu(d,s,i,t,l,u,a,f)&&p(),mu(d,s,i,t,l,u,c,f)&&p();for(let h=l;h<u;h++){let g=s.positionAt(h,a,i),b=s.positionAt(h,c,i);d.replace(d.mapping.slice(f).map(g+t),d.mapping.slice(f).map(b+t),new L(r.rows[h-l],0,0))}p(),d.setSelection(new X(d.doc.resolve(t+s.positionAt(l,a,i)),d.doc.resolve(t+s.positionAt(u-1,c-1,i)))),e(d)}function yr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function gr(n,e){return(t,o,r)=>{if(!r)return!1;let i=t.selection;if(i instanceof X)return yr(t,o,B.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=Hu(r,n,e);if(s==null)return!1;if(n=="horiz")return yr(t,o,B.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=ku(l,n,e),c;return a?c=B.near(a,1):e<0?c=B.near(t.doc.resolve(l.before(-1)),-1):c=B.near(t.doc.resolve(l.after(-1)),1),yr(t,o,c)}}}function br(n,e){return(t,o,r)=>{if(!r)return!1;let i=t.selection,s;if(i instanceof X)s=i;else{let a=Hu(r,n,e);if(a==null)return!1;s=new X(t.doc.resolve(a))}let l=ku(s.$headCell,n,e);return l?yr(t,o,new X(s.$anchorCell,l)):!1}}function zb(n,e){let t=n.state.doc,o=Yt(t.resolve(e));return o?(n.dispatch(n.state.tr.setSelection(new X(o))),!0):!1}function Fb(n,e,t){if(!Q(n.state))return!1;let o=Rb(t),r=n.state.selection;if(r instanceof X){o||(o={width:1,height:1,rows:[A.from(gs(ke(n.state.schema).cell,t))]});let i=r.$anchorCell.node(-1),s=r.$anchorCell.start(-1),l=oe.get(i).rectBetween(r.$anchorCell.pos-s,r.$headCell.pos-s);return o=Pb(o,l.right-l.left,l.bottom-l.top),gu(n.state,n.dispatch,s,l,o),!0}else if(o){let i=wr(n.state),s=i.start(-1);return gu(n.state,n.dispatch,s,oe.get(i.node(-1)).findCell(i.pos-s),o),!0}else return!1}function $b(n,e){var t;if(e.button!=0||e.ctrlKey||e.metaKey)return;let o=bu(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof X)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&o&&(r=Yt(n.state.selection.$anchor))!=null&&((t=fs(n,e))===null||t===void 0?void 0:t.pos)!=r.pos)i(r,e),e.preventDefault();else if(!o)return;function i(a,c){let u=fs(n,c),d=Dt.getState(n.state)==null;if(!u||!ys(a,u))if(d)u=a;else return;let f=new X(a,u);if(d||!n.state.selection.eq(f)){let p=n.state.tr.setSelection(f);d&&p.setMeta(Dt,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),Dt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Dt,-1))}function l(a){let c=a,u=Dt.getState(n.state),d;if(u!=null)d=n.state.doc.resolve(u);else if(bu(n,c.target)!=o&&(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 Hu(n,e,t){if(!(n.state.selection instanceof P))return null;let{$head:o}=n.state.selection;for(let r=o.depth-1;r>=0;r--){let i=o.node(r);if((t<0?o.index(r):o.indexAfter(r))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let s=o.before(r),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?s:null}}return null}function bu(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:o,pos:r}=t;return o>=0&&Yt(n.state.doc.resolve(o))||Yt(n.state.doc.resolve(r))}function bs(n,e,t,o,r,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 g=0;g<p;g++,f++){let b=r==f?i:h&&h[g],m=b?b+"px":"";if(s+=b||o,b||(l=!1),a)a.style.width!=m&&(a.style.width=m),a=a.nextSibling;else{let y=document.createElement("col");y.style.width=m,e.appendChild(y)}}}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 zu({handleWidth:n=5,cellMinWidth:e=25,defaultCellMinWidth:t=100,View:o=ws,lastColumnResizable:r=!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=ke(l.schema).table.name;return o&&c&&(c[u]=(d,f)=>new o(d,t,f)),new _b(-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)=>{Vb(s,l,n,r)},mouseleave:s=>{qb(s)},mousedown:(s,l)=>{Wb(s,l,e,t)}},decorations:s=>{let l=$e.getState(s);if(l&&l.activeHandle>-1)return Gb(s,l.activeHandle)},nodeViews:{}}});return i}function Vb(n,e,t,o){if(!n.editable)return;let r=$e.getState(n.state);if(r&&!r.dragging){let i=jb(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=yu(n,e,"left",t):a-e.clientX<=t&&(s=yu(n,e,"right",t))}if(s!=r.activeHandle){if(!o&&s!==-1){let l=n.state.doc.resolve(s),a=l.node(-1),c=oe.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}Fu(n,s)}}}function qb(n){if(!n.editable)return;let e=$e.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Fu(n,-1)}function Wb(n,e,t,o){var r;if(!n.editable)return!1;let i=(r=n.dom.ownerDocument.defaultView)!==null&&r!==void 0?r:window,s=$e.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=n.state.doc.nodeAt(s.activeHandle),a=Ub(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&&(Kb(n,f.activeHandle,vu(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=vu(f.dragging,d,t);wu(n,f.activeHandle,p,o)}}return wu(n,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",u),e.preventDefault(),!0}function Ub(n,e,{colspan:t,colwidth:o}){let r=o&&o[o.length-1];if(r)return r;let i=n.domAtPos(e),s=i.node.childNodes[i.offset].offsetWidth,l=t;if(o)for(let a=0;a<t;a++)o[a]&&(s-=o[a],l--);return s/l}function jb(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function yu(n,e,t,o){let r=t=="right"?-o:o,i=n.posAtCoords({left:e.clientX+r,top:e.clientY});if(!i)return-1;let{pos:s}=i,l=Yt(n.state.doc.resolve(s));if(!l)return-1;if(t=="right")return l.pos;let a=oe.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 vu(n,e,t){let o=e.clientX-n.startX;return Math.max(t,n.startWidth+o)}function Fu(n,e){n.dispatch(n.state.tr.setMeta($e,{setHandle:e}))}function Kb(n,e,t){let o=n.state.doc.resolve(e),r=o.node(-1),i=oe.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.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=r.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():Jb(f.colspan);h[p]=t,a.setNodeMarkup(s+d,null,{...f,colwidth:h})}a.docChanged&&n.dispatch(a)}function wu(n,e,t,o){let r=n.state.doc.resolve(e),i=r.node(-1),s=r.start(-1),l=oe.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=n.domAtPos(r.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&bs(i,a.firstChild,a,o,l,t)}function Jb(n){return Array(n).fill(0)}function Gb(n,e){let t=[],o=n.doc.resolve(e),r=o.node(-1);if(!r)return J.empty;let i=oe.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.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+r.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(te.node(s+d,s+d+r.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),t.push(te.widget(f,p))}}return J.create(n.doc,t)}function $u({allowTableNodeSelection:n=!1}={}){return new _({key:Dt,state:{init(){return null},apply(e,t){let o=e.getMeta(Dt);if(o!=null)return o==-1?null:o;if(t==null||!e.docChanged)return t;let{deleted:r,pos:i}=e.mapping.mapResult(t);return r?null:i}},props:{decorations:yb,handleDOMEvents:{mousedown:$b},createSelectionBetween(e){return Dt.getState(e.state)!=null?e.state.selection:null},handleTripleClick:zb,handleKeyDown:Hb,handlePaste:Fb},appendTransaction(e,t,o){return xb(o,Mb(o,t),n)}})}var ps,hs,oe,Dt,X,bb,kb,Pw,Bw,Hw,Hb,ws,$e,_b,xs=D(()=>{"use strict";U();ce();Lt();ut();Ge();if(typeof WeakMap<"u"){let n=new WeakMap;ps=e=>n.get(e),hs=(e,t)=>(n.set(e,t),t)}else{let n=[],t=0;ps=o=>{for(let r=0;r<n.length;r+=2)if(n[r]==o)return n[r+1]},hs=(o,r)=>(t==10&&(t=0),n[t++]=o,n[t++]=r)}oe=class{constructor(n,e,t,o){this.width=n,this.height=e,this.map=t,this.problems=o}findCell(n){for(let e=0;e<this.map.length;e++){let t=this.map[e];if(t!=n)continue;let o=e%this.width,r=e/this.width|0,i=o+1,s=r+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:o,top:r,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:o,right:r,top:i,bottom:s}=this.findCell(n);return e=="horiz"?(t<0?o==0:r==this.width)?null:this.map[i*this.width+(t<0?o-1:r)]:(t<0?i==0:s==this.height)?null:this.map[o+this.width*(t<0?i-1:s)]}rectBetween(n,e){let{left:t,right:o,top:r,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(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(n){let e=[],t={};for(let o=n.top;o<n.bottom;o++)for(let r=n.left;r<n.right;r++){let i=o*this.width+r,s=this.map[i];t[s]||(t[s]=!0,!(r==n.left&&r&&this.map[i-1]==s||o==n.top&&o&&this.map[i-this.width]==s)&&e.push(s))}return e}positionAt(n,e,t){for(let o=0,r=0;;o++){let i=r+t.child(o).nodeSize;if(o==n){let s=e+n*this.width,l=(n+1)*this.width;for(;s<l&&this.map[s]<r;)s++;return s==l?i-1:this.map[s]}r=i}}static get(n){return ps(n)||hs(n,ab(n))}};Dt=new K("selectingCells");X=class ft extends B{constructor(e,t=e){let o=e.node(-1),r=oe.get(o),i=e.start(-1),s=r.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=r.cellsInRect(s).filter(u=>u!=t.pos-i);a.unshift(t.pos-i);let c=a.map(u=>{let d=o.nodeAt(u);if(!d)throw new RangeError(`No cell with offset ${u} found`);let f=i+u+1;return new St(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 o=e.resolve(t.map(this.$anchorCell.pos)),r=e.resolve(t.map(this.$headCell.pos));if(ms(o)&&ms(r)&&ys(o,r)){let i=this.$anchorCell.node(-1)!=o.node(-1);return i&&this.isRowSelection()?ft.rowSelection(o,r):i&&this.isColSelection()?ft.colSelection(o,r):new ft(o,r)}return P.between(o,r)}content(){let e=this.$anchorCell.node(-1),t=oe.get(e),o=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o),i={},s=[];for(let a=r.top;a<r.bottom;a++){let c=[];for(let u=a*t.width+r.left,d=r.left;d<r.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 g=r.left-p.left,b=p.right-r.right;if(g>0||b>0){let m=h.attrs;if(g>0&&(m=Qt(m,0,g)),b>0&&(m=Qt(m,m.colspan-b,b)),p.left<r.left){if(h=h.type.createAndFill(m),!h)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(m)}`)}else h=h.type.create(m,h.content)}if(p.top<r.top||p.bottom>r.bottom){let m={...h.attrs,rowspan:Math.min(p.bottom,r.bottom)-Math.max(p.top,r.top)};p.top<r.top?h=h.type.createAndFill(m):h=h.type.create(m,h.content)}c.push(h)}s.push(e.child(a).copy(A.from(c)))}let l=this.isColSelection()&&this.isRowSelection()?e:s;return new L(A.from(l),1,1)}replace(e,t=L.empty){let o=e.steps.length,r=this.ranges;for(let s=0;s<r.length;s++){let{$from:l,$to:a}=r[s],c=e.mapping.slice(o);e.replace(c.map(l.pos),c.map(a.pos),s?L.empty:t)}let i=B.findFrom(e.doc.resolve(e.mapping.slice(o).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new L(A.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),o=oe.get(t),r=this.$anchorCell.start(-1),i=o.cellsInRect(o.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let s=0;s<i.length;s++)e(t.nodeAt(i[s]),r+i[s])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let o=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(o,r)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let o=e.node(-1),r=oe.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(e=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new ft(e,t)}isRowSelection(){let e=this.$anchorCell.node(-1),t=oe.get(e),o=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-o),i=t.colCount(this.$headCell.pos-o);if(Math.min(r,i)>0)return!1;let s=r+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof ft&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let o=e.node(-1),r=oe.get(o),i=e.start(-1),s=r.findCell(e.pos-i),l=r.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(t=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(e=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new ft(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ft(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,o=t){return new ft(e.resolve(t),e.resolve(o))}getBookmark(){return new bb(this.$anchorCell.pos,this.$headCell.pos)}};X.prototype.visible=!1;B.jsonID("cell",X);bb=class Su{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Su(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),o=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&o.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&o.index()<o.parent.childCount&&ys(t,o)?new X(t,o):B.near(o,1)}};kb=new K("fix-tables");Pw=Tn("row",{useDeprecatedLogic:!0}),Bw=Tn("column",{useDeprecatedLogic:!0}),Hw=Tn("cell",{useDeprecatedLogic:!0});Hb=co({ArrowLeft:gr("horiz",-1),ArrowRight:gr("horiz",1),ArrowUp:gr("vert",-1),ArrowDown:gr("vert",1),"Shift-ArrowLeft":br("horiz",-1),"Shift-ArrowRight":br("horiz",1),"Shift-ArrowUp":br("vert",-1),"Shift-ArrowDown":br("vert",1),Backspace:mr,"Mod-Backspace":mr,Delete:mr,"Mod-Delete":mr});ws=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")),bs(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,bs(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 K("tableColumnResizing");_b=class vr{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,o=e.getMeta($e);if(o&&o.setHandle!=null)return new vr(o.setHandle,!1);if(o&&o.setDragging!==void 0)return new vr(t.activeHandle,o.setDragging);if(t.activeHandle>-1&&e.docChanged){let r=e.mapping.map(t.activeHandle,-1);return ms(e.doc.resolve(r))||(r=-1),new vr(r,t.dragging)}return t}}});function _u(n){let t=n.replace(/[\u0000- \u007f-\u009f]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);return t?`${t[1].toLowerCase()}:`:null}function De(n){let e=_u(n);return e===null||Xb.has(e)}function Re(n){if(Qb.test(n.trim()))return!0;let e=_u(n);return e===null||Yb.has(e)}var Xb,Yb,Qb,pt=D(()=>{"use strict";Xb=new Set(["http:","https:","mailto:","tel:"]),Yb=new Set(["http:","https:","blob:"]),Qb=/^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,/i});function oy(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(r=>Math.min(255,Number(r)).toString(16).padStart(2,"0")).join("");let o=e.match(/^#([0-9a-f])([0-9a-f])([0-9a-f])$/);return o?`#${o[1]}${o[1]}${o[2]}${o[2]}${o[3]}${o[3]}`:e}function ry(n){let e=n.getAttribute("dir")?.toLowerCase();return e==="rtl"||e==="ltr"?e:null}function Vu(n){let e=n.style.textAlign;return{align:Ju.includes(e)?e:null,lineHeight:Z.lineHeight(n.style.lineHeight),dir:ry(n)}}function qu(n){let e={};(n.dir==="rtl"||n.dir==="ltr")&&(e.dir=n.dir);let t=[],o=n.align;o&&Ju.includes(o)&&t.push(`text-align: ${o};`);let r=Z.lineHeight(n.lineHeight);return r&&t.push(`line-height: ${r};`),t.length&&(e.style=t.join(" ")),e}function Uu(n,e,t){let o=n.style.listStyleType.toLowerCase(),r=iy[n.getAttribute("type")??""]??"",i=e.includes(o)?o:e.includes(r)?r:null;return i===t?null:i}function ju(n,e){return typeof n=="string"&&e.includes(n)?{style:`list-style-type: ${n};`}:{}}function ly(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 ay(n){let e=[],t=Z.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 uy(){let n=xu({tableGroup:"block",cellContent:"block+",cellAttributes:{background:{default:null,getFromDOM:e=>Z.color(e.getAttribute("data-nova-cell-bg")??e.style.backgroundColor),setDOMAttr:(e,t)=>{let o=Z.color(e);o&&(t.style=`${t.style??""}background-color: ${o};`)}},valign:{default:null,getFromDOM:e=>{let t=e,o=(t.style.verticalAlign||t.getAttribute("valign")||"").toLowerCase();return Ku.includes(o)?o:null},setDOMAttr:(e,t)=>{Ku.includes(e)&&(t.style=`${t.style??""}vertical-align: ${e};`)}}}});n.table.attrs={width:{default:null},align:{default:null}},n.table.parseDOM=[{tag:"table",getAttrs:e=>{let t=e,o=Z.length(t.style.width)??Z.length(`${t.getAttribute("width")??""}px`),r=s=>s==="auto",i=t.getAttribute("align")==="center"||r(t.style.marginLeft)&&r(t.style.marginRight)?"center":t.getAttribute("align")==="right"||r(t.style.marginLeft)?"right":null;return{width:o,align:i}}}],n.table.toDOM=e=>{let t=ay(e.attrs);return["table",t?{style:t}:{},["tbody",0]]};for(let e of["table_cell","table_header"]){let t=n[e],o=t.parseDOM[0],r=o.getAttrs;o.getAttrs=s=>{let l=r(s);if(!l)return l;let a=c=>Math.min(cy,Math.max(1,Number.isFinite(c)?Math.floor(c):1));return{...l,colspan:a(l.colspan),rowspan:a(l.rowspan)}};let i=t.toDOM;t.toDOM=s=>{let l=i(s),a=s.attrs.colwidth;if(a?.every(c=>c>0)){let c=a.reduce((d,f)=>d+f,0),u=l[1].style?` ${l[1].style}`:"";l[1]={...l[1],style:`width: ${c}px;${u}`}}return l}}return n}function ho(n){return n?{value:n}:!1}function kr(n,e){return e?["span",{style:`${n}: ${e};`},0]:["span",0]}function Ss(n={}){let e=Object.entries(n.nodes??{}),t=Object.entries(n.marks??{});if(!e.length&&!t.length)return Zt;for(let[o]of e)if(o in ks)throw new Error(`[nova] node "${o}" already exists in the base schema`);for(let[o]of t)if(o in Ms)throw new Error(`[nova] mark "${o}" already exists in the base schema`);return new qn({nodes:{...ks,...Object.fromEntries(e)},marks:{...Ms,...Object.fromEntries(t)}})}var Ju,Zb,ey,ty,ny,Z,Wu,Mr,Sr,iy,sy,Ku,cy,ks,Ms,Zt,ht=D(()=>{"use strict";ce();xs();pt();Ju=["left","center","right","justify"],Zb=/^(#[0-9a-f]{3,8}|rgba?\(\s*[\d.]+%?\s*,\s*[\d.]+%?\s*,\s*[\d.]+%?\s*(,\s*[\d.]+%?\s*)?\)|[a-z]{3,20})$/i,ey=/^\d{1,4}(\.\d{1,3})?(px|pt|em|rem|%)$/,ty=/^\d{1,2}(\.\d{1,3})?(px|em|%)?$/,ny=/^[\w\s,'"-]{1,200}$/;Z={color:n=>typeof n=="string"&&Zb.test(n.trim())&&!/^(inherit|initial|unset|currentcolor|transparent|windowtext|window|auto|none)$/i.test(n.trim())?oy(n):null,length:n=>typeof n=="string"&&ey.test(n.trim())?n.trim():null,lineHeight:n=>typeof n=="string"&&ty.test(n.trim())&&n.trim()!=="normal"?n.trim():null,fontFamily:n=>typeof n=="string"&&ny.test(n.trim())?n.trim():null};Wu={align:{default:null},lineHeight:{default:null},dir:{default:null}},Mr=["disc","circle","square"],Sr=["decimal","lower-alpha","upper-alpha","lower-roman","upper-roman","lower-greek"],iy={1:"decimal",a:"lower-alpha",A:"upper-alpha",i:"lower-roman",I:"upper-roman"};sy={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;"};Ku=["top","middle","bottom"];cy=100;ks={doc:{content:"block+"},paragraph:{group:"block",content:"inline*",attrs:{...Wu},parseDOM:[{tag:"p",getAttrs:n=>Vu(n)}],toDOM:n=>["p",qu(n.attrs),0]},heading:{group:"block",content:"inline*",defining:!0,attrs:{level:{default:1},...Wu},parseDOM:[1,2,3,4,5,6].map(n=>({tag:`h${n}`,getAttrs:e=>({level:n,...Vu(e)})})),toDOM:n=>[`h${n.attrs.level}`,qu(n.attrs),0]},blockquote:{group:"block",content:"block+",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>["blockquote",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:n=>({language:n.querySelector("code")?.className.match(/language-([\w-]+)/)?.[1]??null})}],toDOM:n=>["pre",["code",n.attrs.language?{class:`language-${n.attrs.language}`}:{},0]]},bullet_list:{group:"block",content:"list_item+",attrs:{listStyle:{default:null}},parseDOM:[{tag:"ul",getAttrs:n=>({listStyle:Uu(n,Mr,"disc")})}],toDOM:n=>["ul",ju(n.attrs.listStyle,Mr),0]},ordered_list:{group:"block",content:"list_item+",attrs:{start:{default:1},listStyle:{default:null}},parseDOM:[{tag:"ol",getAttrs:n=>{let e=n.getAttribute("start");return{start:e?Number(e):1,listStyle:Uu(n,Sr,"decimal")}}}],toDOM:n=>["ol",{...n.attrs.start===1?{}:{start:n.attrs.start},...ju(n.attrs.listStyle,Sr)},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}},parseDOM:[{tag:"img[src]",getAttrs:n=>{let e=n;return Re(e.getAttribute("src")??"")?{src:e.getAttribute("src"),alt:e.getAttribute("alt"),title:e.getAttribute("title"),width:Ie(e.getAttribute("width")??e.style.width),height:Ie(e.getAttribute("height")??e.style.height),align:ly(e)}:!1}}],toDOM:n=>{let{alt:e,title:t}=n.attrs,o=Re(n.attrs.src)?n.attrs.src:"",r=Ie(n.attrs.width),i=Ie(n.attrs.height),s=sy[n.attrs.align];return["img",{src:o,...e?{alt:e}:{},...t?{title:t}:{},...r?{width:String(r)}:{},...i?{height:String(i)}:{},...s?{style:s}:{}}]}},hard_break:{group:"inline",inline:!0,selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>["br"]},...uy()},Ms={link:{attrs:{href:{},title:{default:null},target:{default:null}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:n=>{let e=n;return De(e.getAttribute("href")??"")?{href:e.getAttribute("href"),title:e.getAttribute("title"),target:e.getAttribute("target")}:!1}}],toDOM:n=>{let{title:e,target:t}=n.attrs;return["a",{href:De(n.attrs.href)?n.attrs.href:"#",...e?{title:e}:{},...t?{target:t,rel:"noopener noreferrer"}:{}},0]}},bold:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&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:n=>ho(Z.color(n))},{tag:"font[color]",getAttrs:n=>ho(Z.color(n.getAttribute("color")))}],toDOM:n=>kr("color",Z.color(n.attrs.value))},background:{attrs:{value:{}},parseDOM:[{style:"background-color",getAttrs:n=>ho(Z.color(n))},{tag:"mark",getAttrs:()=>({value:"yellow"})}],toDOM:n=>kr("background-color",Z.color(n.attrs.value))},font_family:{attrs:{value:{}},parseDOM:[{style:"font-family",getAttrs:n=>ho(Z.fontFamily(n))}],toDOM:n=>kr("font-family",Z.fontFamily(n.attrs.value))},font_size:{attrs:{value:{}},parseDOM:[{style:"font-size",getAttrs:n=>ho(Z.length(n))}],toDOM:n=>kr("font-size",Z.length(n.attrs.value))}};Zt=new qn({nodes:ks,marks:Ms})});var od={};He(od,{default:()=>yy});function nd(n,e){let{state:t,dispatch:o}=n.view;o(t.tr.insertText(e).scrollIntoView()),n.focus()}var ed,td,by,yy,rd=D(()=>{"use strict";j();ed=k.dateTime,td={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"}},by={date:{dateStyle:"short"},long:{dateStyle:"long"},time:{timeStyle:"short"},dateTime:{dateStyle:"short",timeStyle:"short"}};yy={name:"insertdatetime",toolbar:"insertdatetime",setup(n){let e=n.options.language??"en",t=td[e.split("-")[0]]??td.en,o=()=>n.options.pluginOptions?.insertdatetime?.now?.()??new Date,r=i=>new Intl.DateTimeFormat(e,by[i]).format(o());n.ui.registry.addMenuItem("insertdatetime",{text:t.title,icon:ed,onAction:i=>nd(i,r("dateTime"))}),n.ui.registry.addMenuButton("insertdatetime",{icon:ed,tooltip:t.title,items:i=>["date","long","time","dateTime"].map(s=>{let l=r(s);return{id:s,label:`${t[s]}: ${l}`,onSelect:()=>nd(i,l)}})})}}});function vy(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}function Nn(n,e,t=!1){for(let o=n;o;o=e=="start"?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(t&&o.childCount!=1)return!1}return!1}function ld(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 ky(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}function ad(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 Es(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 Ty(n){return(e,t)=>{if(e.selection instanceof R&&e.selection.node.isBlock){let{$from:p}=e.selection;return!p.parentOffset||!Mt(e.doc,p.pos)?!1:(t&&t(e.tr.split(p.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let o=e.tr;!e.selection.empty&&(e.selection instanceof P||e.selection instanceof me)&&o.deleteSelection();let{$from:r}=o.selection,i=o.steps.length,s=[],l,a,c=!1,u=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){c=r.end(p)==r.pos+(r.depth-p),u=r.start(p)==r.pos-(r.depth-p),a=Es(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let g=n&&n(r.parent,c,r);s.unshift(g||(c&&a?{type:a}:null)),l=p;break}else{if(p==1)return!1;s.unshift(null)}let d=r.pos,f=Mt(o.doc,d,s.length,s);if(f||(s[0]=a?{type:a}:null,f=Mt(o.doc,d,s.length,s)),!f)return!1;if(o.split(d,s.length,s),!c&&u&&r.node(l).type!=a){let p=o.mapping.slice(i),h=p.map(r.before(l)),g=o.doc.resolve(h);a&&r.node(l-1).canReplaceWith(g.index(),g.index()+1,a)&&o.setNodeMarkup(p.map(r.before(l)),a)}return t&&t(o.scrollIntoView()),!0}}function Ly(n,e,t){let o=e.nodeBefore,r=e.nodeAfter,i=e.index();return!o||!r||!o.type.compatibleContent(r.type)?!1:!o.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-o.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(r.isTextblock||Vt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function ud(n,e,t,o){let r=e.nodeBefore,i=e.nodeAfter,s,l,a=r.type.spec.isolating||i.type.spec.isolating;if(!a&&Ly(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,h=A.empty;for(let m=s.length-1;m>=0;m--)h=A.from(s[m].create(null,h));h=A.from(r.copy(h));let g=n.tr.step(new he(e.pos-1,p,e.pos,p,new L(h,1,0),s.length,!0)),b=g.doc.resolve(p+2*s.length);b.nodeAfter&&b.nodeAfter.type==r.type&&Vt(g.doc,b.pos)&&g.join(b.pos),t(g.scrollIntoView())}return!0}let u=i.type.spec.isolating||o>0&&a?null:B.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&_t(d);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(d,f).scrollIntoView()),!0;if(c&&Nn(i,"start",!0)&&Nn(r,"end")){let p=r,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let g=i,b=1;for(;!g.isTextblock;g=g.firstChild)b++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(t){let m=A.empty;for(let v=h.length-1;v>=0;v--)m=A.from(h[v].copy(m));let y=n.tr.step(new he(e.pos-h.length,e.pos+i.nodeSize,e.pos+b,e.pos+i.nodeSize-b,new L(m,h.length,0),0,!0));t(y.scrollIntoView())}return!0}}return!1}function dd(n){return function(e,t){let o=e.selection,r=n<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return r.node(i).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?r.start(i):r.end(i)))),!0):!1}}function fd(n,e=null){return function(t,o){let{$from:r,$to:i}=t.selection,s=r.blockRange(i),l=s&&hn(s,n,e);return l?(o&&o(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Ts(n,e=null){return function(t,o){let r=!1;for(let i=0;i<t.selection.ranges.length&&!r;i++){let{$from:{pos:s},$to:{pos:l}}=t.selection.ranges[i];t.doc.nodesBetween(s,l,(a,c)=>{if(r)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)r=!0;else{let u=t.doc.resolve(c),d=u.index();r=u.parent.canReplaceWith(d,d+1,n)}})}if(!r)return!1;if(o){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)}o(i.scrollIntoView())}return!0}}function Iy(n,e,t,o){for(let r=0;r<e.length;r++){let{$from:i,$to:s}=e[r],l=i.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(i.pos,s.pos,(a,c)=>{if(l||!o&&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 Py(n){let e=[];for(let t=0;t<n.length;t++){let{$from:o,$to:r}=n[t];o.doc.nodesBetween(o.pos,r.pos,(i,s)=>{if(i.isAtom&&i.content.size&&i.isInline&&s>=o.pos&&s+i.nodeSize<=r.pos)return s+1>o.pos&&e.push(new St(o,o.doc.resolve(s+1))),o=o.doc.resolve(s+1+i.content.size),!1}),o.pos<r.pos&&e.push(new St(o,r))}return e}function Rt(n,e=null,t){let o=(t&&t.removeWhenPresent)!==!1,r=(t&&t.enterInlineAtoms)!==!1,i=!(t&&t.includeWhitespace);return function(s,l){let{empty:a,$cursor:c,ranges:u}=s.selection;if(a&&!c||!Iy(s.doc,u,n,r))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;r||(u=Py(u)),o?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,(g,b,m)=>{if(h)return!1;h=!n.isInSet(g.marks)&&!!m&&m.type.allowsMarkType(n)&&!(g.isText&&/^\s*$/.test(g.textBetween(Math.max(0,p.$from.pos-b),Math.min(g.nodeSize,p.$to.pos-b))))}),!h});for(let p=0;p<u.length;p++){let{$from:h,$to:g}=u[p];if(!d)f.removeMark(h.pos,g.pos,n);else{let b=h.pos,m=g.pos,y=h.nodeAfter,v=g.nodeBefore,M=i&&y&&y.isText?/^\s*/.exec(y.text)[0].length:0,T=i&&v&&v.isText?/\s*$/.exec(v.text)[0].length:0;b+M<m&&(b+=M,m-=T),f.addMark(b,m,n.create(e))}}l(f.scrollIntoView())}return!0}}function mo(...n){return function(e,t,o){for(let r=0;r<n.length;r++)if(n[r](e,t,o))return!0;return!1}}var sd,wy,xy,My,Sy,cd,Cy,As,Ey,Ay,Ny,Oy,Dy,Ry,Cs,id,mt,pd,By,hd,Ns=D(()=>{"use strict";Ge();ce();U();sd=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);wy=(n,e,t)=>{let o=vy(n,t);if(!o)return!1;let r=ld(o);if(!r){let s=o.blockRange(),l=s&&_t(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=r.nodeBefore;if(ud(n,r,e,-1))return!0;if(o.parent.content.size==0&&(Nn(i,"end")||R.isSelectable(i)))for(let s=o.depth;;s--){let l=Uo(n.doc,o.before(s),o.after(s),L.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(Nn(i,"end")?B.findFrom(a.doc.resolve(a.mapping.map(r.pos,-1)),-1):R.create(a.doc,r.pos-i.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||o.node(s-1).childCount>1)break}return i.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),!0):!1};xy=(n,e,t)=>{let{$head:o,empty:r}=n.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):o.parentOffset>0)return!1;i=ld(o)}let s=i&&i.nodeBefore;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};My=(n,e,t)=>{let o=ky(n,t);if(!o)return!1;let r=ad(o);if(!r)return!1;let i=r.nodeAfter;if(ud(n,r,e,1))return!0;if(o.parent.content.size==0&&(Nn(i,"start")||R.isSelectable(i))){let s=Uo(n.doc,o.before(),o.after(),L.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=n.tr.step(s);l.setSelection(Nn(i,"start")?B.findFrom(l.doc.resolve(l.mapping.map(r.pos)),1):R.create(l.doc,l.mapping.map(r.pos))),e(l.scrollIntoView())}return!0}}return i.isAtom&&r.depth==o.depth-1?(e&&e(n.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),!0):!1},Sy=(n,e,t)=>{let{$head:o,empty:r}=n.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):o.parentOffset<o.parent.content.size)return!1;i=ad(o)}let s=i&&i.nodeAfter;return!s||!R.isSelectable(s)?!1:(e&&e(n.tr.setSelection(R.create(n.doc,i.pos)).scrollIntoView()),!0)};cd=(n,e)=>{let{$from:t,$to:o}=n.selection,r=t.blockRange(o),i=r&&_t(r);return i==null?!1:(e&&e(n.tr.lift(r,i).scrollIntoView()),!0)},Cy=(n,e)=>{let{$head:t,$anchor:o}=n.selection;return!t.parent.type.spec.code||!t.sameParent(o)?!1:(e&&e(n.tr.insertText(`
|
|
10
|
-
`).scrollIntoView()),!0)};As=(n,e)=>{let{$head:t,$anchor:o}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(o))return!1;let r=t.node(-1),i=t.indexAfter(-1),s=Es(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(B.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ey=(n,e)=>{let t=n.selection,{$from:o,$to:r}=t;if(t instanceof me||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=Es(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,l=n.tr.insert(s,i.createAndFill());l.setSelection(P.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Ay=(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(Mt(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let o=t.blockRange(),r=o&&_t(o);return r==null?!1:(e&&e(n.tr.lift(o,r).scrollIntoView()),!0)};Ny=Ty(),Oy=(n,e)=>(e&&e(n.tr.setSelection(new me(n.doc))),!0);Dy=dd(-1),Ry=dd(1);Cs=mo(sd,wy,xy),id=mo(sd,My,Sy),mt={Enter:mo(Cy,Ey,Ay,Ny),"Mod-Enter":As,Backspace:Cs,"Mod-Backspace":Cs,"Shift-Backspace":Cs,Delete:id,"Mod-Delete":id,"Mod-a":Oy},pd={"Ctrl-h":mt.Backspace,"Alt-Backspace":mt["Mod-Backspace"],"Ctrl-d":mt.Delete,"Ctrl-Alt-Backspace":mt["Mod-Delete"],"Alt-Delete":mt["Mod-Delete"],"Alt-d":mt["Mod-Delete"],"Ctrl-a":Dy,"Ctrl-e":Ry};for(let n in mt)pd[n]=mt[n];By=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,hd=By?pd:mt});var Er,be,md,Hy,Os,gd=D(()=>{"use strict";Er=200,be=function(){};be.prototype.append=function(e){return e.length?(e=be.from(e),!this.length&&e||e.length<Er&&this.leafAppend(e)||this.length<Er&&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 Hy(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,o){t===void 0&&(t=0),o===void 0&&(o=this.length),t<=o?this.forEachInner(e,t,o,0):this.forEachInvertedInner(e,t,o,0)};be.prototype.map=function(e,t,o){t===void 0&&(t=0),o===void 0&&(o=this.length);var r=[];return this.forEach(function(i,s){return r.push(e(i,s))},t,o),r};be.from=function(e){return e instanceof be?e:e&&e.length?new md(e):be.empty};md=(function(n){function e(o){n.call(this),this.values=o}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,i){return r==0&&i==this.length?this:new e(this.values.slice(r,i))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,i,s,l){for(var a=i;a<s;a++)if(r(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,l){for(var a=i-1;a>=s;a--)if(r(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=Er)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=Er)return new e(r.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 md([]);Hy=(function(n){function e(t,o){n.call(this),this.left=t,this.right=o,this.length=t.length+o.length,this.depth=Math.max(t.depth,o.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(o){return o<this.left.length?this.left.get(o):this.right.get(o-this.left.length)},e.prototype.forEachInner=function(o,r,i,s){var l=this.left.length;if(r<l&&this.left.forEachInner(o,r,Math.min(i,l),s)===!1||i>l&&this.right.forEachInner(o,Math.max(r-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(o,r,i,s){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(o,r-l,Math.max(i,l)-l,s+l)===!1||i<l&&this.left.forEachInvertedInner(o,Math.min(r,l),i,s)===!1)return!1},e.prototype.sliceInner=function(o,r){if(o==0&&r==this.length)return this;var i=this.left.length;return r<=i?this.left.slice(o,r):o>=i?this.right.slice(o-i,r-i):this.left.slice(o,i).append(this.right.slice(0,r-i))},e.prototype.leafAppend=function(o){var r=this.right.leafAppend(o);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(o){var r=this.left.leafPrepend(o);if(r)return new e(r,this.right)},e.prototype.appendInner=function(o){return this.left.depth>=Math.max(this.right.depth,o.depth)+1?new e(this.left,new e(this.right,o)):new e(this,o)},e})(be),Os=be});function Fy(n,e){let t;return n.forEach((o,r)=>{if(o.selection&&e--==0)return t=r,!1}),n.slice(t)}function _y(n,e,t,o){let r=t.getMeta(en),i;if(r)return r.historyState;t.getMeta(wd)&&(n=new Ze(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(en))return s.getMeta(en).redo?new Ze(n.done.addTransform(t,void 0,o,Ar(e)),n.undone,bd(t.mapping.maps),n.prevTime,n.prevComposition):new Ze(n.done,n.undone.addTransform(t,void 0,o,Ar(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-o.newGroupDelay||!Vy(t,n.prevRanges)),c=s?Ls(n.prevRanges,t.mapping):bd(t.mapping.maps);return new Ze(n.done.addTransform(t,a?e.selection.getBookmark():void 0,o,Ar(e)),tn.empty,c,t.time,l??n.prevComposition)}else return(i=t.getMeta("rebased"))?new Ze(n.done.rebased(t,i),n.undone.rebased(t,i),Ls(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new Ze(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Ls(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Vy(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((o,r)=>{for(let i=0;i<e.length;i+=2)o<=e[i+1]&&r>=e[i]&&(t=!0)}),t}function bd(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((o,r,i,s)=>e.push(i,s));return e}function Ls(n,e){if(!n)return null;let t=[];for(let o=0;o<n.length;o+=2){let r=e.map(n[o],1),i=e.map(n[o+1],-1);r<=i&&t.push(r,i)}return t}function qy(n,e){for(let t=0;t<e.steps.length;t++){let o=e.mapping.maps[t],r=-1;if(o.forEach((i,s)=>r=s),r<0){let i=e.steps[t];(i instanceof $t||i instanceof kt)&&(r=i.to)}if(r>-1)return B.near(n.doc.resolve(r))}return n.selection}function Wy(n,e,t){let o=Ar(e),r=en.get(e).spec.config,i=(t?n.undone:n.done).popEvent(e,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(t?n.done:n.undone).addTransform(i.transform,qy(e,i.transform).getBookmark(),r,o),a=new Ze(t?l:i.remaining,t?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(en,{redo:t,historyState:a})}function Ar(n){let e=n.plugins;if(yd!=e){Ds=!1,yd=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ds=!0;break}}return Ds}function vd(n){return n.setMeta(wd,!0)}function xd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new _({key:en,state:{init(){return new Ze(tn.empty,tn.empty,null,0,-1)},apply(e,t,o){return _y(t,o,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let o=t.inputType,r=o=="historyUndo"?Rs:o=="historyRedo"?Is:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Tr(n,e){return(t,o)=>{let r=en.getState(t);if(!r||(n?r.undone:r.done).eventCount==0)return!1;if(o){let i=Wy(r,t,n);i&&o(e?i.scrollIntoView():i)}return!0}}var zy,tn,Qe,Ze,$y,Ds,yd,en,wd,Rs,Is,fx,px,Nr=D(()=>{"use strict";gd();Ge();U();zy=500,tn=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let o=this.items.length;for(;;o--)if(this.items.get(o-1).selection){--o;break}let r,i;t&&(r=this.remapping(o,this.items.length),i=r.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){r||(r=this.remapping(o,f+1),i=r.maps.length),i--,u.push(d);return}if(r){u.push(new Qe(d.map));let p=d.step.map(r.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new Qe(h,void 0,void 0,c.length+u.length))),i--,h&&r.appendMap(h,i)}else s.maybeStep(d.step);if(d.selection)return l=r?d.selection.map(r.slice(i)):d.selection,a=new n(this.items.slice(0,o).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,o,r){let i=[],s=this.eventCount,l=this.items,a=!r&&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 Qe(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),r||(a=f)}let c=s-o.depth;return c>$y&&(l=Fy(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let o=new Jn;return this.items.forEach((r,i)=>{let s=r.mirrorOffset!=null&&i-r.mirrorOffset>=e?o.maps.length-r.mirrorOffset:void 0;o.appendMap(r.map,s)},e,t),o}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new Qe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;t=Math.min(this.items.length,t);let o=[],r=this.items.length-t,i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},r);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 g=e.steps[p].invert(e.docs[p]),b=f.selection&&f.selection.map(i.slice(a+1,p));b&&l++,o.push(new Qe(h,g,b))}else o.push(new Qe(h))},r);let c=[];for(let f=t;f<s;f++)c.push(new Qe(i.maps[f]));let u=this.items.slice(0,r).append(c).append(o),d=new n(u,l);return d.emptyItemCount()>zy&&(d=d.compress(this.items.length-o.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),o=t.maps.length,r=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)r.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(o)),c=a&&a.getMap();if(o--,c&&t.appendMap(c,o),a){let u=s.selection&&s.selection.map(t.slice(o));u&&i++;let d=new Qe(c.invert(),a,u),f,p=r.length-1;(f=r.length&&r[p].merge(d))?r[p]=f:r.push(d)}}else s.map&&o--},this.items.length,0),new n(Os.from(r.reverse()),i)}};tn.empty=new tn(Os.empty,0);Qe=class n{constructor(e,t,o,r){this.map=e,this.step=t,this.selection=o,this.mirrorOffset=r}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)}}},Ze=class{constructor(e,t,o,r,i){this.done=e,this.undone=t,this.prevRanges=o,this.prevTime=r,this.prevComposition=i}},$y=20;Ds=!1,yd=null;en=new K("history"),wd=new K("closeHistory");Rs=Tr(!1,!0),Is=Tr(!0,!0),fx=Tr(!1,!1),px=Tr(!0,!1)});function kd(n,e=null){return function(t,o){let{$from:r,$to:i}=t.selection,s=r.blockRange(i);if(!s)return!1;let l=o?t.tr:null;return Uy(l,s,n,e)?(o&&o(l.scrollIntoView()),!0):!1}}function Uy(n,e,t,o=null){let r=!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 zt(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new zt(e.$from,s.resolve(e.$to.end(e.depth)),e.depth)),r=!0}let l=hn(i,t,o,e);return l?(n&&jy(n,e,l,r,t),!0):!1}function jy(n,e,t,o,r){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-(o?2:0),e.end,e.start,e.end,new L(i,0,0),t.length,!0));let s=0;for(let u=0;u<t.length;u++)t[u].type==r&&(s=u+1);let l=t.length-s,a=e.start+t.length-(o?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&l&&Mt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function On(n,e){return n instanceof rt?e==n:n.indexOf(e)>-1}function Md(n,e){return function(t,o){let{$from:r,$to:i,node:s}=t.selection;if(s&&s.isBlock||r.depth<2||!r.sameParent(i))return!1;let l=r.node(-1);if(!On(n,l.type))return!1;if(r.parent.content.size==0&&r.node(-1).childCount==r.indexAfter(-1)){if(r.depth==3||!On(n,r.node(-3).type)||r.index(-2)!=r.node(-2).childCount-1)return!1;if(o){let d=A.empty,f=r.index(-1)?1:r.index(-2)?2:3;for(let m=r.depth-f;m>=r.depth-3;m--)d=A.from(r.node(m).copy(d));let p=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;d=d.append(A.from(r.node(-3).type.createAndFill()));let h=r.before(r.depth-(f-1)),g=t.tr.replace(h,r.after(-p),new L(d,4-f,0)),b=-1;g.doc.nodesBetween(h,g.doc.content.size,(m,y)=>{if(b>-1)return!1;m.isTextblock&&m.content.size==0&&(b=y+1)}),b>-1&&g.setSelection(B.near(g.doc.resolve(b))),o(g.scrollIntoView())}return!0}let a=i.pos==r.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(r.pos,i.pos),u=a||e?[e?{type:l.type,attrs:e}:null,a?{type:a}:null]:void 0;return Mt(c.doc,r.pos,2,u)?(o&&o(c.split(r.pos,2,u).scrollIntoView()),!0):!1}}function Ps(n){return function(e,t){let{$from:o,$to:r}=e.selection,i=o.blockRange(r,s=>s.childCount>0&&On(n,s.firstChild.type));return i?t?On(n,o.node(i.depth-1).type)?Ky(e,t,i):Jy(e,t,i):!0:!1}}function Ky(n,e,t){let o=n.tr,r=t.end,i=t.$to.end(t.depth),s=t.parent.child(t.endIndex-1).type;r<i&&(o.step(new he(r-1,i,r,i,new L(A.from(s.create(null,t.parent.copy())),1,0),1,!0)),t=new zt(o.doc.resolve(t.$from.pos),o.doc.resolve(i),t.depth));let l=_t(t);if(l==null)return!1;o.lift(t,l);let a=o.doc.resolve(o.mapping.map(r,-1)-1);return Vt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Jy(n,e,t){let o=n.tr,r=t.parent;for(let p=t.end,h=t.endIndex-1,g=t.startIndex;h>g;h--)p-=r.child(h).nodeSize,o.delete(p-1,p+1);let i=o.doc.resolve(t.start),s=i.nodeAfter;if(o.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==r.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(r))))return!1;let d=i.pos,f=d+s.nodeSize;return o.step(new he(d-(l?1:0),f+(a?1:0),d+1,f-1,new L((l?A.empty:A.from(r.copy(A.empty))).append(a?A.empty:A.from(r.copy(A.empty))),l?0:1,a?0:1),l?0:1)),e(o.scrollIntoView()),!0}function Sd(n){return function(e,t){let{$from:o,$to:r}=e.selection,i=o.blockRange(r,c=>c.childCount>0&&On(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(!On(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 L(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 Bs=D(()=>{"use strict";Ge();ce();U()});function Or(n){return(e,t)=>{let{from:o,to:r}=e.selection,i=e.tr,s=!1;return e.doc.nodesBetween(o,r,(l,a)=>{let c=ee(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 Ed(n,e={}){let t=Ts(n,e);return(o,r)=>{if(!t(o))return!1;if(r){let i=o.tr;for(let s of o.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}:{}}));r(i.scrollIntoView())}return!0}}function Ln(n){return on("heading",e=>Ed(e,{level:n}))}function Cd(n){return(e,t)=>et(e,n)?Ps(ee(e).list_item)(e,t):kd(n)(e,t)}function Ad(n,e){return(t,o)=>Re(n)?(o?.(t.tr.replaceSelectionWith(ee(t).image.create({src:n,alt:e??null})).scrollIntoView()),!0):!1}function go(n,e){let{from:t,$from:o,to:r,empty:i}=n.selection;return i?!!e.isInSet(n.storedMarks??o.marks()):n.doc.rangeHasMark(t,r,e)}function et(n,e,t){let{$from:o,to:r}=n.selection;for(let i=o.depth;i>0;i--){let s=o.node(i);if(s.type===e&&(!t||Object.entries(t).every(([l,a])=>s.attrs[l]===a)))return r<=o.end(i)}return!1}function rn(n){return n.selection.$from.parent.attrs.align??"left"}function Td(n,e){let t=n.selection.$from.parent,o=ee(n),r=ie(n);switch(e){case"bold":case"italic":case"underline":case"strike":case"code":case"subscript":case"superscript":return go(n,r[e]);case"paragraph":return t.type===o.paragraph;case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t.type===o.heading&&t.attrs.level===Number(e[1]);case"codeBlock":return t.type===o.code_block;case"blockquote":return et(n,o.blockquote);case"bulletList":return et(n,o.bullet_list);case"orderedList":return et(n,o.ordered_list);case"alignLeft":return rn(n)==="left";case"alignCenter":return rn(n)==="center";case"alignRight":return rn(n)==="right";case"alignJustify":return rn(n)==="justify";default:return!1}}function Dn(n){let{$from:e}=n.selection,t=ie(n),o=t.link.isInSet(e.marks())??t.link.isInSet(e.nodeAfter?.marks??[]);return o?o.attrs:null}function bo(n,e,t){let o=n.doc.resolve(t),r=o.start(),i=[];return o.parent.forEach((s,l)=>{if(!e.isInSet(s.marks))return;let a=r+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 ee,ie,on,nn,Gy,Xy,Yy,G,Pe=D(()=>{"use strict";Ns();Nr();Bs();pt();ee=n=>n.schema.nodes,ie=n=>n.schema.marks,on=(n,e)=>(t,o,r)=>e(ee(t)[n])(t,o,r),nn=(n,e)=>(t,o,r)=>e(ie(t)[n])(t,o,r);Gy=(n,e)=>(e?.(n.tr.replaceSelectionWith(ee(n).horizontal_rule.create()).scrollIntoView()),!0),Xy=(n,e)=>{let{from:t,to:o,empty:r,$from:i}=n.selection,s=ie(n);if(r){let l=bo(n,s.link,i.pos);return l?(e?.(n.tr.removeMark(l.from,l.to,s.link)),!0):!1}return n.doc.rangeHasMark(t,o,s.link)?(e?.(n.tr.removeMark(t,o,s.link)),!0):!1},Yy=(n,e)=>{let{from:t,to:o,empty:r}=n.selection;if(r)return!1;if(e){let i=ie(n),s=n.tr;for(let l of Object.values(i))l!==i.link&&(s=s.removeMark(t,o,l));e(s)}return!0};G={bold:nn("bold",Rt),italic:nn("italic",Rt),underline:nn("underline",Rt),strike:nn("strike",Rt),code:nn("code",Rt),subscript:nn("subscript",Rt),superscript:nn("superscript",Rt),paragraph:on("paragraph",n=>Ed(n)),h1:Ln(1),h2:Ln(2),h3:Ln(3),h4:Ln(4),h5:Ln(5),h6:Ln(6),blockquote:(n,e)=>et(n,ee(n).blockquote)?cd(n,e):fd(ee(n).blockquote)(n,e),codeBlock:on("code_block",n=>Ts(n)),bulletList:on("bullet_list",Cd),orderedList:on("ordered_list",Cd),indent:on("list_item",Sd),outdent:on("list_item",Ps),alignLeft:Or(null),alignCenter:Or("center"),alignRight:Or("right"),alignJustify:Or("justify"),horizontalRule:Gy,unlink:Xy,clearFormatting:Yy,undo:Rs,redo:Is}});function Rn(n){return Qy.test(n.type)}function Zy(n){return new Promise((e,t)=>{let o=new FileReader;o.onload=()=>e(String(o.result)),o.onerror=()=>t(o.error??new Error("FileReader failed")),o.readAsDataURL(n)})}function Nd(n,e){let t=null;return n.state.doc.descendants((o,r)=>t!==null?!1:(o.type===ee(n.state).image&&o.attrs.src===e&&(t=r),!0)),t}function yo(n,e,t){let o=e.filter(Rn),r=n.view;for(let i of o){let s=URL.createObjectURL(i),l=ee(r.state).image.create({src:s,alt:null}),a=r.state.tr;t!==void 0?a.insert(Math.min(t,a.doc.content.size),l):a.replaceSelectionWith(l),r.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)}%`)):Zy(i)).then(f=>{if(!Re(f))throw new Error(`Unsafe image URL returned: ${f}`);let p=Nd(r,s);if(p===null)return;let h=r.state.doc.nodeAt(p);r.dispatch(r.state.tr.setNodeMarkup(p,void 0,{...h.attrs,src:f}).setMeta("addToHistory",!1))}).catch(f=>{console.error("[nova] image upload failed",f);let p=Nd(r,s);p!==null&&r.dispatch(r.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 ev(n,e="pasted-image"){let t=n.match(Ld);if(!t)return null;let o=t[1].toLowerCase();try{let r=atob(t[2]),i=new Uint8Array(r.length);for(let l=0;l<r.length;l++)i[l]=r.charCodeAt(l);let s=o.split("/")[1].replace("jpeg","jpg");return new File([i],`${e}.${s}`,{type:o})}catch{return null}}function tv(n,e,t){let o=n.state.tr;n.state.doc.descendants((r,i)=>{r.type===ee(n.state).image&&r.attrs.src===e&&o.setNodeMarkup(i,void 0,{...r.attrs,src:t})}),o.docChanged&&n.dispatch(o.setMeta("addToHistory",!1))}async function nv(n,e){let t=n.options.uploadImage,o=t?ev(e):null;if(!t||!o)return;let r=n.ui.notify({text:n.ui.t("image.uploading"),timeout:0});try{let i=await t(o,s=>r.setText(`${n.ui.t("image.uploading")} ${Math.round(s)}%`));if(!Re(i))throw new Error(`Unsafe image URL returned: ${i}`);tv(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{r.close()}}function Od(n,e){let t=new Set;return n.descendants(o=>{o.type===e&&Ld.test(o.attrs.src)&&t.add(o.attrs.src)}),t}function Dd(n){return new _({key:new K("nova-embedded-image-upload"),appendTransaction(e,t,o){if(!n.options.uploadImage||!e.some(a=>["paste","drop"].includes(a.getMeta("uiEvent")))||!e.some(a=>a.docChanged))return null;let i=ee(o).image,s=Od(t.doc,i),l=[...Od(o.doc,i)].filter(a=>!s.has(a));return l.length&&queueMicrotask(()=>l.forEach(a=>{nv(n,a)})),null}})}function Rd(n){return new _({key:new K("nova-image-drop-paste"),props:{handlePaste(e,t){if(!n.isAllowed("image"))return!1;let o=t.clipboardData;if(!o||o.getData("text/html"))return!1;let r=[...o.files].filter(Rn);return r.length?(yo(n,r),!0):!1},handleDrop(e,t){if(!n.isAllowed("image"))return!1;let o=[...t.dataTransfer?.files??[]].filter(Rn);if(!o.length)return!1;t.preventDefault();let r=e.posAtCoords({left:t.clientX,top:t.clientY});return yo(n,o,r?.pos),!0}}})}function Lr(n){let{t:e}=n.ui,t=w("input",{type:"file",accept:"image/png,image/jpeg,image/gif,image/webp,image/avif",className:"nova-visually-hidden",tabindex:"-1"}),o=w("button",{type:"button",className:"nova-dropzone"},ne(k.upload),w("span",{},e("image.drop"))),r=ue({label:e("image.url"),type:"url",placeholder:"https://"}),i=ue({label:e("image.alt"),hint:e("image.altHint")}),s=w("div",{className:"nova-form"},o,t,w("div",{className:"nova-divider"},w("span",{},e("image.or"))),r.el,i.el),l=n.ui.openDialog({title:e("image.title"),body:s,submitLabel:e("dialog.insert"),initialFocus:r.input,onSubmit:()=>{let c=r.input.value.trim();return!c||!Re(c)?(r.input.setAttribute("aria-invalid","true"),r.input.focus(),e("image.invalid")):(n.exec(Ad(c,i.input.value.trim()||void 0)),!0)}}),a=c=>{let u=c.filter(Rn);u.length&&(l.close(),yo(n,u))};o.addEventListener("click",()=>t.click()),t.addEventListener("change",()=>a([...t.files??[]])),o.addEventListener("dragover",c=>{c.preventDefault(),o.classList.add("is-dragover")}),o.addEventListener("dragleave",()=>o.classList.remove("is-dragover")),o.addEventListener("drop",c=>{c.preventDefault(),o.classList.remove("is-dragover"),a([...c.dataTransfer?.files??[]])})}function sn(n){let{selection:e}=n;return e instanceof R&&e.node.type===ee(n).image?{node:e.node,pos:e.from}:null}function vo(n){return(e,t)=>{let o=sn(e);if(!o)return!1;if(t){let r=e.tr.setNodeMarkup(o.pos,void 0,{...o.node.attrs,...n});r.setSelection(R.create(r.doc,o.pos)),t(r)}return!0}}function Id(n,e){let t=sn(n.view.state);if(!t)return!1;if(e===null)return n.exec(vo({width:null,height:null}));let r=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=r&&r.naturalWidth?r.naturalHeight/r.naturalWidth:null;return n.exec(vo({width:l,height:a?Math.round(l*a):null}))}function Pd(n){let e=sn(n.view.state);if(!e)return;let{t}=n.ui,o=ue({label:t("image.alt"),value:e.node.attrs.alt??"",hint:t("image.altHint")}),r=ue({label:t("link.tooltip"),value:e.node.attrs.title??""});n.ui.openDialog({title:t("image.editAlt"),body:w("div",{className:"nova-form"},o.el,r.el),submitLabel:t("dialog.save"),initialFocus:o.input,onSubmit:()=>(n.exec(vo({alt:o.input.value.trim()||null,title:r.input.value.trim()||null})),!0)})}var Qy,Ld,wo=D(()=>{"use strict";U();Pe();Pe();Ct();Y();j();pt();Qy=/^image\/(png|jpe?g|gif|webp|avif|bmp)$/;Ld=/^data:(image\/(?:png|jpe?g|gif|webp|avif|bmp));base64,(.+)$/i});function Bd(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 Hs(n){let{from:e,to:t,empty:o,$from:r}=n.selection;return o?bo(n,ie(n).link,r.pos)??{from:e,to:t}:{from:e,to:t}}function ov(n){return(e,t)=>{let o=Bd(n.href);if(!o||!De(o))return!1;if(!t)return!0;let{from:r,to:i}=Hs(e),s=ie(e).link.create({href:o,title:n.title||null,target:n.target||null}),l=e.doc.textBetween(r,i),a=n.text?.trim()?n.text:null,c=e.tr;if(r===i||a!==null&&a!==l){let u=ie(e).link.removeFromSet(e.doc.resolve(r).marks()),d=e.schema.text(a??(l||o),s.addToSet(u));c.replaceWith(r,i,d)}else c.removeMark(r,i,ie(e).link).addMark(r,i,s);return t(c.scrollIntoView()),!0}}function xo(){return(n,e)=>{let{from:t,to:o}=Hs(n);return t===o||!n.doc.rangeHasMark(t,o,ie(n).link)?!1:(e?.(n.tr.removeMark(t,o,ie(n).link)),!0)}}function tt(n){let{t:e}=n.ui,t=n.view.state,o=Dn(t),r=Hs(t),i=t.doc.textBetween(r.from,r.to),s=!i.includes(`
|
|
11
|
-
`)&&t.selection.$from.sameParent(t.doc.resolve(r.to)),l=ue({label:e("link.url"),type:"url",value:o?.href??"",placeholder:"https://",required:!0}),a=ue({label:e("link.text"),value:i}),c=ue({label:e("link.tooltip"),value:o?.title??""}),u=Ca(e("link.newTab"),o?.target==="_blank"),d=w("div",{className:"nova-form"},l.el,s?a.el:null,c.el,u.el);n.ui.openDialog({title:e(o?"link.editTitle":"link.title"),body:d,submitLabel:e(o?"dialog.save":"dialog.insert"),initialFocus:l.input,onSubmit:()=>{let f=Bd(l.input.value);return!f||!De(f)?(l.input.setAttribute("aria-invalid","true"),l.input.focus(),e("link.invalid")):(n.exec(ov({href:f,...s?{text:a.input.value}:{},title:c.input.value.trim()||null,target:u.input.checked?"_blank":null})),!0)}})}var In=D(()=>{"use strict";Pe();Pe();Ct();Y();pt()});function rv(n,e,t=!0,o=Zt){let{table:r,table_row:i,table_cell:s,table_header:l,paragraph:a}=o.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 r.create(null,c)}function nt(n,e,t=!0){return(o,r)=>{if(n<1||e<1||n>100||e>50||Q(o))return!1;if(r){let i=rv(n,e,t,o.schema),s=o.tr.replaceSelectionWith(i),l=-1;s.doc.descendants((a,c)=>(a===i&&(l=c),l<0)),l>=0&&s.setSelection(P.near(s.doc.resolve(l+3))),r(s.scrollIntoView())}return!0}}function Hd(){return[zu({cellMinWidth:48,View:zs}),$u(),Fe({Tab:iv,"Shift-Tab":xr(-1)})]}function zd(n){return Pu("background",n)}function Fd(n){if(!Q(n))return!1;let e=An(n.selection.$from)?.node.firstChild;if(!e||e.childCount===0)return!1;let t=!0;return e.forEach(o=>{o.type!==n.schema.nodes.table_header&&(t=!1)}),t}function $d(n){if(!Q(n))return!1;let e=An(n.selection.$from)?.node;if(!e)return!1;let t=!0;return e.forEach(o=>{o.firstChild?.type!==n.schema.nodes.table_header&&(t=!1)}),t}function _d(n){let{state:e}=n.view;if(!Q(e))return null;let t=An(e.selection.$from);return t?n.view.nodeDOM(t.pos)?.getBoundingClientRect()??null:null}function Vd(n,e,t){let o=1,r=1,i=[],s=w("div",{className:"nova-grid-caption","aria-live":"polite"}),l=w("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<=o&&d<=r),c.tabIndex=u===o&&d===r?0:-1}s.textContent=e(o,r)};for(let c=1;c<=ko;c++)for(let u=1;u<=ko;u++){let d=w("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",()=>{o=c,r=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(),o=Math.min(ko,Math.max(1,o+d[0])),r=Math.min(ko,Math.max(1,r+d[1])),a(),i[(o-1)*ko+(r-1)].focus())}),a(),w("div",{className:"nova-grid-panel"},l,s)}function sv(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 lv(n){if(!Q(n))return null;let e=_e(n),t=e.table,o=!1;if(t.descendants(s=>((s.attrs.colspan>1||s.attrs.rowspan>1)&&(o=!0),!o&&s.type.spec.tableRole!=="cell"&&s.type.spec.tableRole!=="header_cell")),o)return null;let r=n.schema.nodes,i=0;for(let s=0;s<t.childCount;s++){let l=!0;if(t.child(s).forEach(a=>{a.type!==r.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 Fs(n,e){return(t,o)=>{let r=lv(t);if(!r)return!1;if(o){let{table:i,column:s,headerRows:l,pos:a}=r,c=[];i.forEach(y=>c.push(y));let u=c.slice(0,l),d=c.slice(l),f=d.map(y=>s<y.childCount?y.child(s).textContent.trim():""),p=f.map(sv),h=f.every((y,v)=>y===""||p[v]!==null),g=new Intl.Collator(e,{numeric:!0,sensitivity:"base"}),b=d.map((y,v)=>({row:y,i:v})).sort((y,v)=>{let M=f[y.i],T=f[v.i];if(!M||!T)return M?-1:T?1:y.i-v.i;let C=h?p[y.i]-p[v.i]:g.compare(M,T);return(n==="asc"?C:-C)||y.i-v.i}).map(({row:y})=>y),m=i.copy(A.from([...u,...b]));o(t.tr.replaceWith(a,a+i.nodeSize,m).scrollIntoView())}return!0}}function qd(n){let e=An(n.selection.$from);return e?{width:e.node.attrs.width??null,align:e.node.attrs.align??null}:null}function Wd(n){return(e,t)=>{let o=An(e.selection.$from);return!o||n.width!==null&&!Z.length(n.width)?!1:(t?.(e.tr.setNodeMarkup(o.pos,void 0,{...o.node.attrs,...n})),!0)}}function Ud(n){let e=[];if(n.selection instanceof X)return n.selection.forEachCell((o,r)=>e.push({node:o,pos:r})),e;let{$from:t}=n.selection;for(let o=t.depth;o>0;o--){let r=t.node(o),i=r.type.spec.tableRole;if(i==="cell"||i==="header_cell"){e.push({node:r,pos:t.before(o)});break}}return e}function jd(n){let e=Ud(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}}function Kd(n){return(e,t)=>{let o=Ud(e);if(!o.length||n.width!=null&&!(n.width>=24&&n.width<=4e3))return!1;if(!t)return!0;let r=e.schema.nodes,i=e.tr;for(let{pos:s,node:l}of o){let a=n.header===void 0?l.type:n.header?r.table_header:r.table_cell,c={...l.attrs,...n.valign!==void 0?{valign:n.valign}:{}};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 g=c-l.colCount(d),b=[...h.attrs.colwidth??new Array(h.attrs.colspan).fill(0)];b[g]=n.width??0,i.setNodeMarkup(p,void 0,{...h.attrs,colwidth:b.every(m=>!m)?null:b})}}return t(i),!0}}var ko,iv,qe,zs,Pn=D(()=>{"use strict";ut();ce();U();xs();ht();Y();ko=10;iv=(n,e,t)=>{if(!Q(n))return!1;if(xr(1)(n,e,t)||!e)return!0;let o=n;return vs(n,r=>{o=n.apply(r),e(r)}),xr(1)(o,e,t)};qe={addRowBefore:Lu,addRowAfter:vs,deleteRow:Du,addColumnBefore:Au,addColumnAfter:Tu,deleteColumn:Nu,mergeCells:Ru,splitCell:Iu,toggleHeaderRow:Tn("row"),toggleHeaderColumn:Tn("column"),deleteTable:Bu};zs=class extends ws{constructor(e,t){super(e,t),this.apply(e)}update(e){return super.update(e)?(this.apply(e),!0):!1}apply(e){let t=Z.length(e.attrs.width);t&&(this.table.style.width=t,this.table.style.minWidth="");let o=e.attrs.align;this.table.style.marginLeft=o?"auto":"",this.table.style.marginRight=o==="center"?"auto":""}}});var Qd={};He(Qd,{DEFAULT_INSERT:()=>Gd,DEFAULT_SELECTION:()=>Jd,default:()=>cv,hasTextSelection:()=>Xd,isOnEmptyLine:()=>Yd});function Xd(n){let{selection:e}=n.view.state;return!(e instanceof P)||e.empty||e.$from.parent.type.spec.code?!1:n.view.state.doc.textBetween(e.from,e.to).trim().length>0}function Yd(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&&!Q(n.view.state)}function av(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(Rn);t.length&&yo(n,t)}),e.click()}var Jd,Gd,cv,Zd=D(()=>{"use strict";U();wo();In();Pn();j();Jd="bold italic underline | quicklink h2 h3 blockquote",Gd="quickimage quicktable";cv={name:"quickbars",setup(n){let{registry:e,t}=n.ui,o=n.options.pluginOptions?.quickbars??{};e.addButton("quicklink",{icon:k.link,tooltip:t("link"),shortcut:"Mod-k",onAction:s=>tt(s)}),e.addButton("quickimage",{icon:k.image,tooltip:t("image"),onAction:s=>av(s)}),e.addButton("quicktable",{icon:k.table,tooltip:t("table.insert"),onAction:s=>s.exec(nt(2,2))});let r=o.selection===void 0?Jd:o.selection;r&&e.addContextToolbar("quickbars-selection",{label:t("quickbars.selection"),predicate:Xd,items:r,position:"selection",placement:"top-start",priority:10});let i=o.insert===void 0?Gd:o.insert;i&&e.addContextToolbar("quickbars-insert",{label:t("quickbars.insert"),predicate:Yd,items:i,position:"selection",placement:"bottom-start"})}}});var tf={};He(tf,{default:()=>fv});var ef,uv,dv,fv,nf=D(()=>{"use strict";j();Ce();ef=k.charmap,uv={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"]}},dv=[[["\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"]]],fv={name:"charmap",toolbar:"charmap",setup(n){let e=W(n,uv),t=dv.map((r,i)=>({title:e.groups[i],items:r})),o=r=>Go({groups:t,searchLabel:e.search,emptyText:e.empty,className:"nova-charmap",onPick:i=>{r(),bn(n,i)}});n.ui.registry.addPanelButton("charmap",{icon:ef,tooltip:e.title,isEnabled:r=>r.isEditable(),render:(r,i)=>o(i)}),n.ui.registry.addMenuItem("charmap",{text:e.title,icon:ef,onAction:()=>Xo(n,e.title,o)})}}});var sf={};He(sf,{default:()=>hv});var of,pv,rf,hv,lf=D(()=>{"use strict";j();Ce();of=k.emoji,pv={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"]}},rf=[[["\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"]]],hv={name:"emoticons",toolbar:"emoticons",setup(n){let e=W(n,pv),t=rf.map((i,s)=>({title:e.groups[s],items:i})),o=rf.flat(),r=i=>Go({groups:t,searchLabel:e.search,emptyText:e.empty,className:"nova-emoticons",onPick:s=>{i(),bn(n,s)}});n.ui.registry.addPanelButton("emoticons",{icon:of,tooltip:e.title,isEnabled:i=>i.isEditable(),render:(i,s)=>r(s)}),n.ui.registry.addMenuItem("emoticons",{text:e.title,icon:of,onAction:()=>Xo(n,e.title,r)}),n.ui.registry.addAutocompleter("emoticons",{trigger:":",minChars:2,label:e.title,maxResults:8,fetch:i=>{let s=i.toLowerCase();return/^[a-z]+$/.test(s)?o.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 uf={};He(uf,{default:()=>gv});var af,cf,mv,gv,df=D(()=>{"use strict";j();ut();Ce();af="\xA0",cf=k.nonBreaking,mv={en:{title:"Nonbreaking space"},ru:{title:"\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B"}},gv={name:"nonbreaking",toolbar:"nonbreaking",prosemirrorPlugins:()=>[Fe({"Mod-Shift-Space":(n,e)=>(e?.(n.tr.insertText(af).scrollIntoView()),!0)})],setup(n){let{title:e}=W(n,mv),t={icon:cf,tooltip:e,shortcut:"Mod-Shift-Space",isEnabled:()=>n.isEditable(),onAction:()=>bn(n,af)};n.ui.registry.addButton("nonbreaking",t),n.ui.registry.addMenuItem("nonbreaking",{text:e,icon:cf,onAction:t.onAction})}}});function bv(n){return function(e,t,o,r){let i=n;if(t[1]){let s=t[0].lastIndexOf(t[1]);i+=t[0].slice(s+t[1].length),o+=s;let l=o-r;l>0&&(i=t[0].slice(s-l,s)+i,o=r)}return e.tr.insertText(i,o,r)}}function Dr({rules:n}){let e=new _({state:{init(){return null},apply(t,o){let r=t.getMeta(this);return r||(t.selectionSet||t.docChanged?null:o)}},props:{handleTextInput(t,o,r,i){return ff(t,o,r,i,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:o}=t.state.selection;o&&ff(t,o.pos,o.pos,"",n,e)})}}},isInputRules:!0});return e}function ff(n,e,t,o,r,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-yv),l.parentOffset,null,"\uFFFC")+o,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<r.length;d++){let f=r[d];if(!f.inCodeMark&&u.some(b=>b.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<o.length)continue;let h=e-(p[0].length-o.length);if(!f.inCodeMark){let b=!1;if(s.doc.nodesBetween(h,l.pos,m=>{m.isInline&&m.marks.some(y=>y.type.spec.code)&&(b=!0)}),b)continue}let g=f.handler(s,p,h,t,o);if(g)return f.undoable&&g.setMeta(i,{transform:g,from:e,to:t,text:o}),n.dispatch(g),!0}return!1}function Rr(n,e,t,o){let r,i;return e instanceof rt?i=e:(r=e,i=e.nodeType,t=e.getAttrs,o=e.joinPredicate),new We(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&&hn(p,i,u);if(!h)return null;d.wrap(p,h);let g=d.doc.resolve(a-1).nodeBefore;return g&&g.type==i&&Vt(d.doc,a-1)&&(!o||o(l,g))&&d.join(a-1),d},r)}function $s(n,e,t){let o,r;return e instanceof rt?r=e:(o=e,r=e.nodeType,t=e.getAttrs),new We(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),r)?i.tr.delete(l,a).setBlockType(l,l,r,u):null},o)}var We,yv,pf,hf,sk,lk,ak,ck,_s=D(()=>{"use strict";U();Ge();ce();We=class{constructor(e,t,o={}){this.match=e,this.match=e,this.handler=typeof t=="string"?bv(t):t,this.undoable=o.undoable!==!1,this.inCode=o.inCode||!1,this.inCodeMark=o.inCodeMark!==!1}};yv=500;pf=new We(/--$/,"\u2014",{inCodeMark:!1}),hf=new We(/\.\.\.$/,"\u2026",{inCodeMark:!1}),sk=new We(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"\u201C",{inCodeMark:!1}),lk=new We(/"$/,"\u201D",{inCodeMark:!1}),ak=new We(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"\u2018",{inCodeMark:!1}),ck=new We(/'$/,"\u2019",{inCodeMark:!1})});var bf={};He(bf,{default:()=>xv});function gf(n){return/^www\./i.test(n)?`https://${n}`:/^[\w.+-]+@/.test(n)?`mailto:${n}`:n}function mf(n,e,t){let o=n.doc.resolve(t);if(!o.parent.isTextblock||o.parent.type.spec.code)return!1;let i=o.parent.textBetween(0,o.parentOffset,void 0,"\uFFFC").match(vv);if(!i)return!1;let s=i[1],l=t-i[2].length,a=l-s.length,c=ie(n).link;if(n.doc.rangeHasMark(a,l,c))return!1;let u=gf(s);return De(u)?(e.addMark(a,l,c.create({href:u})),!0):!1}var vv,wv,xv,yf=D(()=>{"use strict";_s();U();Pe();pt();vv=/(?:^|[\s(])((?:https?:\/\/|www\.)[^\s<>"]*[^\s<>".,;:!?)\]'"]|[\w.+-]+@[\w-]+(?:\.[\w-]+)+)([.,;:!?)\]'"]*)$/i,wv=/^(?:https?:\/\/|www\.)\S+$|^mailto:\S+$/i;xv={name:"autolink",prosemirrorPlugins:n=>[Dr({rules:[new We(/\S\s$/,(e,t,o,r)=>{if(!n.isAllowed("link"))return null;let i=e.tr,s=o+t[0].length-1;return mf(e,i,s)?i.insertText(t[0].slice(-1),r).removeStoredMark(ie(e).link):null})]}),new _({appendTransaction(e,t,o){if(!n.isAllowed("link")||!e.some(a=>a.docChanged))return null;let{$from:r,empty:i}=o.selection;if(!i||r.parentOffset!==0||r.depth<1)return null;let s=B.findFrom(o.doc.resolve(r.before()),-1,!0);if(!s||!s.empty||s.$from.parentOffset!==s.$from.parent.content.size)return null;let l=o.tr;return mf(o,l,s.from)?l:null}}),new _({props:{handlePaste(e,t){let{state:o}=e;if(o.selection.empty||!n.isAllowed("link"))return!1;let r=(t.clipboardData?.getData("text/plain")??"").trim();if(!wv.test(r))return!1;let i=gf(r);if(!De(i))return!1;let{from:s,to:l}=o.selection,a=ie(o).link;return e.dispatch(o.tr.removeMark(s,l,a).addMark(s,l,a.create({href:i}))),!0}}})]}});var wf={};He(wf,{default:()=>Sv});function Mv(){try{return typeof localStorage>"u"?null:localStorage}catch{return null}}var vf,kv,Sv,xf=D(()=>{"use strict";j();Ce();vf=k.save,kv={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"}};Sv={name:"autosave",toolbar:"restoredraft",setup(n){let e=n.options.pluginOptions?.autosave??{},t=W(n,kv),o=Mv(),r=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(o?.getItem(r)??"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()?o?.removeItem(r):o?.setItem(r,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:vf,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:vf,onAction:f}),()=>{d(),c!==void 0&&(clearTimeout(c),u())}}}});var kf={};He(kf,{default:()=>Cv});var Cv,Mf=D(()=>{"use strict";Cv={name:"autoresize",setup(n){let{minHeight:e,maxHeight:t}=n.options.pluginOptions?.autoresize??{},o=n.root.querySelector(".nova-content");if(o)return n.root.classList.add("nova-autoresize"),e!==void 0&&n.root.style.setProperty("--nova-min-height",`${e}px`),t!==void 0&&(o.style.maxHeight=`${t}px`),()=>{n.root.classList.remove("nova-autoresize"),n.root.style.removeProperty("--nova-min-height"),o.style.removeProperty("max-height")}}}});var Cf={};He(Cf,{default:()=>Av});var Sf,Ev,Av,Ef=D(()=>{"use strict";j();Ce();Sf=k.visualBlocks,Ev={en:{title:"Show blocks"},ru:{title:"\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438"}},Av={name:"visualblocks",toolbar:"visualblocks",setup(n){let{title:e}=W(n,Ev),t=n.options.pluginOptions?.visualblocks??{},o=()=>n.root.classList.contains("nova-visualblocks"),r=()=>{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:Sf,tooltip:e,isActive:o,onAction:r}),n.ui.registry.addToggleMenuItem("visualblocks",{text:e,icon:Sf,isActive:o,onAction:r}),()=>n.root.classList.remove("nova-visualblocks")}}});var Nf={};He(Nf,{default:()=>Ov});function Nv(n){return n.view.state.selection.$from.parent.attrs.dir??null}function Tf(n){return(e,t)=>{let{paragraph:o,heading:r}=ee(e),i=e.tr,s=!1;return e.doc.nodesBetween(e.selection.from,e.selection.to,(l,a)=>l.type!==o&&l.type!==r?!0:(s=!0,i.setNodeMarkup(a,void 0,{...l.attrs,dir:n}),!1)),s?(t?.(i),!0):!1}}var Af,Tv,Ov,Of=D(()=>{"use strict";j();Pe();Ce();Af={ltr:k.ltr,rtl:k.rtl},Tv={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"}};Ov={name:"directionality",toolbar:"ltr rtl",setup(n){let e=W(n,Tv);for(let t of["ltr","rtl"]){let o=()=>Nv(n)===t,r=()=>{n.exec(Tf(o()?null:t)),n.focus()};n.ui.registry.addToggleButton(t,{icon:Af[t],tooltip:e[t],isActive:o,isEnabled:i=>i.can(Tf(t)),onAction:r}),n.ui.registry.addToggleMenuItem(t,{text:e[t],icon:Af[t],isActive:o,onAction:r})}}}});var Lf={};He(Lf,{default:()=>Rv});function Vs(n,e){let{$from:t}=n.selection;for(let o=t.depth;o>0;o--){let r=t.node(o);if(r.type===e)return{pos:t.before(o),attrs:r.attrs}}return null}function Dv(n,e,t,o){let r=()=>ee(n.view.state)[e];Vs(n.view.state,r())||n.exec(e==="bullet_list"?"bulletList":"orderedList");let i=Vs(n.view.state,r());if(!i)return;let{state:s,dispatch:l}=n.view;l(s.tr.setNodeMarkup(i.pos,void 0,{...i.attrs,listStyle:t===o?null:t})),n.focus()}var Lv,Rv,Df=D(()=>{"use strict";Pe();ht();Ce();Lv={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)"}};Rv={name:"advlist",setup(n){let e=W(n,Lv),t=n.options.pluginOptions?.advlist??{},o=[{control:"bullist",kind:"bullet_list",styles:t.bullets??[...Mr],fallback:"disc"},{control:"numlist",kind:"ordered_list",styles:t.numbers??[...Sr],fallback:"decimal"}];for(let{control:r,kind:i,styles:s,fallback:l}of o){let a=n.ui.registry.get(r);if(!a||a.type!=="button")continue;let{type:c,...u}=a;n.ui.registry.addSplitButton(r,{...u,items:d=>{let f=Vs(d.view.state,ee(d.view.state)[i]),p=f?.attrs.listStyle??(f?l:null);return s.map(h=>({id:h,label:e[h],active:p===h,onSelect:()=>Dv(d,i,h,l)}))}})}}}});function Rf(n={}){return new _({view(e){return new qs(e,n)}})}var qs,If=D(()=>{"use strict";U();Ge();qs=class{constructor(e,t){var o;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=(o=t.width)!==null&&o!==void 0?o:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let i=s=>{this[r](s)};return e.dom.addEventListener(r,i),{name:r,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 o=this.computeTarget(this.lastDragEvent);o==this.cursorPos?this.updateOverlay():this.setCursor(o)}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,o,r=this.editorView.dom,i=r.getBoundingClientRect(),s=i.width/r.offsetWidth,l=i.height/r.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(),g=d?h.bottom:h.top;d&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let b=this.width/2*l;o={left:h.left,right:h.right,top:g-b,bottom:g+b}}}}if(!o){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;o={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=(o.left-c)/s+"px",this.element.style.top=(o.top-u)/l+"px",this.element.style.width=(o.right-o.left)/s+"px",this.element.style.height=(o.bottom-o.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}),o=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=o&&o.type.spec.disableDropCursor,i=typeof r=="function"?r(this.editorView,t,e):r;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Wo(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 Pf(n){return n.isAtom||n.spec.isolating||n.spec.createGapCursor}function Iv(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),o=n.node(e);if(t==0){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||Pf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function Pv(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),o=n.node(e);if(t==o.childCount){if(o.type.spec.isolating)return!0;continue}for(let r=o.child(t);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||Pf(r.type))return!0;if(r.inlineContent)return!1}}return!0}function Bf(){return new _({props:{decorations:Fv,createSelectionBetween(n,e,t){return e.pos==t.pos&&Me.valid(t)?new Me(t):null},handleClick:Hv,handleKeyDown:Bv,handleDOMEvents:{beforeinput:zv}}})}function Ir(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(o,r,i){let s=o.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof P){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=o.doc.resolve(e>0?l.after():l.before())}let c=Me.findGapCursorFrom(l,e,a);return c?(r&&r(o.tr.setSelection(new Me(c))),!0):!1}}function Hv(n,e,t){if(!n||!n.editable)return!1;let o=n.state.doc.resolve(e);if(!Me.valid(o))return!1;let r=n.posAtCoords({left:t.clientX,top:t.clientY});return r&&r.inside>-1&&R.isSelectable(n.state.doc.nodeAt(r.inside))?!1:(n.dispatch(n.state.tr.setSelection(new Me(o))),!0)}function zv(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof Me))return!1;let{$from:t}=n.state.selection,o=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!o)return!1;let r=A.empty;for(let s=o.length-1;s>=0;s--)r=A.from(o[s].createAndFill(null,r));let i=n.state.tr.replace(t.pos,t.pos,new L(r,0,0));return i.setSelection(P.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Fv(n){if(!(n.selection instanceof Me))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",J.create(n.doc,[te.widget(n.selection.head,e,{key:"gapcursor"})])}var Me,Ws,Bv,Hf=D(()=>{"use strict";ut();U();ce();Lt();Me=class n extends B{constructor(e){super(e,e)}map(e,t){let o=e.resolve(t.map(this.head));return n.valid(o)?new n(o):B.near(o)}content(){return L.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 Ws(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!Iv(e)||!Pv(e))return!1;let o=t.type.spec.allowGapCursor;if(o!=null)return o;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,o=!1){e:for(;;){if(!o&&n.valid(e))return e;let r=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;r+=t;let a=e.doc.resolve(r);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!R.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),o=!1;continue e}break}i=s,r+=t;let l=e.doc.resolve(r);if(n.valid(l))return l}return null}}};Me.prototype.visible=!1;Me.findFrom=Me.findGapCursorFrom;B.jsonID("gapcursor",Me);Ws=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):B.near(t)}};Bv=co({ArrowLeft:Ir("horiz",-1),ArrowRight:Ir("horiz",1),ArrowUp:Ir("vert",-1),ArrowDown:Ir("vert",1)})});var Pr,zf=D(()=>{"use strict";Pr={"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",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",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.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 Ff,$f=D(()=>{"use strict";Ff={"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",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}",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.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 Vf(n="en",e={}){let t=n.toLowerCase(),o=_f[t]??_f[t.split("-")[0]]??Pr,r={...Pr,...o,...e};return(i,s)=>{let l=r[i]??i;return s?l.replace(/\{(\w+)\}/g,(a,c)=>String(s[c]??`{${c}}`)):l}}var _f,qf=D(()=>{"use strict";zf();$f();_f={en:Pr,ru:Ff}});function Wf(n=()=>!0,e=Zt){let{nodes:t}=e,o=[hf,pf];n("blockquote")&&o.push(Rr(/^\s*>\s$/,t.blockquote)),n("numlist")&&o.push(Rr(/^(\d+)\.\s$/,t.ordered_list,r=>({start:Number(r[1])}),(r,i)=>i.childCount+i.attrs.start===Number(r[1]))),n("bullist")&&o.push(Rr(/^\s*([-+*])\s$/,t.bullet_list)),n("codeblock")&&o.push($s(/^```$/,t.code_block));for(let r=1;r<=6;r++)n(`h${r}`)&&o.push($s(new RegExp(`^(#{${r}})\\s$`),t.heading,{level:r}));return Dr({rules:o})}var Uf=D(()=>{"use strict";_s();ht()});function jf(n=e=>G[e]){let e={"Mod-z":Us(n,"undo"),"Shift-Mod-z":Us(n,"redo"),"Mod-b":G.bold,"Mod-i":G.italic,"Mod-u":G.underline,"Mod-Shift-x":G.strike,"Mod-e":G.code,"Mod-,":G.subscript,"Mod-.":G.superscript,"Mod-Alt-0":G.paragraph,"Mod-Alt-1":G.h1,"Mod-Alt-2":G.h2,"Mod-Alt-3":G.h3,"Mod-Alt-4":G.h4,"Mod-Alt-5":G.h5,"Mod-Alt-6":G.h6,"Mod-Shift-7":G.orderedList,"Mod-Shift-8":G.bulletList,"Mod-Shift-l":G.alignLeft,"Mod-Shift-e":G.alignCenter,"Mod-Shift-r":G.alignRight,"Mod-Shift-j":G.alignJustify,"Mod-\\":G.clearFormatting,"Shift-Enter":_v,Enter:(t,o)=>Md(ee(t).list_item)(t,o),Tab:G.indent,"Shift-Tab":G.outdent};return $v||(e["Mod-y"]=Us(n,"redo")),[Fe(e),Fe(hd)]}var $v,_v,Us,Kf=D(()=>{"use strict";Ns();ut();Bs();Pe();$v=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),_v=mo(As,(n,e)=>(e?.(n.tr.replaceSelectionWith(ee(n).hard_break.create()).scrollIntoView()),!0)),Us=(n,e)=>(t,o,r)=>n(e)(t,o,r)});function Vv(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 Yf(n,e="clean"){let t=Vv(n);if(t==="nova")return n;let o=document.createElement("template");o.innerHTML=n;let r=document.createElement("div");return r.append(o.content),qv(r),Uv(r),t==="word"&&Qv(r),t==="google-docs"&&o0(r),t0(r),r0(r),r.querySelectorAll("[style]").forEach(i=>l0(i,e)),e==="clean"&&a0(r),c0(r),u0(r),d0(r),f0(r),r.innerHTML}function js(n){let e=new Map;for(let t of n.split(";")){let o=t.indexOf(":");if(o<0)continue;let r=t.slice(0,o).trim().toLowerCase(),i=t.slice(o+1).trim().replace(/\s*!important$/i,"");r&&i&&e.set(r,i)}return e}function Qf(n){return[...n].map(([e,t])=>`${e}: ${t}`).join("; ")}function qv(n){let e=[...n.querySelectorAll("style")].map(r=>r.textContent??"");if(!e.length)return;let t=[],o=e.join(`
|
|
12
|
-
`).replace(/\/\*[\s\S]*?\*\//g,"").replace(/<!--|-->/g,"");for(let r of o.matchAll(/([^{}@]+)\{([^{}]*)\}/g)){let i=js(r[2]);for(let s of r[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(r=>{let i=r.className.split(/\s+/).filter(Boolean),s=new Map;for(let l of t)i.includes(l.cls)&&(l.tag&&l.tag!==r.tagName.toLowerCase()||l.decls.forEach((a,c)=>s.set(c,a)));s.size&&(js(r.getAttribute("style")??"").forEach((l,a)=>s.set(a,l)),r.setAttribute("style",Qf(s)))})}function Uv(n){let e=document.createTreeWalker(n,NodeFilter.SHOW_COMMENT),t=[];for(;e.nextNode();)t.push(e.currentNode);t.forEach(o=>o.parentNode?.removeChild(o));for(let o of[...n.querySelectorAll("*")]){if(!n.contains(o))continue;let r=o.tagName.toUpperCase();if(Wv.test(r)){o.remove();continue}if(r.includes(":")){let i=r.split(":")[0];i==="O"||i==="V"?o.remove():Bn(o)}}n.querySelectorAll("span.EOP").forEach(o=>{/^\s*$/.test(o.textContent??"")&&o.remove()}),n.querySelectorAll("a").forEach(o=>{let r=o.getAttribute("href")??"",i=r.match(/^https?:\/\/(www\.)?google\.[a-z.]+\/url\?(.*)$/i);if(i){let s=new URLSearchParams(i[2]).get("q");s&&o.setAttribute("href",s)}(!r||/^#_(ftn|edn|msocom|Toc|Ref)/i.test(r))&&Bn(o)}),n.querySelectorAll('br[style*="page-break"]').forEach(o=>o.remove()),n.querySelectorAll('[style*="mso-element:footnote-list"], [style*="mso-element:comment-list"], [style*="mso-element:endnote-list"]').forEach(o=>o.remove())}function Kv(n){let t=(n.getAttribute("style")??"").match(/mso-list:\s*(l\d+)\s+level(\d+)/i);if(!t)return null;let o=[...n.querySelectorAll("[style]")].find(a=>/mso-list:\s*Ignore/i.test(a.getAttribute("style")??"")),r=(o?.textContent??"").replace(/\s+/g,"");o?.remove();let i=jv.test(r),{style:s,start:l}=i?Xv(r):{style:Yv(r),start:1};return{el:n,level:Math.max(1,Math.min(9,Number(t[2]))),ordered:i,start:l,style:s}}function Gv(n){let e=0,t=n.toLowerCase();for(let o=0;o<t.length;o++){let r=Jf[t[o]],i=Jf[t[o+1]??""]??0;e+=r<i?-r:r}return e}function Xv(n){let e=n.match(/\d+/);if(e)return{style:null,start:Number(e[0])};let t=n.replace(/[^a-z]/gi,"");return Jv.test(t)?{style:t===t.toLowerCase()?"lower-roman":"upper-roman",start:Gv(t)}:{style:t===t.toLowerCase()?"lower-alpha":"upper-alpha",start:t.toLowerCase().charCodeAt(0)-96}}function Yv(n){return n==="o"?"circle":/^[§▪■]$/.test(n)?"square":null}function Qv(n){let e=[...n.querySelectorAll("p, div, h1, h2, h3, h4, h5, h6")].filter(r=>/mso-list:\s*l\d+\s+level\d+/i.test(r.getAttribute("style")??""));for(let r of e.filter(i=>/^H[1-6]$/.test(i.tagName)))r.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(r=>!/^H[1-6]$/.test(r.tagName)),o=new Set;for(let r of t){if(o.has(r))continue;let i=[],s=r;for(;s instanceof HTMLElement&&t.includes(s);){let l=Kv(s);if(!l)break;i.push(l),o.add(s),s=Zf(s)}i.length&&Zv(i)}}function Zf(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 Zv(n){let e=n[0].el.ownerDocument,t=n[0].el,o=[],r=null;for(let i of n){for(;o.length&&o[o.length-1].level>i.level;)o.pop();let s=o[o.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):r=c,s={list:c,level:i.level},o.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(r),n.slice(1).forEach(i=>i.el.remove())}function e0(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 t0(n){n.querySelectorAll("div").forEach(o=>{let r=o.children.length===1?o.firstElementChild:null;r&&/^(UL|OL)$/.test(r.tagName)&&!o.textContent?.replace(r.textContent??"","").trim()&&Bn(o)}),n.querySelectorAll("ul > ul, ul > ol, ol > ul, ol > ol").forEach(o=>{let r=o.previousElementSibling;r?.tagName==="LI"&&r.appendChild(o)});let e=[...n.querySelectorAll("ul, ol")].filter(o=>!o.parentElement?.closest("ul, ol")&&o.querySelector("li[aria-level], li[data-aria-level]")),t=new Set;for(let o of e){if(t.has(o)||!n.contains(o))continue;let r=[],i=o;for(;i&&/^(UL|OL)$/.test(i.tagName);){t.add(i),ep(i,1,r);let l=Zf(i);i!==o&&i.remove(),i=l}if(!r.length)continue;let s=o.ownerDocument.createElement("div");o.replaceWith(s),n0(r,s)}}function ep(n,e,t){for(let o of[...n.children]){if(o.tagName!=="LI")continue;let r=e0(o)??e,i=[...o.children].filter(l=>/^(UL|OL)$/.test(l.tagName));i.forEach(l=>l.remove());let s=o.ownerDocument.createElement("div");for(;o.firstChild;)s.appendChild(o.firstChild);t.push({el:s,level:r,ordered:n.tagName==="OL",start:Number(n.getAttribute("start")??1)||1}),i.forEach(l=>ep(l,r+1,t))}}function n0(n,e){let t=e.ownerDocument,o=[],r=null;for(let i of n){for(;o.length&&o[o.length-1].level>i.level;)o.pop();let s=o[o.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):r=a,s={list:a,level:i.level},o.push(s)}let l=t.createElement("li");for(;i.el.firstChild;)l.appendChild(i.el.firstChild);s.list.appendChild(l)}e.replaceWith(r)}function o0(n){n.querySelectorAll('[id^="docs-internal-guid-"]').forEach(Bn),n.querySelectorAll('li[role="checkbox"]').forEach(e=>{e.removeAttribute("role"),e.removeAttribute("aria-checked")})}function r0(n){n.querySelectorAll('p.MsoTitle, p[class*="Title"]').forEach(e=>{/\bMsoTitle\b|^Title$/.test(e.className)&&p0(e,"h1")}),n.querySelectorAll('div.WordSection1, div[class^="WordSection"], div.Section1').forEach(Bn)}function l0(n,e){let t=js(n.getAttribute("style")??""),o=new Map;t.forEach((s,l)=>{if(l.startsWith("mso-")){l==="mso-highlight"&&!Gf.test(s)&&!t.has("background-color")&&o.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)&&!o.has("background-color")&&o.set("background-color",a);return}if(l==="text-decoration"||l==="text-decoration-line"){/underline/.test(s)?o.set("text-decoration","underline"):/line-through/.test(s)&&o.set("text-decoration","line-through");return}e==="clean"&&s0.test(l)||e==="clean"&&l==="vertical-align"&&/^(TD|TH)$/.test(n.tagName)||o.set(l,s)}});let r=o.get("color");r&&i0.test(r.trim())&&e==="clean"&&o.delete("color");let i=o.get("background-color");i&&Gf.test(i.trim())&&o.delete("background-color"),o.get("font-weight")==="normal"&&n.tagName!=="B"&&o.delete("font-weight"),o.get("font-style")==="normal"&&o.delete("font-style"),o.get("text-decoration")==="none"&&o.delete("text-decoration"),o.get("vertical-align")==="baseline"&&o.delete("vertical-align"),/^(left|start)$/i.test(o.get("text-align")??"")&&o.delete("text-align"),e==="clean"&&n.closest("a")&&(o.delete("color"),o.get("text-decoration")==="underline"&&o.delete("text-decoration")),o.size?n.setAttribute("style",Qf(o)):n.removeAttribute("style")}function a0(n){n.querySelectorAll("table, tr, td, th, col, colgroup").forEach(e=>{e.removeAttribute("width"),e.removeAttribute("height"),e.removeAttribute("valign")})}function c0(n){for(let e of[...n.querySelectorAll("span, font")].reverse()){if(!n.contains(e))continue;e.hasAttribute("style")||e.tagName==="FONT"&&e.hasAttribute("color")||Bn(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 u0(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 o=Xf(e,-1),r=Xf(e,1);(o&&Ks.test(o.tagName)||r&&Ks.test(r.tagName)||!o&&!r&&t===n)&&e.remove()})}function Xf(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 d0(n){n.querySelectorAll("p").forEach(e=>{e.children.length===0&&/^\s*$/.test(e.textContent??"")&&(e.textContent="")})}function f0(n){n.querySelectorAll("td, th").forEach(e=>{let t=e.style.textAlign,o=[...e.children].some(i=>Ks.test(i.tagName));if(!t||o||!e.textContent?.trim())return;let r=e.ownerDocument.createElement("p");for(r.style.textAlign=t;e.firstChild;)r.appendChild(e.firstChild);e.appendChild(r),e.style.removeProperty("text-align"),e.getAttribute("style")||e.removeAttribute("style")})}function Bn(n){let e=n.parentNode;if(e){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}}function p0(n,e){let t=n.ownerDocument.createElement(e);for(let o of[...n.attributes])t.setAttribute(o.name,o.value);for(;n.firstChild;)t.appendChild(n.firstChild);return n.replaceWith(t),t}var Wv,jv,Jv,Jf,i0,Gf,s0,Ks,tp=D(()=>{"use strict";Wv=/^(STYLE|SCRIPT|META|LINK|TITLE|XML|HEAD|NOSCRIPT|TEMPLATE)$/;jv=/^[([]?(\d+(\.\d+)*[.)\]]?|[a-z]{1,4}[.)\]])$/i;Jv=/^(i|ii|iii|iv|v|vi|vii|viii|ix|x|xi|xii)$/i,Jf={i:1,v:5,x:10};i0=/^(black|windowtext|auto|#000|#000000|rgb\(0,\s*0,\s*0\)|initial|inherit)$/i,Gf=/^(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,s0=/^(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;Ks=/^(P|DIV|H[1-6]|UL|OL|TABLE|BLOCKQUOTE|PRE|HR)$/});function h0(n,e){let t=0;for(let o=e;o<n.length;o++){let r=n[o];if(r==="\\"){o++;continue}if(r==="{")t++;else if(r==="}"&&(t--,t===0))return o}return-1}function m0(n){let e="",t=0;for(let o=0;o<n.length;o++){let r=n[o];if(r==="\\"){t===0&&(e+=r+(n[o+1]??"")),o++;continue}r==="{"?t++:r==="}"?t--:t===0&&(e+=r)}return e}function b0(n){if(n.length%2!==0||n.length/2>g0||!/^[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 np(n){let e=[],t=0;for(;;){let o=n.indexOf("{\\pict",t);if(o<0)break;let r=h0(n,o);if(r<0)break;if(t=r+1,/\\nonshppict\s*$/.test(n.slice(Math.max(0,o-16),o)))continue;let i=m0(n.slice(o+1,r)),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=b0(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 op(n){return/<img[^>]+src=["']?file:/i.test(n)}function rp(n,e){let t=document.createElement("template");t.innerHTML=n;let o=[...t.content.querySelectorAll("img")].filter(r=>/^file:/i.test(r.getAttribute("src")??""));return!o.length||o.length!==e.length?n:(o.forEach((r,i)=>{let s=e[i];r.setAttribute("src",`data:${s.type};base64,${s.base64}`)}),t.innerHTML)}var g0,ip=D(()=>{"use strict";g0=20*1024*1024});function v0(n){let e=document.createElement("template");e.innerHTML=n;let t=/^(P|DIV|H[1-6]|LI|BLOCKQUOTE|PRE|TR|SECTION|ARTICLE|HEADER|FOOTER)$/,o="",r=i=>{if(i.nodeType===Node.TEXT_NODE){o+=(i.textContent??"").replace(/\s+/g," ");return}if(!(i instanceof Element)){i.childNodes.forEach(r);return}if(/^(SCRIPT|STYLE|META|TITLE|HEAD)$/.test(i.tagName))return;if(i.tagName==="BR"){o+=`
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`)
|
|
16
|
-
`)
|
|
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
|
+
`;return}let s=t.test(i.tagName);s&&r&&!r.endsWith(`
|
|
16
|
+
`)&&(r+=`
|
|
17
|
+
`),i.childNodes.forEach(o),s&&(r+=`
|
|
18
|
+
`)};return e.content.childNodes.forEach(o),r.split(`
|
|
17
19
|
`).map(i=>i.trim()).join(`
|
|
18
20
|
`).replace(/\n{3,}/g,`
|
|
19
21
|
|
|
20
|
-
`).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,`
|
|
21
23
|
|
|
22
|
-
`);if(!s)return!1;e=!0;try{t.pasteText(s)}finally{e=!1}return!0}}})}var y0,lp=D(()=>{"use strict";ce();U();tp();ip();y0=new K("nova-paste")});function ap(n){n.querySelectorAll("td, th").forEach(e=>{let t=e.style.backgroundColor;t&&(e.setAttribute(w0,t),e.style.removeProperty("background-color"),e.getAttribute("style")||e.removeAttribute("style"))})}function ln(n){let e=cp.get(n);return e||(e=new Js(n,xt.fromSchema(n).rules),cp.set(n,e)),e}var w0,Js,cp,tM,Gs=D(()=>{"use strict";ce();ht();w0="data-nova-cell-bg";Js=class extends xt{parse(e,t){return ap(e),super.parse(e,t)}parseSlice(e,t){return ap(e),super.parseSlice(e,t)}},cp=new WeakMap;tM=ln(Zt)});function Br(n,e,t){let o=[],r=w("div",{className:"nova-menu",role:"menu","aria-label":t}),i=n.some(a=>a.type!=="separator"&&a.active!==void 0);for(let a of n){if(a.type==="separator"){r.append(w("div",{className:"nova-menu-sep",role:"separator"}));continue}let c=w("span",{className:"nova-menu-label"},a.label);a.labelStyle&&c.setAttribute("style",a.labelStyle);let u=w("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?w("span",{className:"nova-menu-check"},a.active?ne(k.check):null):null,a.icon?ne(a.icon):null,c,a.shortcut?w("kbd",{className:"nova-menu-shortcut"},Xe(a.shortcut)):null);u.addEventListener("click",()=>{e(),a.onSelect()}),o.push(u),r.append(u)}let s=()=>o.filter(a=>!a.disabled),l=a=>{let c=s();c.length&&c[(a+c.length)%c.length].focus()};return r.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()}}}),r}function Hr(n){(n.querySelector('[aria-checked="true"]:not(:disabled)')??n.querySelector(".nova-menu-item:not(:disabled)"))?.focus()}var Xs=D(()=>{"use strict";Y();j()});function fp(n,e,t,o){let{t:r}=n.ui;e.className="nova-menubar",e.setAttribute("role","menubar"),e.setAttribute("aria-label",r("menu.label"));let i=new AbortController,{signal:s}=i,l=p=>p.title.startsWith("menu.")?r(p.title):p.title,a=p=>{let h=[];for(let g of p.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 b=n.ui.registry.getMenuItem(g);b&&h.push({id:g,label:b.text,...b.icon?{icon:b.icon}:{},...b.shortcut?{shortcut:b.shortcut}:{},...b.isActive?{active:b.isActive(n),checkbox:!0}:{},disabled:!n.isEditable()||(b.isEnabled?!b.isEnabled(n):!1),onSelect:()=>b.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 g=c[p],b=o[g.dataset.menu],m=a(b);if(!m.length)return;let y=Br(m,()=>n.ui.closePopover(),l(b));y.addEventListener("keydown",M=>{if(M.key!=="ArrowLeft"&&M.key!=="ArrowRight")return;M.preventDefault();let T=(p+(M.key==="ArrowRight"?1:-1)+c.length)%c.length;f(T,!0)}),g.setAttribute("aria-expanded","true");let v=n.ui.openPopover({anchor:g,content:y,ignore:[e],className:"nova-popover-menu",onClose:M=>{g.setAttribute("aria-expanded","false"),u?.popover===v&&(u=null),M==="escape"&&g.focus()}});u={index:p,popover:v},h&&Hr(y)};for(let p of t.split(/\s+/).filter(Boolean)){let h=o[p];if(!h)continue;let g=w("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)),b=c.length;g.addEventListener("click",m=>{if(u?.index===b)return d();f(b,m.detail===0)}),g.addEventListener("mouseenter",()=>{u&&u.index!==b&&f(b,!1)}),c.push(g),e.append(g)}return e.addEventListener("keydown",p=>{let h=c.indexOf(document.activeElement);if(h<0)return;let g=b=>{p.preventDefault();let m=(b+c.length)%c.length;c.forEach((y,v)=>y.tabIndex=v===m?0:-1),c[m].focus()};p.key==="ArrowRight"?g(h+1):p.key==="ArrowLeft"?g(h-1):p.key==="Home"?g(0):p.key==="End"?g(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 up,dp,pp=D(()=>{"use strict";Y();Xs();up={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"}},dp="file edit view insert format table help"});function k0(n){let e=w("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 o=t.createElement("style");o.textContent=x0,t.head.append(o),t.body.append(Ue.fromSchema(n.schema).serializeFragment(n.view.state.doc.content,{document:t}));let r=e.contentWindow,i=()=>setTimeout(()=>e.remove(),1e3);r?.addEventListener("afterprint",i),r?.focus(),r?.print(),i()}function M0(n){let{t:e}=n.ui,t=ue({label:e("table.rows"),value:"3"}),o=ue({label:e("table.cols"),value:"3"});for(let r of[t,o])r.input.type="number",r.input.min="1",r.input.max="50",r.input.inputMode="numeric";n.ui.openDialog({title:e("table.insert"),body:w("div",{className:"nova-form nova-form-row"},t.el,o.el),submitLabel:e("dialog.insert"),initialFocus:t.input,onSubmit:()=>{let r=Number(t.input.value),i=Number(o.input.value);return!Number.isInteger(r)||!Number.isInteger(i)||r<1||i<1||r>50||i>50?e("table.invalidSize"):(n.exec(nt(r,i)),!0)}})}function hp(n){let{registry:e,t}=n.ui;e.addToggleMenuItem("paragraph",{text:t("paragraph"),icon:k.paragraph,shortcut:"Mod-Alt-0",isActive:o=>o.view.state.selection.$from.parent.type.name==="paragraph",onAction:o=>o.exec("paragraph")}),e.addMenuItem("selectall",{text:t("selectAll"),shortcut:"Mod-a",onAction:o=>{o.view.dispatch(o.view.state.tr.setSelection(new me(o.view.state.doc))),o.focus()}}),e.addMenuItem("print",{text:t("print"),icon:k.print,shortcut:"Mod-p",onAction:o=>k0(o)}),e.addMenuItem("inserttable",{text:t("table.insert"),icon:k.table,isEnabled:o=>o.can(nt(1,1)),onAction:o=>M0(o)})}var x0,mp=D(()=>{"use strict";ce();U();Pn();Ct();Y();j();x0=`
|
|
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=`
|
|
23
25
|
body { font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: #000; margin: 2cm; }
|
|
24
26
|
img { max-width: 100%; height: auto; }
|
|
25
27
|
table { border-collapse: collapse; width: 100%; }
|
|
26
28
|
td, th { border: 1px solid #999; padding: 4px 8px; vertical-align: top; }
|
|
27
29
|
pre { white-space: pre-wrap; background: #f5f5f5; padding: 8px; }
|
|
28
30
|
blockquote { border-left: 3px solid #ccc; margin-left: 0; padding-left: 1em; color: #444; }
|
|
29
|
-
|
|
30
|
-
`).map(l=>
|
|
31
|
-
`)&&
|
|
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
|
|
32
34
|
`).replace(/(<(ul|ol|table|tbody|tr|blockquote)( [^>]*)?>)/g,`$1
|
|
33
35
|
`).replace(/\n{2,}/g,`
|
|
34
|
-
`).trim()}function Op(n){let{t:e}=n.ui,t=R0(n.getHTML()),o=w("textarea",{className:"nova-input nova-source",spellcheck:"false","aria-label":e("sourceCode"),autocomplete:"off",rows:"18"});o.value=t,n.ui.openDialog({title:e("sourceCode"),body:o,size:"large",submitLabel:e("dialog.save"),initialFocus:o,onSubmit:()=>(o.value!==t&&n.setContent(o.value),!0)})}function Fr(n){let{t:e}=n.ui,t=w("div",{className:"nova-help"});for(let{group:o,rows:r}of I0)t.append(w("section",{},w("h3",{},e(o)),w("table",{className:"nova-help-table"},w("tbody",{},r.map(({label:i,keys:s})=>w("tr",{},w("td",{},e(i)),w("td",{},w("kbd",{},s.length===1?s:Xe(s)))))))));n.ui.openDialog({title:e("help"),body:t,size:"large",cancelLabel:e("dialog.close")})}var I0,tl=D(()=>{"use strict";ce();Y();I0=[{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 Rp(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(Dp," ")}function B0(n){return n.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">").replace(Dp," ")}function V0(n,e){let t=n.toLowerCase();return t.startsWith("on")?null:F0.has(t)?De(e)?e:null:$0.has(t)?Re(e)?e:null:t==="srcset"?e.split(",").map(r=>r.trim().split(/\s+/)[0]??"").every(r=>Re(r))?e:null:t==="style"&&_0.test(e)?null:e}function q0(n){Lp.has(n)||(Lp.add(n),console.error(`[nova] toDOM produced <${n}>, which is not allowed in output; the tag was dropped`))}function nl(n){if(typeof n=="string")return{open:"",close:"",hole:!1,html:Rp(n)};if(!Array.isArray(n))throw new Error("[nova] serializer supports only array/string toDOM specs");let[e,...t]=n,o=e.includes(" ")?e.split(" ")[1]:e;if(!H0.test(o))throw new Error(`[nova] invalid tag in toDOM: ${o}`);let r=z0.has(o.toLowerCase());r&&q0(o.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 g=p.includes(" ")?p.split(" ")[1]:p;if(!W0.test(g))continue;let b=V0(g,String(h));b!==null&&(i+=` ${g}="${B0(b)}"`)}s=t.slice(1)}let a=r?"":`<${o}${i}>`;if(P0.has(o.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=nl(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(r)return{open:"",close:"",hole:d,html:""};let f=`</${o}>`;return{open:a+c,close:u+f,hole:d,html:a+c+u+f}}var P0,Dp,H0,z0,F0,$0,_0,Lp,W0,gt,$r=D(()=>{"use strict";pt();P0=new Set(["area","base","br","col","embed","hr","img","input","link","meta","source","track","wbr"]),Dp=new RegExp("\xA0","g");H0=/^[a-z][a-z0-9-]*$/i,z0=new Set(["script","style","base","link","meta","object","embed","applet","frame","frameset","template","noscript"]),F0=new Set(["href","xlink:href","action","formaction","cite"]),$0=new Set(["src","poster","data","background"]),_0=/url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;Lp=new Set;W0=/^[a-z_:][a-z0-9_.:-]*$/i;gt=class{cache=new Map;serializeFragment(e){let t="",o=[],r=[],i=s=>{for(;o.length>s;)t+=r.pop(),o.pop()};return e.forEach(s=>{if(!s.isInline){i(0),t+=this.serializeNode(s);return}let l=0;for(;l<o.length&&l<s.marks.length&&o[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,r.push(u.close),o.push(c)}t+=s.isText?Rp(s.text??""):this.serializeNode(s)}),i(0),o=[],r=[],t}serializeNode(e){let t=e.type.spec.toDOM;if(!t)throw new Error(`[nova] node "${e.type.name}" has no toDOM`);let o=nl(t(e));return o.hole?o.open+this.serializeFragment(e.content)+o.close:o.html}renderMark(e,t){let o=e.type.spec.toDOM;if(!o)throw new Error(`[nova] mark "${e.type.name}" has no toDOM`);let r=`${e.type.name}:${JSON.stringify(e.attrs)}`,i=this.cache.get(r);return i||(i=nl(o(e,t)),this.cache.size>500&&this.cache.clear(),this.cache.set(r,i)),i}}});function bt(n,e){return(t,o)=>{let r=ie(t)[n],i=e===null?null:U0[n](e);if(e!==null&&!i)return!1;let{empty:s}=t.selection;if(!o)return!0;let l=t.tr;if(s)l.removeStoredMark(r),i&&l.addStoredMark(r.create({value:i}));else for(let a of t.selection.ranges)l.removeMark(a.$from.pos,a.$to.pos,r),i&&l.addMark(a.$from.pos,a.$to.pos,r.create({value:i}));return o(l.scrollIntoView()),!0}}function ot(n,e){let t=ie(n)[e],{$from:o,empty:r}=n.selection,i=r?n.storedMarks??o.marks():o.nodeAfter?.marks??o.marks(),s=t.isInSet(i);return s?s.attrs.value:null}function Eo(n){return(e,t)=>{let o=n===null?null:Z.lineHeight(n);if(n!==null&&!o)return!1;let{from:r,to:i}=e.selection,s=e.tr,l=!1;return e.doc.nodesBetween(r,i,(a,c)=>{(a.type===ee(e).paragraph||a.type===ee(e).heading)&&(l=!0,s.setNodeMarkup(c,void 0,{...a.attrs,lineHeight:o}))}),l?(t?.(s),!0):!1}}function ol(n){return n.selection.$from.parent.attrs.lineHeight??null}var U0,rl=D(()=>{"use strict";Pe();ht();U0={color:Z.color,background:Z.color,font_family:Z.fontFamily,font_size:Z.length}});function Vr(n){let t=[],o=n.current?.toLowerCase()??null,r=w("div",{className:"nova-swatches",role:"grid","aria-label":n.label});for(let l of n.colors){let a=o===l.toLowerCase(),c=w("button",{type:"button",className:"nova-swatch",role:"gridcell","aria-label":l,"aria-selected":String(a),title:l,tabindex:"-1"},a?ne(k.check):null);c.style.setProperty("--swatch",l),c.addEventListener("click",()=>n.onPick(l)),t.push(c),r.append(c)}(t.find(l=>l.getAttribute("aria-selected")==="true")??t[0])?.setAttribute("tabindex","0"),r.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=w("button",{type:"button",className:"nova-panel-action"},ne(k.clearFormatting),n.removeLabel);i.addEventListener("click",()=>n.onPick(null));let s=w("input",{type:"color",className:"nova-color-input","aria-label":n.customLabel,value:/^#[0-9a-f]{6}$/i.test(o??"")?o:"#000000"});return s.addEventListener("change",()=>n.onPick(s.value)),w("div",{className:"nova-color-panel"},r,w("div",{className:"nova-panel-footer"},i,w("label",{className:"nova-panel-action"},s,n.customLabel)))}var _r,il=D(()=>{"use strict";Y();j();_r=["#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 Ip(n){let{registry:e,t}=n.ui,o=(i,s)=>t("table.size",{rows:i,cols:s});e.addPanelButton("table",{icon:k.table,tooltip:t("table.insert"),isEnabled:i=>i.can(nt(1,1)),render:(i,s)=>Vd((l,a)=>{s(),i.exec(nt(l,a))},o,t("table.insert"))});let r=(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}:{}});r("tableinsertrowbefore","table.rowBefore",k.rowBefore,qe.addRowBefore),r("tableinsertrowafter","table.rowAfter",k.rowAfter,qe.addRowAfter),r("tabledeleterow","table.rowDelete",k.rowDelete,qe.deleteRow),r("tableinsertcolbefore","table.colBefore",k.colBefore,qe.addColumnBefore),r("tableinsertcolafter","table.colAfter",k.colAfter,qe.addColumnAfter),r("tabledeletecol","table.colDelete",k.colDelete,qe.deleteColumn),r("tablemergecells","table.merge",k.merge,qe.mergeCells),r("tablesplitcells","table.split",k.split,qe.splitCell),r("tablerowheader","table.rowHeader",k.rowHeader,qe.toggleHeaderRow,i=>Fd(i.view.state)),r("tablecolheader","table.colHeader",k.colHeader,qe.toggleHeaderColumn,i=>$d(i.view.state)),r("tabledelete","table.delete",k.tableDelete,qe.deleteTable),e.addPanelButton("tablecellbackground",{icon:k.highlight,tooltip:t("table.cellBackground"),isEnabled:i=>Q(i.view.state),render:(i,s)=>Vr({colors:i.options.colors??_r,current:null,label:t("table.cellBackground"),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:l=>{s(),i.exec(zd(l))}})}),e.addMenuButton("advtablesort",{icon:k.sort,tooltip:t("table.sort"),isEnabled:i=>i.can(Fs("asc")),items:i=>["asc","desc"].map(s=>({id:s,label:t(s==="asc"?"table.sortAsc":"table.sortDesc"),onSelect:()=>i.exec(Fs(s,i.options.language))}))}),e.addButton("tableprops",{icon:k.tableProps,tooltip:t("table.props"),isEnabled:i=>Q(i.view.state),onAction:i=>j0(i)}),e.addButton("tablecellprops",{icon:k.cellProps,tooltip:t("table.cellProps"),isEnabled:i=>Q(i.view.state),onAction:i=>K0(i)}),e.addContextToolbar("table",{label:t("table.toolbar"),predicate:i=>Q(i.view.state),anchor:i=>_d(i),placement:"bottom-start",items:"tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"})}function j0(n){let{t:e}=n.ui,t=qd(n.view.state);if(!t)return;let o=ue({label:e("table.width"),hint:e("table.widthHint"),value:t.width??""}),r=Jo({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")}]});n.ui.openDialog({title:e("table.props"),body:w("div",{className:"nova-form"},o.el,r.el),submitLabel:e("dialog.save"),onSubmit:()=>{let s={width:o.input.value.trim().replace(/^(\d+(\.\d+)?)$/,"$1px")||null,align:r.select.value||null};return n.exec(Wd(s))||e("table.invalidWidth")}})}function K0(n){let{t:e}=n.ui,t=jd(n.view.state);if(!t)return;let o=Jo({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")}]}),r=Jo({label:e("table.cellType"),value:t.header?"th":"td",options:[{value:"td",label:e("table.cellData")},{value:"th",label:e("table.cellHeader")}]}),i=ue({label:e("table.colWidth"),hint:e("table.colWidthHint"),value:t.width?String(t.width):""});n.ui.openDialog({title:e("table.cellProps"),body:w("div",{className:"nova-form"},o.el,r.el,i.el),submitLabel:e("dialog.save"),onSubmit:()=>{let s=i.input.value.trim(),l=s?Number(s.replace(/px$/i,"")):null;return l!==null&&!(Number.isInteger(l)&&l>=24&&l<=4e3)?e("table.invalidColWidth"):(n.exec(Kd({valign:o.select.value||null,header:r.select.value==="th",width:l})),!0)}})}var Pp=D(()=>{"use strict";Pn();il();Ct();Y();j()});function Bp(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 Hp(n){let e=n.split(",")[0].trim().replace(/["']/g,"");return Y0[e.toLowerCase()]??e}function Q0(n){let e=parseFloat(n);return!Number.isFinite(e)||e<=0?null:`${Math.round(e*.75*2)/2}pt`}function Fp(n){let{registry:e,t}=n.ui,o=()=>n.view.state,r=(m,y,v,M)=>e.addButton(m,{icon:v,tooltip:t(y),...Ke[y]?{shortcut:Ke[y]}:{},onAction:T=>T.exec(y),isEnabled:T=>T.can(y),...M?{isActive:M}:{}}),i=(m,y,v,M)=>r(m,y,M,()=>go(o(),n.schema.marks[v]));r("undo","undo",k.undo),r("redo","redo",k.redo),i("bold","bold","bold",k.bold),i("italic","italic","italic",k.italic),i("underline","underline","underline",k.underline),i("strikethrough","strike","strike",k.strike),i("inlinecode","code","code",k.code),i("subscript","subscript","subscript",k.subscript),i("superscript","superscript","superscript",k.superscript),r("bullist","bulletList",k.bulletList,()=>et(o(),n.schema.nodes.bullet_list)),r("numlist","orderedList",k.orderedList,()=>et(o(),n.schema.nodes.ordered_list)),r("indent","indent",k.indent),r("outdent","outdent",k.outdent),r("blockquote","blockquote",k.blockquote,()=>et(o(),n.schema.nodes.blockquote)),r("codeblock","codeBlock",k.codeBlock,()=>et(o(),n.schema.nodes.code_block)),r("hr","horizontalRule",k.horizontalRule),r("removeformat","clearFormatting",k.clearFormatting);let s=[["alignLeft","left",k.alignLeft],["alignCenter","center",k.alignCenter],["alignRight","right",k.alignRight],["alignJustify","justify",k.alignJustify]];for(let[m,y,v]of s)r(m.toLowerCase(),m,v,()=>rn(o())===y);e.addMenuButton("align",{icon:k.alignLeft,tooltip:t("align"),isEnabled:m=>m.can("alignLeft"),items:m=>s.map(([y,v,M])=>({id:y,label:t(y),icon:M,...Ke[y]?{shortcut:Ke[y]}:{},active:rn(m.view.state)===v,onSelect:()=>m.exec(y)}))});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 m=o().selection.$from.parent;return m.type===n.schema.nodes.heading?`h${m.attrs.level}`:m.type===n.schema.nodes.code_block?"codeBlock":"paragraph"};for(let m=1;m<=6;m++){let y=`h${m}`;e.addToggleButton(y,{...m<=3?{icon:k[`h${m}`]}:{text:`H${m}`},tooltip:t(y),...Ke[y]?{shortcut:Ke[y]}:{},isActive:()=>a()===y,isEnabled:v=>v.can(y)||a()===y,onAction:v=>v.exec(a()===y?"paragraph":y)})}e.addMenuButton("blocks",{tooltip:t("blocks"),label:()=>t(a()),minChars:11,isEnabled:m=>l.some(({command:y})=>m.can(y)),items:m=>l.filter(({command:y})=>m.isAllowed(y)).map(({command:y,style:v})=>({id:y,label:t(y),labelStyle:v,...Ke[y]?{shortcut:Ke[y]}:{},active:a()===y,onSelect:()=>m.exec(y)}))});let c=n.options.fontFamilies??J0;e.addMenuButton("fontfamily",{tooltip:t("fontFamily"),minChars:9,label:m=>{let y=ot(o(),"font_family");if(y)return c.find(M=>zp(y,M.value))?.label??Hp(y);let v=Bp(m)?.fontFamily;return v?Hp(v):t("fontFamily")},items:m=>{let y=ot(m.view.state,"font_family");return[{id:"default",label:t("default"),active:y===null,onSelect:()=>m.exec(bt("font_family",null))},{type:"separator"},...c.map(v=>({id:v.label,label:v.label,labelStyle:`font-family: ${v.value}`,active:zp(y,v.value),onSelect:()=>m.exec(bt("font_family",v.value))}))]}});let u=n.options.fontSizes??G0;e.addMenuButton("fontsize",{tooltip:t("fontSize"),minChars:4,label:m=>ot(o(),"font_size")??Q0(Bp(m)?.fontSize??"")??"\u2014",items:m=>{let y=ot(m.view.state,"font_size");return[{id:"default",label:t("default"),active:y===null,onSelect:()=>m.exec(bt("font_size",null))},{type:"separator"},...u.map(v=>({id:v,label:v,active:y===v,onSelect:()=>m.exec(bt("font_size",v))}))]}});let d=n.options.lineHeights??X0;e.addMenuButton("lineheight",{icon:k.lineHeight,tooltip:t("lineHeight"),isEnabled:m=>m.can(Eo(null)),items:m=>{let y=ol(m.view.state);return[{id:"default",label:t("default"),active:y===null,onSelect:()=>m.exec(Eo(null))},...d.map(v=>({id:v,label:v,active:y===v,onSelect:()=>m.exec(Eo(v))}))]}});let f=(m,y,v,M)=>e.addPanelButton(m,{icon:v,tooltip:t(M),indicator:()=>ot(o(),y),render:(T,C)=>Vr({colors:T.options.colors??_r,current:ot(T.view.state,y),label:t(M),removeLabel:t("removeColor"),customLabel:t("customColor"),onPick:N=>{C(),T.exec(bt(y,N))}})});f("forecolor","color",k.textColor,"textColor"),f("backcolor","background",k.highlight,"backgroundColor");let p=[["superscript","superscript",k.superscript],["subscript","subscript",k.subscript],["code","code",k.code]];e.addMenuButton("moreformats",{icon:k.formatMore,tooltip:t("moreFormats"),isActive:m=>p.some(([,y])=>go(m.view.state,n.schema.marks[y])),items:m=>[...p.filter(([y])=>m.isAllowed(y)).map(([y,v,M])=>({id:y,label:t(y),icon:M,checkbox:!0,active:go(m.view.state,n.schema.marks[v]),disabled:!m.can(y),...Ke[y]?{shortcut:Ke[y]}:{},onSelect:()=>m.exec(y)})),{type:"separator"},{id:"clearFormatting",label:t("clearFormatting"),icon:k.clearFormatting,disabled:!m.can("clearFormatting"),shortcut:Ke.clearFormatting,onSelect:()=>m.exec("clearFormatting")},{id:"pasteAsText",label:t("pasteAsText"),icon:k.pasteText,checkbox:!0,active:m.isPasteAsText(),onSelect:()=>{m.setPasteAsText(!m.isPasteAsText()),m.focus()}}]}),e.addToggleButton("pastetext",{icon:k.pasteText,tooltip:t("pasteAsText"),isActive:m=>m.isPasteAsText(),onAction:m=>{m.setPasteAsText(!m.isPasteAsText()),m.focus()}}),e.addButton("link",{icon:k.link,tooltip:t("link"),shortcut:"Mod-k",onAction:m=>tt(m),isActive:()=>!!Dn(o())}),e.addButton("unlink",{icon:k.unlink,tooltip:t("unlink"),onAction:m=>m.exec(xo()),isEnabled:m=>m.can(xo())}),e.addButton("image",{icon:k.image,tooltip:t("image"),onAction:m=>Lr(m)});let h=()=>sn(o())?.node.attrs.align??null,g=(m,y,v,M)=>e.addToggleButton(m,{icon:v,tooltip:t(M),isActive:()=>h()===y,onAction:T=>T.exec(vo({align:h()===y?null:y}))});g("imagealignleft","left",k.imageLeft,"image.alignLeft"),g("imagealigncenter","center",k.imageCenter,"image.alignCenter"),g("imagealignright","right",k.imageRight,"image.alignRight");let b=[["image.sizeSmall",.25],["image.sizeMedium",.5],["image.sizeLarge",.75],["image.sizeFull",1],["image.sizeOriginal",null]];e.addMenuButton("imagesize",{icon:k.resize,tooltip:t("image.size"),items:m=>b.map(([y,v])=>({id:y,label:t(y),onSelect:()=>Id(m,v)}))}),e.addButton("imagealt",{icon:k.altText,tooltip:t("image.editAlt"),onAction:m=>Pd(m)}),e.addButton("imagedelete",{icon:k.trash,tooltip:t("image.delete"),onAction:m=>m.exec((y,v)=>sn(y)?(v?.(y.tr.deleteSelection().scrollIntoView()),!0):!1)}),Ip(n),e.addButton("searchreplace",{icon:k.search,tooltip:t("search.title"),shortcut:"Mod-f",onAction:m=>m.openSearch()}),e.addToggleButton("fullscreen",{icon:k.fullscreen,tooltip:t("fullscreen"),shortcut:"Mod-Shift-f",isActive:m=>el(m),onAction:m=>Co(m)}),e.addButton("preview",{icon:k.preview,tooltip:t("preview"),onAction:m=>Np(m)}),e.addButton("code",{icon:k.sourceCode,tooltip:t("sourceCode"),onAction:m=>Op(m)}),e.addButton("help",{icon:k.help,tooltip:t("help"),shortcut:"Alt-0",onAction:m=>Fr(m)}),e.addContextToolbar("image",{label:t("image.toolbar"),predicate:m=>!!sn(m.view.state),items:"imagealignleft imagealigncenter imagealignright | imagesize imagealt | imagedelete"})}var J0,G0,X0,Ke,Y0,zp,$p=D(()=>{"use strict";Pe();wo();In();rl();il();Pp();tl();j();J0=[{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'}],G0=["8pt","10pt","12pt","14pt","16pt","18pt","24pt","36pt","48pt"],X0=["1","1.15","1.5","2","2.5","3"],Ke={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"};Y0={"system-ui":"Sans Serif","-apple-system":"Sans Serif","sans-serif":"Sans Serif",serif:"Serif",monospace:"Monospace","ui-monospace":"Monospace"};zp=(n,e)=>n!==null&&n.replace(/["'\s]/g,"").toLowerCase()===e.replace(/["'\s]/g,"").toLowerCase()});function yt(n,e,t){let o=window.innerWidth,r=window.innerHeight,{width:i,height:s}=n.getBoundingClientRect(),l=r-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,o-i-8)),d=Math.max(8,Math.min(d,r-s-8)),n.style.left=`${Math.round(f)}px`,n.style.top=`${Math.round(d)}px`,n.dataset.side=u?"top":"bottom"}var Ao,zn,cn=D(()=>{"use strict";Ao=[],zn=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),Ao.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,o=typeof e=="function"?e():e.getBoundingClientRect();yt(this.el,o,t)};close(e="api"){this.closed||(this.closed=!0,Ao.splice(Ao.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||Ao[Ao.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(o=>o.contains(t))||this.close("outside")}}});function _p(n){return new _({key:new K("nova-link-bubble"),view(e){let{t}=n.ui,o=w("a",{className:"nova-bubble-link",target:"_blank",rel:"noopener noreferrer"}),r=(c,u,d)=>{let f=w("button",{type:"button",className:"nova-btn","aria-label":u,"data-tooltip":u},ne(c));return f.addEventListener("click",d),n.ui.tooltip.attach(f),f},i=w("div",{className:"nova-bubble",role:"toolbar","aria-label":t("link"),hidden:!0},ne(k.externalLink),o,w("span",{className:"nova-bubble-sep"}),r(k.edit,t("link.edit"),()=>tt(n)),r(k.copy,t("link.copy"),()=>{navigator.clipboard?.writeText(o.href).then(()=>n.ui.notify({text:t("link.copied"),type:"success",timeout:2e3}))}),r(k.unlink,t("unlink"),()=>n.exec(xo())));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=Dn(c),d=e.hasFocus()||i.contains(document.activeElement);if(!u||!d||!n.isEditable()||n.ui.activeDialog||!c.selection.empty){s();return}let f=bo(c,ie(c).link,c.selection.from);if(!f)return s();o.textContent=u.href,o.title=u.href,De(u.href)?o.setAttribute("href",u.href):o.removeAttribute("href"),i.hidden=!1;let p=e.coordsAtPos(f.from),h=e.coordsAtPos(f.to),g=new DOMRect(p.left,p.top,Math.max(1,h.right-p.left),h.bottom-p.top);yt(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 Vp=D(()=>{"use strict";U();Pe();In();Pe();pt();Y();j();cn()});function ll(n){let e=Array.isArray(n)?n:n.split(/\s+/),t=[[]];for(let o of e){let r=o.trim();r&&(r==="|"?t.push([]):t[t.length-1].push(r))}return t.filter(o=>o.length>0)}function al(n,e,t,o,{warnUnknown:r=!0}={}){let{ui:i}=n,s=i.t,l=new AbortController,{signal:a}=l;e.className=`nova-toolbar nova-toolbar-${o}`,e.setAttribute("role","toolbar"),e.setAttribute("aria-label",s("toolbar.label"));let c=[],u=[];for(let x of ll(t)){let S=w("div",{className:"nova-tb-group",role:"group"});for(let E of x){if(!n.isAllowed(E))continue;let F=i.registry.get(E);if(!F){r&&console.warn(`[nova] Unknown toolbar item "${E}"`);continue}let z=To(n,E,F);c.push(z),S.append(z.el)}S.childElementCount&&(u.push(S),e.append(S))}let d=w("div",{className:"nova-toolbar nova-tb-overflow",role:"group"}),f=w("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},ne(k.more));i.tooltip.attach(f);let p=null,h=()=>{p?.close(),p=null},g=i.onDialogOpen(h);f.addEventListener("click",x=>{if(p)return h();f.setAttribute("aria-expanded","true");let S=new zn({host:i.overlayHost,anchor:f,placement:"bottom-end",content:d,className:"nova-tb-overflow-popover",ignore:[i.overlayHost,f],onClose:E=>{p=null,f.setAttribute("aria-expanded","false"),E==="escape"&&S.focusWasInside&&f.focus()}});p=S,x.detail===0&&d.querySelector("button:not(:disabled)")?.focus()}),o==="sliding"&&e.append(f);let b=()=>{if(o!=="sliding")return;for(let S of u)e.insertBefore(S,f);if(f.hidden=!0,e.scrollWidth<=e.clientWidth+1){h();return}f.hidden=!1;let x=u.length;for(;x>1&&e.scrollWidth>e.clientWidth+1;)x-=1,d.prepend(u[x]);d.childElementCount||(f.hidden=!0),p?.reposition(),T()},m=-1,y=typeof ResizeObserver<"u"&&o==="sliding"?new ResizeObserver(()=>{e.clientWidth!==m&&(m=e.clientWidth,b())}):null;y?.observe(e);let v=()=>[...e.querySelectorAll("button")].filter(x=>!x.disabled&&!x.hidden),M=null,T=()=>{let x=v();(!M||!x.includes(M))&&(M=x[0]??null);for(let S of e.querySelectorAll("button"))S.tabIndex=S===M?0:-1};e.addEventListener("focusin",x=>{let S=x.target;S instanceof HTMLButtonElement&&e.contains(S)&&(M=S,T())},{signal:a}),e.addEventListener("keydown",x=>{let S=v(),E=S.indexOf(document.activeElement);if(E<0)return;let F=null;if(x.key==="ArrowRight")F=E+1;else if(x.key==="ArrowLeft")F=E-1;else if(x.key==="Home")F=0;else if(x.key==="End")F=S.length-1;else if(x.key==="Escape"){x.preventDefault(),n.focus();return}F!==null&&(x.preventDefault(),S[(F+S.length)%S.length].focus())},{signal:a});let C=x=>{x.target.closest("button")&&x.preventDefault()};e.addEventListener("mousedown",C,{signal:a}),d.addEventListener("mousedown",C),d.addEventListener("keydown",x=>{if(x.key==="Escape")return;let S=[...d.querySelectorAll("button")].filter(F=>!F.disabled),E=S.indexOf(document.activeElement);E<0||(x.key==="ArrowRight"||x.key==="ArrowDown"?(x.preventDefault(),S[(E+1)%S.length].focus()):(x.key==="ArrowLeft"||x.key==="ArrowUp")&&(x.preventDefault(),S[(E-1+S.length)%S.length].focus()))});let N=()=>{for(let x of c)x.update();T()};return N(),b(),{update:N,focus:()=>{T(),M?.focus()},destroy:()=>{y?.disconnect(),g(),h(),l.abort(),e.replaceChildren()}}}function To(n,e,t){if(t.type==="split")return Z0(n,e,t);let{ui:o}=n,r=w("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}:{}});o.tooltip.attach(r),t.icon&&r.append(ne(t.icon));let i=t.type==="menu"&&(t.label||t.text)?w("span",{className:"nova-tb-label"}):null;i?(t.type==="menu"&&t.minChars&&(i.style.minWidth=`${t.minChars}ch`),r.append(i),r.classList.add("nova-tb-has-label")):!t.icon&&t.text&&r.append(t.text);let s=null;return t.type==="panel"&&t.indicator&&(s=w("span",{className:"nova-color-bar"}),r.append(s)),t.type!=="button"&&(r.setAttribute("aria-haspopup",t.type==="menu"?"menu":"dialog"),r.setAttribute("aria-expanded","false"),r.append(ne(k.chevronDown)),r.lastElementChild?.classList.add("nova-chevron")),r.addEventListener("click",a=>{if(t.type==="button"){t.onAction(n);return}if(r.getAttribute("aria-expanded")==="true"){o.closePopover();return}let c=a.detail===0,u=()=>o.closePopover(),d=t.type==="menu"?Br(t.items(n),u,t.tooltip):t.render(n,u);r.setAttribute("aria-expanded","true");let f=o.openPopover({anchor:r,content:d,ignore:[r],className:t.type==="menu"?"nova-popover-menu":"nova-popover-panel",onClose:p=>{r.setAttribute("aria-expanded","false"),p==="escape"&&f.focusWasInside&&r.focus()}});t.type==="menu"?Hr(d):c&&d.querySelector("button, input")?.focus()}),t.type!=="button"&&r.addEventListener("keydown",a=>{a.key==="ArrowDown"&&r.getAttribute("aria-expanded")!=="true"&&(a.preventDefault(),r.click())}),{el:r,update:()=>{let a=n.isEditable();if(r.disabled=!a||(t.isEnabled?!t.isEnabled(n):!1),t.isActive){let c=t.isActive(n);r.classList.toggle("is-active",c),t.type==="button"&&r.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 Z0(n,e,t){let o=To(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}:{}}),r=To(n,`${e}-options`,{type:"menu",tooltip:`${t.tooltip}: ${n.ui.t("toolbar.options")}`,items:t.items,...t.isEnabled?{isEnabled:t.isEnabled}:{}});return r.el.classList.add("nova-tb-split-more"),{el:w("span",{className:"nova-tb-split"},o.el,r.el),update:()=>{o.update(),r.update()}}}var sl,cl=D(()=>{"use strict";Y();j();Xs();cn();sl="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 qp(n){return new _({key:new K("nova-context-toolbar"),view(e){let t=w("div",{className:"nova-bubble nova-context-toolbar",role:"toolbar",hidden:!0});n.ui.overlayHost.append(t);let o=new Map,r=null,i=(g,b)=>{let m=o.get(g);if(m)return m;let y=w("div",{className:"nova-context-items"}),v=[];return ll(b.items).forEach((M,T)=>{T>0&&y.append(w("span",{className:"nova-bubble-sep",role:"separator"}));for(let C of M){if(!n.isAllowed(C))continue;let N=n.ui.registry.get(C);if(!N)continue;let x=To(n,C,N);v.push(x),y.append(x.el)}}),m={el:y,controls:v},o.set(g,m),m},s=()=>{t.hidden=!0,r=null},l=g=>{let{selection:b}=e.state;if((g.position??"node")==="node"&&b instanceof R)return e.nodeDOM(b.from)?.getBoundingClientRect()??null;let m=e.coordsAtPos(b.from),y=e.coordsAtPos(b.to);return new DOMRect(m.left,m.top,Math.max(1,y.right-m.left),y.bottom-m.top)},a=!1,c=g=>{g.pointerType==="mouse"&&g.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=g=>{if(!(g.hasFocus()||t.contains(document.activeElement))||!n.isEditable()||n.ui.activeDialog||a)return s();let m=n.ui.registry.getContextToolbars().find(([,N])=>N.predicate(n));if(!m)return s();let[y,v]=m,M=i(y,v);r!==y&&(t.replaceChildren(M.el),t.setAttribute("aria-label",v.label),r=y);for(let N of M.controls)N.update();let T=v.anchor?v.anchor(n):l(v);if(!T)return s();t.hidden=!1;let C=v.placement??(v.position==="selection"?"bottom-start":"top-start");d&&v.position==="selection"&&(C="bottom-start"),yt(t,T,C)};t.addEventListener("mousedown",g=>{g.target.closest("button")&&g.preventDefault()}),t.addEventListener("keydown",g=>{let b=[...t.querySelectorAll("button:not(:disabled)")],m=b.indexOf(document.activeElement);if(g.key==="Escape")g.preventDefault(),n.focus();else if(m>=0&&(g.key==="ArrowRight"||g.key==="ArrowLeft")){g.preventDefault();let y=g.key==="ArrowRight"?1:-1;b[(m+y+b.length)%b.length].focus()}});let p=g=>{let b=g.relatedTarget;!t.contains(b)&&!n.ui.overlayHost.contains(b)&&s()};e.dom.addEventListener("blur",p),t.addEventListener("focusout",g=>{let b=g.relatedTarget;!t.contains(b)&&!e.hasFocus()&&!n.ui.overlayHost.contains(b)&&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 Wp(n){let e=n.ui.overlayHost.querySelector(".nova-context-toolbar:not([hidden]) button:not(:disabled)");return e?.focus(),!!e}var Up=D(()=>{"use strict";U();Y();cn();cl()});var jp,qr,Kp=D(()=>{"use strict";U();ht();pt();jp=24,qr=class{constructor(e,t,o,r){this.view=t;this.getPos=o;this.editor=r;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:o,width:r,height:i,align:s}=this.node.attrs,l=Re(e)?e:"";this.img.getAttribute("src")!==l&&this.img.setAttribute("src",l),this.setAttr("alt",t),this.setAttr("title",o);let a=Ie(r),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 o=e.currentTarget;o.setPointerCapture(e.pointerId);let r=this.img.getBoundingClientRect(),i=e.clientX,s=r.width,l=r.width>0?r.height/r.width:this.img.naturalHeight/(this.img.naturalWidth||1),a=Math.max(jp,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(jp,s+c*(p.clientX-i)))),this.img.style.width=`${u}px`,this.dom.dataset.size=`${u} \xD7 ${Math.round(u*l)}`},f=()=>{o.removeEventListener("pointermove",d),o.removeEventListener("pointerup",f),o.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(R.create(h.doc,p)),this.view.dispatch(h)};o.addEventListener("pointermove",d),o.addEventListener("pointerup",f),o.addEventListener("pointercancel",f)}}});function t1(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function n1(n,e){let{selection:t}=n.state;if(!t.empty)return null;let o=t.$from;if(!o.parent.isTextblock||o.parent.type.spec.code)return null;let r=o.parent.textBetween(Math.max(0,o.parentOffset-e1-1),o.parentOffset,"\0","\0");for(let[i,s]of e.ui.registry.getAutocompleters()){let l=new RegExp(`(?:^|\\s)${t1(s.trigger)}([\\p{L}\\p{N}_-]*)$`,"u"),a=r.match(l);if(!a)continue;let c=a[1]??"";if(c.length<(s.minChars??0))continue;let u=o.parentOffset-c.length-s.trigger.length,d=u>0?o.parent.textBetween(u-1,u,"\0","\0"):"";if(!(d&&!/\s/.test(d)))return{name:i,spec:s,from:o.pos-c.length-s.trigger.length,to:o.pos,query:c}}return null}function Jp(n){let e,t=[],o=0,r=null,i=null,s=0,l=Se("nova-ac"),a=()=>!e.hidden,c=h=>{e.hidden=!0,r=null,t=[],h.dom.removeAttribute("aria-activedescendant"),h.dom.removeAttribute("aria-controls"),h.dom.setAttribute("aria-expanded","false")},u=(h,g)=>{let b=t[g];if(!b||!r)return;let{spec:m,from:y,to:v}=r;c(h),m.onSelect(b,{from:y,to:v},n)},d=h=>{if(!r)return;let{spec:g}=r;if(e.replaceChildren(),e.setAttribute("aria-label",g.label),!t.length){if(!g.emptyText)return c(h);e.append(w("div",{className:"nova-ac-empty"},g.emptyText))}t.forEach((m,y)=>{let v=w("div",{id:`${l}-${y}`,className:"nova-menu-item nova-ac-item",role:"option","aria-selected":String(y===o)},m.icon?ne(m.icon):null,w("span",{className:"nova-menu-label"},m.label),m.shortcut?w("kbd",{className:"nova-menu-shortcut"},Xe(m.shortcut)):m.detail?w("span",{className:"nova-menu-shortcut"},m.detail):null);v.addEventListener("mousedown",M=>{M.preventDefault(),u(h,y)}),v.addEventListener("mousemove",()=>{o!==y&&f(h,y)}),e.append(v)}),e.hidden=!1,h.dom.setAttribute("aria-controls",l),h.dom.setAttribute("aria-expanded","true"),f(h,Math.min(o,Math.max(0,t.length-1)));let b=h.coordsAtPos(r.from);yt(e,new DOMRect(b.left,b.top,1,b.bottom-b.top),"bottom-start")},f=(h,g)=>{o=g,e.querySelectorAll('[role="option"]').forEach((m,y)=>m.setAttribute("aria-selected",String(y===g)));let b=e.querySelector(`#${l}-${g}`);b&&(h.dom.setAttribute("aria-activedescendant",b.id),b.scrollIntoView?.({block:"nearest"}))},p=h=>{let g=n.isEditable()&&h.hasFocus()?n1(h,n):null;if(!g||g.from===i){g||(i=null),(a()||r)&&c(h);return}let b=!r||r.query!==g.query||r.from!==g.from;if(r=g,!b&&a())return d(h);let m=++s;Promise.resolve(g.spec.fetch(g.query,n)).then(y=>{m!==s||!r||(t=y.slice(0,g.spec.maxResults??10),o=0,d(h))})};return new _({key:new K("nova-autocompleter"),view(h){e=w("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:b=>p(b),destroy(){h.dom.removeEventListener("blur",g),e.remove()}}},props:{handleKeyDown(h,g){if(!a()||!r)return!1;let b=t.length;switch(g.key){case"ArrowDown":return b&&f(h,(o+1)%b),!0;case"ArrowUp":return b&&f(h,(o-1+b)%b),!0;case"Enter":case"Tab":return b?(u(h,o),!0):!1;case"Escape":return i=r.from,c(h),!0;default:return!1}}}})}var e1,Gp=D(()=>{"use strict";U();Y();cn();e1=30});function r1(n,e,t){let o=e.toLowerCase();if(!o)return n;let r=[];return n.forEach((i,s)=>{let l=t(i.label).toLowerCase(),a=[l,...l.split(/\s+/),...i.keywords],c=-1;l.startsWith(o)?c=3:a.some(u=>u.startsWith(o))?c=2:a.some(u=>u.includes(o))&&(c=1),c>0&&r.push([c,s,i])}),r.sort((i,s)=>s[0]-i[0]||i[1]-s[1]).map(([,,i])=>i)}function Xp(n,e=[]){let{t}=n.ui,o=[...o1,...e].filter(r=>n.isAllowed(r.name));n.ui.registry.addAutocompleter("slashcommands",{trigger:"/",label:t("slash.label"),emptyText:t("slash.empty"),fetch:r=>r1(o,r,t).map(i=>({value:i.name,label:t(i.label),icon:i.icon,...i.shortcut?{shortcut:i.shortcut}:{}})),onSelect:(r,i,s)=>{let l=o.find(a=>a.name===r.value);l&&(s.view.dispatch(s.view.state.tr.delete(i.from,i.to)),l.run(s))}})}var vt,o1,Yp=D(()=>{"use strict";wo();In();Pn();j();vt=n=>e=>e.exec(n),o1=[{name:"paragraph",label:"paragraph",icon:k.paragraph,keywords:["text","p","paragraph"],run:vt("paragraph")},{name:"h1",label:"h1",icon:k.h1,keywords:["h1","heading","title"],shortcut:"Mod-Alt-1",run:vt("h1")},{name:"h2",label:"h2",icon:k.h2,keywords:["h2","heading","subtitle"],shortcut:"Mod-Alt-2",run:vt("h2")},{name:"h3",label:"h3",icon:k.h3,keywords:["h3","heading"],shortcut:"Mod-Alt-3",run:vt("h3")},{name:"bullist",label:"bulletList",icon:k.bulletList,keywords:["ul","list","bullet"],shortcut:"Mod-Shift-8",run:vt("bulletList")},{name:"numlist",label:"orderedList",icon:k.orderedList,keywords:["ol","list","numbered"],shortcut:"Mod-Shift-7",run:vt("orderedList")},{name:"blockquote",label:"blockquote",icon:k.blockquote,keywords:["quote","blockquote","citation"],run:vt("blockquote")},{name:"codeblock",label:"codeBlock",icon:k.codeBlock,keywords:["code","pre","snippet"],run:vt("codeBlock")},{name:"hr",label:"horizontalRule",icon:k.horizontalRule,keywords:["hr","divider","line","separator"],run:vt("horizontalRule")},{name:"table",label:"table",icon:k.table,keywords:["table","grid"],run:n=>n.exec(nt(3,3))},{name:"image",label:"image",icon:k.image,keywords:["image","picture","photo","img"],run:n=>Lr(n)},{name:"link",label:"link",icon:k.link,keywords:["link","url","href"],shortcut:"Mod-k",run:n=>tt(n)}]});var Wr,Qp=D(()=>{"use strict";Y();j();Wr=class{region;closeLabel;constructor(e,t){this.closeLabel=t,this.region=w("div",{className:"nova-notifications","aria-live":"polite"}),e.append(this.region)}open(e){let t=e.type??"info",o=e.timeout??(t==="error"?0:4e3),r=w("span",{className:"nova-notification-text"},e.text),i=w("button",{type:"button",className:"nova-btn","aria-label":this.closeLabel},ne(k.close)),s=w("div",{className:`nova-notification nova-notification-${t}`,role:t==="error"?"alert":"status"},r,i);this.region.append(s);let l=null,a=()=>{l&&clearTimeout(l),s.remove()};return i.addEventListener("click",a),o>0&&(l=setTimeout(a,o)),{close:a,setText:c=>r.textContent=c}}destroy(){this.region.remove()}}});var Ur,Zp=D(()=>{"use strict";Ur=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 o=this.get(e);if(!(o?.type!=="button"&&o?.type!=="split"))return{text:o.tooltip,...o.icon?{icon:o.icon}:{},...o.shortcut?{shortcut:o.shortcut}:{},onAction:o.onAction,...o.isActive?{isActive:o.isActive}:{},...o.isEnabled?{isEnabled:o.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 i1,jr,eh=D(()=>{"use strict";Y();cn();i1=450,jr=class{el;timer=null;target=null;constructor(e){this.el=w("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),i1)}show(e){this.clearTimer();let t=e.dataset.tooltip;if(!t||e.getAttribute("aria-expanded")==="true")return;this.target=e;let o=e.dataset.shortcut;this.el.replaceChildren(w("span",{},t)),o&&this.el.append(w("kbd",{},Xe(o))),this.el.hidden=!1,yt(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 Kr,th=D(()=>{"use strict";Ct();Y();Qp();cn();Zp();eh();Kr=class{constructor(e,t,o){this.focusEditor=o;this.t=t,this.overlayHost=w("div",{className:"nova-overlays"}),e.append(this.overlayHost),this.tooltip=new jr(this.overlayHost),this.notifications=new Wr(e,t("dialog.close"))}focusEditor;registry=new Ur;t;overlayHost;tooltip;notifications;popover=null;dialog=null;openPopover(e){this.closePopover(),this.tooltip.hide();let t=new zn({...e,host:this.overlayHost,onClose:o=>{this.popover===t&&(this.popover=null),e.onClose?.(o)}});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(o=>o()),this.dialog?.close();let t=Sa({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 a1(n){let e=n.match(/[\p{L}\p{N}]+(?:['’-][\p{L}\p{N}]+)*/gu);return e?e.length:0}function nh(n,e){e.className="nova-statusbar";let t=w("div",{className:"nova-path","aria-hidden":"true"}),o=w("div",{className:"nova-wordcount","aria-live":"off"});e.append(t,o);let r=null,i=()=>{let l=n.view.state.doc;o.textContent=n.ui.t("status.words",{count:a1(l.textBetween(0,l.content.size," "," "))})},s=l=>{let{$from:a}=n.view.state.selection,c=[];for(let d=1;d<=a.depth;d++){let f=a.node(d),p=s1[f.type.name]?.(f);p&&c.push(p)}n.view.state.selection.node?.type.name==="image"&&c.push("img");for(let d of a.marks()){let f=l1[d.type.name];f&&c.push(f)}t.textContent=c.join(" \u203A "),l&&(r&&clearTimeout(r),r=setTimeout(i,250))};return i(),s(!1),{update:s,destroy:()=>{r&&clearTimeout(r),e.replaceChildren()}}}var s1,l1,oh=D(()=>{"use strict";Y();s1={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"},l1={bold:"strong",italic:"em",underline:"u",strike:"s",code:"code",link:"a",subscript:"sub",superscript:"sup"}});function Je(n,e){console.error(`[nova] ${n}`,...e===void 0?[]:[e])}function Gr(n,e){if(typeof e!="string")return Le.fromJSON(n,e);let t=document.createElement("div"),o=document.createElement("template");return o.innerHTML=e,t.appendChild(o.content),ln(n).parse(t)}function ul(n){return new Jr(n)}var c1,Jr,dl=D(()=>{"use strict";If();Hf();Nr();ut();ce();U();Lt();Pe();qf();wo();Uf();Kf();In();lp();Pn();Gs();pp();mp();vp();Do();Zs();Tp();tl();ht();$r();$p();Vp();Up();Kp();Gp();Yp();th();oh();cl();c1=new gt,Jr=class{view;root;ui;options;listeners=new Map;ready;toolbar;toolbarHost;menubar;mode;pluginsByName=new Map;commandOverrides=new Map;transactionTransforms=[];cleanups=[];contentRules;schema;statusbar;searchBar;destroyed=!1;editable;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"),o=document.createElement("div"),r=document.createElement("div");o.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,o,r),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 Kr(this.root,Vf(e.language,e.translations),()=>this.focus());let a=Fe({"Mod-k":()=>(tt(this),!0),"Alt-F9":()=>this.menubar?(this.menubar.focus(),!0):!1,"Alt-F10":()=>this.toolbar?(this.toolbar.focus(),!0):!1,"Ctrl-F9":()=>Wp(this),"Mod-f":()=>(this.openSearch(),!0),"Mod-Shift-f":()=>(Co(this),!0),"Alt-0":()=>(Fr(this),!0),Escape:()=>this.searchBar.isOpen()?(this.searchBar.close(),!0):!1}),c=[...e.plugins??[]];l&&!c.includes("quickbars")&&c.push("quickbars");let u=Ml(c);u.errors.forEach(M=>Je(M));let{ordered:d,errors:f}=oi(u.plugins);f.forEach(M=>Je(M));let p=d.flatMap(M=>this.collectPmPlugins(M)),h=e.validElements!==void 0||e.invalidElements!==void 0||e.validStyles!==void 0;this.contentRules=h?new zr(e):null,this.schema=this.buildSchema(d),d.forEach(M=>this.registerCommands(M));let g=Gr(this.schema,e.content??""),b=gn.create({doc:this.contentRules?this.contentRules.normalizeDoc(g):g,plugins:[Jp(this),Wf(M=>this.isAllowed(M),this.schema),a,...Hd(),kp(),...jf(M=>this.resolveCommand(M)),...d.some(M=>M.replaceHistory)?[]:[xd()],Rf({color:"var(--nova-accent)",width:2}),Bf(),Rd(this),Dd(this),sp(this),_p(this),qp(this),...this.contentRules?[yp(this.contentRules)]:[],...p,...e.prosemirrorPlugins??[]]});this.editable=e.editable??!0,this.pasteAsText=e.pasteAsText??!1;let m=this.handleTransaction.bind(this);this.view=new Xt(o,{state:b,editable:()=>this.editable,attributes:{class:"nova-prosemirror",role:"textbox","aria-multiline":"true","aria-label":this.ui.t("editor.label"),...e.placeholder?{"data-placeholder":e.placeholder}:{}},dispatchTransaction:function(M){m(M,this)},clipboardParser:ln(this.schema),nodeViews:{image:(M,T,C)=>new qr(M,T,C,this)},handleDOMEvents:{focus:()=>(this.emit("focus"),!1),blur:()=>(this.emit("blur"),!1)}}),this.root.classList.toggle("nova-readonly",!this.editable),Fp(this),hp(this),e.slashCommands!==!1&&Xp(this,e.slashCommands??[]),d.forEach(M=>this.setupPlugin(M)),e.setup?.(this);let y=e.menubar===!0?dp:typeof e.menubar=="string"?e.menubar:null;this.menubar=y?fp(this,s,y,{...up,...e.menu}):null,this.menubar||s.remove(),this.toolbar=e.toolbar===!1||l&&e.toolbar===void 0?null:al(this,t,this.toolbarConfig(),e.toolbarMode??"sliding",{warnUnknown:u.loaders.length===0}),this.toolbar||t.remove(),!this.toolbar&&!this.menubar&&i.remove(),this.searchBar=Ap(this,o);let v=e.statusbar??this.mode==="classic";this.statusbar=v?nh(this,r):null,this.statusbar||r.remove(),e.onChange&&this.on("change",e.onChange),this.updatePlaceholder(),this.ready=u.loaders.length?this.loadLazyPlugins(u.loaders):Promise.resolve()}isAllowed(e){return this.contentRules?.isAllowed(e)??!0}hasPlugin(e){return this.pluginsByName.has(e)}buildSchema(e){let t={},o={};for(let r of e){for(let[i,s]of Object.entries(r.nodes??{}))i in t?Je(`Node "${i}" is defined by several plugins`):t[i]=s;for(let[i,s]of Object.entries(r.marks??{}))i in o?Je(`Mark "${i}" is defined by several plugins`):o[i]=s}try{return Ss({nodes:t,marks:o})}catch(r){return Je("Failed to build the document schema from plugins",r),Ss()}}collectPmPlugins(e){try{return e.prosemirrorPlugins?.(this)??[]}catch(t){return Je(`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){Je(`Plugin "${e.name}" failed during setup`,t)}}async loadLazyPlugins(e){let t=await Promise.all(e.map(l=>Sl(l).catch(a=>(Je("Failed to load plugin",a),null))));if(this.destroyed)return;let o=t.filter(l=>l?l.nodes||l.marks?(Je(`Plugin "${l.name}" defines nodes or marks and cannot be loaded lazily; pass the plugin object instead`),!1):!0:!1),{ordered:r,errors:i}=oi(o,new Set(this.pluginsByName.keys()));i.forEach(l=>Je(l));let s=r.flatMap(l=>this.collectPmPlugins(l));if(s.length){let l=this.view.state;this.view.updateState(l.reconfigure({plugins:[...l.plugins,...s]}))}r.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=al(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?`${sl} | ${e.join(" ")}`:sl}handleTransaction(e,t=this.view){if(!t.isDestroyed){for(let o of this.transactionTransforms)e=o(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"),(e.selectionSet||e.docChanged)&&this.emit("selectionChange"))}}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 c1.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,`
|
|
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,`
|
|
35
38
|
|
|
36
|
-
`)}setContent(e,{addToHistory:t=!0}={}){let o=Gr(this.schema,e),r=this.view.state.tr.replaceWith(0,this.view.state.doc.content.size,o.content);t||r.setMeta("addToHistory",!1),this.view.dispatch(r)}isEmpty(){return this.view.dom.classList.contains("nova-empty")}resolveCommand(e){return this.commandOverrides.get(e)??G[e]}registerCommands(e){for(let[t,o]of Object.entries(e.commands??{}))o&&this.commandOverrides.set(t,o);e.transformTransaction&&this.transactionTransforms.push(e.transformTransaction)}exec(e){let o=(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,this.view.dispatch,this.view);return o&&this.view.focus(),o}can(e){return(typeof e=="string"?this.resolveCommand(e):e)(this.view.state,void 0,this.view)}isActive(e){return Td(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}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 o=this.listeners.get(e);return o||this.listeners.set(e,o=new Set),o.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){Je("Plugin cleanup failed",t)}this.searchBar.destroy(),this.root.classList.contains("nova-fullscreen")&&Co(this,!1),this.view.destroy(),this.root.remove(),this.listeners.clear()}}}});function rh(n){let e=[];return n.descendants((t,o)=>{if(!t.isTextblock)return!0;let r="",i=[];return t.forEach((s,l)=>{let a=o+1+l;if(s.isText){for(let c=0;c<s.text.length;c+=1)i.push(a+c);r+=s.text}else{let c=s.type.spec.leafText?.(s)??" ";for(let u=0;u<c.length;u+=1)i.push(a);r+=c}}),e.push({pos:o,end:o+t.nodeSize-1,depth:n.resolve(o).depth,type:t.type.name,text:r,chars:i}),!1}),e}function sh(n,e,t){let o=n.length,r=e.length;if((o+1)*(r+1)>2e6)return null;let i=new Uint32Array((o+1)*(r+1)),s=(u,d)=>u*(r+1)+d;for(let u=o-1;u>=0;u-=1)for(let d=r-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<o&&c<r;)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 Xr(n,e,t){if(e>=t)return;let o=n.added[n.added.length-1];o&&o.to>=e?o.to=Math.max(o.to,t):n.added.push({from:e,to:t})}function u1(n,e,t){if(e.text===t.text){e.text&&Xr(n,e.chars[0],e.end);return}let o=ih(e.text),r=ih(t.text),i=sh(o,r,(f,p)=>f===p);if(!i){e.text&&Xr(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 o)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=r.slice(u,f).join("");if(h.trim()){let g=p<o.length?a(s[p]):e.end;n.removed.push({pos:g,text:h,block:!1})}u=f};for(let[f,p]of[...i,[o.length,r.length]]){for(;c<f;c+=1){if(!o[c].trim())continue;let h=s[c];Xr(n,a(h),a(h+o[c].length-1)+1)}d(p,f),c=f+1,u=p+1}}function d1(n,e,t){return e?t>=e.depth?e.pos:n.resolve(e.pos).before(t+1):n.content.size}function lh(n,e){let t={added:[],removed:[]},o=rh(n),r=rh(e),s=sh(o,r,(c,u)=>c.type===u.type&&c.text===u.text)??[],l=0,a=0;for(let[c,u]of[...s,[o.length,r.length]]){let d=o.slice(l,c),f=r.slice(a,u),p=Math.min(d.length,f.length);for(let h=0;h<p;h+=1)u1(t,d[h],f[h]);for(let h of d.slice(p))h.text&&Xr(t,h.chars[0],h.end);for(let h of f.slice(p))h.text.trim()&&t.removed.push({pos:d1(n,o[c],h.depth),text:h.text,block:!0});l=c+1,a=u+1}return t}var ih,ah=D(()=>{"use strict";ih=n=>n.split(/(\s+)/).filter(Boolean)});var dh={};He(dh,{default:()=>m1});function p1(n,e){let t=typeof e=="string"?e:f1.serializeFragment(Le.fromJSON(n.schema,e).content);return Gr(n.schema,t)}function h1(n,e){let t=W(n,uh),o=n.options.language??"en",r=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeStyle:"short"}),i=Se("nova-history-title"),s=[],l=null,a=null,c=!0,u=null,d=0,f=w("ol",{className:"nova-history-list","aria-label":t.versions}),p=w("div",{className:"nova-history-preview"}),h=w("p",{className:"nova-history-status",role:"status"}),g=w("button",{type:"button",className:"nova-button nova-button-primary",disabled:!0},t.restore),b=w("input",{type:"checkbox",checked:!0}),m=w("div",{className:"nova-history-legend"},w("label",{className:"nova-history-toggle"},b,t.highlight),w("span",{className:"nova-history-swatch is-added"},t.onlyHere),w("span",{className:"nova-history-swatch is-removed"},t.onlyNow)),y=e.save?w("button",{type:"button",className:"nova-button"},t.save):null,v=w("button",{type:"button",className:"nova-button"},t.close),M=w("section",{className:"nova-history",role:"region","aria-labelledby":i},w("header",{className:"nova-history-head"},w("h2",{id:i,className:"nova-history-title"},t.title),m,w("span",{className:"nova-history-spacer"}),y,g,v),w("div",{className:"nova-history-body"},p,w("aside",{className:"nova-history-side"},h,f))),T=z=>{if(!c||!l)return J.empty;let{added:I,removed:$}=lh(z,n.view.state.doc),le=[...I.map(fe=>te.inline(fe.from,fe.to,{class:"nova-diff-added"})),...$.map(fe=>te.widget(fe.pos,()=>w(fe.block?"div":"span",{className:"nova-diff-removed"},fe.text),{side:-1,ignoreSelection:!0}))];return J.create(z,le)},C=z=>{a=z;let I=gn.create({doc:z}),$=T(z);if(u){u.setProps({state:I,decorations:()=>$});return}u=new Xt(p,{state:I,editable:()=>!1,decorations:()=>$,attributes:{class:"nova-prosemirror nova-history-doc","aria-label":t.title,"aria-readonly":"true"}})},N=()=>{let z=[{revision:null,title:t.current,detail:""},...[...s].sort((I,$)=>$.createdAt-I.createdAt).map(I=>({revision:I,title:r.format(I.createdAt),detail:(I.authors??[]).join(", "),...I.label?{label:I.label}:{}}))];f.replaceChildren(...z.map(I=>{let $=I.revision?.id===l?.id&&!!I.revision==!!l,le=w("button",{type:"button",className:"nova-history-item","aria-current":$?"true":null,tabindex:$?"0":"-1","data-revision":I.revision?.id??"current"},w("span",{className:"nova-history-time"},I.title),I.label?w("span",{className:"nova-history-label"},I.label):null,I.detail?w("span",{className:"nova-history-authors"},I.detail):null);return le.addEventListener("click",()=>{S(I.revision),x()}),w("li",{},le)}))};function x(){f.querySelector('.nova-history-item[aria-current="true"]')?.focus()}async function S(z){l=z,N(),g.disabled=!0;let I=++d;if(!z){C(n.view.state.doc);return}h.textContent=t.loading;try{let $=await e.load(z,n);if(I!==d)return;C(p1(n,$)),h.textContent="",g.disabled=!n.isEditable()}catch{I===d&&(h.textContent=t.failed)}}async function E(){h.textContent=t.loading;try{s=(await e.list()).filter(z=>z&&typeof z.id=="string"),h.textContent=s.length?"":t.empty,N()}catch{h.replaceChildren(t.failed," ",w("button",{type:"button",className:"nova-link-btn",onClick:()=>{E()}},t.retry))}}function F(){u?.destroy(),M.remove(),n.root.classList.remove("nova-history-open"),n.focus()}return g.addEventListener("click",()=>{if(!l||!a)return;let z=l,{state:I}=n.view;n.view.dispatch(vd(I.tr.replaceWith(0,I.doc.content.size,a.content))),e.onRestore?.(z),n.ui.notify({text:t.restored.replace("{date}",r.format(z.createdAt)),type:"success"}),F()}),y?.addEventListener("click",async()=>{y.disabled=!0;try{await e.save(),n.ui.notify({text:t.saved,type:"success"}),await E(),x()}finally{y.disabled=!1}}),v.addEventListener("click",F),b.addEventListener("change",()=>{c=b.checked,a&&C(a)}),M.addEventListener("keydown",z=>{if(z.key==="Escape"){z.preventDefault(),F();return}let I=z.target;if(!I.classList.contains("nova-history-item")||z.key!=="ArrowDown"&&z.key!=="ArrowUp")return;z.preventDefault();let $=[...f.querySelectorAll(".nova-history-item")],le=$[$.indexOf(I)+(z.key==="ArrowDown"?1:-1)];le?.click(),f.querySelector(`[data-revision="${le?.dataset.revision}"]`)?.focus()}),n.ui.closeOverlays(),n.root.classList.add("nova-history-open"),n.root.append(M),S(null),E().then(()=>{f.querySelector(".nova-history-item")?.focus()}),{close:F,element:M}}var uh,ch,f1,m1,fh=D(()=>{"use strict";j();ce();Nr();U();Lt();dl();$r();Y();ah();Ce();uh={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"}},ch=k.history,f1=new gt;m1={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=W(n,uh),o=null,r=()=>{o?.element.isConnected||(o=h1(n,e))};return n.ui.registry.addButton("revisionhistory",{icon:ch,tooltip:t.button,onAction:r}),n.ui.registry.addMenuItem("revisionhistory",{text:t.button,icon:ch,onAction:r}),()=>o?.close()}}});Do();j();U();Ct();Y();Ce();var Ea=k.anchor,mm={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"}},Yo=/^[A-Za-z][\w.-]{0,63}$/,Aa={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 Yo.test(e)?{id:e}:!1}},{tag:"a[name]:not([href])",getAttrs:n=>{let e=n.getAttribute("name")??"";return Yo.test(e)?{id:e}:!1}}],toDOM:n=>["a",{id:Yo.test(n.attrs.id)?n.attrs.id:null}]}},setup(n){let e=W(n,mm),t=()=>{let{selection:r}=n.view.state;return r instanceof R&&r.node.type.name==="anchor"?r:null},o=()=>{let r=t(),i=ue({label:e.id,hint:e.hint,value:r?.node.attrs.id??""});n.ui.openDialog({title:e.title,body:w("div",{className:"nova-form"},i.el),submitLabel:e.save,onSubmit:()=>{let s=i.input.value.trim();if(!Yo.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:Ea,tooltip:e.title,isActive:()=>t()!==null,isEnabled:r=>r.isEditable(),onAction:o}),n.ui.registry.addMenuItem("anchor",{text:e.title,icon:Ea,onAction:o})}};j();U();Lt();ut();Kc();Ce();var Jg={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"}},Zi=/^[\w.@:+-]{1,128}$/,Gg=80,pr=n=>n.replace(/^@/,"").trim().slice(0,Gg);async function es(n,e,t=8){let o=await n(e);return Array.isArray(o)?o.filter(r=>r&&typeof r.id=="string"&&Zi.test(r.id)&&r.name).slice(0,t).map(r=>({id:r.id,name:pr(String(r.name)),...r.description?{description:String(r.description).slice(0,120)}:{}})):[]}var Jc={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 Zi.test(t)?{id:t,name:pr(e.textContent??"")}:!1}}],toDOM:n=>["span",{"data-mention":Zi.test(n.attrs.id)?n.attrs.id:null},`@${pr(String(n.attrs.name))}`],leafText:n=>`@${pr(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=W(n,Jg),o=e.maxResults??8,r=new Map;n.ui.registry.addAutocompleter("mentions",{trigger:"@",label:t.list,emptyText:t.empty,maxResults:o,fetch:async i=>{let s=await es(e.fetch,i,o);return r=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=r.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)}})}};Ce();var eb={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}"}},Qc=k.commentAdd,Zc=k.comments,hr="Mod-Alt-m",dt=new K("nova-comments"),rs=new WeakMap;function ns(n){return rs.get(n)}function eu(n){let e=new Map;return n.descendants((t,o)=>{if(t.isInline)for(let r of t.marks){if(r.type.name!=="comment")continue;let i=r.attrs.id,s=e.get(i)??[],l=s[s.length-1];l&&l.to===o?l.to=o+t.nodeSize:s.push({from:o,to:o+t.nodeSize}),e.set(i,s)}}),e}function tb(n){let{$from:e,empty:t}=n.selection;return(t?[...e.nodeBefore?.marks??[],...e.nodeAfter?.marks??[]]:e.nodeAfter?.marks??[]).filter(r=>r.type.name==="comment").map(r=>r.attrs.id)}var tu={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 uo.test(e)?{id:e}:!1}}],toDOM:n=>["span",{"data-comment":uo.test(n.attrs.id)?n.attrs.id:null},0]}},prosemirrorPlugins:n=>{let e=null;return[Fe({[hr]:()=>ns(n)?.startComment()??!1}),new _({key:dt,state:{init:()=>({pending:null,active:null}),apply(t,o){let r=t.getMeta(dt),i=o;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 r&&("pending"in r||"active"in r)&&(i={...i,...r}),i}},props:{decorations(t){let o=ns(n),r=dt.getState(t),i=o?.store.threads();if(e&&e.doc===t.doc&&e.threads===i&&e.state===r)return e.set;let s=new Set((i??[]).filter(c=>!c.resolved).map(c=>c.id)),l=[];for(let[c,u]of eu(t.doc)){if(!s.has(c))continue;let d=c===r.active?"nova-comment is-active":"nova-comment";for(let{from:f,to:p}of u)l.push(te.inline(f,p,{class:d}))}if(r.pending){let{from:c,to:u}=r.pending;l.push(te.inline(c,u,{class:"nova-comment is-active is-pending"}))}let a=J.create(t.doc,l);return e={doc:t.doc,threads:i,state:r,set:a},a}},view:()=>({update(t,o){if(o.selection.eq(t.state.selection)||o.doc!==t.state.doc)return;let r=ns(n);if(!r||dt.getState(t.state).pending)return;let i=new Set(r.store.threads().filter(l=>!l.resolved).map(l=>l.id)),s=tb(t.state).find(l=>i.has(l));s&&(s!==r.active()||!r.isPanelOpen())&&queueMicrotask(()=>{r.setActive(s),r.openPanel()})}})})]},setup(n){let e=W(n,eb),t=n.options.pluginOptions?.comments??{},o=t.store??jc(t.threads??[],t.onChange),r={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(S=>[S.id,S])).values()].filter(S=>C.includes(`@${S.name}`)),a=(C,N)=>{let x=l(C,N);return{id:Qi(),author:r,text:C,createdAt:Date.now(),...x.length?{mentions:x}:{}}},c=(C,N)=>{N.mentions?.length&&t.onMention?.({threadId:C,comment:N,users:N.mentions})},u=()=>dt.getState(n.view.state),d=C=>n.view.dispatch(n.view.state.tr.setMeta(dt,C)),f=null,p=!1,h=null,g=n.view.dom.parentElement,b=document.createElement("div");b.className="nova-body",g.parentElement.insertBefore(b,g),b.append(g);let m={editor:n,store:o,author:r,labels:e,shortcut:hr,pending:()=>u().pending,active:()=>u().active,setActive(C,N=!1){u().active!==C&&d({active:C}),f?.render();let x=C?m.ranges(C)[0]:void 0;if(N&&x){let{node:S}=n.view.domAtPos(x.from);(S instanceof Element?S:S.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}),m.openPanel().then(()=>{f?.render(),f?.focusComposer()}),!0)},cancelPending(){d({pending:null}),f?.render(),n.focus()},findUsers:s?C=>es(s,C):null,submitPending(C,N){let x=u().pending,S=C.trim().slice(0,5e3);if(!x||!S)return null;let E=Qi("t"),F=a(S,N);o.createThread({id:E,createdAt:F.createdAt,comments:[F],resolved:null});let{state:z}=n.view;return n.view.dispatch(z.tr.addMark(x.from,x.to,i().create({id:E})).setMeta(dt,{pending:null,active:E}).setMeta("addToHistory",!1)),f?.render(),c(E,F),E},reply(C,N,x){let S=N.trim().slice(0,5e3);if(!S)return;let E=a(S,x);o.reply(C,E),c(C,E)},ranges:C=>eu(n.view.state.doc).get(C)??[],quote(C){let{doc:N}=n.view.state;return m.ranges(C).map(({from:x,to:S})=>N.textBetween(x,S," ")).join(" \u2026 ")},positionOf:C=>m.ranges(C)[0]?.from??Number.MAX_SAFE_INTEGER,deleteThread(C){let{state:N}=n.view,x=N.tr;for(let{from:S,to:E}of m.ranges(C))x.removeMark(S,E,i().create({id:C}));u().active===C&&x.setMeta(dt,{active:null}),(x.docChanged||x.getMeta(dt))&&n.view.dispatch(x.setMeta("addToHistory",!1)),o.deleteThread(C)},setResolved(C,N){o.setResolved(C,N?{by:r,at:Date.now()}:null),N&&u().active===C&&d({active:null})},canEdit:C=>t.canEdit?t.canEdit(C,r):C.author.id===r.id,isPanelOpen:()=>p,async openPanel(){f||(h??=Promise.resolve().then(()=>(Yc(),Xc)).then(({createCommentsPanel:C})=>{n.view.isDestroyed||(f=C(m),b.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())}};rs.set(n,m);let y=o.subscribe(()=>{n.view.isDestroyed||(d({refresh:!0}),f?.render())}),v=()=>m.startComment(),M=()=>m.isPanelOpen()?m.closePanel():void m.openPanel(),T=C=>C.isEditable()&&!C.view.state.selection.empty;return n.ui.registry.addButton("addcomment",{icon:Qc,tooltip:e.add,shortcut:hr,isEnabled:T,onAction:v}),n.ui.registry.addToggleButton("showcomments",{icon:Zc,tooltip:e.show,isActive:()=>p,onAction:M}),n.ui.registry.addMenuItem("addcomment",{text:e.add,icon:Qc,shortcut:hr,isEnabled:T,onAction:v}),n.ui.registry.addMenuItem("showcomments",{text:e.show,icon:Zc,isActive:()=>p,onAction:M}),()=>{y(),f?.destroy(),rs.delete(n)}}};j();ce();U();Ge();Lt();ut();Ce();var nu=/^[A-Za-z0-9_-]{1,64}$/,cs=/^[\w.@:+-]{1,128}$/,is={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"}},ou=k.suggest,nb=k.review,ob=k.check,rb=k.close,fo=new K("nova-suggestions"),us="nova-suggestions-own",ru=["#1a7f37","#8250df","#bf3989","#0969da","#bc4c00","#1b7c83"];function ib(n){let e=0;for(let t of n)e=e*31+t.charCodeAt(0)|0;return ru[Math.abs(e)%ru.length]}function iu(){let n=new Uint8Array(9);return globalThis.crypto.getRandomValues(n),"s"+Array.from(n,e=>(e%36).toString(36)).join("")}function su(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 o=t,r=o.getAttribute("data-suggestion")??"";if(!nu.test(r))return!1;let i=o.getAttribute("data-author")??"";return{id:r,author:cs.test(i)?i:"",name:(o.getAttribute("data-name")??"").slice(0,80),time:Number(o.getAttribute("data-time"))||0}}}],toDOM:t=>[e,{"data-suggestion":nu.test(t.attrs.id)?t.attrs.id:null,"data-author":cs.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 ds=n=>({insert:n.marks.suggestion_insert,delete:n.marks.suggestion_delete});function sb(n){return!n.docChanged||n.getMeta(us)||n.getMeta("addToHistory")===!1||n.getMeta("history$")||n.getMeta("y-sync$")?.isChangeOrigin?!1:n.steps.every(t=>t instanceof ve)}function ss(n,e,t,o){let r=n.resolve(e);for(let i of[r.nodeBefore,r.nodeAfter]){let s=i?.marks.find(l=>l.type===t&&l.attrs.author===o);if(s)return s}return null}function au(n,e,t){let o=[];return n.forEach(r=>{r.isInline?o.push(t&&!t.allowsMarkType(e.type)?r:r.mark(e.addToSet(r.marks))):o.push(r.copy(au(r.content,e,r.type)))}),A.from(o)}function lb(n,e,t){if(!sb(n))return n;let o=ds(e.schema),r=e.tr,i=Date.now(),s=c=>c,l=null,a=null;if(n.steps.forEach(c=>{let u=c,d=r.steps.length,f=s,p=f(u.from),h=Math.max(p,f(u.to));if(h>p){let m=[],y=[];if(r.doc.nodesBetween(p,h,(T,C)=>{if(!T.isInline)return!0;let N=Math.max(C,p),x=Math.min(C+T.nodeSize,h);return N>=x||(T.marks.some(E=>E.type===o.insert&&E.attrs.author===t.id)?m.push({from:N,to:x}):o.delete.isInSet(T.marks)||y.push({from:N,to:x})),!1}),y.length){let T=y[0],C=ss(r.doc,T.from,o.delete,t.id)??ss(r.doc,y[y.length-1].to,o.delete,t.id)??o.delete.create({id:iu(),author:t.id,name:t.name,time:i});for(let N of y)r.addMark(N.from,N.to,C)}for(let T of m.reverse())r.delete(T.from,T.to);let v=r.mapping.slice(d);p=v.map(p,1),h=v.map(h,-1);let M=e.selection;n.steps.length===1&&u.slice.size===0&&M.empty&&M.from===u.from&&n.selection.head===u.from&&(l=h)}if(u.slice.size>0){let m=h;if(!u.slice.openStart)for(let T=r.doc.resolve(m).nodeAfter;T&&o.delete.isInSet(T.marks);)m+=T.nodeSize,T=r.doc.resolve(m).nodeAfter;let y=ss(r.doc,m,o.insert,t.id)??o.insert.create({id:iu(),author:t.id,name:t.name,time:i}),v=r.doc.resolve(m),M=au(u.slice.content,y,u.slice.openStart?null:v.parent.type);r.replace(m,m,new L(M,u.slice.openStart,u.slice.openEnd)),n.steps.length===1&&(a=m+u.slice.size)}let g=u.getMap().invert(),b=r.mapping.slice(d);s=m=>b.map(f(g.map(m,-1)),1)}),l!==null)r.setSelection(P.create(r.doc,l));else if(a!==null&&n.selection.empty)r.setSelection(P.create(r.doc,a));else{let c=s(n.selection.anchor),u=s(n.selection.head);try{r.setSelection(P.create(r.doc,c,u))}catch{}}for(let c of["addToHistory","uiEvent","paste","scrollIntoView"]){let u=n.getMeta(c);u!==void 0&&r.setMeta(c,u)}return n.scrolledIntoView&&r.scrollIntoView(),r}function po(n){let e=ds(n.type.schema),t=[];return n.descendants((o,r)=>{if(!o.isInline)return!0;for(let i of o.marks){let s=i.type===e.insert?"insert":i.type===e.delete?"delete":null;if(!s)continue;let l=t[t.length-1],a=o.isText?o.text:"";l&&l.id===i.attrs.id&&l.kind===s&&l.to===r?(l.to=r+o.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:r,to:r+o.nodeSize,text:a})}return!1}),t}function ls(n,e,t){let o=ds(n.schema),r=n.tr.setMeta(us,!0),i=po(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")?r.delete(s.from,s.to):r.removeMark(s.from,s.to,s.kind==="insert"?o.insert:o.delete);return r}function lu(n){let{from:e}=n.selection;return po(n.doc).find(t=>e>=t.from&&e<=t.to&&(t.to>e||t.from<e))??null}function En(n){return fo.getState(n)?.enabled??!1}function as(n,e){let{state:t,dispatch:o}=n.view;o(t.tr.setMeta(fo,{enabled:e}).setMeta(us,!0)),n.updateUI()}var cu={name:"suggestions",toolbar:"suggestions reviewsuggestions",marks:{suggestion_insert:su("insert"),suggestion_delete:su("delete")},prosemirrorPlugins:n=>{let e=n.options.pluginOptions?.suggestions??{},t=null;return[new _({key:fo,state:{init:()=>({enabled:!!(e.enabled||e.force)}),apply(o,r){let i=o.getMeta(fo);return i?{enabled:e.force?!0:i.enabled}:r}},props:{attributes:o=>fo.getState(o)?.enabled?{class:"nova-suggesting"}:{},decorations(o){if(t?.doc===o.doc)return t.set;let r=W(n,is),i=new Intl.DateTimeFormat(n.options.language??"en",{dateStyle:"medium",timeStyle:"short"}),s=J.create(o.doc,po(o.doc).map(l=>te.inline(l.from,l.to,{title:(l.kind==="insert"?r.inserted:r.deleted).replace("{name}",l.author.name||r.guest)+(l.time?` \xB7 ${i.format(l.time)}`:""),class:l.kind==="insert"?"nova-sugg-insert":"nova-sugg-delete",style:`--nova-suggestion: ${ib(l.author.id||l.author.name)}`})));return t={doc:o.doc,set:s},s}}}),Fe({"Mod-Alt-Shift-e":()=>e.force?!1:(as(n,!En(n.view.state)),!0)})]},transformTransaction(n,e,t){if(!En(e))return n;let o=t.options.pluginOptions?.suggestions??{},r=W(t,is),i={id:cs.test(o.author?.id??"")?o.author.id:"guest",name:String(o.author?.name||r.guest).slice(0,80)};return lb(n,e,i)},setup(n){let e=n.options.pluginOptions?.suggestions??{},t=W(n,is),o=e.canReview!==!1,r=c=>n.view.dispatch(c),i=()=>lu(n.view.state),s=c=>{let u=i();u&&r(ls(n.view.state,c,[u.id])),n.focus()},l=c=>{let{state:u}=n.view,d=po(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}r(u.tr.setSelection(P.create(u.doc,p.from)).scrollIntoView()),n.focus()},a=()=>po(n.view.state.doc).length>0;n.ui.registry.addToggleButton("suggestions",{icon:ou,tooltip:t.toggle,shortcut:"Mod-Alt-Shift-e",isActive:c=>En(c.view.state),isEnabled:()=>!e.force,onAction:c=>as(c,!En(c.view.state))}),n.ui.registry.addMenuButton("reviewsuggestions",{icon:nb,tooltip:t.review,isEnabled:a,items:()=>[{id:"next",label:t.next,onSelect:()=>l(1)},{id:"previous",label:t.previous,onSelect:()=>l(-1)},...o?[{type:"separator"},{id:"accept-all",label:t.acceptAll,onSelect:()=>r(ls(n.view.state,"accept"))},{id:"reject-all",label:t.rejectAll,onSelect:()=>r(ls(n.view.state,"reject"))}]:[]]}),o&&(n.ui.registry.addButton("acceptsuggestion",{icon:ob,text:t.accept,tooltip:t.accept,onAction:()=>s("accept")}),n.ui.registry.addButton("rejectsuggestion",{icon:rb,text:t.reject,tooltip:t.reject,onAction:()=>s("reject")}),n.ui.registry.addContextToolbar("suggestion",{label:t.toolbar,predicate:c=>lu(c.view.state)!==null,items:"acceptsuggestion rejectsuggestion",position:"selection",placement:"bottom-start",priority:20})),n.ui.registry.addMenuItem("suggestions",{text:t.toggle,icon:ou,isActive:c=>En(c.view.state),isEnabled:()=>!e.force,onAction:c=>as(c,!En(c.view.state))})}};j();U();ht();Ct();Y();Ce();var dy=/^https?:\/\/(?:www\.|m\.)?(?:youtube(?:-nocookie)?\.com\/(?:watch\?(?:[^#]*&)?v=|embed\/|shorts\/|live\/)|youtu\.be\/)([\w-]{11})(?:[?&#]|$)/i,fy=/^https?:\/\/(?:www\.|player\.)?vimeo\.com\/(?:video\/)?(\d{1,12})(?:[/?#]|$)/i,py=/^https:\/\/[^\s"'<>]+\.(?:mp4|webm|ogv|ogg)(?:\?[^\s"'<>#]*)?$/i;function Cr(n){let e=n.trim(),t=e.match(dy);if(t)return{kind:"youtube",src:`https://www.youtube-nocookie.com/embed/${t[1]}`};let o=e.match(fy);return o?{kind:"vimeo",src:`https://player.vimeo.com/video/${o[1]}`}:py.test(e)?{kind:"video",src:e}:null}var Gu=k.media,hy={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 Xu(n,e){let t=e?Cr(e):null;return t?{...t,width:Ie(n.getAttribute("width"))??560,height:Ie(n.getAttribute("height"))??315,title:n.getAttribute("title")??""}:!1}function my(n){let e=Cr(n.attrs.src);if(!e)return null;let t=String(Ie(n.attrs.width)??560),o=String(Ie(n.attrs.height)??315);return e.kind==="video"?w("video",{src:e.src,controls:!0,width:t,height:o,preload:"metadata"}):w("iframe",{src:e.src,width:t,height:o,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 Yu={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=>Xu(n,n.getAttribute("src"))},{tag:"video",getAttrs:n=>{let e=n,t=e.getAttribute("src")??e.querySelector("source[src]")?.getAttribute("src")??null;return Xu(e,t)}}],toDOM:n=>{let e=Cr(n.attrs.src),t=String(Ie(n.attrs.width)??560),o=String(Ie(n.attrs.height)??315);return e?e.kind==="video"?["video",{src:e.src,controls:"",width:t,height:o}]:["iframe",{src:e.src,width:t,height:o,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=my(n);return{dom:w("div",{className:"nova-media",contenteditable:"false"},e,w("div",{className:"nova-media-overlay","aria-hidden":"true"})),ignoreMutation:()=>!0,stopEvent:()=>!1}}}}})],setup(n){let e=W(n,hy),t=()=>{let{selection:r}=n.view.state;return r instanceof R&&r.node.type.name==="media"?r:null},o=()=>{let r=t(),i=ue({label:e.url,type:"url",placeholder:"https://",hint:e.hint,value:r?.node.attrs.src??""}),s=ue({label:e.name,value:r?.node.attrs.title??""});n.ui.openDialog({title:e.title,body:w("div",{className:"nova-form"},i.el,s.el),submitLabel:e.save,onSubmit:()=>{let l=Cr(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:Gu,tooltip:e.title,isActive:()=>t()!==null,isEnabled:r=>r.isEditable(),onAction:o}),n.ui.registry.addMenuItem("media",{text:e.title,icon:Gu,onAction:o})}};j();Ce();var Qu=k.pageBreak,gy={en:{title:"Page break"},ru:{title:"\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B"}},Zu={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}=W(n,gy),t=()=>{let{state:o,dispatch:r}=n.view,i=n.schema.nodes.pagebreak;r(o.tr.replaceSelectionWith(i.create()).scrollIntoView()),n.focus()};n.ui.registry.addButton("pagebreak",{icon:Qu,tooltip:e,isEnabled:o=>o.isEditable(),onAction:t}),n.ui.registry.addMenuItem("pagebreak",{text:e,icon:Qu,onAction:t})}};ae("insertdatetime",()=>Promise.resolve().then(()=>(rd(),od)));ae("quickbars",()=>Promise.resolve().then(()=>(Zd(),Qd)));ae("charmap",()=>Promise.resolve().then(()=>(nf(),tf)));ae("emoticons",()=>Promise.resolve().then(()=>(lf(),sf)));ae("nonbreaking",()=>Promise.resolve().then(()=>(df(),uf)));ae("autolink",()=>Promise.resolve().then(()=>(yf(),bf)));ae("autosave",()=>Promise.resolve().then(()=>(xf(),wf)));ae("autoresize",()=>Promise.resolve().then(()=>(Mf(),kf)));ae("visualblocks",()=>Promise.resolve().then(()=>(Ef(),Cf)));ae("anchor",Aa);ae("pagebreak",Zu);ae("media",Yu);ae("comments",tu);ae("mentions",Jc);ae("suggestions",cu);ae("directionality",()=>Promise.resolve().then(()=>(Of(),Nf)));ae("advlist",()=>Promise.resolve().then(()=>(Df(),Lf)));ae("revisionhistory",()=>Promise.resolve().then(()=>(fh(),dh)));dl();Gs();rl();Do();j();$r();var g1=0,ph=()=>`nova-compat-field-${++g1}`;function se(n,e,t){let o=document.createElement(n);return e&&(o.className=e),t!==void 0&&(o.textContent=t),o}function b1(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 o of[...t.attributes]){let r=o.value.trim().toLowerCase();(o.name.startsWith("on")||/^(javascript|vbscript|data):/.test(r))&&t.removeAttribute(o.name)}}),e.content}function hh(n,e,t){let o=new Map,r=new Map,i="",s=!1,l=null,a=b=>e.onChange?.(g,{name:b});function c(b,m){let y=ph();m.id=y;let v=se("div","nova-field");if(b.label){let M=se("label","nova-label",b.label);M.htmlFor=y,v.append(M)}return v.append(m),v}function u(b){let m=b.name??"",y=b.enabled!==!1&&b.disabled!==!0;switch(b.type){case"input":case"urlinput":case"colorinput":{let v=se("input","nova-input");return v.type=b.type==="colorinput"?"color":b.type==="urlinput"?"url":"text",b.inputMode&&(v.inputMode=b.inputMode),b.placeholder&&(v.placeholder=b.placeholder),v.disabled=!y,v.addEventListener("input",()=>a(m)),m&&o.set(m,{get:()=>b.type==="urlinput"?{value:v.value}:v.value,set:M=>{v.value=String(b.type==="urlinput"&&M&&typeof M=="object"?M.value??"":M??"")},focus:()=>v.focus(),setEnabled:M=>v.disabled=!M}),c(b,v)}case"textarea":{let v=se("textarea","nova-input");return v.rows=b.maximized?10:4,b.placeholder&&(v.placeholder=b.placeholder),v.disabled=!y,v.addEventListener("input",()=>a(m)),m&&o.set(m,{get:()=>v.value,set:M=>v.value=String(M??""),focus:()=>v.focus(),setEnabled:M=>v.disabled=!M}),c(b,v)}case"checkbox":{let v=se("input","nova-checkbox");v.type="checkbox",v.id=ph(),v.disabled=!y,v.addEventListener("change",()=>a(m));let M=se("label",void 0,b.label??"");M.htmlFor=v.id,m&&o.set(m,{get:()=>v.checked,set:C=>v.checked=!!C,focus:()=>v.focus(),setEnabled:C=>v.disabled=!C});let T=se("div","nova-field nova-field-inline");return T.append(v,M),T}case"selectbox":case"listbox":{let v=se("select","nova-input nova-select");for(let M of b.items??[]){let T=se("option",void 0,M.text);T.value=M.value,v.append(T)}return v.disabled=!y,v.addEventListener("change",()=>a(m)),m&&o.set(m,{get:()=>v.value,set:M=>v.value=String(M??""),focus:()=>v.focus(),setEnabled:M=>v.disabled=!M}),c(b,v)}case"button":{let v=se("button",b.primary||b.buttonType==="primary"?"nova-button nova-button-primary":"nova-button",b.text??"");return v.type="button",v.disabled=!y,v.addEventListener("click",()=>e.onAction?.(g,{name:m})),m&&o.set(m,{get:()=>{},set:()=>{},focus:()=>v.focus(),setEnabled:M=>v.disabled=!M}),v}case"htmlpanel":{let v=se("div","nova-compat-html");return v.append(b1(b.html??"")),v}case"alertbanner":{let v=se("p",`nova-compat-alert is-${b.level??"info"}`,b.text??"");return v.setAttribute("role",b.level==="error"?"alert":"status"),v}case"label":{let v=se("div","nova-compat-group");v.append(se("p","nova-label",b.label??""));for(let M of b.items??[]){let T=u(M);T&&v.append(T)}return v}case"grid":case"bar":{let v=se("div","nova-compat-grid"),M=b.type==="bar"?b.items?.length??1:b.columns==="auto"?2:b.columns??2;v.style.gridTemplateColumns=`repeat(${Number(M)||2}, minmax(0, 1fr))`;for(let T of b.items??[]){let C=u(T);C&&v.append(C)}return v}default:return console.warn(`[nova] tinymce-compat: dialog component "${b.type}" is not supported yet`),null}}let d=se("div","nova-compat-dialog nova-form");if(e.body.type==="tabpanel"){let b=se("div","nova-compat-tabs");b.setAttribute("role","tablist"),d.append(b),e.body.tabs.forEach((m,y)=>{let v=m.name??m.title,M=se("button","nova-compat-tab",m.title);M.type="button",M.setAttribute("role","tab");let T=se("div","nova-compat-tabpanel");T.setAttribute("role","tabpanel");for(let C of m.items){let N=u(C);N&&T.append(N)}M.addEventListener("click",()=>g.showTab(v)),r.set(v,{button:M,panel:T}),b.append(M),d.append(T),y===0&&(i=v)})}else for(let b of e.body.items){let m=u(b);m&&d.append(m)}let f=e.buttons??[],p=f.find(b=>b.type==="submit"),h=f.filter(b=>b.type==="custom");if(h.length){let b=se("div","nova-compat-actions");for(let m of h){let y=se("button",m.primary?"nova-button nova-button-primary":"nova-button",m.text);y.type="button",y.disabled=m.enabled===!1,y.addEventListener("click",()=>e.onAction?.(g,{name:m.name??m.text})),m.name&&o.set(m.name,{get:()=>{},set:()=>{},focus:()=>y.focus(),setEnabled:v=>y.disabled=!v}),b.append(y)}d.append(b)}let g={getData:()=>{let b={};return o.forEach((m,y)=>{let v=m.get();v!==void 0&&(b[y]=v)}),b},setData:b=>{for(let[m,y]of Object.entries(b))o.get(m)?.set(y)},close:()=>{s=!0,l?.close()},block:()=>l?.setBusy(!0),unblock:()=>l?.setBusy(!1),focus:b=>o.get(b)?.focus(),disable:b=>o.get(b)?.setEnabled(!1),enable:b=>o.get(b)?.setEnabled(!0),showTab:b=>{if(!r.has(b))return;let m=i;i=b,r.forEach(({button:y,panel:v},M)=>{let T=M===b;y.setAttribute("aria-selected",String(T)),y.tabIndex=T?0:-1,v.hidden=!T}),m&&m!==b&&e.onTabChange?.(g,{newTabName:b,oldTabName:m})},redial:b=>{g.close(),Object.assign(g,t(b))}};return e.initialData&&g.setData(e.initialData),i&&g.showTab(i),l=n.ui.openDialog({title:e.title,body:d,...p?{submitLabel:p.text}:{},...e.size==="large"?{size:"large"}:{},onSubmit:()=>(e.onSubmit?.(g),s),onClose:()=>{s||e.onCancel?.(g),e.onClose?.()}}),g}ce();U();var y1=new gt,v1=new Set(["P","H1","H2","H3","H4","H5","H6","UL","OL","TABLE","BLOCKQUOTE","PRE","HR","DIV","FIGURE"]),Yr={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"},w1={p:"paragraph",h1:"h1",h2:"h2",h3:"h3",h4:"h4",h5:"h5",h6:"h6",blockquote:"blockquote",pre:"codeBlock"},x1={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"},fl={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"},k1=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre"]),M1=new Set(["p","h1","h2","h3","h4","h5","h6","blockquote","pre","alignleft","aligncenter","alignright","alignjustify"]),pl={forecolor:"color",hilitecolor:"background",fontname:"font_family",fontsize:"font_size"};function No(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 Qr=new Map;function hl(n){if(typeof n!="string"||!n)return;if(Qr.has(n))return Qr.get(n);let e=x1[n]??(n in k?n:void 0);return e?k[e]:void 0}function S1(n){let e=!1,t=!0;return{state:{get active(){return e},get enabled(){return t}},api:{isActive:()=>e,setActive:o=>{e=o,n.core.updateUI()},isEnabled:()=>t,setEnabled:o=>{t=o,n.core.updateUI()},isDisabled:()=>!t,setDisabled:o=>{t=!o,n.core.updateUI()}}}}var Oo=class{id;core;targetElm;settings;initialized=!1;removed=!1;handlers=new Map;dirty=!1;teardowns=[];constructor(e,t,o,r){this.core=e,this.targetElm=t,this.id=o,this.settings=r}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 o={content:e,...t};return this.fire("BeforeSetContent",o),this.core.setContent(o.content),this.fire("SetContent",o),o.content}insertContent(e){let t=document.createElement("template");t.innerHTML=e;let o=document.createElement("div");o.append(t.content);let r=ln(this.core.schema),s=[...o.children].some(c=>v1.has(c.tagName))?new L(r.parse(o).content,0,0):r.parseSlice(o),{state:l,dispatch:a}=this.core.view;a(l.tr.replaceSelection(s).scrollIntoView())}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,o){let r=e.toLowerCase(),i=!1;if(Yr[r])i=this.core.exec(Yr[r]);else if(r==="formatblock"||r==="mcetoggleformat"){let s=w1[String(o??"").toLowerCase()];i=s?this.core.exec(s):!1}else if(r==="mceinsertcontent"||r==="inserthtml")this.insertContent(String(o??"")),i=!0;else if(r==="mcesetcontent")this.setContent(String(o??"")),i=!0;else if(r==="selectall"){let{state:s,dispatch:l}=this.core.view;l(s.tr.setSelection(new me(s.doc))),i=!0}else if(r==="mcecleanup")i=!0;else{let s=this.commands.get(r);s&&(s(t,o),i=!0)}return i&&this.fire("ExecCommand",{command:e,ui:t,value:o}),i}queryCommandState(e){let t=Yr[e.toLowerCase()];return t?this.core.isActive(t):!1}queryCommandSupported(e){let t=e.toLowerCase();return t in Yr||["formatblock","mceinsertcontent","mcesetcontent"].includes(t)||this.commands.has(t)}commands=new Map;addCommand(e,t){this.commands.set(e.toLowerCase(),t)}on(e,t,o=!1){for(let r of e.toLowerCase().split(/\s+/).filter(Boolean)){let i=this.handlers.get(r)??new Set;o?this.handlers.set(r,new Set([t,...i])):this.handlers.set(r,i.add(t))}return this}off(e,t){if(!e)return this.handlers.clear(),this;for(let o of e.toLowerCase().split(/\s+/).filter(Boolean))t?this.handlers.get(o)?.delete(t):this.handlers.delete(o);return this}once(e,t){let o=r=>(this.off(e,o),t(r));return this.on(e,o)}fire(e,t={}){let o=Object.assign(t,{type:e.toLowerCase(),target:this});for(let r of[...this.handlers.get(e.toLowerCase())??[]])try{r(o)}catch(i){console.error(`[nova] tinymce-compat: "${e}" handler failed`,i)}return o}fireNative(e,t){for(let o of[...this.handlers.get(e)??[]])try{o(t)}catch(r){console.error(`[nova] tinymce-compat: "${e}" handler failed`,r)}}static registerIcon(e,t){Qr.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,!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:o,to:r}=t.selection;return e.format==="text"?t.doc.textBetween(o,r,`
|
|
37
|
-
`):y1.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:o}=this.core.view,r=e?t.selection.from:t.selection.to;o(t.tr.setSelection(P.near(t.doc.resolve(r))))}};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 o=document.createElement("p");o.textContent=e,this.core.ui.openDialog({title:"",body:o,onSubmit:()=>!0,...t?{onClose:t}:{}})},confirm:(e,t)=>{let o=document.createElement("p");o.textContent=e;let r=!1;this.core.ui.openDialog({title:"",body:o,submitLabel:"OK",onSubmit:()=>(r=!0,!0),onClose:()=>t?.(r)})},open:e=>hh(this.core,e,t=>this.windowManager.open(t))};ui={registry:{addIcon:(e,t)=>{Qr.set(e,t)},addButton:(e,t)=>this.addButton(e,t,!1),addToggleButton:(e,t)=>this.addButton(e,t,!0),addMenuButton:(e,t)=>{let o=[];t.fetch(i=>o=i);let r=hl(t.icon);this.core.ui.registry.addMenuButton(e,{tooltip:t.tooltip??t.text??e,...r?{icon:r}:{text:t.text??e},items:()=>(t.fetch(i=>o=i),o.map((i,s)=>i.type==="separator"?{type:"separator"}:{id:`${e}-${s}`,label:i.text??"",onSelect:()=>i.onAction?.({})}))})},addMenuItem:(e,t)=>{let o=hl(t.icon);this.core.ui.registry.addMenuItem(e,{text:t.text??e,...o?{icon:o}:{},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 o=this.selection.getNode();return!!o&&this.getBody().contains(o)&&t.predicate(o)}})},addContextForm:()=>{console.warn("[nova] tinymce-compat: addContextForm is not supported yet")},getAll:()=>({})}};addButton(e,t,o){let{api:r,state:i}=S1(this);t.enabled===!1&&r.setEnabled(!1),t.active&&r.setActive(!0);let s=hl(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,...o?{isActive:()=>i.active}:{},onAction:()=>t.onAction?.(r)}),t.onSetup){let l=()=>{let a=t.onSetup(r);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 o=e instanceof Element?e:e?.parentElement??null;for(;o&&o!==this.getBody();){if(typeof t=="string"?o.matches(t):t(o))return o;o=o.parentElement}return null},getParents:(e,t)=>{let o=[],r=e instanceof Element?e:e?.parentElement??null;for(;r&&r!==this.getBody();)(!t||r.matches(t))&&o.push(r),r=r.parentElement;return o},is:(e,t)=>!!e?.matches(t),getAttrib:(e,t,o="")=>e?.getAttribute(t)??o,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={},o)=>{let r=document.createElement(e);for(let[i,s]of Object.entries(t))i.startsWith("on")||r.setAttribute(i,s);return o!==void 0&&(r.textContent=o),r},uniqueId:(e="mce_")=>`${e}${Math.random().toString(36).slice(2,10)}`,setAttrib:()=>No("setAttrib"),addClass:()=>No("addClass"),removeClass:()=>No("removeClass"),setStyle:()=>No("setStyle"),remove:()=>No("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=>{let t=e.toLowerCase();if(k1.has(t))return this.blockMatches(t);let o=fl[t];if(o)return this.core.isActive(o);let r=pl[t];if(!r)return!1;let{state:i}=this.core.view,{from:s,to:l,empty:a}=i.selection,c=i.schema.marks[r];return a||!c?ot(i,r)!==null:i.doc.rangeHasMark(s,l,c)},canApply:e=>e.toLowerCase()in fl||e.toLowerCase()in pl,register:e=>{console.warn(`[nova] tinymce-compat: formatter.register("${e}") is not supported yet`)}};blockMatches(e){let{$from:t}=this.core.view.state.selection;for(let r=t.depth;r>0;r-=1){let i=t.node(r),s=i.type.name;if(e==="blockquote"&&s==="blockquote")return!0;if(r===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 o=null;if(this.core.view.state.doc.descendants(r=>o||!r.isTextblock?!o:(o={name:r.type.name,level:r.attrs.level},!1)),!t.depth&&o){let r=o;if(e==="p")return r.name==="paragraph";if(e==="pre")return r.name==="code_block";if(/^h[1-6]$/.test(e))return r.name==="heading"&&r.level===Number(e[1])}return!1}applyFormat(e,t,o){let r=e.toLowerCase(),i=fl[r];if(i){let l=this.formatter.match(r);M1.has(r)?o==="apply"?this.core.exec(i):l&&this.core.exec("paragraph"):o==="apply"!==l&&this.core.exec(i);return}let s=pl[r];if(s){this.core.exec(bt(s,o==="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 C1=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"]),E1={tinycomments:"comments"},A1=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","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"]),T1=n=>(Array.isArray(n)?n.join(" "):String(n??"")).split(/[\s,]+/).filter(Boolean);function ml(n){if(typeof n=="string")return n.split(";").map(e=>e.trim()).filter(Boolean).map(e=>{let[t,o]=e.includes("=")?e.split("="):[e,e];return{label:t.trim(),value:(o??t).trim()}})}function N1(n){let e="",t=new Promise(r=>{let i=new FileReader;i.onload=()=>{e=String(i.result).replace(/^data:[^,]*,/,""),r()},i.onerror=()=>r(),i.readAsDataURL(n)}),o="";return{ready:t,info:{id:()=>n.name.replace(/\.[^.]+$/,"")||"image",name:()=>n.name.replace(/\.[^.]+$/,"")||"image",filename:()=>n.name||"image",blob:()=>n,base64:()=>e,blobUri:()=>o||=URL.createObjectURL(n),uri:()=>{}}}}function mh(n){let e=Object.keys(n).filter(c=>!A1.has(c)),t=[],o=[];for(let c of T1(n.plugins)){let u=E1[c]??c;C1.has(c)||(ni(u)?t.push(u):o.push(c))}let r={plugins:t};if(n.toolbar===!1?r.toolbar=!1:Array.isArray(n.toolbar)?r.toolbar=n.toolbar.join(" | "):typeof n.toolbar=="string"&&(r.toolbar=n.toolbar),n.menubar!==void 0&&(r.menubar=n.menubar),typeof n.statusbar=="boolean"&&(r.statusbar=n.statusbar),typeof n.placeholder=="string"&&(r.placeholder=n.placeholder),n.readonly===!0&&(r.editable=!1),typeof n.language=="string"&&(r.language=n.language.replace("_","-")),n.toolbar_mode==="sliding"||n.toolbar_mode==="wrap"?r.toolbarMode=n.toolbar_mode:(n.toolbar_mode==="floating"||n.toolbar_mode==="scrolling")&&(r.toolbarMode="sliding"),n.inline===!0&&(r.mode="inline"),n.paste_as_text===!0&&(r.pasteAsText=!0),typeof n.paste_preprocess=="function"){let c=n.paste_preprocess;r.pastePreprocess=(u,d)=>{let f={content:u};return c(d,f),f.content}}typeof n.invalid_elements=="string"&&(r.invalidElements=n.invalid_elements),typeof n.valid_elements=="string"&&(r.validElements=n.valid_elements),n.valid_styles&&(r.validStyles=n.valid_styles);let i=ml(n.font_family_formats);i&&(r.fontFamilies=i);let s=ml(n.font_size_formats);s&&(r.fontSizes=s.map(c=>c.value));let l=ml(n.line_height_formats);if(l&&(r.lineHeights=l.map(c=>c.value)),Array.isArray(n.color_map)&&(r.colors=n.color_map.filter((c,u)=>u%2===0).map(c=>c.startsWith("#")?c:`#${c}`)),typeof n.images_upload_handler=="function"){let c=n.images_upload_handler,u=async(d,f)=>{let{ready:p,info:h}=N1(d);return await p,c(h,f)};r.uploadImage=u}let a={};if(n.autosave_interval||n.autosave_retention||n.autosave_prefix){let c=u=>parseInt(String(u),10);a.autosave={...n.autosave_interval?{delay:c(n.autosave_interval)*1e3}:{},...n.autosave_retention?{retention:c(n.autosave_retention)}:{},...n.autosave_prefix?{key:String(n.autosave_prefix)}:{}}}if((n.quickbars_selection_toolbar!==void 0||n.quickbars_insert_toolbar!==void 0)&&(a.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 c=n.mentions_fetch;a.mentions={fetch:u=>new Promise(d=>c({term:u},d))}}return n.tinycomments_author&&(a.comments={author:{id:String(n.tinycomments_author),name:String(n.tinycomments_author_name??n.tinycomments_author)}}),Object.keys(a).length&&(r.pluginOptions=a),{options:r,unknown:e,missingPlugins:o}}var gh=new Set;function gl(n){gh.has(n)||(gh.add(n),console.warn(`[nova] tinymce-compat: ${n}`))}var bh=0;function O1(n,e){let t=`nova-compat-${++bh}`;n.root.classList.add(t);let o=document.createElement("style");o.setAttribute("data-nova-compat",t),o.textContent=`.${t} .nova-prosemirror { ${e.replace(/\b(html|body)\b/g,"&")} }`,n.root.prepend(o)}var Zr=n=>typeof n=="number"?`${n}px`:String(n);function L1(){let n=[],e=new Map,t=null;async function o(i,s){let l=n.find(C=>C.targetElm===i&&!C.removed);if(l)return l;let{options:a,unknown:c,missingPlugins:u}=mh(s);c.length&&gl(`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&&gl(`plugins not available: ${f.join(", ")}`);let p=i.id||`mce_${++bh}`;i.id||(i.id=p);let h=i instanceof HTMLTextAreaElement,g=h?i.value:i.innerHTML,b={...s,__initialContent:g},m;s.inline===!0&&!h?(i.replaceChildren(),m=i):(m=document.createElement("div"),m.className="nova-compat",i.after(m),i.hidden=!0,b.__wrapper=m);let y,v=ul({...a,element:m,content:g,setup:C=>{y=new Oo(C,i,p,b);for(let N of d)try{e.get(N)(y,"")}catch(x){console.error(`[nova] tinymce-compat: plugin "${N}" failed`,x)}s.setup?.(y)}});s.height!==void 0&&(v.root.style.height=Zr(s.height)),s.min_height!==void 0&&(v.root.style.minHeight=Zr(s.min_height)),s.max_height!==void 0&&(v.root.style.maxHeight=Zr(s.max_height)),s.width!==void 0&&(v.root.style.width=Zr(s.width)),typeof s.content_style=="string"&&O1(v,s.content_style);let M=!1;v.on("change",()=>{y.setDirty(!0),M=!0,y.fire("input")}),v.on("selectionChange",()=>{y.fire("NodeChange",{element:y.selection.getNode(),selectionChange:!0})}),v.on("focus",()=>{t=y,M=!1,y.fire("focus")}),v.on("blur",()=>{M&&y.fire("change",{level:{content:y.getContent()}}),M=!1,y.fire("blur")});for(let C of["keydown","keyup","keypress","click","dblclick","mousedown","mouseup","paste","copy","cut","drop"])v.view.dom.addEventListener(C,N=>y.fireNative(C,N));return(h?i.form:i.closest("form"))?.addEventListener("submit",()=>y.save()),y.on("remove",()=>{let C=n.indexOf(y);C>=0&&n.splice(C,1),t===y&&(t=n[0]??null)}),n.push(y),t??=y,await v.ready,y.removed||(y.initialized=!0,y.fire("init"),s.init_instance_callback?.(y)),y}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||gl(`no elements match "${i.selector??""}"`);let l=[];for(let a of s)l.push(await o(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??{}))Oo.registerIcon(l,a)}},util:{I18n:{translate:i=>i}}}}var yh=L1();var vh=document.currentScript;if(vh?.src&&!document.querySelector("link[data-novaprose-css]")){let n=document.createElement("link");n.rel="stylesheet",n.href=vh.src.replace(/[^/]*$/,"novaprose.css"),n.setAttribute("data-novaprose-css",""),document.head.append(n)}window.tinymce=yh;})();
|
|
38
|
-
//# 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
|