@vonage/vivid 5.7.0 → 5.9.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/bundled/data-grid.options.cjs +1 -0
- package/bundled/data-grid.options.js +29 -0
- package/bundled/definition19.cjs +3 -4
- package/bundled/definition19.js +35 -52
- package/bundled/definition2.cjs +1 -1
- package/bundled/definition2.js +1 -1
- package/bundled/definition3.cjs +1 -1
- package/bundled/definition3.js +1 -1
- package/bundled/definition8.cjs +1 -1
- package/bundled/definition8.js +1 -1
- package/bundled/definition9.cjs +9 -9
- package/bundled/definition9.js +113 -1342
- package/bundled/feature.cjs +4 -0
- package/bundled/feature.js +2886 -0
- package/bundled/floating-ui.dom.cjs +1 -0
- package/bundled/floating-ui.dom.js +1242 -0
- package/bundled/listbox.cjs +1 -1
- package/bundled/listbox.js +49 -22
- package/bundled/localized.cjs +1 -1
- package/bundled/localized.js +15 -13
- package/bundled/vivid-element.cjs +3 -3
- package/bundled/vivid-element.js +89 -69
- package/checkbox/definition.cjs +1 -1
- package/checkbox/definition.js +1 -1
- package/combobox/definition.cjs +14 -15
- package/combobox/definition.js +15 -16
- package/combobox/index.cjs +4 -4
- package/combobox/index.js +82 -87
- package/contextual-help/definition.cjs +1 -0
- package/contextual-help/definition.js +1 -1
- package/custom-elements.json +5145 -3781
- package/data-grid/definition.cjs +23 -49
- package/data-grid/definition.js +1 -27
- package/data-grid/index.cjs +27 -27
- package/data-grid/index.js +44 -64
- package/data-table/definition.cjs +204 -0
- package/data-table/definition.js +188 -0
- package/data-table/index.cjs +37 -0
- package/data-table/index.js +143 -0
- package/file-picker/definition.cjs +10 -8
- package/file-picker/definition.js +10 -8
- package/file-picker/index.cjs +5 -5
- package/file-picker/index.js +12 -12
- package/icon/definition.cjs +1 -1
- package/icon/definition.js +1 -1
- package/index.cjs +26 -0
- package/index.js +4 -0
- package/lib/components.d.ts +4 -0
- package/lib/contextual-help/definition.d.ts +2 -0
- package/lib/data-table/definition.d.ts +8 -0
- package/lib/data-table/table-body.d.ts +3 -0
- package/lib/data-table/table-body.template.d.ts +3 -0
- package/lib/data-table/table-cell.d.ts +381 -0
- package/lib/data-table/table-cell.template.d.ts +3 -0
- package/lib/data-table/table-head.d.ts +3 -0
- package/lib/data-table/table-head.template.d.ts +3 -0
- package/lib/data-table/table-header-cell.d.ts +381 -0
- package/lib/data-table/table-header-cell.template.d.ts +3 -0
- package/lib/data-table/table-row.d.ts +381 -0
- package/lib/data-table/table-row.template.d.ts +3 -0
- package/lib/data-table/table.d.ts +3 -0
- package/lib/data-table/table.template.d.ts +3 -0
- package/lib/popover/definition.d.ts +4 -0
- package/lib/popover/locale.d.ts +3 -0
- package/lib/popover/popover.d.ts +781 -0
- package/lib/popover/popover.template.d.ts +3 -0
- package/lib/rich-text-editor/locale.d.ts +0 -1
- package/lib/rich-text-editor/rte/config.d.ts +3 -0
- package/lib/rich-text-editor/rte/document.d.ts +2 -0
- package/lib/rich-text-editor/rte/exports.d.ts +1 -0
- package/lib/rich-text-editor/rte/view.d.ts +30 -0
- package/lib/rich-text-view/definition.d.ts +4 -0
- package/lib/rich-text-view/rich-text-view.d.ts +15 -0
- package/lib/rich-text-view/rich-text-view.template.d.ts +3 -0
- package/lib/tag-name-map.d.ts +10 -1
- package/locales/de-DE.cjs +3 -1
- package/locales/de-DE.js +3 -1
- package/locales/en-GB.cjs +3 -1
- package/locales/en-GB.js +3 -1
- package/locales/en-US.cjs +3 -1
- package/locales/en-US.js +3 -1
- package/locales/ja-JP.cjs +3 -1
- package/locales/ja-JP.js +3 -1
- package/locales/zh-CN.cjs +3 -1
- package/locales/zh-CN.js +3 -1
- package/package.json +8 -12
- package/popover/definition.cjs +363 -0
- package/popover/definition.js +357 -0
- package/popover/index.cjs +27 -0
- package/popover/index.js +263 -0
- package/rich-text-editor/definition.cjs +328 -3882
- package/rich-text-editor/definition.js +143 -3697
- package/rich-text-editor/index.cjs +12 -15
- package/rich-text-editor/index.js +3489 -6291
- package/rich-text-view/definition.cjs +159 -0
- package/rich-text-view/definition.js +153 -0
- package/rich-text-view/index.cjs +1 -0
- package/rich-text-view/index.js +95 -0
- package/select/definition.cjs +27 -15
- package/select/definition.js +27 -15
- package/shared/foundation/listbox/listbox.d.ts +0 -1
- package/shared/localization/Locale.d.ts +2 -0
- package/tag/definition.cjs +1 -1
- package/tag/definition.js +1 -1
- package/tag/index.cjs +1 -1
- package/tag/index.js +1 -1
- package/unbundled/_commonjsHelpers.cjs +26 -0
- package/unbundled/_commonjsHelpers.js +26 -1
- package/unbundled/data-grid.options.cjs +34 -0
- package/unbundled/data-grid.options.js +28 -0
- package/unbundled/definition.cjs +1 -1
- package/unbundled/definition.js +1 -1
- package/unbundled/feature.cjs +3678 -0
- package/unbundled/feature.js +3662 -0
- package/unbundled/listbox.cjs +29 -2
- package/unbundled/listbox.js +29 -2
- package/unbundled/vivid-element.cjs +1 -1
- package/unbundled/vivid-element.js +1 -1
- package/video-player/definition.cjs +11 -1
- package/video-player/definition.js +12 -2
- package/video-player/index.cjs +30 -30
- package/video-player/index.js +705 -702
- package/vivid.api.json +1478 -39
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const me=require("../bundled/vivid-element.cjs"),Ua=require("../bundled/localized.cjs"),hs=require("../bundled/ref.cjs"),Gr=require("../bundled/definition9.cjs"),qa=require("../bundled/definition15.cjs"),No=require("../bundled/definition19.cjs"),Do=require("../bundled/definition12.cjs"),Ao=require("../bundled/definition3.cjs"),vo=require("../bundled/definition11.cjs"),Io=require("../bundled/definition6.cjs"),Ro=require("../bundled/definition7.cjs"),Po=require("../bundled/definition10.cjs"),Ja=require("../bundled/divider.cjs"),$a=require("../bundled/mixins.cjs"),Ka=":host{display:block}.rte{display:flex;flex-direction:column;block-size:100%}.editor{display:contents}.editor-viewport{position:relative;overflow:hidden;flex:1;contain:layout}.editor-scroll-area{--editor-padding-block: 8px;--editor-padding-inline: 16px;display:flex;flex-direction:column;background-color:var(--vvd-color-canvas);block-size:100%;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.editor-scroll-area{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}";function j(r){this.content=r}j.prototype={constructor:j,find:function(r){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===r)return e;return-1},get:function(r){var e=this.find(r);return e==-1?void 0:this.content[e+1]},update:function(r,e,t){var n=t&&t!=r?this.remove(t):this,i=n.find(r),s=n.content.slice();return i==-1?s.push(t||r,e):(s[i+1]=e,t&&(s[i]=t)),new j(s)},remove:function(r){var e=this.find(r);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new j(t)},addToStart:function(r,e){return new j([r,e].concat(this.remove(r).content))},addToEnd:function(r,e){var t=this.remove(r).content.slice();return t.push(r,e),new j(t)},addBefore:function(r,e,t){var n=this.remove(e),i=n.content.slice(),s=n.find(r);return i.splice(s==-1?i.length:s,0,e,t),new j(i)},forEach:function(r){for(var e=0;e<this.content.length;e+=2)r(this.content[e],this.content[e+1])},prepend:function(r){return r=j.from(r),r.size?new j(r.content.concat(this.subtract(r).content)):this},append:function(r){return r=j.from(r),r.size?new j(this.subtract(r).content.concat(r.content)):this},subtract:function(r){var e=this;r=j.from(r);for(var t=0;t<r.content.length;t+=2)e=e.remove(r.content[t]);return e},toObject:function(){var r={};return this.forEach(function(e,t){r[e]=t}),r},get size(){return this.content.length>>1}};j.from=function(r){if(r instanceof j)return r;var e=[];if(r)for(var t in r)e.push(t,r[t]);return new j(e)};function Fo(r,e,t){for(let n=0;;n++){if(n==r.childCount||n==e.childCount)return r.childCount==e.childCount?null:t;let i=r.child(n),s=e.child(n);if(i==s){t+=i.nodeSize;continue}if(!i.sameMarkup(s))return t;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)t++;return t}if(i.content.size||s.content.size){let o=Fo(i.content,s.content,t+1);if(o!=null)return o}t+=i.nodeSize}}function Lo(r,e,t,n){for(let i=r.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:t,b:n};let o=r.child(--i),l=e.child(--s),a=o.nodeSize;if(o==l){t-=a,n-=a;continue}if(!o.sameMarkup(l))return{a:t,b:n};if(o.isText&&o.text!=l.text){let c=0,h=Math.min(o.text.length,l.text.length);for(;c<h&&o.text[o.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,n--;return{a:t,b:n}}if(o.content.size||l.content.size){let c=Lo(o.content,l.content,t-1,n-1);if(c)return c}t-=a,n-=a}}class b{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let n=0;n<e.length;n++)this.size+=e[n].nodeSize}nodesBetween(e,t,n,i=0,s){for(let o=0,l=0;l<t;o++){let a=this.content[o],c=l+a.nodeSize;if(c>e&&n(a,i+l,s||null,o)!==!1&&a.content.size){let h=l+1;a.nodesBetween(Math.max(0,e-h),Math.min(a.content.size,t-h),n,i+h)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,i){let s="",o=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&n&&(o?o=!1:s+=n),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,i=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(n)&&(i[i.length-1]=t.withText(t.text+n.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new b(i,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let n=[],i=0;if(t>e)for(let s=0,o=0;o<t;s++){let l=this.content[s],a=o+l.nodeSize;a>e&&((o<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,t-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,t-o-1))),n.push(l),i+=l.nodeSize),o=a}return new b(n,i)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let i=this.content.slice(),s=this.size+t.nodeSize-n.nodeSize;return i[e]=t,new b(i,s)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(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,n=0;t<this.content.length;t++){let i=this.content[t];e(i,n,t),n+=i.nodeSize}}findDiffStart(e,t=0){return Fo(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return Lo(this,e,t,n)}findIndex(e){if(e==0)return En(0,e);if(e==this.size)return En(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let i=this.child(t),s=n+i.nodeSize;if(s>=e)return s==e?En(t+1,s):En(t,n);n=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.empty;let t,n=0;for(let i=0;i<e.length;i++){let s=e[i];n+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(t||(t=e.slice(0,i)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new b(t||e,n)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const Sr={index:0,offset:0};function En(r,e){return Sr.index=r,Sr.offset=e,Sr}function Vn(r,e){if(r===e)return!0;if(!(r&&typeof r=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(r);if(Array.isArray(e)!=t)return!1;if(t){if(r.length!=e.length)return!1;for(let n=0;n<r.length;n++)if(!Vn(r[n],e[n]))return!1}else{for(let n in r)if(!(n in e)||!Vn(r[n],e[n]))return!1;for(let n in e)if(!(n in r))return!1}return!0}class D{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!n&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,i)),t.push(this),n=!0),t&&t.push(s)}}return t||(t=e.slice()),n||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&&Vn(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 n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let i=n.create(t.attrs);return n.checkAttrs(i.attrs),i}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return D.none;if(e instanceof D)return[e];let t=e.slice();return t.sort((n,i)=>n.type.rank-i.type.rank),t}}D.none=[];class Hn extends Error{}class S{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=Bo(this.content,e+this.openStart,t);return n&&new S(n,this.openStart,this.openEnd)}removeBetween(e,t){return new S(zo(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 S.empty;let n=t.openStart||0,i=t.openEnd||0;if(typeof n!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(b.fromJSON(e,t.content),n,i)}static maxOpen(e,t=!0){let n=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)n++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)i++;return new S(e,n,i)}}S.empty=new S(b.empty,0,0);function zo(r,e,t){let{index:n,offset:i}=r.findIndex(e),s=r.maybeChild(n),{index:o,offset:l}=r.findIndex(t);if(i==e||s.isText){if(l!=t&&!r.child(o).isText)throw new RangeError("Removing non-flat range");return r.cut(0,e).append(r.cut(t))}if(n!=o)throw new RangeError("Removing non-flat range");return r.replaceChild(n,s.copy(zo(s.content,e-i-1,t-i-1)))}function Bo(r,e,t,n){let{index:i,offset:s}=r.findIndex(e),o=r.maybeChild(i);if(s==e||o.isText)return n&&!n.canReplace(i,i,t)?null:r.cut(0,e).append(t).append(r.cut(e));let l=Bo(o.content,e-s-1,t,o);return l&&r.replaceChild(i,o.copy(l))}function Ga(r,e,t){if(t.openStart>r.depth)throw new Hn("Inserted content deeper than insertion position");if(r.depth-t.openStart!=e.depth-t.openEnd)throw new Hn("Inconsistent open depths");return _o(r,e,t,0)}function _o(r,e,t,n){let i=r.index(n),s=r.node(n);if(i==e.index(n)&&n<r.depth-t.openStart){let o=_o(r,e,t,n+1);return s.copy(s.content.replaceChild(i,o))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&r.depth==n&&e.depth==n){let o=r.parent,l=o.content;return ut(o,l.cut(0,r.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=ja(t,r);return ut(s,Ho(r,o,l,e,n))}else return ut(s,Wn(r,e,n))}function Vo(r,e){if(!e.type.compatibleContent(r.type))throw new Hn("Cannot join "+e.type.name+" onto "+r.type.name)}function jr(r,e,t){let n=r.node(t);return Vo(n,e.node(t)),n}function ht(r,e){let t=e.length-1;t>=0&&r.isText&&r.sameMarkup(e[t])?e[t]=r.withText(e[t].text+r.text):e.push(r)}function nn(r,e,t,n){let i=(e||r).node(t),s=0,o=e?e.index(t):i.childCount;r&&(s=r.index(t),r.depth>t?s++:r.textOffset&&(ht(r.nodeAfter,n),s++));for(let l=s;l<o;l++)ht(i.child(l),n);e&&e.depth==t&&e.textOffset&&ht(e.nodeBefore,n)}function ut(r,e){return r.type.checkContent(e),r.copy(e)}function Ho(r,e,t,n,i){let s=r.depth>i&&jr(r,e,i+1),o=n.depth>i&&jr(t,n,i+1),l=[];return nn(null,r,i,l),s&&o&&e.index(i)==t.index(i)?(Vo(s,o),ht(ut(s,Ho(r,e,t,n,i+1)),l)):(s&&ht(ut(s,Wn(r,e,i+1)),l),nn(e,t,i,l),o&&ht(ut(o,Wn(t,n,i+1)),l)),nn(n,null,i,l),new b(l)}function Wn(r,e,t){let n=[];if(nn(null,r,t,n),r.depth>t){let i=jr(r,e,t+1);ht(ut(i,Wn(r,e,t+1)),n)}return nn(e,null,t,n),new b(n)}function ja(r,e){let t=e.depth-r.openStart,i=e.node(t).copy(r.content);for(let s=t-1;s>=0;s--)i=e.node(s).copy(b.from(i));return{start:i.resolveNoCache(r.openStart+t),end:i.resolveNoCache(i.content.size-r.openEnd-t)}}class an{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,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 n=this.pos-this.path[this.path.length-1],i=e.child(t);return n?e.child(t).cut(n):i}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[t*3],i=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)i+=n.child(s).nodeSize;return i}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return D.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),i=e.maybeChild(t);if(!n){let l=n;n=i,i=l}let s=n.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<n.length;s++)n[s].type.spec.inclusive===!1&&(!i||!n[s].isInSet(i.marks))&&(n=n[s--].removeFromSet(n));return n}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 n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new Wo(this,e,n);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 n=[],i=0,s=t;for(let o=e;;){let{index:l,offset:a}=o.content.findIndex(s),c=s-a;if(n.push(o,l,i+a),!c||(o=o.child(l),o.isText))break;s=c-1,i+=a+1}return new an(t,n,s)}static resolveCached(e,t){let n=us.get(e);if(n)for(let s=0;s<n.elts.length;s++){let o=n.elts[s];if(o.pos==t)return o}else us.set(e,n=new Ya);let i=n.elts[n.i]=an.resolve(e,t);return n.i=(n.i+1)%Xa,i}}class Ya{constructor(){this.elts=[],this.i=0}}const Xa=12,us=new WeakMap;class Wo{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Za=Object.create(null);class Ie{constructor(e,t,n,i=D.none){this.type=e,this.attrs=t,this.marks=i,this.content=n||b.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,n,i=0){this.content.nodesBetween(e,t,n,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,i){return this.content.textBetween(e,t,n,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&Vn(this.attrs,t||e.defaultAttrs||Za)&&D.sameSet(this.marks,n||D.none)}copy(e=null){return e==this.content?this:new Ie(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Ie(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,n=!1){if(e==t)return S.empty;let i=this.resolve(e),s=this.resolve(t),o=n?0:i.sharedDepth(t),l=i.start(o),c=i.node(o).content.cut(i.pos-l,s.pos-l);return new S(c,i.depth-o,s.depth-o)}replace(e,t,n){return Ga(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:i}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(i==e||t.isText)return t;e-=i+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let i=this.content.child(t-1);return{node:i,index:t-1,offset:n-i.nodeSize}}resolve(e){return an.resolveCached(this,e)}resolveNoCache(e){return an.resolve(this,e)}rangeHasMark(e,t,n){let i=!1;return t>e&&this.nodesBetween(e,t,s=>(n.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Uo(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,n=b.empty,i=0,s=n.childCount){let o=this.contentMatchAt(e).matchFragment(n,i,s),l=o&&o.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=i;a<s;a++)if(!this.type.allowsMarks(n.child(a).marks))return!1;return!0}canReplaceWith(e,t,n,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(n),o=s&&s.matchFragment(this.content,t);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=D.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!D.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 n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=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,n)}let i=b.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,i,n);return s.type.checkAttrs(s.attrs),s}}Ie.prototype.text=void 0;class Un extends Ie{constructor(e,t,n,i){if(super(e,t,null,i),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Uo(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Un(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Un(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Uo(r,e){for(let t=r.length-1;t>=0;t--)e=r[t].type.name+"("+e+")";return e}class mt{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new Qa(e,t);if(n.next==null)return mt.empty;let i=qo(n);n.next&&n.err("Unexpected trailing text");let s=oc(sc(i));return lc(s,n),s}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,n=e.childCount){let i=this;for(let s=t;i&&s<n;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let i=[this];function s(o,l){let a=o.matchFragment(e,n);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<o.next.length;c++){let{type:h,next:u}=o.next[c];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(u)==-1){i.push(u);let f=s(u,l.concat(h));if(f)return f}}return null}return s(this,[])}findWrapping(e){for(let n=0;n<this.wrapCache.length;n+=2)if(this.wrapCache[n]==e)return this.wrapCache[n+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let i=n.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:a}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!i.type||a.validEnd)&&(n.push({match:l.contentMatch,type:l,via:i}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(n){e.push(n);for(let i=0;i<n.next.length;i++)e.indexOf(n.next[i].next)==-1&&t(n.next[i].next)}return t(this),e.map((n,i)=>{let s=i+(n.validEnd?"*":" ")+" ";for(let o=0;o<n.next.length;o++)s+=(o?", ":"")+n.next[o].type.name+"->"+e.indexOf(n.next[o].next);return s}).join(`
|
|
2
|
-
`)}}mt.empty=new mt(!0);class Qa{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 qo(r){let e=[];do e.push(ec(r));while(r.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ec(r){let e=[];do e.push(tc(r));while(r.next&&r.next!=")"&&r.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function tc(r){let e=ic(r);for(;;)if(r.eat("+"))e={type:"plus",expr:e};else if(r.eat("*"))e={type:"star",expr:e};else if(r.eat("?"))e={type:"opt",expr:e};else if(r.eat("{"))e=nc(r,e);else break;return e}function fs(r){/\D/.test(r.next)&&r.err("Expected number, got '"+r.next+"'");let e=Number(r.next);return r.pos++,e}function nc(r,e){let t=fs(r),n=t;return r.eat(",")&&(r.next!="}"?n=fs(r):n=-1),r.eat("}")||r.err("Unclosed braced range"),{type:"range",min:t,max:n,expr:e}}function rc(r,e){let t=r.nodeTypes,n=t[e];if(n)return[n];let i=[];for(let s in t){let o=t[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&r.err("No node type or group '"+e+"' found"),i}function ic(r){if(r.eat("(")){let e=qo(r);return r.eat(")")||r.err("Missing closing paren"),e}else if(/\W/.test(r.next))r.err("Unexpected token '"+r.next+"'");else{let e=rc(r,r.next).map(t=>(r.inline==null?r.inline=t.isInline:r.inline!=t.isInline&&r.err("Mixing inline and block content"),{type:"name",value:t}));return r.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function sc(r){let e=[[]];return i(s(r,0),t()),e;function t(){return e.push([])-1}function n(o,l,a){let c={term:a,to:l};return e[o].push(c),c}function i(o,l){o.forEach(a=>a.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(o.type=="seq")for(let a=0;;a++){let c=s(o.exprs[a],l);if(a==o.exprs.length-1)return c;i(c,l=t())}else if(o.type=="star"){let a=t();return n(l,a),i(s(o.expr,a),a),[n(a)]}else if(o.type=="plus"){let a=t();return i(s(o.expr,l),a),i(s(o.expr,a),a),[n(a)]}else{if(o.type=="opt")return[n(l)].concat(s(o.expr,l));if(o.type=="range"){let a=l;for(let c=0;c<o.min;c++){let h=t();i(s(o.expr,a),h),a=h}if(o.max==-1)i(s(o.expr,a),a);else for(let c=o.min;c<o.max;c++){let h=t();n(a,h),i(s(o.expr,a),h),a=h}return[n(a)]}else{if(o.type=="name")return[n(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function Jo(r,e){return e-r}function ds(r,e){let t=[];return n(e),t.sort(Jo);function n(i){let s=r[i];if(s.length==1&&!s[0].term)return n(s[0].to);t.push(i);for(let o=0;o<s.length;o++){let{term:l,to:a}=s[o];!l&&t.indexOf(a)==-1&&n(a)}}}function oc(r){let e=Object.create(null);return t(ds(r,0));function t(n){let i=[];n.forEach(o=>{r[o].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let h=0;h<i.length;h++)i[h][0]==l&&(c=i[h][1]);ds(r,a).forEach(h=>{c||i.push([l,c=[]]),c.indexOf(h)==-1&&c.push(h)})})});let s=e[n.join(",")]=new mt(n.indexOf(r.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(Jo);s.next.push({type:i[o][0],next:e[l.join(",")]||t(l)})}return s}}function lc(r,e){for(let t=0,n=[r];t<n.length;t++){let i=n[t],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:a,next:c}=i.next[l];o.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),n.indexOf(c)==-1&&n.push(c)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function $o(r){let e=Object.create(null);for(let t in r){let n=r[t];if(!n.hasDefault)return null;e[t]=n.default}return e}function Ko(r,e){let t=Object.create(null);for(let n in r){let i=e&&e[n];if(i===void 0){let s=r[n];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+n)}t[n]=i}return t}function Go(r,e,t,n){for(let i in e)if(!(i in r))throw new RangeError(`Unsupported attribute ${i} for ${t} of type ${i}`);for(let i in r){let s=r[i];s.validate&&s.validate(e[i])}}function jo(r,e){let t=Object.create(null);if(e)for(let n in e)t[n]=new cc(r,n,e[n]);return t}let ps=class Yo{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=jo(e,n.attrs),this.defaultAttrs=$o(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==mt.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:Ko(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Ie(this,this.computeAttrs(e),b.from(t),D.setFrom(n))}createChecked(e=null,t,n){return t=b.from(t),this.checkContent(t),new Ie(this,this.computeAttrs(e),t,D.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),t=b.from(t),t.size){let o=this.contentMatch.fillBefore(t);if(!o)return null;t=o.append(t)}let i=this.contentMatch.matchFragment(t),s=i&&i.fillBefore(b.empty,!0);return s?new Ie(this,e,t.append(s),D.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let n=0;n<e.childCount;n++)if(!this.allowsMarks(e.child(n).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){Go(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:D.none:e}static compile(e,t){let n=Object.create(null);e.forEach((s,o)=>n[s]=new Yo(s,t,o));let i=t.spec.topNode||"doc";if(!n[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let s in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};function ac(r,e,t){let n=t.split("|");return i=>{let s=i===null?"null":typeof i;if(n.indexOf(s)<0)throw new RangeError(`Expected value of type ${n} for attribute ${e} on type ${r}, got ${s}`)}}class cc{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate=typeof n.validate=="string"?ac(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Zn{constructor(e,t,n,i){this.name=e,this.rank=t,this.schema=n,this.spec=i,this.attrs=jo(e,i.attrs),this.excluded=null;let s=$o(this.attrs);this.instance=s?new D(this,s):null}create(e=null){return!e&&this.instance?this.instance:new D(this,Ko(this.attrs,e))}static compile(e,t){let n=Object.create(null),i=0;return e.forEach((s,o)=>n[s]=new Zn(s,i++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Go(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Xo{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let i in e)t[i]=e[i];t.nodes=j.from(e.nodes),t.marks=j.from(e.marks||{}),this.nodes=ps.compile(this.spec.nodes,this),this.marks=Zn.compile(this.spec.marks,this);let n=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=n[o]||(n[o]=mt.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?ms(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:ms(this,o.split(" "))}this.nodeFromJSON=i=>Ie.fromJSON(this,i),this.markFromJSON=i=>D.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof ps){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,n,i)}text(e,t){let n=this.nodes.text;return new Un(n,n.defaultAttrs,e,D.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 ms(r,e){let t=[];for(let n=0;n<e.length;n++){let i=e[n],s=r.marks[i],o=s;if(s)t.push(s);else for(let l in r.marks){let a=r.marks[l];(i=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(i)>-1)&&t.push(o=a)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[n]+"'")}return t}function hc(r){return r.tag!=null}function uc(r){return r.style!=null}class Lt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(i=>{if(hc(i))this.tags.push(i);else if(uc(i)){let s=/[^=]*/.exec(i.style)[0];n.indexOf(s)<0&&n.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let n=new ys(this,t,!1);return n.addAll(e,D.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new ys(this,t,!0);return n.addAll(e,D.none,t.from,t.to),S.maxOpen(n.finish())}matchTag(e,t,n){for(let i=n?this.tags.indexOf(n)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(pc(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,t,n,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!n.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(o.getAttrs){let a=o.getAttrs(t);if(a===!1)continue;o.attrs=a||void 0}return o}}}static schemaRules(e){let t=[];function n(i){let s=i.priority==null?50:i.priority,o=0;for(;o<t.length;o++){let l=t[o];if((l.priority==null?50:l.priority)<s)break}t.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{n(o=bs(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{n(o=bs(o)),o.node||o.ignore||o.mark||(o.node=i)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Lt(e,Lt.schemaRules(e)))}}const Zo={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},fc={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qo={ol:!0,ul:!0},cn=1,Yr=2,rn=4;function gs(r,e,t){return e!=null?(e?cn:0)|(e==="full"?Yr:0):r&&r.whitespace=="pre"?cn|Yr:t&~rn}class Nn{constructor(e,t,n,i,s,o){this.type=e,this.attrs=t,this.marks=n,this.solid=i,this.options=o,this.content=[],this.activeMarks=D.none,this.match=s||(o&rn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let n=this.type.contentMatch,i;return(i=n.findWrapping(e.type))?(this.match=n,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&cn)){let n=this.content[this.content.length-1],i;if(n&&n.isText&&(i=/[ \t\r\n\u000c]+$/.exec(n.text))){let s=n;n.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.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&&!Zo.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ys{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let i=t.topNode,s,o=gs(null,t.preserveWhitespace,0)|(n?rn:0);i?s=new Nn(i.type,i.attrs,D.none,!0,t.topMatch||i.type.contentMatch,o):n?s=new Nn(null,null,D.none,!0,null,o):s=new Nn(e.schema.topNodeType,null,D.none,!0,null,o),this.nodes=[s],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 n=e.nodeValue,i=this.top,s=i.options&Yr?"full":this.localPreserveWS||(i.options&cn)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(s)if(s==="full")n=n.replace(/\r\n?/g,`
|
|
3
|
-
`);else if(o.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=n.split(/\r?\n|\r/);for(let a=0;a<l.length;a++)a&&this.insertNode(o.linebreakReplacement.create(),t,!0),l[a]&&this.insertNode(o.text(l[a]),t,!/\S/.test(l[a]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let l=i.content[i.content.length-1],a=e.previousSibling;(!l||a&&a.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(n=n.slice(1))}n&&this.insertNode(o.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;Qo.hasOwnProperty(o)&&this.parser.normalizeLists&&dc(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,n));e:if(a?a.ignore:fc.hasOwnProperty(o))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,h=this.needsBlock;if(Zo.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(s),this.needsBlock=h}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=i}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 n=e.style;if(n&&n.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=n.getPropertyValue(s);if(o)for(let l=void 0;;){let a=this.parser.matchStyle(s,o,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,n,i){let s,o;if(t.node)if(o=this.parser.schema.nodes[t.node],o.isLeaf)this.insertNode(o.create(t.attrs),n,e.nodeName=="BR")||this.leafFallback(e,n);else{let a=this.enter(o,t.attrs||null,n,t.preserveWhitespace);a&&(s=!0,n=a)}else{let a=this.parser.schema.marks[t.mark];n=n.concat(a.create(t.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,n,i);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,n,!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,n),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,n,i){let s=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,t);this.findAtPoint(e,s)}findPlace(e,t,n){let i,s;for(let o=this.open,l=0;o>=0;o--){let a=this.nodes[o],c=a.findWrapping(e);if(c&&(!i||i.length>c.length+l)&&(i=c,s=a,!c.length))break;if(a.solid){if(n)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)t=this.enterInner(i[o],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let i=this.findPlace(e,t,n);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=D.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):ks(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,t,n,i){let s=this.findPlace(e.create(t),n,!1);return s&&(s=this.enterInner(e,t,n,!0,i)),s}enterInner(e,t,n,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=gs(e,s,o.options);o.options&rn&&o.content.length==0&&(l|=rn);let a=D.none;return n=n.filter(c=>(o.type?o.type.allowsMarkType(c.type):ks(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Nn(e,t,a,i,null,l)),this.open++,n}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|=cn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let i=n.length-1;i>=0;i--)e+=n[i].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].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,n){if(e!=t&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&t.compareDocumentPosition(this.find[i].node)&(n?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,i=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),s=-(n?n.depth+1:0)+(i?0:1),o=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(o(l-1,a))return!0;return!1}else{let h=a>0||a==0&&i?this.nodes[a].type:n&&a>=s?n.node(a-s).type:null;if(!h||h.name!=c&&!h.isInGroup(c))return!1;a--}}return!0};return o(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let n=this.parser.schema.nodes[t];if(n.isTextblock&&n.defaultAttrs)return n}}}function dc(r){for(let e=r.firstChild,t=null;e;e=e.nextSibling){let n=e.nodeType==1?e.nodeName.toLowerCase():null;n&&Qo.hasOwnProperty(n)&&t?(t.appendChild(e),e=t):n=="li"?t=e:n&&(t=null)}}function pc(r,e){return(r.matches||r.msMatchesSelector||r.webkitMatchesSelector||r.mozMatchesSelector).call(r,e)}function bs(r){let e={};for(let t in r)e[t]=r[t];return e}function ks(r,e){let t=e.schema.nodes;for(let n in t){let i=t[n];if(!i.allowsMarkType(r))continue;let s=[],o=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:h}=l.edge(a);if(c==e||s.indexOf(h)<0&&o(h))return!0}};if(o(i.contentMatch))return!0}}class kt{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=xr(t).createDocumentFragment());let i=n,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,a=0;for(;l<s.length&&a<o.marks.length;){let c=o.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)i=s.pop()[1];for(;a<o.marks.length;){let c=o.marks[a++],h=this.serializeMark(c,o.isInline,t);h&&(s.push([c,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(o,t))}),n}serializeNodeInner(e,t){let{dom:n,contentDOM:i}=Pn(xr(t),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,i)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(n),n=s.dom)}return n}serializeMark(e,t,n={}){let i=this.marks[e.type.name];return i&&Pn(xr(n),i(e,t),null,e.attrs)}static renderSpec(e,t,n=null,i){return Pn(e,t,n,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new kt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ss(e.nodes);return t.text||(t.text=n=>n.text),t}static marksFromSchema(e){return Ss(e.marks)}}function Ss(r){let e={};for(let t in r){let n=r[t].spec.toDOM;n&&(e[t]=n)}return e}function xr(r){return r.document||window.document}const xs=new WeakMap;function mc(r){let e=xs.get(r);return e===void 0&&xs.set(r,e=gc(r)),e}function gc(r){let e=null;function t(n){if(n&&typeof n=="object")if(Array.isArray(n))if(typeof n[0]=="string")e||(e=[]),e.push(n);else for(let i=0;i<n.length;i++)t(n[i]);else for(let i in n)t(n[i])}return t(r),e}function Pn(r,e,t,n){if(typeof e=="string")return{dom:r.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(n&&(s=mc(n))&&s.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 o=i.indexOf(" ");o>0&&(t=i.slice(0,o),i=i.slice(o+1));let l,a=t?r.createElementNS(t,i):r.createElement(i),c=e[1],h=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){h=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):u=="style"&&a.style?a.style.cssText=c[u]:a.setAttribute(u,c[u])}}for(let u=h;u<e.length;u++){let f=e[u];if(f===0){if(u<e.length-1||u>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:d}=Pn(r,f,t,n);if(a.appendChild(p),d){if(l)throw new RangeError("Multiple content holes");l=d}}}return{dom:a,contentDOM:l}}const el=65535,tl=Math.pow(2,16);function yc(r,e){return r+e*tl}function Ts(r){return r&el}function bc(r){return(r-(r&el))/tl}const nl=1,rl=2,Fn=4,il=8;class Xr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&il)>0}get deletedBefore(){return(this.delInfo&(nl|Fn))>0}get deletedAfter(){return(this.delInfo&(rl|Fn))>0}get deletedAcross(){return(this.delInfo&Fn)>0}}class be{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&be.empty)return be.empty}recover(e){let t=0,n=Ts(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+bc(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+s],h=this.ranges[l+o],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,p=a+i+(f<0?0:h);if(n)return p;let d=e==(t<0?a:u)?null:yc(l/3,e-a),g=e==a?rl:e==u?nl:Fn;return(t<0?e!=a:e!=u)&&(g|=il),new Xr(p,g,d)}i+=h-c}return n?e+i:new Xr(e+i,0,null)}touches(e,t){let n=0,i=Ts(t),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+s],h=a+c;if(e<=h&&l==i*3)return!0;n+=this.ranges[l+o]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),a=o+(this.inverted?0:s),c=this.ranges[i+t],h=this.ranges[i+n];e(l,l+c,a,a+h),s+=h-c}}invert(){return new be(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?be.empty:new be(e<0?[0,-e,0]:[0,0,e])}}be.empty=new be([]);class hn{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new hn(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=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new hn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Xr(e,i,null)}}const Tr=Object.create(null);class oe{getMap(){return be.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Tr[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Tr)throw new RangeError("Duplicate use of step JSON ID "+e);return Tr[e]=t,t.prototype.jsonID=e,t}}class V{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new V(e,null)}static fail(e){return new V(null,e)}static fromReplace(e,t,n,i){try{return V.ok(e.replace(t,n,i))}catch(s){if(s instanceof Hn)return V.fail(s.message);throw s}}}function mi(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let s=r.child(i);s.content.size&&(s=s.copy(mi(s.content,e,s))),s.isInline&&(s=e(s,t,i)),n.push(s)}return b.fromArray(n)}class Xe extends oe{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),s=new S(mi(t.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),t.openStart,t.openEnd);return V.fromReplace(e,this.from,this.to,s)}invert(){return new xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Xe(t.pos,n.pos,this.mark)}merge(e){return e instanceof Xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Xe(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",Xe);class xe extends oe{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new S(mi(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return V.fromReplace(e,this.from,this.to,n)}invert(){return new Xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new xe(t.pos,n.pos,this.mark)}merge(e){return e instanceof xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"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 xe(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",xe);class Ze extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return V.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return V.fromReplace(e,this.pos,this.pos+1,new S(b.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Ze(this.pos,t.marks[i]);return new Ze(this.pos,this.mark)}}return new gt(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ze(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 Ze(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",Ze);class gt extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return V.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return V.fromReplace(e,this.pos,this.pos+1,new S(b.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ze(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new gt(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 gt(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",gt);class ne extends oe{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Zr(e,this.from,this.to)?V.fail("Structure replace would overwrite content"):V.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new be([this.from,this.to-this.from,this.slice.size])}invert(e){return new ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new ne(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ne)||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?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ne(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?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ne(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 ne(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",ne);class se extends oe{constructor(e,t,n,i,s,o,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(Zr(e,this.from,this.gapFrom)||Zr(e,this.gapTo,this.to)))return V.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return V.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?V.fromReplace(e,this.from,this.to,n):V.fail("Content does not fit in gap")}getMap(){return new be([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 se(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),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||s>n.pos?null:new se(t.pos,n.pos,i,s,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 se(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",se);function Zr(r,e,t){let n=r.resolve(e),i=t-e,s=n.depth;for(;i>0&&s>0&&n.indexAfter(s)==n.node(s).childCount;)s--,i--;if(i>0){let o=n.node(s).maybeChild(n.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function kc(r,e,t,n){let i=[],s=[],o,l;r.doc.nodesBetween(e,t,(a,c,h)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&h.type.allowsMarkType(n.type)){let f=Math.max(c,e),p=Math.min(c+a.nodeSize,t),d=n.addToSet(u);for(let g=0;g<u.length;g++)u[g].isInSet(d)||(o&&o.to==f&&o.mark.eq(u[g])?o.to=p:i.push(o=new xe(f,p,u[g])));l&&l.to==f?l.to=p:s.push(l=new Xe(f,p,n))}}),i.forEach(a=>r.step(a)),s.forEach(a=>r.step(a))}function Sc(r,e,t,n){let i=[],s=0;r.doc.nodesBetween(e,t,(o,l)=>{if(!o.isInline)return;s++;let a=null;if(n instanceof Zn){let c=o.marks,h;for(;h=n.isInSet(c);)(a||(a=[])).push(h),c=h.removeFromSet(c)}else n?n.isInSet(o.marks)&&(a=[n]):a=o.marks;if(a&&a.length){let c=Math.min(l+o.nodeSize,t);for(let h=0;h<a.length;h++){let u=a[h],f;for(let p=0;p<i.length;p++){let d=i[p];d.step==s-1&&u.eq(i[p].style)&&(f=d)}f?(f.to=c,f.step=s):i.push({style:u,from:Math.max(l,e),to:c,step:s})}}}),i.forEach(o=>r.step(new xe(o.from,o.to,o.style)))}function gi(r,e,t,n=t.contentMatch,i=!0){let s=r.doc.nodeAt(e),o=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),h=l+c.nodeSize,u=n.matchType(c.type);if(!u)o.push(new ne(l,h,S.empty));else{n=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new xe(l,h,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,p=/\r?\n|\r/g,d;for(;f=p.exec(c.text);)d||(d=new S(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),o.push(new ne(l+f.index,l+f.index+f[0].length,d))}}l=h}if(!n.validEnd){let a=n.fillBefore(b.empty,!0);r.replace(l,l,new S(a,0,0))}for(let a=o.length-1;a>=0;a--)r.step(o[a])}function xc(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function yi(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,s=0;;--n){let o=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-s;if(n<r.depth&&o.canReplace(l,a,t))return n;if(n==0||o.type.spec.isolating||!xc(o,l,a))break;l&&(i=1),a<o.childCount&&(s=1)}return null}function Tc(r,e,t){let{$from:n,$to:i,depth:s}=e,o=n.before(s+1),l=i.after(s+1),a=o,c=l,h=b.empty,u=0;for(let d=s,g=!1;d>t;d--)g||n.index(d)>0?(g=!0,h=b.from(n.node(d).copy(h)),u++):a--;let f=b.empty,p=0;for(let d=s,g=!1;d>t;d--)g||i.after(d+1)<i.end(d)?(g=!0,f=b.from(i.node(d).copy(f)),p++):c++;r.step(new se(a,c,o,l,new S(h.append(f),u,p),h.size-u,!0))}function Cc(r,e,t){let n=b.empty;for(let o=t.length-1;o>=0;o--){if(n.size){let l=t[o].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=b.from(t[o].type.create(t[o].attrs,n))}let i=e.start,s=e.end;r.step(new se(i,s,i,s,new S(n,0,0),t.length,!0))}function wc(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=r.steps.length;r.doc.nodesBetween(e,t,(o,l)=>{let a=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(n,a)&&Mc(r.doc,r.mapping.slice(s).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let p=n.whitespace=="pre",d=!!n.contentMatch.matchType(n.schema.linebreakReplacement);p&&!d?c=!1:!p&&d&&(c=!0)}c===!1&&ol(r,o,l,s),gi(r,r.mapping.slice(s).map(l,1),n,void 0,c===null);let h=r.mapping.slice(s),u=h.map(l,1),f=h.map(l+o.nodeSize,1);return r.step(new se(u,f,u+1,f-1,new S(b.from(n.create(a,null,o.marks)),0,0),1,!0)),c===!0&&sl(r,o,l,s),!1}})}function sl(r,e,t,n){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+s+o.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function ol(r,e,t,n){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=r.mapping.slice(n).map(t+1+s);r.replaceWith(o,o+1,e.type.schema.text(`
|
|
5
|
-
`))}})}function Mc(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function Oc(r,e,t,n,i){let s=r.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let o=t.create(n,null,i||s.marks);if(s.isLeaf)return r.replaceWith(e,e+s.nodeSize,o);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new se(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(b.from(o),0,0),1,!0))}function Ln(r,e,t=1,n){let i=r.resolve(e),s=i.depth-t,o=n&&n[n.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,h=t-2;c>s;c--,h--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(f,u.childCount),d=n&&n[h+1];d&&(p=p.replaceChild(0,d.type.create(d.attrs)));let g=n&&n[h]||u;if(!u.canReplace(f+1,u.childCount)||!g.type.validContent(p))return!1}let l=i.indexAfter(s),a=n&&n[0];return i.node(s).canReplaceWith(l,l,a?a.type:i.node(s+1).type)}function Ec(r,e,t=1,n){let i=r.doc.resolve(e),s=b.empty,o=b.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){s=b.from(i.node(l).copy(s));let h=n&&n[c];o=b.from(h?h.type.create(h.attrs,o):i.node(l).copy(o))}r.step(new ne(e,e,new S(s.append(o),t,t),!0))}function bi(r,e){let t=r.resolve(e),n=t.index();return Dc(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Nc(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==n?r.type.schema.nodes.text:s.type;if(t=t.matchType(o),!t||!r.type.allowsMarks(s.marks))return!1}return t.validEnd}function Dc(r,e){return!!(r&&e&&!r.isLeaf&&Nc(r,e))}function Ac(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,s=r.doc.resolve(e-t),o=s.node().type;if(i&&o.inlineContent){let h=o.whitespace=="pre",u=!!o.contentMatch.matchType(i);h&&!u?n=!1:!h&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let h=r.doc.resolve(e+t);ol(r,h.node(),h.before(),l)}o.inlineContent&&gi(r,e+t-1,o,s.node().contentMatchAt(s.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new ne(c,a.map(e+t,-1),S.empty,!0)),n===!0){let h=r.doc.resolve(c);sl(r,h.node(),h.before(),r.steps.length)}return r}function vc(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let s=n.index(i);if(n.node(i).canReplaceWith(s,s,t))return n.before(i+1);if(s>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let s=n.indexAfter(i);if(n.node(i).canReplaceWith(s,s,t))return n.after(i+1);if(s<n.node(i).childCount)return null}return null}function ki(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let s=0;s<t.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let o=n.depth;o>=0;o--){let l=o==n.depth?0:n.pos<=(n.start(o+1)+n.end(o+1))/2?-1:1,a=n.index(o)+(l>0?1:0),c=n.node(o),h=!1;if(s==1)h=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);h=u&&c.canReplaceWith(a,a,u[0])}if(h)return l==0?n.pos:l<0?n.before(o+1):n.after(o+1)}return null}function Si(r,e,t=e,n=S.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),s=r.resolve(t);return ll(i,s,n)?new ne(e,t,n):new Ic(i,s,n).fit()}function ll(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class Ic{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=b.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=b.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let s=this.placed,o=n.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let a=new S(s,o,l);return e>-1?new se(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ne(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let s=t.firstChild;if(t.childCount>1&&(i=0),s.type.spec.isolating&&i<=n){e=n;break}t=s.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,s=null;n?(s=Cr(this.unplaced.content,n-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],h,u=null;if(t==1&&(o?c.matchType(o.type)||(u=c.fillBefore(b.from(o),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:n,frontierDepth:l,parent:s,inject:u};if(t==2&&o&&(h=c.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:l,parent:s,wrap:h};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Cr(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Cr(e,t);if(i.childCount<=1&&t>0){let s=e.size-t<=t+i.size;this.unplaced=new S(Zt(e,t-1,1),t-1,s?t-1:n)}else this.unplaced=new S(Zt(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let g=0;g<s.length;g++)this.openFrontierNode(s[g]);let o=this.unplaced,l=n?n.content:o.content,a=o.openStart-e,c=0,h=[],{match:u,type:f}=this.frontier[t];if(i){for(let g=0;g<i.childCount;g++)h.push(i.child(g));u=u.matchFragment(i)}let p=l.size+e-(o.content.size-o.openEnd);for(;c<l.childCount;){let g=l.child(c),y=u.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(u=y,h.push(al(g.mark(f.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?p:-1)))}let d=c==l.childCount;d||(p=-1),this.placed=Qt(this.placed,t,b.from(h)),this.frontier[t].match=u,d&&p<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<p;g++){let C=y.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),y=C.content}this.unplaced=d?e==0?S.empty:new S(Zt(o.content,e-1,1),e-1,p<0?o.openEnd:e-1):new S(Zt(o.content,e,c),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!wr(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:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),o=wr(e,t,i,n,s);if(o){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],h=wr(e,l,c,a,!0);if(!h||h.childCount)continue e}return{depth:t,fit:o,move:s?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=Qt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Qt(this.placed,this.depth,b.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=Qt(this.placed,this.frontier.length,t))}}function Zt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(Zt(r.firstChild.content,e-1,t)))}function Qt(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Qt(r.lastChild.content,e-1,t)))}function Cr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function al(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,al(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(b.empty,!0)))),r.copy(n)}function wr(r,e,t,n,i){let s=r.node(e),o=i?r.indexAfter(e):r.index(e);if(o==s.childCount&&!t.compatibleContent(s.type))return null;let l=n.fillBefore(s.content,!0,o);return l&&!Rc(t,s.content,o)?l:null}function Rc(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function Pc(r){return r.spec.defining||r.spec.definingForContent}function Fc(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),s=r.doc.resolve(t);if(ll(i,s,n))return r.step(new ne(e,t,n));let o=hl(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let f=i.depth,p=i.pos-1;f>0;f--,p--){let d=i.node(f).type.spec;if(d.defining||d.definingAsContext||d.isolating)break;o.indexOf(f)>-1?l=f:i.before(f)==p&&o.splice(1,0,-f)}let a=o.indexOf(l),c=[],h=n.openStart;for(let f=n.content,p=0;;p++){let d=f.firstChild;if(c.push(d),p==n.openStart)break;f=d.content}for(let f=h-1;f>=0;f--){let p=c[f],d=Pc(p.type);if(d&&!p.sameMarkup(i.node(Math.abs(l)-1)))h=f;else if(d||!p.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let p=(f+h+1)%(n.openStart+1),d=c[p];if(d)for(let g=0;g<o.length;g++){let y=o[(g+a)%o.length],C=!0;y<0&&(C=!1,y=-y);let L=i.node(y-1),I=i.index(y-1);if(L.canReplaceWith(I,I,d.type,d.marks))return r.replace(i.before(y),C?s.after(y):t,new S(cl(n.content,0,n.openStart,p),p,n.openEnd))}}let u=r.steps.length;for(let f=o.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>u));f--){let p=o[f];p<0||(e=i.before(p),t=s.after(p))}}function cl(r,e,t,n,i){if(e<t){let s=r.firstChild;r=r.replaceChild(0,s.copy(cl(s.content,e+1,t,n,s)))}if(e>n){let s=i.contentMatchAt(0),o=s.fillBefore(r).append(r);r=o.append(s.matchFragment(o).fillBefore(b.empty,!0))}return r}function Lc(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=vc(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new S(b.from(n),0,0))}function zc(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),s=hl(n,i);for(let o=0;o<s.length;o++){let l=s[o],a=o==s.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let o=1;o<=n.depth&&o<=i.depth;o++)if(e-n.start(o)==n.depth-o&&t>n.end(o)&&i.end(o)-t!=i.depth-o&&n.start(o-1)==i.start(o-1)&&n.node(o-1).canReplace(n.index(o-1),i.index(o-1)))return r.delete(n.before(o),t);r.delete(e,t)}function hl(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let s=r.start(i);if(s<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&t.push(i)}return t}class Rt extends oe{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return V.fail("No node at attribute step's position");let n=Object.create(null);for(let s in t.attrs)n[s]=t.attrs[s];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return V.fromReplace(e,this.pos,this.pos+1,new S(b.from(i),0,t.isLeaf?0:1))}getMap(){return be.empty}invert(e){return new Rt(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 Rt(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 Rt(t.pos,t.attr,t.value)}}oe.jsonID("attr",Rt);class un extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return V.ok(n)}getMap(){return be.empty}invert(e){return new un(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 un(t.attr,t.value)}}oe.jsonID("docAttr",un);let zt=class extends Error{};zt=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};zt.prototype=Object.create(Error.prototype);zt.prototype.constructor=zt;zt.prototype.name="TransformError";class Bc{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new hn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new zt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=S.empty){let i=Si(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new S(b.from(n),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Fc(this,e,t,n),this}replaceRangeWith(e,t,n){return Lc(this,e,t,n),this}deleteRange(e,t){return zc(this,e,t),this}lift(e,t){return Tc(this,e,t),this}join(e,t=1){return Ac(this,e,t),this}wrap(e,t){return Cc(this,e,t),this}setBlockType(e,t=e,n,i=null){return wc(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return Oc(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new Rt(e,t,n)),this}setDocAttribute(e,t){return this.step(new un(e,t)),this}addNodeMark(e,t){return this.step(new Ze(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof D)t.isInSet(n.marks)&&this.step(new gt(e,t));else{let i=n.marks,s,o=[];for(;s=t.isInSet(i);)o.push(new gt(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,t=1,n){return Ec(this,e,t,n),this}addMark(e,t,n){return kc(this,e,t,n),this}removeMark(e,t,n){return Sc(this,e,t,n),this}clearIncompatible(e,t,n){return gi(this,e,t,n),this}}const Mr=Object.create(null);class N{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new _c(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=S.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:a,$to:c}=o[l],h=e.mapping.slice(s);e.replaceRange(h.map(a.pos),h.map(c.pos),l?S.empty:t),l==0&&Ms(e,s,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],a=e.mapping.slice(n),c=a.map(o.pos),h=a.map(l.pos);s?e.deleteRange(c,h):(e.replaceRangeWith(c,h,t),Ms(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new O(e):At(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=t<0?At(e.node(0),e.node(s),e.before(s+1),e.index(s),t,n):At(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new Z(e.node(0))}static atStart(e){return At(e,e,0,0,1)||new Z(e)}static atEnd(e){return At(e,e,e.content.size,e.childCount,-1)||new Z(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Mr[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Mr)throw new RangeError("Duplicate use of selection JSON ID "+e);return Mr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return O.between(this.$anchor,this.$head).getBookmark()}}N.prototype.visible=!0;class _c{constructor(e,t){this.$from=e,this.$to=t}}let Cs=!1;function ws(r){!Cs&&!r.parent.inlineContent&&(Cs=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class O extends N{constructor(e,t=e){ws(e),ws(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return N.near(n);let i=e.resolve(t.map(this.anchor));return new O(i.parent.inlineContent?i:n,n)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof O&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Qn(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 O(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let s=N.findFrom(t,n,!0)||N.findFrom(t,-n,!0);if(s)t=s.$head;else return N.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(N.findFrom(e,-n,!0)||N.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new O(e,t)}}N.jsonID("text",O);class Qn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Qn(e.map(this.anchor),e.map(this.head))}resolve(e){return O.between(e.resolve(this.anchor),e.resolve(this.head))}}class w extends N{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),s=e.resolve(i);return n?N.near(s):new w(s)}content(){return new S(b.from(this.node),0,0)}eq(e){return e instanceof w&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new xi(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new w(e.resolve(t.anchor))}static create(e,t){return new w(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}w.prototype.visible=!1;N.jsonID("node",w);class xi{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new Qn(n,n):new xi(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&w.isSelectable(n)?new w(t):N.near(t)}}class Z extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let n=N.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new Z(e)}map(e){return new Z(e)}eq(e){return e instanceof Z}getBookmark(){return Vc}}N.jsonID("all",Z);const Vc={map(){return this},resolve(r){return new Z(r)}};function At(r,e,t,n,i,s=!1){if(e.inlineContent)return O.create(r,t);for(let o=n-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&w.isSelectable(l))return w.create(r,t-(i<0?l.nodeSize:0))}else{let a=At(r,l,t+i,i<0?l.childCount:0,i,s);if(a)return a}t+=l.nodeSize*i}return null}function Ms(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof ne||i instanceof se))return;let s=r.mapping.maps[n],o;s.forEach((l,a,c,h)=>{o==null&&(o=h)}),r.setSelection(N.near(r.doc.resolve(o),t))}const Os=1,Dn=2,Es=4;class Hc extends Bc{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|Os)&~Dn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Os)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Dn,this}ensureMarks(e){return D.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&Dn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~Dn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||D.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let s=this.storedMarks;if(!s){let o=this.doc.resolve(t);s=n==t?o.marks():o.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,s)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(N.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|=Es,this}get scrolledIntoView(){return(this.updated&Es)>0}}function Ns(r,e){return!e||!r?r:r.bind(e)}class en{constructor(e,t,n){this.name=e,this.init=Ns(t.init,n),this.apply=Ns(t.apply,n)}}const Wc=[new en("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new en("selection",{init(r,e){return r.selection||N.atStart(e.doc)},apply(r){return r.selection}}),new en("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new en("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class Or{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Wc.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new en(n.key,n.spec.state,n))})}}class It{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 n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let a=i?i[o].n:0,c=i?i[o].state:this,h=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(h&&n.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<o?{state:n,n:t.length}:{state:this,n:0})}t.push(h),n=n.applyInner(h),s=!0}i&&(i[o]={state:n,n:t.length})}}if(!s)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new It(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let s=n[i];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new Hc(this)}static create(e){let t=new Or(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new It(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new Or(this.schema,e.plugins),n=t.fields,i=new It(t);for(let s=0;s<n.length;s++){let o=n[s].name;i[o]=this.hasOwnProperty(o)?this[o]:n[s].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],s=i.spec.state;s&&s.toJSON&&(t[n]=s.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Or(e.schema,e.plugins),s=new It(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=Ie.fromJSON(e.schema,t.doc);else if(o.name=="selection")s.selection=N.fromJSON(s.doc,t.selection);else if(o.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==o.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[o.name]=c.fromJSON.call(a,e,t[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function ul(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=ul(i,e,{})),t[n]=i}return t}class ce{constructor(e){this.spec=e,this.props={},e.props&&ul(e.props,this,this.props),this.key=e.key?e.key.key:fl("plugin")}getState(e){return e[this.key]}}const Er=Object.create(null);function fl(r){return r in Er?r+"$"+ ++Er[r]:(Er[r]=0,r+"$")}class dl{constructor(e="key"){this.key=fl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Y=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Bt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Qr=null;const He=function(r,e,t){let n=Qr||(Qr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Uc=function(){Qr=null},yt=function(r,e,t,n){return t&&(Ds(r,e,t,n,-1)||Ds(r,e,t,n,1))},qc=/^(img|br|input|textarea|hr)$/i;function Ds(r,e,t,n,i){for(var s;;){if(r==t&&e==n)return!0;if(e==(i<0?0:Se(r))){let o=r.parentNode;if(!o||o.nodeType!=1||mn(r)||qc.test(r.nodeName)||r.contentEditable=="false")return!1;e=Y(r)+(i<0?0:1),r=o}else if(r.nodeType==1){let o=r.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else r=o,e=i<0?Se(r):0}else return!1}}function Se(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Jc(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=Se(r)}else if(r.parentNode&&!mn(r))e=Y(r),r=r.parentNode;else return null}}function $c(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!mn(r))e=Y(r)+1,r=r.parentNode;else return null}}function Kc(r,e,t){for(let n=e==0,i=e==Se(r);n||i;){if(r==t)return!0;let s=Y(r);if(r=r.parentNode,!r)return!1;n=n&&s==0,i=i&&s==Se(r)}}function mn(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const er=function(r){return r.focusNode&&yt(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function lt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Gc(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function jc(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(Se(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(Se(n.startContainer),n.startOffset)}}}const Re=typeof navigator<"u"?navigator:null,As=typeof document<"u"?document:null,it=Re&&Re.userAgent||"",ei=/Edge\/(\d+)/.exec(it),pl=/MSIE \d/.exec(it),ti=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(it),ye=!!(pl||ti||ei),et=pl?document.documentMode:ti?+ti[1]:ei?+ei[1]:0,Te=!ye&&/gecko\/(\d+)/i.test(it);Te&&+(/Firefox\/(\d+)/.exec(it)||[0,0])[1];const ni=!ye&&/Chrome\/(\d+)/.exec(it),re=!!ni,ml=ni?+ni[1]:0,he=!ye&&!!Re&&/Apple Computer/.test(Re.vendor),_t=he&&(/Mobile\/\w+/.test(it)||!!Re&&Re.maxTouchPoints>2),ke=_t||(Re?/Mac/.test(Re.platform):!1),Yc=Re?/Win/.test(Re.platform):!1,Ue=/Android \d/.test(it),gn=!!As&&"webkitFontSmoothing"in As.documentElement.style,Xc=gn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Zc(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function _e(r,e){return typeof r=="number"?r:r[e]}function Qc(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function vs(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,s=r.dom.ownerDocument;for(let o=t||r.dom;o;){if(o.nodeType!=1){o=Bt(o);continue}let l=o,a=l==s.body,c=a?Zc(s):Qc(l),h=0,u=0;if(e.top<c.top+_e(n,"top")?u=-(c.top-e.top+_e(i,"top")):e.bottom>c.bottom-_e(n,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+_e(i,"top")-c.top:e.bottom-c.bottom+_e(i,"bottom")),e.left<c.left+_e(n,"left")?h=-(c.left-e.left+_e(i,"left")):e.right>c.right-_e(n,"right")&&(h=e.right-c.right+_e(i,"right")),h||u)if(a)s.defaultView.scrollBy(h,u);else{let p=l.scrollLeft,d=l.scrollTop;u&&(l.scrollTop+=u),h&&(l.scrollLeft+=h);let g=l.scrollLeft-p,y=l.scrollTop-d;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(f))break;o=f=="absolute"?o.offsetParent:Bt(o)}}function eh(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let s=(e.left+e.right)/2,o=t+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=r.root.elementFromPoint(s,o);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:gl(r.dom)}}function gl(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Bt(n));return e}function th({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;yl(t,n==0?0:n-e)}function yl(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:s}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=s&&(n.scrollLeft=s)}}let Nt=null;function nh(r){if(r.setActive)return r.setActive();if(Nt)return r.focus(Nt);let e=gl(r);r.focus(Nt==null?{get preventScroll(){return Nt={preventScroll:!0},!0}}:void 0),Nt||(Nt=!1,yl(e,0))}function bl(r,e){let t,n=2e8,i,s=0,o=e.top,l=e.top,a,c;for(let h=r.firstChild,u=0;h;h=h.nextSibling,u++){let f;if(h.nodeType==1)f=h.getClientRects();else if(h.nodeType==3)f=He(h).getClientRects();else continue;for(let p=0;p<f.length;p++){let d=f[p];if(d.top<=o&&d.bottom>=l){o=Math.max(d.bottom,o),l=Math.min(d.top,l);let g=d.left>e.left?d.left-e.left:d.right<e.left?e.left-d.right:0;if(g<n){t=h,n=g,i=g&&t.nodeType==3?{left:d.right<e.left?d.right:d.left,top:e.top}:e,h.nodeType==1&&g&&(s=u+(e.left>=(d.left+d.right)/2?1:0));continue}}else d.top>e.top&&!a&&d.left<=e.left&&d.right>=e.left&&(a=h,c={left:Math.max(d.left,Math.min(d.right,e.left)),top:d.top});!t&&(e.left>=d.right&&e.top>=d.top||e.left>=d.left&&e.top>=d.bottom)&&(s=u+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?rh(t,i):!t||n&&t.nodeType==1?{node:r,offset:s}:bl(t,i)}function rh(r,e){let t=r.nodeValue.length,n=document.createRange();for(let i=0;i<t;i++){n.setEnd(r,i+1),n.setStart(r,i);let s=Ke(n,1);if(s.top!=s.bottom&&Ti(e,s))return{node:r,offset:i+(e.left>=(s.left+s.right)/2?1:0)}}return{node:r,offset:0}}function Ti(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function ih(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function sh(r,e,t){let{node:n,offset:i}=bl(e,t),s=-1;if(n.nodeType==1&&!n.firstChild){let o=n.getBoundingClientRect();s=o.left!=o.right&&t.left>(o.left+o.right)/2?1:-1}return r.docView.posFromDOM(n,i,s)}function oh(r,e,t,n){let i=-1;for(let s=e,o=!1;s!=r.dom;){let l=r.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(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)&&(!o&&a.left>n.left||a.top>n.top?i=l.posBefore:(!o&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function kl(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),s=i;;){let o=r.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ti(e,c))return kl(o,e,c)}}if((s=(s+1)%n)==i)break}return r}function lh(r,e){let t=r.dom.ownerDocument,n,i=0,s=jc(t,e.left,e.top);s&&({node:n,offset:i}=s);let o=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!o||!r.dom.contains(o.nodeType!=1?o.parentNode:o)){let c=r.dom.getBoundingClientRect();if(!Ti(e,c)||(o=kl(r.dom,e,c),!o))return null}if(he)for(let c=o;n&&c;c=Bt(c))c.draggable&&(n=void 0);if(o=ih(o,e),n){if(Te&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let h=n.childNodes[i],u;h.nodeName=="IMG"&&(u=h.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;gn&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=oh(r,n,i,e))}l==null&&(l=sh(r,o,e));let a=r.docView.nearestDesc(o,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Is(r){return r.top<r.bottom||r.left<r.right}function Ke(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(Is(n))return n}return Array.prototype.find.call(t,Is)||r.getBoundingClientRect()}const ah=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Sl(r,e,t){let{node:n,offset:i,atom:s}=r.docView.domFromPos(e,t<0?-1:1),o=gn||Te;if(n.nodeType==3)if(o&&(ah.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=Ke(He(n,i,i),t);if(Te&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=Ke(He(n,i-1,i-1),-1);if(c.top==a.top){let h=Ke(He(n,i,i+1),-1);if(h.top!=a.top)return $t(h,h.left<c.left)}}return a}else{let a=i,c=i,h=t<0?1:-1;return t<0&&!i?(c++,h=-1):t>=0&&i==n.nodeValue.length?(a--,h=1):t<0?a--:c++,$t(Ke(He(n,a,c),h),h<0)}if(!r.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(t<0||i==Se(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return Nr(a.getBoundingClientRect(),!1)}if(s==null&&i<Se(n)){let a=n.childNodes[i];if(a.nodeType==1)return Nr(a.getBoundingClientRect(),!0)}return Nr(n.getBoundingClientRect(),t>=0)}if(s==null&&i&&(t<0||i==Se(n))){let a=n.childNodes[i-1],c=a.nodeType==3?He(a,Se(a)-(o?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return $t(Ke(c,1),!1)}if(s==null&&i<Se(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?He(a,0,o?0:1):a.nodeType==1?a:null:null;if(c)return $t(Ke(c,-1),!0)}return $t(Ke(n.nodeType==3?He(n):n,-t),t>=0)}function $t(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function Nr(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function xl(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function ch(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return xl(r,e,()=>{let{node:s}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=Sl(r,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=He(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let h=a[c];if(h.bottom>h.top+1&&(t=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const hh=/[\u0590-\u08ac]/;function uh(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,s=!i,o=i==n.parent.content.size,l=r.domSelection();return l?!hh.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:o:xl(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:h,anchorOffset:u}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let p=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:d,focusOffset:g}=r.domSelectionRange(),y=d&&!p.contains(d.nodeType==1?d:d.parentNode)||a==d&&c==g;try{l.collapse(h,u),a&&(a!=h||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let Rs=null,Ps=null,Fs=!1;function fh(r,e,t){return Rs==e&&Ps==t?Fs:(Rs=e,Ps=t,Fs=t=="up"||t=="down"?ch(r,e,t):uh(r,e,t))}const Ce=0,Ls=1,at=2,Pe=3;class yn{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=Ce,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let s,o;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>Y(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!t||s.node))if(n&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))n=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],s=n+i.size;if(n==e&&s!=n){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-n-i.border);n=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let s=0;n<this.children.length;n++){let o=this.children[n],l=s+o.size;if(l>e||o instanceof Cl){i=e-s;break}s=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let s;n&&!(s=this.children[n-1]).size&&s instanceof Tl&&s.side>=0;n--);if(t<=0){let s,o=!0;for(;s=n?this.children[n-1]:null,!(!s||s.dom.parentNode==this.contentDOM);n--,o=!1);return s&&t&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Y(s.dom)+1:0}}else{let s,o=!0;for(;s=n<this.children.length?this.children[n]:null,!(!s||s.dom.parentNode==this.contentDOM);n++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Y(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,s=-1;for(let o=n,l=0;;l++){let a=this.children[l],c=o+a.size;if(i==-1&&e<=c){let h=o+a.border;if(e>=h&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,h);e=o;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=Y(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let h=l+1;h<this.children.length;h++){let u=this.children[h];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){s=Y(u.dom);break}t+=u.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:s}}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:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let s=Math.min(e,t),o=Math.max(e,t);for(let p=0,d=0;p<this.children.length;p++){let g=this.children[p],y=d+g.size;if(s>d&&o<y)return g.setSelection(e-d-g.border,t-d-g.border,n,i);d=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),h=n.domSelectionRange(),u=!1;if((Te||he)&&e==t){let{node:p,offset:d}=l;if(p.nodeType==3){if(u=!!(d&&p.nodeValue[d-1]==`
|
|
6
|
-
`),u&&d==p.nodeValue.length)for(let g=p,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:Y(y)+1});break}let C=g.pmViewDesc;if(C&&C.node&&C.node.isBlock)break}}else{let g=p.childNodes[d-1];u=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(Te&&h.focusNode&&h.focusNode!=a.node&&h.focusNode.nodeType==1){let p=h.focusNode.childNodes[h.focusOffset];p&&p.contentEditable=="false"&&(i=!0)}if(!(i||u&&he)&&yt(l.node,l.offset,h.anchorNode,h.anchorOffset)&&yt(a.node,a.offset,h.focusNode,h.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&Te)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let d=l;l=a,a=d}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let s=this.children[i],o=n+s.size;if(n==o?e<=o&&t>=n:e<o&&t>n){let l=n+s.border,a=o-s.border;if(e>=l&&t<=a){this.dirty=e==n||t==o?at:Ls,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Pe:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?at:Pe}n=o}this.dirty=at}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?at:Ls;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Tl extends yn{constructor(e,t,n,i){let s,o=t.type.toDOM;if(typeof o=="function"&&(o=o(n,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ce&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class dh extends yn{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class bt extends yn{constructor(e,t,n,i,s){super(e,[],n,i),this.mark=t,this.spec=s}static create(e,t,n,i){let s=i.nodeViews[t.type.name],o=s&&s(t,i,n);return(!o||!o.dom)&&(o=kt.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new bt(e,t,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Pe||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Pe&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ce){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Ce}}slice(e,t,n){let i=bt.create(this.parent,this.mark,!0,n),s=this.children,o=this.size;t<o&&(s=ii(s,t,o,n)),e>0&&(s=ii(s,0,e,n));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class tt extends yn{constructor(e,t,n,i,s,o,l,a,c){super(e,[],s,o),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,s,o){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return o;if(a.parent)return a.parent.posBeforeChild(a)},n,i),h=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!h)h=document.createTextNode(t.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:u}=kt.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let f=h;return h=Ol(h,n,t),c?a=new ph(e,t,n,i,h,u||null,f,c,s,o+1):t.isText?new tr(e,t,n,i,h,f,s):new tt(e,t,n,i,h,u||null,f,s,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>b.empty)}return e}matchesNode(e,t,n){return this.dirty==Ce&&e.eq(this.node)&&qn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,s=e.composing?this.localCompositionInfo(e,t):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new gh(this,o&&o.node,e);kh(this.node,this.innerDeco,(c,h,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!u&&a.syncToMarks(h==this.node.childCount?D.none:this.node.child(h).marks,n,e),a.placeWidget(c,e,i)},(c,h,u,f)=>{a.syncToMarks(c.marks,n,e);let p;a.findNodeMatch(c,h,u,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,h,u,p,e)||a.updateNextNode(c,h,u,e,f,i)||a.addNode(c,h,u,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==at)&&(o&&this.protectLocalComposition(e,o),wl(this.contentDOM,this.children,e),_t&&Sh(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof O)||n<t||i>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=xh(this.node.content,o,n-t,i-t);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new dh(this,s,t,i);e.input.compositionNodes.push(o),this.children=ii(this.children,n,n+i.length,e,o)}update(e,t,n,i){return this.dirty==Pe||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Ce}updateOuterDeco(e){if(qn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Ml(this.dom,this.nodeDOM,ri(this.outerDeco,this.node,t),ri(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function zs(r,e,t,n,i){Ol(n,e,r);let s=new tt(void 0,r,e,t,n,n,n,i,0);return s.contentDOM&&s.updateChildren(i,0),s}class tr extends tt{constructor(e,t,n,i,s,o,l){super(e,t,n,i,s,null,o,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==Pe||this.dirty!=Ce&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ce||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Ce,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),s=document.createTextNode(i.text);return new tr(this.parent,i,this.outerDeco,this.innerDeco,s,s,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Pe)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Cl extends yn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ce&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ph extends tt{constructor(e,t,n,i,s,o,l,a,c,h){super(e,t,n,i,s,o,l,c,h),this.spec=a}update(e,t,n,i){if(this.dirty==Pe)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,n);return s&&this.updateInner(e,t,n,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function wl(r,e,t){let n=r.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==r){for(;l!=n;)n=Bs(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(o instanceof bt){let a=n?n.previousSibling:r.lastChild;wl(o.contentDOM,o.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Bs(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const sn=function(r){r&&(this.nodeName=r)};sn.prototype=Object.create(null);const ct=[new sn];function ri(r,e,t){if(r.length==0)return ct;let n=t?ct[0]:new sn,i=[n];for(let s=0;s<r.length;s++){let o=r[s].type.attrs;if(o){o.nodeName&&i.push(n=new sn(o.nodeName));for(let l in o){let a=o[l];a!=null&&(t&&i.length==1&&i.push(n=new sn(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function Ml(r,e,t,n){if(t==ct&&n==ct)return e;let i=e;for(let s=0;s<n.length;s++){let o=n[s],l=t[s];if(s){let a;l&&l.nodeName==o.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==o.nodeName||(a=document.createElement(o.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=ct[0]),i=a}mh(i,l||ct[0],o)}return i}function mh(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<n.length;s++)i.indexOf(n[s])==-1&&r.classList.remove(n[s]);for(let s=0;s<i.length;s++)n.indexOf(i[s])==-1&&r.classList.add(i[s]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function Ol(r,e,t){return Ml(r,r,ct,ri(e,t,r.nodeType!=1))}function qn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Bs(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class gh{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=yh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,s=this.stack.length>>1,o=Math.min(s,e.length);for(;i<o&&(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.dirty=Ce,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=bt.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))s=this.top.children.indexOf(o,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,n)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,n,i,s){let o=this.top.children[i];return o.dirty==Pe&&o.dom==o.contentDOM&&(o.dirty=at),o.update(e,t,n,s)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof tt){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let h=a.dom,u,f=this.isLocked(h)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Pe&&qn(t,a.outerDeco));if(!f&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=h&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,n,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=at,u.updateChildren(i,o+1),u.dirty=Ce),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,s,o){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!qn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=tt.create(this.top,t,n,i,s,o);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,n,i,s){let o=tt.create(this.top,e,t,n,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new Tl(this.top,e,t,n);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof bt;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof tr)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((he||re)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new Cl(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function yh(r,e){let t=e,n=t.children.length,i=r.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof bt)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function bh(r,e){return r.type.side-e.type.side}function kh(r,e,t,n){let i=e.locals(r),s=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let h=r.child(c);n(h,i,e.forChild(s,h),c),s+=h.nodeSize}return}let o=0,l=[],a=null;for(let c=0;;){let h,u;for(;o<i.length&&i[o].to==s;){let y=i[o++];y.widget&&(h?(u||(u=[h])).push(y):h=y)}if(h)if(u){u.sort(bh);for(let y=0;y<u.length;y++)t(u[y],c,!!a)}else t(h,c,!!a);let f,p;if(a)p=-1,f=a,a=null;else if(c<r.childCount)p=c,f=r.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let d=s+f.nodeSize;if(f.isText){let y=d;o<i.length&&i[o].from<y&&(y=i[o].from);for(let C=0;C<l.length;C++)l[C].to<y&&(y=l[C].to);y<d&&(a=f.cut(y-s),f=f.cut(0,y-s),d=y,p=-1)}else for(;o<i.length&&i[o].to<d;)o++;let g=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,g,e.forChild(s,f),p),s=d}}function Sh(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function xh(r,e,t,n){for(let i=0,s=0;i<r.childCount&&s<=n;){let o=r.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let a=o.text;for(;i<r.childCount;){let c=r.child(i++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function ii(r,e,t,n,i){let s=[];for(let o=0,l=0;o<r.length;o++){let a=r[o],c=l,h=l+=a.size;c>=t||h<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,n)),i&&(s.push(i),i=void 0),h>t&&s.push(a.slice(t-c,a.size,n)))}return s}function Ci(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),s=i&&i.size==0,o=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(o<0)return null;let l=n.resolve(o),a,c;if(er(t)){for(a=o;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&w.isSelectable(u)&&i.parent&&!(u.isInline&&Kc(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new w(o==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=o,f=o;for(let p=0;p<t.rangeCount;p++){let d=t.getRangeAt(p);u=Math.min(u,r.docView.posFromDOM(d.startContainer,d.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(d.endContainer,d.endOffset,-1))}if(u<0)return null;[a,o]=f==r.state.selection.anchor?[f,u]:[u,f],l=n.resolve(o)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let h=n.resolve(a);if(!c){let u=e=="pointer"||r.state.selection.head<l.pos&&!s?1:-1;c=wi(r,h,l,u)}return c}function El(r){return r.editable?r.hasFocus():Dl(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function qe(r,e=!1){let t=r.state.selection;if(Nl(r,t),!!El(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&re){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&yt(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Ch(r);else{let{anchor:n,head:i}=t,s,o;_s&&!(t instanceof O)&&(t.$from.parent.inlineContent||(s=Vs(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(o=Vs(r,t.to))),r.docView.setSelection(n,i,r,e),_s&&(s&&Hs(s),o&&Hs(o)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Th(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const _s=he||re&&ml<63;function Vs(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,s=n?t.childNodes[n-1]:null;if(he&&i&&i.contentEditable=="false")return Dr(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Dr(i);if(s)return Dr(s)}}function Dr(r){return r.contentEditable="true",he&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Hs(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Th(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!El(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ch(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,Y(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&ye&&et<=11&&(t.disabled=!0,t.disabled=!1)}function Nl(r,e){if(e instanceof w){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(Ws(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else Ws(r)}function Ws(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function wi(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||O.between(e,t,n)}function Us(r){return r.editable&&!r.hasFocus()?!1:Dl(r)}function Dl(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function wh(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return yt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function si(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),s=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return s&&N.findFrom(s,e)}function Ge(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function qs(r,e,t){let n=r.state.selection;if(n instanceof O)if(t.indexOf("s")>-1){let{$head:i}=n,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=r.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return Ge(r,new O(n.$anchor,o))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=si(r.state,e);return i&&i instanceof w?Ge(r,i):!1}else if(!(ke&&t.indexOf("m")>-1)){let i=n.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=r.docView.descAt(l))&&!o.contentDOM?w.isSelectable(s)?Ge(r,new w(e<0?r.state.doc.resolve(i.pos-s.nodeSize):i)):gn?Ge(r,new O(r.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(n instanceof w&&n.node.isInline)return Ge(r,new O(e>0?n.$to:n.$from));{let i=si(r.state,e);return i?Ge(r,i):!1}}}function Jn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function on(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function Dt(r,e){return e<0?Mh(r):Oh(r)}function Mh(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,s,o=!1;for(Te&&t.nodeType==1&&n<Jn(t)&&on(t.childNodes[n],-1)&&(o=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(on(l,-1))i=t,s=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(Al(t))break;{let l=t.previousSibling;for(;l&&on(l,-1);)i=t.parentNode,s=Y(l),l=l.previousSibling;if(l)t=l,n=Jn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}o?oi(r,t,n):i&&oi(r,i,s)}function Oh(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Jn(t),s,o;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(on(l,1))s=t,o=++n;else break}else{if(Al(t))break;{let l=t.nextSibling;for(;l&&on(l,1);)s=l.parentNode,o=Y(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=Jn(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}s&&oi(r,s,o)}function Al(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Eh(r,e){for(;r&&e==r.childNodes.length&&!mn(r);)e=Y(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function Nh(r,e){for(;r&&!e&&!mn(r);)e=Y(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function oi(r,e,t){if(e.nodeType!=3){let s,o;(o=Eh(e,t))?(e=o,t=0):(s=Nh(e,t))&&(e=s,t=s.nodeValue.length)}let n=r.domSelection();if(!n)return;if(er(n)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),n.removeAllRanges(),n.addRange(s)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&qe(r)},50)}function Js(r,e){let t=r.state.doc.resolve(e);if(!(re||Yc)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let s=r.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<t.end()){let s=r.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function $s(r,e,t){let n=r.state.selection;if(n instanceof O&&!n.empty||t.indexOf("s")>-1||ke&&t.indexOf("m")>-1)return!1;let{$from:i,$to:s}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let o=si(r.state,e);if(o&&o instanceof w)return Ge(r,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=n instanceof Z?N.near(o,e):N.findFrom(o,e);return l?Ge(r,l):!1}return!1}function Ks(r,e){if(!(r.state.selection instanceof O))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let o=r.state.tr;return e<0?o.delete(t.pos-s.nodeSize,t.pos):o.delete(t.pos,t.pos+s.nodeSize),r.dispatch(o),!0}return!1}function Gs(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function Dh(r){if(!he||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;Gs(r,n,"true"),setTimeout(()=>Gs(r,n,"false"),20)}return!1}function Ah(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function vh(r,e){let t=e.keyCode,n=Ah(e);if(t==8||ke&&t==72&&n=="c")return Ks(r,-1)||Dt(r,-1);if(t==46&&!e.shiftKey||ke&&t==68&&n=="c")return Ks(r,1)||Dt(r,1);if(t==13||t==27)return!0;if(t==37||ke&&t==66&&n=="c"){let i=t==37?Js(r,r.state.selection.from)=="ltr"?-1:1:-1;return qs(r,i,n)||Dt(r,i)}else if(t==39||ke&&t==70&&n=="c"){let i=t==39?Js(r,r.state.selection.from)=="ltr"?1:-1:1;return qs(r,i,n)||Dt(r,i)}else{if(t==38||ke&&t==80&&n=="c")return $s(r,-1,n)||Dt(r,-1);if(t==40||ke&&t==78&&n=="c")return Dh(r)||$s(r,1,n)||Dt(r,1);if(n==(ke?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Mi(r,e){r.someProp("transformCopied",p=>{e=p(e,r)});let t=[],{content:n,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,s--;let p=n.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),n=p.content}let o=r.someProp("clipboardSerializer")||kt.fromSchema(r.state.schema),l=Ll(),a=l.createElement("div");a.appendChild(o.serializeFragment(n,{document:l}));let c=a.firstChild,h,u=0;for(;c&&c.nodeType==1&&(h=Fl[c.nodeName.toLowerCase()]);){for(let p=h.length-1;p>=0;p--){let d=l.createElement(h[p]);for(;a.firstChild;)d.appendChild(a.firstChild);a.appendChild(d),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${s}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",p=>p(e,r))||e.content.textBetween(0,e.content.size,`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ce=require("../bundled/vivid-element.cjs"),m=require("../bundled/feature.cjs"),zl=require("../bundled/localized.cjs"),Ri=require("../bundled/ref.cjs"),Tr=require("../bundled/definition9.cjs"),Bl=require("../bundled/definition15.cjs"),Vo=require("../bundled/definition19.cjs"),Ho=require("../bundled/definition12.cjs"),Wo=require("../bundled/definition11.cjs"),Uo=require("../bundled/definition6.cjs"),$o=require("../bundled/definition7.cjs"),qo=require("../bundled/definition10.cjs"),Ko=require("../bundled/definition3.cjs"),_l=require("../bundled/divider.cjs"),Vl=require("../bundled/mixins.cjs"),Hl=":host{display:block}.rte{display:flex;flex-direction:column;block-size:100%}.editor{display:contents}.editor-viewport{position:relative;overflow:hidden;flex:1;contain:layout}.editor-scroll-area{--editor-padding-block: 8px;--editor-padding-inline: 16px;display:flex;flex-direction:column;background-color:var(--vvd-color-canvas);block-size:100%;color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.editor-scroll-area{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}",Jo=65535,Go=Math.pow(2,16);function Wl(r,e){return r+e*Go}function Fi(r){return r&Jo}function Ul(r){return(r-(r&Jo))/Go}const jo=1,Yo=2,mn=4,Xo=8;class Cr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&Xo)>0}get deletedBefore(){return(this.delInfo&(jo|mn))>0}get deletedAfter(){return(this.delInfo&(Yo|mn))>0}get deletedAcross(){return(this.delInfo&mn)>0}}class fe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&fe.empty)return fe.empty}recover(e){let t=0,n=Fi(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+Ul(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+i+(f<0?0:d);if(n)return h;let p=e==(t<0?a:u)?null:Wl(l/3,e-a),b=e==a?Yo:e==u?jo:mn;return(t<0?e!=a:e!=u)&&(b|=Xo),new Cr(h,b,p)}i+=d-c}return n?e+i:new Cr(e+i,0,null)}touches(e,t){let n=0,i=Fi(t),o=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?n:0);if(a>e)break;let c=this.ranges[l+o],d=a+c;if(e<=d&&l==i*3)return!0;n+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],d=this.ranges[i+n];e(l,l+c,a,a+d),o+=d-c}}invert(){return new fe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?fe.empty:new fe(e<0?[0,-e,0]:[0,0,e])}}fe.empty=new fe([]);class Kt{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Kt(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=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new Kt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Cr(e,i,null)}}const jn=Object.create(null);class ee{getMap(){return fe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=jn[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in jn)throw new RangeError("Duplicate use of step JSON ID "+e);return jn[e]=t,t.prototype.jsonID=e,t}}class z{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new z(e,null)}static fail(e){return new z(null,e)}static fromReplace(e,t,n,i){try{return z.ok(e.replace(t,n,i))}catch(o){if(o instanceof m.ReplaceError)return z.fail(o.message);throw o}}}function Vr(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let o=r.child(i);o.content.size&&(o=o.copy(Vr(o.content,e,o))),o.isInline&&(o=e(o,t,i)),n.push(o)}return m.Fragment.fromArray(n)}class $e extends ee{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new m.Slice(Vr(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,o)}invert(){return new ge(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new $e(t.pos,n.pos,this.mark)}merge(e){return e instanceof $e&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new $e(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 $e(t.from,t.to,e.markFromJSON(t.mark))}}ee.jsonID("addMark",$e);class ge extends ee{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new m.Slice(Vr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,n)}invert(){return new $e(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ge(t.pos,n.pos,this.mark)}merge(e){return e instanceof ge&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ge(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 ge(t.from,t.to,e.markFromJSON(t.mark))}}ee.jsonID("removeMark",ge);class qe extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new qe(this.pos,t.marks[i]);return new qe(this.pos,this.mark)}}return new st(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new qe(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new qe(t.pos,e.markFromJSON(t.mark))}}ee.jsonID("addNodeMark",qe);class st extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new qe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new st(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 st(t.pos,e.markFromJSON(t.mark))}}ee.jsonID("removeNodeMark",st);class Y extends ee{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&Mr(e,this.from,this.to)?z.fail("Structure replace would overwrite content"):z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new fe([this.from,this.to-this.from,this.slice.size])}invert(e){return new Y(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Y(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Y)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?m.Slice.empty:new m.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Y(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?m.Slice.empty:new m.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Y(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 Y(t.from,t.to,m.Slice.fromJSON(e,t.slice),!!t.structure)}}ee.jsonID("replace",Y);class Q extends ee{constructor(e,t,n,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(Mr(e,this.from,this.gapFrom)||Mr(e,this.gapTo,this.to)))return z.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return z.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?z.fromReplace(e,this.from,this.to,n):z.fail("Content does not fit in gap")}getMap(){return new fe([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 Q(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),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||o>n.pos?null:new Q(t.pos,n.pos,i,o,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 Q(t.from,t.to,t.gapFrom,t.gapTo,m.Slice.fromJSON(e,t.slice),t.insert,!!t.structure)}}ee.jsonID("replaceAround",Q);function Mr(r,e,t){let n=r.resolve(e),i=t-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,i--;if(i>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function $l(r,e,t,n){let i=[],o=[],s,l;r.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!n.isInSet(u)&&d.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(u);for(let b=0;b<u.length;b++)u[b].isInSet(p)||(s&&s.to==f&&s.mark.eq(u[b])?s.to=h:i.push(s=new ge(f,h,u[b])));l&&l.to==f?l.to=h:o.push(l=new $e(f,h,n))}}),i.forEach(a=>r.step(a)),o.forEach(a=>r.step(a))}function ql(r,e,t,n){let i=[],o=0;r.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(n instanceof m.MarkType){let c=s.marks,d;for(;d=n.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else n?n.isInSet(s.marks)&&(a=[n]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;d<a.length;d++){let u=a[d],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&u.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=o):i.push({style:u,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>r.step(new ge(s.from,s.to,s.style)))}function Hr(r,e,t,n=t.contentMatch,i=!0){let o=r.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),d=l+c.nodeSize,u=n.matchType(c.type);if(!u)s.push(new Y(l,d,m.Slice.empty));else{n=u;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new ge(l,d,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new m.Slice(m.Fragment.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new Y(l+f.index,l+f.index+f[0].length,p))}}l=d}if(!n.validEnd){let a=n.fillBefore(m.Fragment.empty,!0);r.replace(l,l,new m.Slice(a,0,0))}for(let a=s.length-1;a>=0;a--)r.step(s[a])}function Kl(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Wr(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,o=0;;--n){let s=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-o;if(n<r.depth&&s.canReplace(l,a,t))return n;if(n==0||s.type.spec.isolating||!Kl(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function Jl(r,e,t){let{$from:n,$to:i,depth:o}=e,s=n.before(o+1),l=i.after(o+1),a=s,c=l,d=m.Fragment.empty,u=0;for(let p=o,b=!1;p>t;p--)b||n.index(p)>0?(b=!0,d=m.Fragment.from(n.node(p).copy(d)),u++):a--;let f=m.Fragment.empty,h=0;for(let p=o,b=!1;p>t;p--)b||i.after(p+1)<i.end(p)?(b=!0,f=m.Fragment.from(i.node(p).copy(f)),h++):c++;r.step(new Q(a,c,s,l,new m.Slice(d.append(f),u,h),d.size-u,!0))}function Gl(r,e,t){let n=m.Fragment.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let l=t[s].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=m.Fragment.from(t[s].type.create(t[s].attrs,n))}let i=e.start,o=e.end;r.step(new Q(i,o,i,o,new m.Slice(n,0,0),t.length,!0))}function jl(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(n,a)&&Yl(r.doc,r.mapping.slice(o).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Qo(r,s,l,o),Hr(r,r.mapping.slice(o).map(l,1),n,void 0,c===null);let d=r.mapping.slice(o),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return r.step(new Q(u,f,u+1,f-1,new m.Slice(m.Fragment.from(n.create(a,null,s.marks)),0,0),1,!0)),c===!0&&Zo(r,s,l,o),!1}})}function Zo(r,e,t,n){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+o+s.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Qo(r,e,t,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=r.mapping.slice(n).map(t+1+o);r.replaceWith(s,s+1,e.type.schema.text(`
|
|
2
|
+
`))}})}function Yl(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function Xl(r,e,t,n,i){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,i||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new Q(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new m.Slice(m.Fragment.from(s),0,0),1,!0))}function gn(r,e,t=1,n){let i=r.resolve(e),o=i.depth-t,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,d=t-2;c>o;c--,d--){let u=i.node(c),f=i.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=n&&n[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let b=n&&n[d]||u;if(!u.canReplace(f+1,u.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(o),a=n&&n[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function Zl(r,e,t=1,n){let i=r.doc.resolve(e),o=m.Fragment.empty,s=m.Fragment.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=m.Fragment.from(i.node(l).copy(o));let d=n&&n[c];s=m.Fragment.from(d?d.type.create(d.attrs,s):i.node(l).copy(s))}r.step(new Y(e,e,new m.Slice(o.append(s),t,t),!0))}function Ur(r,e){let t=r.resolve(e),n=t.index();return ea(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function Ql(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function ea(r,e){return!!(r&&e&&!r.isLeaf&&Ql(r,e))}function ta(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,o=r.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(i);d&&!u?n=!1:!d&&u&&(n=!0)}let l=r.steps.length;if(n===!1){let d=r.doc.resolve(e+t);Qo(r,d.node(),d.before(),l)}s.inlineContent&&Hr(r,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new Y(c,a.map(e+t,-1),m.Slice.empty,!0)),n===!0){let d=r.doc.resolve(c);Zo(r,d.node(),d.before(),r.steps.length)}return r}function na(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let o=n.index(i);if(n.node(i).canReplaceWith(o,o,t))return n.before(i+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let o=n.indexAfter(i);if(n.node(i).canReplaceWith(o,o,t))return n.after(i+1);if(o<n.node(i).childCount)return null}return null}function $r(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let l=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,a=n.index(s)+(l>0?1:0),c=n.node(s),d=!1;if(o==1)d=c.canReplace(a,a,i);else{let u=c.contentMatchAt(a).findWrapping(i.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?n.pos:l<0?n.before(s+1):n.after(s+1)}return null}function qr(r,e,t=e,n=m.Slice.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),o=r.resolve(t);return es(i,o,n)?new Y(e,t,n):new ra(i,o,n).fit()}function es(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class ra{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=m.Fragment.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=m.Fragment.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new m.Slice(o,s,l);return e>-1?new Q(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new Y(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=Yn(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(m.Fragment.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:d};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Yn(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new m.Slice(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=Yn(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new m.Slice(_t(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new m.Slice(_t(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,d=[],{match:u,type:f}=this.frontier[t];if(i){for(let b=0;b<i.childCount;b++)d.push(i.child(b));u=u.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let b=l.child(c),y=u.matchType(b.type);if(!y)break;c++,(c>1||a==0||b.content.size)&&(u=y,d.push(ts(b.mark(f.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Vt(this.placed,t,m.Fragment.from(d)),this.frontier[t].match=u,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<h;b++){let C=y.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),y=C.content}this.unplaced=p?e==0?m.Slice.empty:new m.Slice(_t(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new m.Slice(_t(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Xn(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:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=Xn(e,t,i,n,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],d=Xn(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:o?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=Vt(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Vt(this.placed,this.depth,m.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(m.Fragment.empty,!0);t.childCount&&(this.placed=Vt(this.placed,this.frontier.length,t))}}function _t(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(_t(r.firstChild.content,e-1,t)))}function Vt(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Vt(r.lastChild.content,e-1,t)))}function Yn(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function ts(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,ts(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(m.Fragment.empty,!0)))),r.copy(n)}function Xn(r,e,t,n,i){let o=r.node(e),s=i?r.indexAfter(e):r.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,s);return l&&!ia(t,o.content,s)?l:null}function ia(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function oa(r){return r.spec.defining||r.spec.definingForContent}function sa(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),o=r.doc.resolve(t);if(es(i,o,n))return r.step(new Y(e,t,n));let s=rs(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:i.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=oa(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+d+1)%(n.openStart+1),p=c[h];if(p)for(let b=0;b<s.length;b++){let y=s[(b+a)%s.length],C=!0;y<0&&(C=!1,y=-y);let R=i.node(y-1),w=i.index(y-1);if(R.canReplaceWith(w,w,p.type,p.marks))return r.replace(i.before(y),C?o.after(y):t,new m.Slice(ns(n.content,0,n.openStart,h),h,n.openEnd))}}let u=r.steps.length;for(let f=s.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>u));f--){let h=s[f];h<0||(e=i.before(h),t=o.after(h))}}function ns(r,e,t,n,i){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(ns(o.content,e+1,t,n,o)))}if(e>n){let o=i.contentMatchAt(0),s=o.fillBefore(r).append(r);r=s.append(o.matchFragment(s).fillBefore(m.Fragment.empty,!0))}return r}function la(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=na(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new m.Slice(m.Fragment.from(n),0,0))}function aa(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),o=rs(n,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let s=1;s<=n.depth&&s<=i.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&i.end(s)-t!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return r.delete(n.before(s),t);r.delete(e,t)}function rs(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let o=r.start(i);if(o<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class Ct extends ee{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(i),0,t.isLeaf?0:1))}getMap(){return fe.empty}invert(e){return new Ct(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 Ct(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 Ct(t.pos,t.attr,t.value)}}ee.jsonID("attr",Ct);class Jt extends ee{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return z.ok(n)}getMap(){return fe.empty}invert(e){return new Jt(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 Jt(t.attr,t.value)}}ee.jsonID("docAttr",Jt);let xt=class extends Error{};xt=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};xt.prototype=Object.create(Error.prototype);xt.prototype.constructor=xt;xt.prototype.name="TransformError";class ca{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Kt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new xt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=m.Slice.empty){let i=qr(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new m.Slice(m.Fragment.from(n),0,0))}delete(e,t){return this.replace(e,t,m.Slice.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return sa(this,e,t,n),this}replaceRangeWith(e,t,n){return la(this,e,t,n),this}deleteRange(e,t){return aa(this,e,t),this}lift(e,t){return Jl(this,e,t),this}join(e,t=1){return ta(this,e,t),this}wrap(e,t){return Gl(this,e,t),this}setBlockType(e,t=e,n,i=null){return jl(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return Xl(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new Ct(e,t,n)),this}setDocAttribute(e,t){return this.step(new Jt(e,t)),this}addNodeMark(e,t){return this.step(new qe(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof m.Mark)t.isInSet(n.marks)&&this.step(new st(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new st(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,n){return Zl(this,e,t,n),this}addMark(e,t,n){return $l(this,e,t,n),this}removeMark(e,t,n){return ql(this,e,t,n),this}clearIncompatible(e,t,n){return Hr(this,e,t,n),this}}const Zn=Object.create(null);class N{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new da(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=m.Slice.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],d=e.mapping.slice(o);e.replaceRange(d.map(a.pos),d.map(c.pos),l?m.Slice.empty:t),l==0&&zi(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(n),c=a.map(s.pos),d=a.map(l.pos);o?e.deleteRange(c,d):(e.replaceRangeWith(c,d,t),zi(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new O(e):St(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?St(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):St(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new K(e.node(0))}static atStart(e){return St(e,e,0,0,1)||new K(e)}static atEnd(e){return St(e,e,e.content.size,e.childCount,-1)||new K(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Zn[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in Zn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return O.between(this.$anchor,this.$head).getBookmark()}}N.prototype.visible=!0;class da{constructor(e,t){this.$from=e,this.$to=t}}let Pi=!1;function Li(r){!Pi&&!r.parent.inlineContent&&(Pi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class O extends N{constructor(e,t=e){Li(e),Li(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return N.near(n);let i=e.resolve(t.map(this.anchor));return new O(i.parent.inlineContent?i:n,n)}replace(e,t=m.Slice.empty){if(super.replace(e,t),t==m.Slice.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof O&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new En(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 O(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let o=N.findFrom(t,n,!0)||N.findFrom(t,-n,!0);if(o)t=o.$head;else return N.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(N.findFrom(e,-n,!0)||N.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new O(e,t)}}N.jsonID("text",O);class En{constructor(e,t){this.anchor=e,this.head=t}map(e){return new En(e.map(this.anchor),e.map(this.head))}resolve(e){return O.between(e.resolve(this.anchor),e.resolve(this.head))}}class M extends N{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return n?N.near(o):new M(o)}content(){return new m.Slice(m.Fragment.from(this.node),0,0)}eq(e){return e instanceof M&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Kr(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new M(e.resolve(t.anchor))}static create(e,t){return new M(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}M.prototype.visible=!1;N.jsonID("node",M);class Kr{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new En(n,n):new Kr(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&M.isSelectable(n)?new M(t):N.near(t)}}class K extends N{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=m.Slice.empty){if(t==m.Slice.empty){e.delete(0,e.doc.content.size);let n=N.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new K(e)}map(e){return new K(e)}eq(e){return e instanceof K}getBookmark(){return ua}}N.jsonID("all",K);const ua={map(){return this},resolve(r){return new K(r)}};function St(r,e,t,n,i,o=!1){if(e.inlineContent)return O.create(r,t);for(let s=n-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&M.isSelectable(l))return M.create(r,t-(i<0?l.nodeSize:0))}else{let a=St(r,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function zi(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof Y||i instanceof Q))return;let o=r.mapping.maps[n],s;o.forEach((l,a,c,d)=>{s==null&&(s=d)}),r.setSelection(N.near(r.doc.resolve(s),t))}const Bi=1,dn=2,_i=4;class fa extends ca{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|Bi)&~dn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Bi)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=dn,this}ensureMarks(e){return m.Mark.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&dn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~dn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||m.Mark.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(N.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|=_i,this}get scrolledIntoView(){return(this.updated&_i)>0}}function Vi(r,e){return!e||!r?r:r.bind(e)}class Ht{constructor(e,t,n){this.name=e,this.init=Vi(t.init,n),this.apply=Vi(t.apply,n)}}const ha=[new Ht("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Ht("selection",{init(r,e){return r.selection||N.atStart(e.doc)},apply(r){return r.selection}}),new Ht("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Ht("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class Qn{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=ha.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Ht(n.key,n.spec.state,n))})}}class Tt{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 n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,d=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(d&&n.filterTransaction(d,s)){if(d.setMeta("appendedTransaction",e),!i){i=[];for(let u=0;u<this.config.plugins.length;u++)i.push(u<s?{state:n,n:t.length}:{state:this,n:0})}t.push(d),n=n.applyInner(d),o=!0}i&&(i[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Tt(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let o=n[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new fa(this)}static create(e){let t=new Qn(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Tt(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new Qn(this.schema,e.plugins),n=t.fields,i=new Tt(t);for(let o=0;o<n.length;o++){let s=n[o].name;i[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],o=i.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Qn(e.schema,e.plugins),o=new Tt(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=m.Node.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=N.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function is(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=is(i,e,{})),t[n]=i}return t}class re{constructor(e){this.spec=e,this.props={},e.props&&is(e.props,this,this.props),this.key=e.key?e.key.key:ss("plugin")}getState(e){return e[this.key]}}const er=Object.create(null);function ss(r){return r in er?r+"$"+ ++er[r]:(er[r]=0,r+"$")}class ls{constructor(e="key"){this.key=ss(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const $=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Ot=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let xr=null;const Fe=function(r,e,t){let n=xr||(xr=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},pa=function(){xr=null},lt=function(r,e,t,n){return t&&(Hi(r,e,t,n,-1)||Hi(r,e,t,n,1))},ma=/^(img|br|input|textarea|hr)$/i;function Hi(r,e,t,n,i){for(var o;;){if(r==t&&e==n)return!0;if(e==(i<0?0:me(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Xt(r)||ma.test(r.nodeName)||r.contentEditable=="false")return!1;e=$(r)+(i<0?0:1),r=s}else if(r.nodeType==1){let s=r.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else r=s,e=i<0?me(r):0}else return!1}}function me(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function ga(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=me(r)}else if(r.parentNode&&!Xt(r))e=$(r),r=r.parentNode;else return null}}function ba(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Xt(r))e=$(r)+1,r=r.parentNode;else return null}}function ya(r,e,t){for(let n=e==0,i=e==me(r);n||i;){if(r==t)return!0;let o=$(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,i=i&&o==me(r)}}function Xt(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const wn=function(r){return r.focusNode&<(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function et(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Sa(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ka(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(me(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(me(n.startContainer),n.startOffset)}}}const De=typeof navigator<"u"?navigator:null,Wi=typeof document<"u"?document:null,Xe=De&&De.userAgent||"",Or=/Edge\/(\d+)/.exec(Xe),as=/MSIE \d/.exec(Xe),Dr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Xe),ue=!!(as||Dr||Or),Je=as?document.documentMode:Dr?+Dr[1]:Or?+Or[1]:0,be=!ue&&/gecko\/(\d+)/i.test(Xe);be&&+(/Firefox\/(\d+)/.exec(Xe)||[0,0])[1];const Nr=!ue&&/Chrome\/(\d+)/.exec(Xe),X=!!Nr,cs=Nr?+Nr[1]:0,ie=!ue&&!!De&&/Apple Computer/.test(De.vendor),Dt=ie&&(/Mobile\/\w+/.test(Xe)||!!De&&De.maxTouchPoints>2),pe=Dt||(De?/Mac/.test(De.platform):!1),Ta=De?/Win/.test(De.platform):!1,Le=/Android \d/.test(Xe),Zt=!!Wi&&"webkitFontSmoothing"in Wi.documentElement.style,Ca=Zt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ma(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Ie(r,e){return typeof r=="number"?r:r[e]}function xa(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Ui(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let s=t||r.dom;s;){if(s.nodeType!=1){s=Ot(s);continue}let l=s,a=l==o.body,c=a?Ma(o):xa(l),d=0,u=0;if(e.top<c.top+Ie(n,"top")?u=-(c.top-e.top+Ie(i,"top")):e.bottom>c.bottom-Ie(n,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Ie(i,"top")-c.top:e.bottom-c.bottom+Ie(i,"bottom")),e.left<c.left+Ie(n,"left")?d=-(c.left-e.left+Ie(i,"left")):e.right>c.right-Ie(n,"right")&&(d=e.right-c.right+Ie(i,"right")),d||u)if(a)o.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let b=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Ot(s)}}function Oa(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=r.root.elementFromPoint(o,s);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:ds(r.dom)}}function ds(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Ot(n));return e}function Da({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;us(t,n==0?0:n-e)}function us(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:o}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let bt=null;function Na(r){if(r.setActive)return r.setActive();if(bt)return r.focus(bt);let e=ds(r);r.focus(bt==null?{get preventScroll(){return bt={preventScroll:!0},!0}}:void 0),bt||(bt=!1,us(e,0))}function fs(r,e){let t,n=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let d=r.firstChild,u=0;d;d=d.nextSibling,u++){let f;if(d.nodeType==1)f=d.getClientRects();else if(d.nodeType==3)f=Fe(d).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let b=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(b<n){t=d,n=b,i=b&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,d.nodeType==1&&b&&(o=u+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=u+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?Ea(t,i):!t||n&&t.nodeType==1?{node:r,offset:o}:fs(t,i)}function Ea(r,e){let t=r.nodeValue.length,n=document.createRange();for(let i=0;i<t;i++){n.setEnd(r,i+1),n.setStart(r,i);let o=Ve(n,1);if(o.top!=o.bottom&&Jr(e,o))return{node:r,offset:i+(e.left>=(o.left+o.right)/2?1:0)}}return{node:r,offset:0}}function Jr(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function wa(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function Aa(r,e,t){let{node:n,offset:i}=fs(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return r.docView.posFromDOM(n,i,o)}function va(r,e,t,n){let i=-1;for(let o=e,s=!1;o!=r.dom;){let l=r.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(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>n.left||a.top>n.top?i=l.posBefore:(!s&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function hs(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=r.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Jr(e,c))return hs(s,e,c)}}if((o=(o+1)%n)==i)break}return r}function Ia(r,e){let t=r.dom.ownerDocument,n,i=0,o=ka(t,e.left,e.top);o&&({node:n,offset:i}=o);let s=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!s||!r.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=r.dom.getBoundingClientRect();if(!Jr(e,c)||(s=hs(r.dom,e,c),!s))return null}if(ie)for(let c=s;n&&c;c=Ot(c))c.draggable&&(n=void 0);if(s=wa(s,e),n){if(be&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let d=n.childNodes[i],u;d.nodeName=="IMG"&&(u=d.getBoundingClientRect()).right<=e.left&&u.bottom>e.top&&i++}let c;Zt&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=va(r,n,i,e))}l==null&&(l=Aa(r,s,e));let a=r.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $i(r){return r.top<r.bottom||r.left<r.right}function Ve(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if($i(n))return n}return Array.prototype.find.call(t,$i)||r.getBoundingClientRect()}const Ra=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function ps(r,e,t){let{node:n,offset:i,atom:o}=r.docView.domFromPos(e,t<0?-1:1),s=Zt||be;if(n.nodeType==3)if(s&&(Ra.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=Ve(Fe(n,i,i),t);if(be&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=Ve(Fe(n,i-1,i-1),-1);if(c.top==a.top){let d=Ve(Fe(n,i,i+1),-1);if(d.top!=a.top)return Rt(d,d.left<c.left)}}return a}else{let a=i,c=i,d=t<0?1:-1;return t<0&&!i?(c++,d=-1):t>=0&&i==n.nodeValue.length?(a--,d=1):t<0?a--:c++,Rt(Ve(Fe(n,a,c),d),d<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==me(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return tr(a.getBoundingClientRect(),!1)}if(o==null&&i<me(n)){let a=n.childNodes[i];if(a.nodeType==1)return tr(a.getBoundingClientRect(),!0)}return tr(n.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==me(n))){let a=n.childNodes[i-1],c=a.nodeType==3?Fe(a,me(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Rt(Ve(c,1),!1)}if(o==null&&i<me(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Fe(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Rt(Ve(c,-1),!0)}return Rt(Ve(n.nodeType==3?Fe(n):n,-t),t>=0)}function Rt(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function tr(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function ms(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function Fa(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return ms(r,e,()=>{let{node:o}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=ps(r,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Fe(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let d=a[c];if(d.bottom>d.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}const Pa=/[\u0590-\u08ac]/;function La(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,o=!i,s=i==n.parent.content.size,l=r.domSelection();return l?!Pa.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:ms(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:b}=r.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==b;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let qi=null,Ki=null,Ji=!1;function za(r,e,t){return qi==e&&Ki==t?Ji:(qi=e,Ki=t,Ji=t=="up"||t=="down"?Fa(r,e,t):La(r,e,t))}const ye=0,Gi=1,tt=2,Ne=3;class Qt{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=ye,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>$(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],l=o+s.size;if(l>e||s instanceof bs){i=e-o;break}o=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof gs&&o.side>=0;n--);if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?$(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?$(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let d=s+a.border;if(e>=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=$(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;d<this.children.length;d++){let u=this.children[d];if(u.size&&u.dom.parentNode==this.contentDOM&&!u.emptyChildAt(-1)){o=$(u.dom);break}t+=u.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}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:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let b=this.children[h],y=p+b.size;if(o>p&&s<y)return b.setSelection(e-p-b.border,t-p-b.border,n,i);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),d=n.domSelectionRange(),u=!1;if((be||ie)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(u=!!(p&&h.nodeValue[p-1]==`
|
|
3
|
+
`),u&&p==h.nodeValue.length)for(let b=h,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:$(y)+1});break}let C=b.pmViewDesc;if(C&&C.node&&C.node.isBlock)break}}else{let b=h.childNodes[p-1];u=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(be&&d.focusNode&&d.focusNode!=a.node&&d.focusNode.nodeType==1){let h=d.focusNode.childNodes[d.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||u&&ie)&<(l.node,l.offset,d.anchorNode,d.anchorOffset)&<(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(u&&be)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let l=n+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==s?tt:Gi,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ne:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?tt:Ne}n=s}this.dirty=tt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?tt:Gi;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class gs extends Qt{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==ye&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ba extends Qt{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class at extends Qt{constructor(e,t,n,i,o){super(e,[],n,i),this.mark=t,this.spec=o}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=m.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new at(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Ne||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ne&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=ye){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=ye}}slice(e,t,n){let i=at.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=wr(o,t,s,n)),e>0&&(o=wr(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ge extends Qt{constructor(e,t,n,i,o,s,l,a,c){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},n,i),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=m.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=ks(d,n,t),c?a=new _a(e,t,n,i,d,u||null,f,c,o,s+1):t.isText?new An(e,t,n,i,d,f,o):new Ge(e,t,n,i,d,u||null,f,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>m.Fragment.empty)}return e}matchesNode(e,t,n){return this.dirty==ye&&e.eq(this.node)&&kn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Ha(this,s&&s.node,e);$a(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?m.Mark.none:this.node.child(d).marks,n,e),a.placeWidget(c,e,i)},(c,d,u,f)=>{a.syncToMarks(c.marks,n,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,i)||a.addNode(c,d,u,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==tt)&&(s&&this.protectLocalComposition(e,s),ys(this.contentDOM,this.children,e),Dt&&qa(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof O)||n<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=Ka(this.node.content,s,n-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Ba(this,o,t,i);e.input.compositionNodes.push(s),this.children=wr(this.children,n,n+i.length,e,s)}update(e,t,n,i){return this.dirty==Ne||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=ye}updateOuterDeco(e){if(kn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Ss(this.dom,this.nodeDOM,Er(this.outerDeco,this.node,t),Er(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function ji(r,e,t,n,i){ks(n,e,r);let o=new Ge(void 0,r,e,t,n,n,n,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class An extends Ge{constructor(e,t,n,i,o,s,l){super(e,t,n,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==Ne||this.dirty!=ye&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=ye||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=ye,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new An(this.parent,i,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ne)}get domAtom(){return!1}isText(e){return this.node.text==e}}class bs extends Qt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==ye&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class _a extends Ge{constructor(e,t,n,i,o,s,l,a,c,d){super(e,t,n,i,o,s,l,c,d),this.spec=a}update(e,t,n,i){if(this.dirty==Ne)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ys(r,e,t){let n=r.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==r){for(;l!=n;)n=Yi(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(s instanceof at){let a=n?n.previousSibling:r.lastChild;ys(s.contentDOM,s.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=Yi(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const Ut=function(r){r&&(this.nodeName=r)};Ut.prototype=Object.create(null);const nt=[new Ut];function Er(r,e,t){if(r.length==0)return nt;let n=t?nt[0]:new Ut,i=[n];for(let o=0;o<r.length;o++){let s=r[o].type.attrs;if(s){s.nodeName&&i.push(n=new Ut(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(n=new Ut(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function Ss(r,e,t,n){if(t==nt&&n==nt)return e;let i=e;for(let o=0;o<n.length;o++){let s=n[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=nt[0]),i=a}Va(i,l||nt[0],s)}return i}function Va(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)i.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<i.length;o++)n.indexOf(i[o])==-1&&r.classList.add(i[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function ks(r,e,t){return Ss(r,r,nt,Er(e,t,r.nodeType!=1))}function kn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function Yi(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class Ha{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Wa(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let i=0,o=this.stack.length>>1,s=Math.min(o,e.length);for(;i<s&&(i==o-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<o;)this.destroyRest(),this.top.dirty=ye,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[o])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=at.create(this.top,e[o],t,n);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=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,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==Ne&&s.dom==s.contentDOM&&(s.dirty=tt),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof Ge){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let d=a.dom,u,f=this.isLocked(d)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ne&&kn(t,a.outerDeco));if(!f&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!f&&(u=this.recreateWrapper(a,e,t,n,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=tt,u.updateChildren(i,s+1),u.dirty=ye),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!kn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Ge.create(this.top,t,n,i,o,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,n,i,o){let s=Ge.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new gs(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof at;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof An)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ie||X)&&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 n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new bs(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Wa(r,e){let t=e,n=t.children.length,i=r.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof at)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Ua(r,e){return r.type.side-e.type.side}function $a(r,e,t,n){let i=e.locals(r),o=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let d=r.child(c);n(d,i,e.forChild(o,d),c),o+=d.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,u;for(;s<i.length&&i[s].to==o;){let y=i[s++];y.widget&&(d?(u||(u=[d])).push(y):d=y)}if(d)if(u){u.sort(Ua);for(let y=0;y<u.length;y++)t(u[y],c,!!a)}else t(d,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+f.nodeSize;if(f.isText){let y=p;s<i.length&&i[s].from<y&&(y=i[s].from);for(let C=0;C<l.length;C++)l[C].to<y&&(y=l[C].to);y<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let b=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,b,e.forChild(o,f),h),o=p}}function qa(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function Ka(r,e,t,n){for(let i=0,o=0;i<r.childCount&&o<=n;){let s=r.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<r.childCount;){let c=r.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function wr(r,e,t,n,i){let o=[];for(let s=0,l=0;s<r.length;s++){let a=r[s],c=l,d=l+=a.size;c>=t||d<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),i&&(o.push(i),i=void 0),d>t&&o.push(a.slice(t-c,a.size,n)))}return o}function Gr(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=n.resolve(s),a,c;if(wn(t)){for(a=s;i&&!i.node;)i=i.parent;let u=i.node;if(i&&u.isAtom&&M.isSelectable(u)&&i.parent&&!(u.isInline&&ya(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new M(s==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,f=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);u=Math.min(u,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(u<0)return null;[a,s]=f==r.state.selection.anchor?[f,u]:[u,f],l=n.resolve(s)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let d=n.resolve(a);if(!c){let u=e=="pointer"||r.state.selection.head<l.pos&&!o?1:-1;c=jr(r,d,l,u)}return c}function Ts(r){return r.editable?r.hasFocus():Ms(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function ze(r,e=!1){let t=r.state.selection;if(Cs(r,t),!!Ts(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&X){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&<(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)Ga(r);else{let{anchor:n,head:i}=t,o,s;Xi&&!(t instanceof O)&&(t.$from.parent.inlineContent||(o=Zi(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=Zi(r,t.to))),r.docView.setSelection(n,i,r,e),Xi&&(o&&Qi(o),s&&Qi(s)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ja(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const Xi=ie||X&&cs<63;function Zi(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ie&&i&&i.contentEditable=="false")return nr(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return nr(i);if(o)return nr(o)}}function nr(r){return r.contentEditable="true",ie&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function Qi(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function Ja(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Ts(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ga(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,$(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&ue&&Je<=11&&(t.disabled=!0,t.disabled=!1)}function Cs(r,e){if(e instanceof M){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(eo(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else eo(r)}function eo(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function jr(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||O.between(e,t,n)}function to(r){return r.editable&&!r.hasFocus()?!1:Ms(r)}function Ms(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function ja(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return lt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ar(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),o=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return o&&N.findFrom(o,e)}function He(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function no(r,e,t){let n=r.state.selection;if(n instanceof O)if(t.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=r.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return He(r,new O(n.$anchor,s))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Ar(r.state,e);return i&&i instanceof M?He(r,i):!1}else if(!(pe&&t.indexOf("m")>-1)){let i=n.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=r.docView.descAt(l))&&!s.contentDOM?M.isSelectable(o)?He(r,new M(e<0?r.state.doc.resolve(i.pos-o.nodeSize):i)):Zt?He(r,new O(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof M&&n.node.isInline)return He(r,new O(e>0?n.$to:n.$from));{let i=Ar(r.state,e);return i?He(r,i):!1}}}function Tn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function $t(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function yt(r,e){return e<0?Ya(r):Xa(r)}function Ya(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,o,s=!1;for(be&&t.nodeType==1&&n<Tn(t)&&$t(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if($t(l,-1))i=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(xs(t))break;{let l=t.previousSibling;for(;l&&$t(l,-1);)i=t.parentNode,o=$(l),l=l.previousSibling;if(l)t=l,n=Tn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}s?vr(r,t,n):i&&vr(r,i,o)}function Xa(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Tn(t),o,s;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if($t(l,1))o=t,s=++n;else break}else{if(xs(t))break;{let l=t.nextSibling;for(;l&&$t(l,1);)o=l.parentNode,s=$(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=Tn(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}o&&vr(r,o,s)}function xs(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function Za(r,e){for(;r&&e==r.childNodes.length&&!Xt(r);)e=$(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function Qa(r,e){for(;r&&!e&&!Xt(r);)e=$(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function vr(r,e,t){if(e.nodeType!=3){let o,s;(s=Za(e,t))?(e=s,t=0):(o=Qa(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(wn(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&ze(r)},50)}function ro(r,e){let t=r.state.doc.resolve(e);if(!(X||Ta)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function io(r,e,t){let n=r.state.selection;if(n instanceof O&&!n.empty||t.indexOf("s")>-1||pe&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let s=Ar(r.state,e);if(s&&s instanceof M)return He(r,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=n instanceof K?N.near(s,e):N.findFrom(s,e);return l?He(r,l):!1}return!1}function oo(r,e){if(!(r.state.selection instanceof O))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=r.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),r.dispatch(s),!0}return!1}function so(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function ec(r){if(!ie||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;so(r,n,"true"),setTimeout(()=>so(r,n,"false"),20)}return!1}function tc(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function nc(r,e){let t=e.keyCode,n=tc(e);if(t==8||pe&&t==72&&n=="c")return oo(r,-1)||yt(r,-1);if(t==46&&!e.shiftKey||pe&&t==68&&n=="c")return oo(r,1)||yt(r,1);if(t==13||t==27)return!0;if(t==37||pe&&t==66&&n=="c"){let i=t==37?ro(r,r.state.selection.from)=="ltr"?-1:1:-1;return no(r,i,n)||yt(r,i)}else if(t==39||pe&&t==70&&n=="c"){let i=t==39?ro(r,r.state.selection.from)=="ltr"?1:-1:1;return no(r,i,n)||yt(r,i)}else{if(t==38||pe&&t==80&&n=="c")return io(r,-1,n)||yt(r,-1);if(t==40||pe&&t==78&&n=="c")return ec(r)||io(r,1,n)||yt(r,1);if(n==(pe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Yr(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,o--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let s=r.someProp("clipboardSerializer")||m.DOMSerializer.fromSchema(r.state.schema),l=As(),a=l.createElement("div");a.appendChild(s.serializeFragment(n,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=ws[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
|
|
7
4
|
|
|
8
|
-
`);return{dom:a,text:f,slice:e}}function
|
|
9
|
-
`))),0,0),r.someProp("transformPasted",f=>{l=f(l,r,!0)}),l;let u=r.someProp("clipboardTextParser",f=>f(e,i,n,r));if(u)l=u;else{let f=i.marks(),{schema:p}=r.state,d=kt.fromSchema(p);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=o.appendChild(document.createElement("p"));g&&y.appendChild(d.serializeNode(p.text(g,f)))})}}else r.someProp("transformPastedHTML",u=>{t=u(t,r)}),o=Fh(t),gn&&Lh(o);let c=o&&o.querySelector("[data-pm-slice]"),h=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let u=+h[3];u>0;u--){let f=o.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;o=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||Lt.fromSchema(r.state.schema)).parseSlice(o,{preserveWhitespace:!!(a||h),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!Ih.test(f.parentNode.nodeName)?{ignore:!0}:null}})),h)l=zh(js(l,+h[1],+h[2]),h[4]);else if(l=S.maxOpen(Rh(l.content,i),!0),l.openStart||l.openEnd){let u=0,f=0;for(let p=l.content.firstChild;u<l.openStart&&!p.type.spec.isolating;u++,p=p.firstChild);for(let p=l.content.lastChild;f<l.openEnd&&!p.type.spec.isolating;f++,p=p.lastChild);l=js(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r,a)}),l}const Ih=/^(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 Rh(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),s,o=[];if(r.forEach(l=>{if(!o)return;let a=i.findWrapping(l.type),c;if(!a)return o=null;if(c=o.length&&s.length&&Rl(a,s,l,o[o.length-1],0))o[o.length-1]=c;else{o.length&&(o[o.length-1]=Pl(o[o.length-1],s.length));let h=Il(l,a);o.push(h),i=i.matchType(h.type),s=a}}),o)return b.from(o)}return r}function Il(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,b.from(r));return r}function Rl(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let s=Rl(r,e,t,n.lastChild,i+1);if(s)return n.copy(n.content.replaceChild(n.childCount-1,s));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(b.from(Il(t,r,i+1))))}}function Pl(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Pl(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(b.empty,!0);return r.copy(t.append(n))}function li(r,e,t,n,i,s){let o=e<0?r.firstChild:r.lastChild,l=o.content;return r.childCount>1&&(s=0),i<n-1&&(l=li(l,e,t,n,i+1,s)),i>=t&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(b.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,o.copy(l))}function js(r,e,t){return e<r.openStart&&(r=new S(li(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new S(li(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Fl={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let Ys=null;function Ll(){return Ys||(Ys=document.implementation.createHTMLDocument("title"))}let Ar=null;function Ph(r){let e=window.trustedTypes;return e?(Ar||(Ar=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ar.createHTML(r)):r}function Fh(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Ll().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Fl[n[1].toLowerCase()])&&(r=i.map(s=>"<"+s+">").join("")+r+i.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Ph(r),i)for(let s=0;s<i.length;s++)t=t.querySelector(i[s])||t;return t}function Lh(r){let e=r.querySelectorAll(re?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function zh(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:s,openEnd:o}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=b.from(a.create(n[l+1],i)),s++,o++}return new S(i,s,o)}const ue={},fe={},Bh={touchstart:!0,touchmove:!0};class _h{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Vh(r){for(let e in ue){let t=ue[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Wh(r,n)&&!Oi(r,n)&&(r.editable||!(n.type in fe))&&t(r,n)},Bh[e]?{passive:!0}:void 0)}he&&r.dom.addEventListener("input",()=>null),ai(r)}function Qe(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Hh(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function ai(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Oi(r,n))})}function Oi(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Wh(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Uh(r,e){!Oi(r,e)&&ue[e.type]&&(r.editable||!(e.type in fe))&&ue[e.type](r,e)}fe.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Bl(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Ue&&re&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),_t&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,lt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||vh(r,t)?t.preventDefault():Qe(r,"key")};fe.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};fe.keypress=(r,e)=>{let t=e;if(Bl(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||ke&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),s=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",o=>o(r,n.$from.pos,n.$to.pos,i,s))&&r.dispatch(s()),t.preventDefault()}};function nr(r){return{left:r.clientX,top:r.clientY}}function qh(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Ei(r,e,t,n,i){if(n==-1)return!1;let s=r.state.doc.resolve(n);for(let o=s.depth+1;o>0;o--)if(r.someProp(e,l=>o>s.depth?l(r,t,s.nodeAfter,s.before(o),i,!0):l(r,t,s.node(o),s.before(o),i,!1)))return!0;return!1}function Pt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Jh(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&w.isSelectable(n)?(Pt(r,new w(t)),!0):!1}function $h(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof w&&(n=t.node);let s=r.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(w.isSelectable(l)){n&&t.$from.depth>0&&o>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?i=s.before(t.$from.depth):i=s.before(o);break}}return i!=null?(Pt(r,w.create(r.state.doc,i)),!0):!1}function Kh(r,e,t,n,i){return Ei(r,"handleClickOn",e,t,n)||r.someProp("handleClick",s=>s(r,e,n))||(i?$h(r,t):Jh(r,t))}function Gh(r,e,t,n){return Ei(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function jh(r,e,t,n){return Ei(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Yh(r,t,n)}function Yh(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Pt(r,O.create(n,0,n.content.size)),!0):!1;let i=n.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)Pt(r,O.create(n,l+1,l+1+o.content.size));else if(w.isSelectable(o))Pt(r,w.create(n,l));else continue;return!0}}function Ni(r){return $n(r)}const zl=ke?"metaKey":"ctrlKey";ue.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Ni(r),i=Date.now(),s="singleClick";i-r.input.lastClick.time<500&&qh(t,r.input.lastClick)&&!t[zl]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?s="doubleClick":r.input.lastClick.type=="doubleClick"&&(s="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:s,button:t.button};let o=r.posAtCoords(nr(t));o&&(s=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Xh(r,o,t,!!n)):(s=="doubleClick"?Gh:jh)(r,o.pos,o.inside,t)?t.preventDefault():Qe(r,"pointer"))};class Xh{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[zl],this.allowDefault=n.shiftKey;let s,o;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),o=t.inside;else{let h=e.state.doc.resolve(t.pos);s=h.parent,o=h.depth?h.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof w&&c.from<=o&&c.to>o)&&(this.mightDrag={node:s,pos:o,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Te&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Qe(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>qe(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(nr(e))),this.updateAllowDefault(e),this.allowDefault||!t?Qe(this.view,"pointer"):Kh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||he&&this.mightDrag&&!this.mightDrag.node.isAtom||re&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Pt(this.view,N.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Qe(this.view,"pointer")}move(e){this.updateAllowDefault(e),Qe(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}ue.touchstart=r=>{r.input.lastTouch=Date.now(),Ni(r),Qe(r,"pointer")};ue.touchmove=r=>{r.input.lastTouch=Date.now(),Qe(r,"pointer")};ue.contextmenu=r=>Ni(r);function Bl(r,e){return r.composing?!0:he&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Zh=Ue?5e3:-1;fe.compositionstart=fe.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof O&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),$n(r,!0),r.markCursor=null;else if($n(r,!e.selection.empty),Te&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,s=n.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=r.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}r.input.composing=!0}_l(r,Zh)};fe.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,_l(r,20))};function _l(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>$n(r),e))}function Vl(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=eu());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Qh(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Jc(e.focusNode,e.focusOffset),n=$c(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,s=r.domObserver.lastChangedTextNode;if(t==s||n==s)return s;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let o=t.pmViewDesc;if(!(!o||!o.isText(t.nodeValue)))return n}}return t||n}function eu(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function $n(r,e=!1){if(!(Ue&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Vl(r),e||r.docView&&r.docView.dirty){let t=Ci(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function tu(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const fn=ye&&et<15||_t&&Xc<604;ue.copy=fe.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let s=fn?null:t.clipboardData,o=n.content(),{dom:l,text:a}=Mi(r,o);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):tu(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function nu(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function ru(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?dn(r,n.value,null,i,e):dn(r,n.textContent,n.innerHTML,i,e)},50)}function dn(r,e,t,n,i){let s=vl(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,s||S.empty)))return!0;if(!s)return!1;let o=nu(s),l=o?r.state.tr.replaceSelectionWith(o,n):r.state.tr.replaceSelection(s);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Hl(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}fe.paste=(r,e)=>{let t=e;if(r.composing&&!Ue)return;let n=fn?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&dn(r,Hl(n),n.getData("text/html"),i,t)?t.preventDefault():ru(r,t)};class Wl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const iu=ke?"altKey":"ctrlKey";function Ul(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[iu]}ue.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,s=i.empty?null:r.posAtCoords(nr(t)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof w?i.to-1:i.to))){if(n&&n.mightDrag)o=w.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=r.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=r.docView&&(o=w.create(r.state.doc,u.posBefore))}}let l=(o||r.state.selection).content(),{dom:a,text:c,slice:h}=Mi(r,l);(!t.dataTransfer.files.length||!re||ml>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",fn||t.dataTransfer.setData("text/plain",c),r.dragging=new Wl(h,Ul(r,t),o)};ue.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};fe.dragover=fe.dragenter=(r,e)=>e.preventDefault();fe.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(nr(t));if(!i)return;let s=r.state.doc.resolve(i.pos),o=n&&n.slice;o?r.someProp("transformPasted",d=>{o=d(o,r,!1)}):o=vl(r,Hl(t.dataTransfer),fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&Ul(r,t));if(r.someProp("handleDrop",d=>d(r,t,o||S.empty,l))){t.preventDefault();return}if(!o)return;t.preventDefault();let a=o?ki(r.state.doc,s.pos,o):s.pos;a==null&&(a=s.pos);let c=r.state.tr;if(l){let{node:d}=n;d?d.replace(c):c.deleteSelection()}let h=c.mapping.map(a),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(h,h,o.content.firstChild):c.replaceRange(h,h,o),c.doc.eq(f))return;let p=c.doc.resolve(h);if(u&&w.isSelectable(o.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(o.content.firstChild))c.setSelection(new w(p));else{let d=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,C,L)=>d=L),c.setSelection(wi(r,p,c.doc.resolve(d)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))};ue.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&qe(r)},20))};ue.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};ue.beforeinput=(r,e)=>{if(re&&Ue&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",s=>s(r,lt(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in fe)ue[r]=fe[r];function pn(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Kn{constructor(e,t){this.toDOM=e,this.spec=t||ft,this.side=this.spec.side||0}map(e,t,n,i){let{pos:s,deleted:o}=e.mapResult(t.from+i,this.side<0?-1:1);return o?null:new ie(s-n,s-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Kn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class nt{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,n,i){let s=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,o=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return s>=o?null:new ie(s,o,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof nt&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}static is(e){return e.type instanceof nt}destroy(){}}class Di{constructor(e,t){this.attrs=e,this.spec=t||ft}map(e,t,n,i){let s=e.mapResult(t.from+i,1);if(s.deleted)return null;let o=e.mapResult(t.to+i,-1);return o.deleted||o.pos<=s.pos?null:new ie(s.pos-n,o.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),s;return i==t.from&&!(s=e.child(n)).isText&&i+s.nodeSize==t.to}eq(e){return this==e||e instanceof Di&&pn(this.attrs,e.attrs)&&pn(this.spec,e.spec)}destroy(){}}class ie{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new ie(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,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new ie(e,e,new Kn(t,n))}static inline(e,t,n,i){return new ie(e,t,new nt(n,i))}static node(e,t,n,i){return new ie(e,t,new Di(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof nt}get widget(){return this.type instanceof Kn}}const vt=[],ft={};class P{constructor(e,t){this.local=e.length?e:vt,this.children=t.length?t:vt}static create(e,t){return t.length?Gn(t,e,0,ft):te}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<t&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,t-l,n,i+l,s)}}map(e,t,n){return this==te||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ft)}mapInner(e,t,n,i,s){let o;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(o||(o=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?su(this.children,o||[],e,t,n,i,s):o?new P(o.sort(dt),vt):te}add(e,t){return t.length?this==te?P.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,s=0;e.forEach((l,a)=>{let c=a+n,h;if(h=Jl(t,l,c)){for(i||(i=this.children.slice());s<i.length&&i[s]<a;)s+=3;i[s]==a?i[s+2]=i[s+2].addInner(l,h,c+1):i.splice(s,0,a,a+l.nodeSize,Gn(h,l,c+1,ft)),s+=3}});let o=ql(s?$l(t):t,-n);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new P(o.length?this.local.concat(o).sort(dt):this.local,i||this.children)}remove(e){return e.length==0||this==te?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let s=0;s<n.length;s+=3){let o,l=n[s]+t,a=n[s+1]+t;for(let h=0,u;h<e.length;h++)(u=e[h])&&u.from>l&&u.to<a&&(e[h]=null,(o||(o=[])).push(u));if(!o)continue;n==this.children&&(n=this.children.slice());let c=n[s+2].removeInner(o,l+1);c!=te?n[s+2]=c:(n.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new P(i,n):te}forChild(e,t){if(this==te)return this;if(t.isLeaf)return P.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let s=e+1,o=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<o&&a.to>s&&a.type instanceof nt){let c=Math.max(s,a.from)-s,h=Math.min(o,a.to)-s;c<h&&(i||(i=[])).push(a.copy(c,h))}}if(i){let l=new P(i.sort(dt),vt);return n?new Ye([l,n]):l}return n||te}eq(e){if(this==e)return!0;if(!(e instanceof P)||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 Ai(this.localsInner(e))}localsInner(e){if(this==te)return vt;if(e.inlineContent||!this.local.some(nt.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof nt||t.push(this.local[n]);return t}forEachSet(e){e(this)}}P.empty=new P([],[]);P.removeOverlap=Ai;const te=P.empty;class Ye{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,ft));return Ye.from(n)}forChild(e,t){if(t.isLeaf)return P.empty;let n=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,t);s!=te&&(s instanceof Ye?n=n.concat(s.members):n.push(s))}return Ye.from(n)}eq(e){if(!(e instanceof Ye)||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,n=!0;for(let i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!t)t=s;else{n&&(t=t.slice(),n=!1);for(let o=0;o<s.length;o++)t.push(s[o])}}return t?Ai(n?t:t.sort(dt)):vt}static from(e){switch(e.length){case 0:return te;case 1:return e[0];default:return new Ye(e.every(t=>t instanceof P)?e:e.reduce((t,n)=>t.concat(n instanceof P?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function su(r,e,t,n,i,s,o){let l=r.slice();for(let c=0,h=s;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,p,d,g)=>{let y=g-d-(p-f);for(let C=0;C<l.length;C+=3){let L=l[C+1];if(L<0||f>L+h-u)continue;let I=l[C]+h-u;p>=I?l[C+1]=f<=I?-2:-1:f>=h&&y&&(l[C]+=y,l[C+1]+=y)}u+=y}),h=t.maps[c].map(h,-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 h=t.map(r[c]+s),u=h-i;if(u<0||u>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+s,-1),p=f-i,{index:d,offset:g}=n.content.findIndex(u),y=n.maybeChild(d);if(y&&g==u&&g+y.nodeSize==p){let C=l[c+2].mapInner(t,y,h+1,r[c]+s+1,o);C!=te?(l[c]=u,l[c+1]=p,l[c+2]=C):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ou(l,r,e,t,i,s,o),h=Gn(c,n,0,o);e=h.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<h.children.length;u+=3){let p=h.children[u];for(;f<l.length&&l[f]<p;)f+=3;l.splice(f,0,h.children[u],h.children[u+1],h.children[u+2])}}return new P(e.sort(dt),l)}function ql(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new ie(i.from+e,i.to+e,i.type))}return t}function ou(r,e,t,n,i,s,o){function l(a,c){for(let h=0;h<a.local.length;h++){let u=a.local[h].map(n,i,c);u?t.push(u):o.onRemove&&o.onRemove(a.local[h].spec)}for(let h=0;h<a.children.length;h+=3)l(a.children[h+2],a.children[h]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+s+1);return t}function Jl(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let s=0,o;s<r.length;s++)(o=r[s])&&o.from>t&&o.to<n&&((i||(i=[])).push(o),r[s]=null);return i}function $l(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function Gn(r,e,t,n){let i=[],s=!1;e.forEach((l,a)=>{let c=Jl(r,l,a+t);if(c){s=!0;let h=Gn(c,l,t+a+1,n);h!=te&&i.push(a,a+l.nodeSize,h)}});let o=ql(s?$l(r):r,-t).sort(dt);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(n.onRemove&&n.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new P(o,i):te}function dt(r,e){return r.from-e.from||r.to-e.to}function Ai(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let s=e[i];if(s.from==n.from){s.to!=n.to&&(e==r&&(e=r.slice()),e[i]=s.copy(s.from,n.to),Xs(e,i+1,s.copy(n.to,s.to)));continue}else{s.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,s.from),Xs(e,i,n.copy(s.from,n.to)));break}}}return e}function Xs(r,e,t){for(;e<r.length&&dt(t,r[e])>0;)e++;r.splice(e,0,t)}function vr(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=te&&e.push(n)}),r.cursorWrapper&&e.push(P.create(r.state.doc,[r.cursorWrapper.deco])),Ye.from(e)}const lu={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},au=ye&&et<=11;class cu{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class hu{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new cu,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);ye&&et<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),au&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,lu)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Us(this.view)){if(this.suppressingSelectionUpdates)return qe(this.view);if(ye&&et<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&yt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let s=e.focusNode;s;s=Bt(s))t.add(s);for(let s=e.anchorNode;s;s=Bt(s))if(t.has(s)){n=s;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Us(e)&&!this.ignoreSelectionChange(n),s=-1,o=-1,l=!1,a=[];if(e.editable)for(let h=0;h<t.length;h++){let u=this.registerMutation(t[h],a);u&&(s=s<0?u.from:Math.min(u.from,s),o=o<0?u.to:Math.max(u.to,o),u.typeOver&&(l=!0))}if(Te&&a.length){let h=a.filter(u=>u.nodeName=="BR");if(h.length==2){let[u,f]=h;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of h){let p=f.parentNode;p&&p.nodeName=="LI"&&(!u||du(e,u)!=p)&&f.remove()}}}let c=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&er(n)&&(c=Ci(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,qe(e),this.currentSelection.set(n),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),uu(e)),this.handleDOMChange(s,o,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||qe(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let h=0;h<e.addedNodes.length;h++){let u=e.addedNodes[h];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,s=e.nextSibling;if(ye&&et<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:u,nextSibling:f}=e.addedNodes[h];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(s=f)}let o=i&&i.parentNode==e.target?Y(i)+1:0,l=n.localPosFromDOM(e.target,o,-1),a=s&&s.parentNode==e.target?Y(s):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Zs=new WeakMap,Qs=!1;function uu(r){if(!Zs.has(r)&&(Zs.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=Te,Qs)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."),Qs=!0}}function eo(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,s=e.endOffset,o=r.domAtPos(r.state.selection.anchor);return yt(o.node,o.offset,i,s)&&([t,n,i,s]=[i,s,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:s}}function fu(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return eo(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?eo(r,t):null}function du(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function pu(r,e,t){let{node:n,fromOffset:i,toOffset:s,from:o,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,h=a.anchorNode;if(h&&r.dom.contains(h.nodeType==1?h:h.parentNode)&&(c=[{node:h,offset:a.anchorOffset}],er(a)||c.push({node:a.focusNode,offset:a.focusOffset})),re&&r.input.lastKeyCode===8)for(let y=s;y>i;y--){let C=n.childNodes[y-1],L=C.pmViewDesc;if(C.nodeName=="BR"&&!L){s=y;break}if(!L||L.size)break}let u=r.state.doc,f=r.someProp("domParser")||Lt.fromSchema(r.state.schema),p=u.resolve(o),d=null,g=f.parse(n,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:mu,context:p});if(c&&c[0].pos!=null){let y=c[0].pos,C=c[1]&&c[1].pos;C==null&&(C=y),d={anchor:y+o,head:C+o}}return{doc:g,sel:d,from:o,to:l}}function mu(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(he&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||he&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const gu=/^(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 yu(r,e,t,n,i){let s=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let E=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,B=Ci(r,E);if(B&&!r.state.selection.eq(B)){if(re&&Ue&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",sr=>sr(r,lt(13,"Enter"))))return;let Q=r.state.tr.setSelection(B);E=="pointer"?Q.setMeta("pointer",!0):E=="key"&&Q.scrollIntoView(),s&&Q.setMeta("composition",s),r.dispatch(Q)}return}let o=r.state.doc.resolve(e),l=o.sharedDepth(t);e=o.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=pu(r,e,t),h=r.state.doc,u=h.slice(c.from,c.to),f,p;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,p="end"):(f=r.state.selection.from,p="start"),r.input.lastKeyCode=null;let d=Su(u.content,c.doc.content,c.from,f,p);if(d&&r.input.domChangeCount++,(_t&&r.input.lastIOSEnter>Date.now()-225||Ue)&&i.some(E=>E.nodeType==1&&!gu.test(E.nodeName))&&(!d||d.endA>=d.endB)&&r.someProp("handleKeyDown",E=>E(r,lt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!d)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))d={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=to(r,r.state.doc,c.sel);if(E&&!E.eq(r.state.selection)){let B=r.state.tr.setSelection(E);s&&B.setMeta("composition",s),r.dispatch(B)}}return}r.state.selection.from<r.state.selection.to&&d.start==d.endB&&r.state.selection instanceof O&&(d.start>r.state.selection.from&&d.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?d.start=r.state.selection.from:d.endA<r.state.selection.to&&d.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(d.endB+=r.state.selection.to-d.endA,d.endA=r.state.selection.to)),ye&&et<=11&&d.endB==d.start+1&&d.endA==d.start&&d.start>c.from&&c.doc.textBetween(d.start-c.from-1,d.start-c.from+1)==" "&&(d.start--,d.endA--,d.endB--);let g=c.doc.resolveNoCache(d.start-c.from),y=c.doc.resolveNoCache(d.endB-c.from),C=h.resolve(d.start),L=g.sameParent(y)&&g.parent.inlineContent&&C.end()>=d.endA;if((_t&&r.input.lastIOSEnter>Date.now()-225&&(!L||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!L&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"","")))&&r.someProp("handleKeyDown",E=>E(r,lt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>d.start&&ku(h,d.start,d.endA,g,y)&&r.someProp("handleKeyDown",E=>E(r,lt(8,"Backspace")))){Ue&&re&&r.domObserver.suppressSelectionUpdates();return}re&&d.endB==d.start&&(r.input.lastChromeDelete=Date.now()),Ue&&!L&&g.start()!=y.start()&&y.parentOffset==0&&g.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==d.endA&&(d.endB-=2,y=c.doc.resolveNoCache(d.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(E){return E(r,lt(13,"Enter"))})},20));let I=d.start,R=d.endA,Oe=E=>{let B=E||r.state.tr.replace(I,R,c.doc.slice(d.start-c.from,d.endB-c.from));if(c.sel){let Q=to(r,B.doc,c.sel);Q&&!(re&&r.composing&&Q.empty&&(d.start!=d.endB||r.input.lastChromeDelete<Date.now()-100)&&(Q.head==I||Q.head==B.mapping.map(R)-1)||ye&&Q.empty&&Q.head==I)&&B.setSelection(Q)}return s&&B.setMeta("composition",s),B.scrollIntoView()},$e;if(L)if(g.pos==y.pos){ye&&et<=11&&g.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>qe(r),20));let E=Oe(r.state.tr.delete(I,R)),B=h.resolve(d.start).marksAcross(h.resolve(d.endA));B&&E.ensureMarks(B),r.dispatch(E)}else if(d.endA==d.endB&&($e=bu(g.parent.content.cut(g.parentOffset,y.parentOffset),C.parent.content.cut(C.parentOffset,d.endA-C.start())))){let E=Oe(r.state.tr);$e.type=="add"?E.addMark(I,R,$e.mark):E.removeMark(I,R,$e.mark),r.dispatch(E)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let E=g.parent.textBetween(g.parentOffset,y.parentOffset),B=()=>Oe(r.state.tr.insertText(E,I,R));r.someProp("handleTextInput",Q=>Q(r,I,R,E,B))||r.dispatch(B())}else r.dispatch(Oe());else r.dispatch(Oe())}function to(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:wi(r,e.resolve(t.anchor),e.resolve(t.head))}function bu(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,s=n,o,l,a;for(let h=0;h<n.length;h++)i=n[h].removeFromSet(i);for(let h=0;h<t.length;h++)s=t[h].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",a=h=>h.mark(l.addToSet(h.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",a=h=>h.mark(l.removeFromSet(h.marks));else return null;let c=[];for(let h=0;h<e.childCount;h++)c.push(a(e.child(h)));if(b.from(c).eq(r))return{mark:l,type:o}}function ku(r,e,t,n,i){if(t-e<=i.pos-n.pos||Ir(n,!0,!1)<i.pos)return!1;let s=r.resolve(e);if(!n.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=r.resolve(Ir(s,!0,!0));return!o.parent.isTextblock||o.pos>t||Ir(o,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(o.parent.content)}function Ir(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let s=r.node(n).maybeChild(r.indexAfter(n));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function Su(r,e,t,n,i){let s=r.findDiffStart(e,t);if(s==null)return null;let{a:o,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,s-Math.min(o,l));n-=o+a-s}if(o<s&&r.size<e.size){let a=n<=s&&n>=o?s-n:0;s-=a,s&&s<e.size&&no(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-o),o=s}else if(l<s){let a=n<=s&&n>=l?s-n:0;s-=a,s&&s<r.size&&no(r.textBetween(s-1,s+1))&&(s+=a?1:-1),o=s+(o-l),l=s}return{start:s,endA:o,endB:l}}function no(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Kl{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 _h,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(lo),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=so(this),io(this),this.nodeViews=oo(this),this.docView=zs(this.state.doc,ro(this),vr(this),this.dom,this),this.domObserver=new hu(this,(n,i,s,o)=>yu(this,n,i,s,o)),this.domObserver.start(),Vh(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&&ai(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(lo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(Vl(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=oo(this);Tu(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ai(this),this.editable=so(this),io(this);let a=vr(this),c=ro(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=s||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(o=!0);let f=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&eh(this);if(o){this.domObserver.stop();let p=u&&(ye||re)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&xu(i.selection,e.selection);if(u){let d=re?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Qh(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=zs(e.doc,c,a,this.dom,this)),d&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wh(this))?qe(this,p):(Nl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():f&&th(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof w){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&vs(this,t.getBoundingClientRect(),e)}else vs(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 n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let s=n.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==n.node&&(i=s)}this.dragging=new Wl(e.slice,e.move,i<0?void 0:w.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=t?t(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&nh(this.dom),qe(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return lh(this,e)}coordsAtPos(e,t=1){return Sl(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,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return fh(this,t||this.state,e)}pasteHTML(e,t){return dn(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return dn(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Mi(this,e)}destroy(){this.docView&&(Hh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],vr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Uc())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Uh(this,e)}domSelectionRange(){let e=this.domSelection();return e?he&&this.root.nodeType===11&&Gc(this.dom.ownerDocument)==this.dom&&fu(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Kl.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function ro(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[ie.node(0,r.state.doc.content.size,e)]}function io(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:ie.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function so(r){return!r.someProp("editable",e=>e(r.state)===!1)}function xu(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function oo(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Tu(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function lo(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class Cu{constructor(e){this.specs=e,this.attrs={};for(const t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join("; ")}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}}const A=Symbol("rte-internal-impl");class wu{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(t=>t.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}}const Ft=r=>r.sort((e,t)=>{const n=e.priority-t.priority;return n!==0?n:e.featureName===t.featureName?0:e.featureName>t.featureName?1:-1}).map(e=>e.value),vi={high:-10,default:0};class Mu{}class ${contribution(e,t){return{featureName:this.name,priority:t??vi.default,value:e}}getStyles(){return[]}getSchema(e,t){return[]}getTextblockAttrs(){return[]}getTextblockMarks(){return[]}getPlugins(e){return[]}getToolbarItems(e){return[]}getFeatures(){return[this]}}const H=r=>{var e;class t extends(e=Mu,e){constructor(...i){super(),this[A]=new r(...i)}}return t};var rt={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},jn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ou=typeof navigator<"u"&&/Mac/.test(navigator.platform),Eu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var X=0;X<10;X++)rt[48+X]=rt[96+X]=String(X);for(var X=1;X<=24;X++)rt[X+111]="F"+X;for(var X=65;X<=90;X++)rt[X]=String.fromCharCode(X+32),jn[X]=String.fromCharCode(X);for(var Rr in rt)jn.hasOwnProperty(Rr)||(jn[Rr]=rt[Rr]);function Nu(r){var e=Ou&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Eu&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?jn:rt)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Du=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Au=typeof navigator<"u"&&/Win/.test(navigator.platform);function vu(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,s,o;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))o=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Du?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),o&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Iu(r){let e=Object.create(null);for(let t in r)e[vu(t)]=r[t];return e}function Pr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Me(r){return new ce({props:{handleKeyDown:Gl(r)}})}function Gl(r){let e=Iu(r);return function(t,n){let i=Nu(n),s,o=e[Pr(i,n)];if(o&&o(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[Pr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Au&&n.ctrlKey&&n.altKey)&&(s=rt[n.keyCode])&&s!=i){let l=e[Pr(s,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const jl=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Ru(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const Pu=(r,e,t)=>{let n=Ru(r,t);if(!n)return!1;let i=Yl(n);if(!i){let o=n.blockRange(),l=o&&yi(o);return l==null?!1:(e&&e(r.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(na(r,i,e,-1))return!0;if(n.parent.content.size==0&&(Vt(s,"end")||w.isSelectable(s)))for(let o=n.depth;;o--){let l=Si(r.doc,n.before(o),n.after(o),S.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(Vt(s,"end")?N.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):w.create(a.doc,i.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(o==1||n.node(o-1).childCount>1)break}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1};function Vt(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Fu=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;s=Yl(n)}let o=s&&s.nodeBefore;return!o||!w.isSelectable(o)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Yl(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Lu(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const zu=(r,e,t)=>{let n=Lu(r,t);if(!n)return!1;let i=Xl(n);if(!i)return!1;let s=i.nodeAfter;if(na(r,i,e,1))return!0;if(n.parent.content.size==0&&(Vt(s,"start")||w.isSelectable(s))){let o=Si(r.doc,n.before(),n.after(),S.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=r.tr.step(o);l.setSelection(Vt(s,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):w.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},Bu=(r,e,t)=>{let{$head:n,empty:i}=r.selection,s=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;s=Xl(n)}let o=s&&s.nodeAfter;return!o||!w.isSelectable(o)?!1:(e&&e(r.tr.setSelection(w.create(r.doc,s.pos)).scrollIntoView()),!0)};function Xl(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Zl=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
10
|
-
`).scrollIntoView()),!0)};function Ii(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const _u=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),s=t.indexAfter(-1),o=Ii(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,o.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Ql=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof Z||n.parent.inlineContent||i.parent.inlineContent)return!1;let s=Ii(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(o,s.createAndFill());l.setSelection(O.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},ea=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ln(r.doc,s))return e&&e(r.tr.split(s).scrollIntoView()),!0}let n=t.blockRange(),i=n&&yi(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function ta(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof w&&e.selection.node.isBlock)return!n.parentOffset||!Ln(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let s=[],o,l,a=!1,c=!1;for(let p=n.depth;;p--)if(n.node(p).isBlock){a=n.end(p)==n.pos+(n.depth-p),c=n.start(p)==n.pos-(n.depth-p),l=Ii(n.node(p-1).contentMatchAt(n.indexAfter(p-1)));let g=r&&r(i.parent,a,n);s.unshift(g||(a&&l?{type:l}:null)),o=p;break}else{if(p==1)return!1;s.unshift(null)}let h=e.tr;(e.selection instanceof O||e.selection instanceof Z)&&h.deleteSelection();let u=h.mapping.map(n.pos),f=Ln(h.doc,u,s.length,s);if(f||(s[0]=l?{type:l}:null,f=Ln(h.doc,u,s.length,s)),!f)return!1;if(h.split(u,s.length,s),!a&&c&&n.node(o).type!=l){let p=h.mapping.map(n.before(o)),d=h.doc.resolve(p);l&&n.node(o-1).canReplaceWith(d.index(),d.index()+1,l)&&h.setNodeMarkup(h.mapping.map(n.before(o)),l)}return t&&t(h.scrollIntoView()),!0}}const Vu=ta(),Hu=(r,e)=>(e&&e(r.tr.setSelection(new Z(r.doc))),!0);function Wu(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,s=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(s-1,s)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||bi(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function na(r,e,t,n){let i=e.nodeBefore,s=e.nodeAfter,o,l,a=i.type.spec.isolating||s.type.spec.isolating;if(!a&&Wu(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,d=b.empty;for(let C=o.length-1;C>=0;C--)d=b.from(o[C].create(null,d));d=b.from(i.copy(d));let g=r.tr.step(new se(e.pos-1,p,e.pos,p,new S(d,1,0),o.length,!0)),y=g.doc.resolve(p+2*o.length);y.nodeAfter&&y.nodeAfter.type==i.type&&bi(g.doc,y.pos)&&g.join(y.pos),t(g.scrollIntoView())}return!0}let h=s.type.spec.isolating||n>0&&a?null:N.findFrom(e,1),u=h&&h.$from.blockRange(h.$to),f=u&&yi(u);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(u,f).scrollIntoView()),!0;if(c&&Vt(s,"start",!0)&&Vt(i,"end")){let p=i,d=[];for(;d.push(p),!p.isTextblock;)p=p.lastChild;let g=s,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(p.canReplace(p.childCount,p.childCount,g.content)){if(t){let C=b.empty;for(let I=d.length-1;I>=0;I--)C=b.from(d[I].copy(C));let L=r.tr.step(new se(e.pos-d.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new S(C,d.length,0),0,!0));t(L.scrollIntoView())}return!0}}return!1}function ra(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(t&&t(e.tr.setSelection(O.create(e.doc,r<0?i.start(s):i.end(s)))),!0):!1}}const Uu=ra(-1),qu=ra(1);function Ju(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:s,$to:o}=e[i],l=s.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(s.pos,o.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Je(r,e=null,t){return function(n,i){let{empty:s,$cursor:o,ranges:l}=n.selection;if(s&&!o||!Ju(n.doc,l,r))return!1;if(i)if(o)r.isInSet(n.storedMarks||o.marks())?i(n.tr.removeStoredMark(r)):i(n.tr.addStoredMark(r.create(e)));else{let a,c=n.tr;a=!l.some(h=>n.doc.rangeHasMark(h.$from.pos,h.$to.pos,r));for(let h=0;h<l.length;h++){let{$from:u,$to:f}=l[h];if(!a)c.removeMark(u.pos,f.pos,r);else{let p=u.pos,d=f.pos,g=u.nodeAfter,y=f.nodeBefore,C=g&&g.isText?/^\s*/.exec(g.text)[0].length:0,L=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;p+C<d&&(p+=C,d-=L),c.addMark(p,d,r.create(e))}}i(c.scrollIntoView())}return!0}}function $u(r,e){return t=>{if(!t.isGeneric)return r(t);let n=[];for(let s=0;s<t.mapping.maps.length;s++){let o=t.mapping.maps[s];for(let l=0;l<n.length;l++)n[l]=o.map(n[l]);o.forEach((l,a,c,h)=>n.push(c,h))}let i=[];for(let s=0;s<n.length;s+=2){let o=n[s],l=n[s+1],a=t.doc.resolve(o),c=a.sharedDepth(l),h=a.node(c);for(let u=a.indexAfter(c),f=a.after(c+1);f<=l;++u){let p=h.maybeChild(u);if(!p)break;if(u&&i.indexOf(f)==-1){let d=h.child(u-1);d.type==p.type&&e(d,p)&&i.push(f)}f+=p.nodeSize}}i.sort((s,o)=>s-o);for(let s=i.length-1;s>=0;s--)bi(t.doc,i[s])&&t.join(i[s]);r(t)}}function Ku(r,e){let t=Array.isArray(e)?n=>e.indexOf(n.type.name)>-1:e;return(n,i,s)=>r(n,i&&$u(i,t),s)}function rr(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}let Fr=rr(jl,Pu,Fu),ao=rr(jl,zu,Bu);const We={Enter:rr(Zl,Ql,ea,Vu),"Mod-Enter":_u,Backspace:Fr,"Mod-Backspace":Fr,"Shift-Backspace":Fr,Delete:ao,"Mod-Delete":ao,"Mod-a":Hu},ia={"Ctrl-h":We.Backspace,"Alt-Backspace":We["Mod-Backspace"],"Ctrl-d":We.Delete,"Ctrl-Alt-Backspace":We["Mod-Delete"],"Alt-Delete":We["Mod-Delete"],"Alt-d":We["Mod-Delete"],"Ctrl-a":Uu,"Ctrl-e":qu};for(let r in We)ia[r]=We[r];const Gu=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,ju=Gu?ia:We,Yu='.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}';function Xu(r={}){return new ce({view(e){return new Zu(e,r)}})}class Zu{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):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,n,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let p=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(p){let d=p.getBoundingClientRect(),g=u?d.bottom:d.top;u&&f&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;n={left:d.left,right:d.right,top:g-y,bottom:g+y}}}}if(!n){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*o;n={left:u.left-f,right:u.left+f,top:u.top,bottom:u.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,h;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,h=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,p=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,h=u.top-a.scrollTop*p}this.element.style.left=(n.left-c)/o+"px",this.element.style.top=(n.top-h)/l+"px",this.element.style.width=(n.right-n.left)/o+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!s){let o=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=ki(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}this.setCursor(o),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class F extends N{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return F.valid(n)?new F(n):N.near(n)}content(){return S.empty}eq(e){return e instanceof F&&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 F(e.resolve(t.pos))}getBookmark(){return new Ri(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Qu(e)||!ef(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&F.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(t>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(t>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=t;let a=e.doc.resolve(i);if(F.valid(a))return a}for(;;){let o=t>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!w.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*t),n=!1;continue e}break}s=o,i+=t;let l=e.doc.resolve(i);if(F.valid(l))return l}return null}}}F.prototype.visible=!1;F.findFrom=F.findGapCursorFrom;N.jsonID("gapcursor",F);class Ri{constructor(e){this.pos=e}map(e){return new Ri(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return F.valid(t)?new F(t):N.near(t)}}function sa(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function Qu(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||sa(i.type))return!0;if(i.inlineContent)return!1}}return!0}function ef(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||sa(i.type))return!0;if(i.inlineContent)return!1}}return!0}function tf(){return new ce({props:{decorations:of,createSelectionBetween(r,e,t){return e.pos==t.pos&&F.valid(t)?new F(t):null},handleClick:rf,handleKeyDown:nf,handleDOMEvents:{beforeinput:sf}}})}const nf=Gl({ArrowLeft:An("horiz",-1),ArrowRight:An("horiz",1),ArrowUp:An("vert",-1),ArrowDown:An("vert",1)});function An(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,s){let o=n.selection,l=e>0?o.$to:o.$from,a=o.empty;if(o instanceof O){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=F.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new F(c))),!0):!1}}function rf(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!F.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&w.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new F(n))),!0)}function sf(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof F))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=b.empty;for(let o=n.length-1;o>=0;o--)i=b.from(n[o].createAndFill(null,i));let s=r.state.tr.replace(t.pos,t.pos,new S(i,0,0));return s.setSelection(O.near(s.doc.resolve(t.pos+1))),r.dispatch(s),!1}function of(r){if(!(r.selection instanceof F))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",P.create(r.doc,[ie.widget(r.selection.head,e,{key:"gapcursor"})])}function oa(r){for(let e=0;e<r.edgeCount;e++){const{type:t}=r.edge(e);/* v8 ignore if -- @preserve It's currently not possible to exercise this code in our RTE */if(t.isTextblock&&!t.hasRequiredAttrs())return t}/* v8 ignore next 1 -- @preserve*/throw new Error("No default textblock found.")}const lf="[data-class=ui-select]{min-inline-size:120px}.ui-divider{block-size:20px}.ui-button-group{display:flex;gap:4px}.ui-tooltip,.ui-menu{display:contents;--_popup-display: contents}.ui-tooltip-wrapper{display:contents}",af='.ProseMirror{flex:1;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none}.ProseMirror-selectednode{--focus-stroke-gap-color: transparent;--focus-border-radius: 2px;position:relative;outline:none}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in srgb,var(--focus-stroke-color, var(--vvd-color-cta-500)),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));position:absolute;display:block;border-radius:var(--focus-border-radius, inherit);block-size:calc(100% + var(--focus-block-size-addition, 4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition, 4px));inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}';var Yn=200,J=function(){};J.prototype.append=function(e){return e.length?(e=J.from(e),!this.length&&e||e.length<Yn&&this.leafAppend(e)||this.length<Yn&&e.leafPrepend(this)||this.appendInner(e)):this};J.prototype.prepend=function(e){return e.length?J.from(e).append(this):this};J.prototype.appendInner=function(e){return new cf(this,e)};J.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?J.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};J.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};J.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};J.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},t,n),i};J.from=function(e){return e instanceof J?e:e&&e.length?new la(e):J.empty};var la=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var a=s;a<o;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var a=s-1;a>=o;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Yn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Yn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(J);J.empty=new la([]);var cf=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(n,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(n,i):n>=s?this.right.slice(n-s,i-s):this.left.slice(n,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(J);const hf=500;class De{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,s;t&&(i=this.remapping(n,this.items.length),s=i.maps.length);let o=e.tr,l,a,c=[],h=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(n,f+1),s=i.maps.length),s--,h.push(u);return}if(i){h.push(new ve(u.map));let p=u.step.map(i.slice(s)),d;p&&o.maybeStep(p).doc&&(d=o.mapping.maps[o.mapping.maps.length-1],c.push(new ve(d,void 0,void 0,c.length+h.length))),s--,d&&i.appendMap(d,s)}else o.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(s)):u.selection,a=new De(this.items.slice(0,n).append(h.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:o,selection:l}}addTransform(e,t,n,i){let s=[],o=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let u=e.steps[h].invert(e.docs[h]),f=new ve(e.mapping.maps[h],u,t),p;(p=a&&a.merge(f))&&(f=p,h?s.pop():l=l.slice(0,l.length-1)),s.push(f),t&&(o++,t=void 0),i||(a=f)}let c=o-n.depth;return c>ff&&(l=uf(l,c),o-=c),new De(l.append(s),o)}remapping(e,t){let n=new hn;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,o)},e,t),n}addMaps(e){return this.eventCount==0?this:new De(this.items.append(e.map(t=>new ve(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let p=s.getMirror(--a);if(p==null)return;o=Math.min(o,p);let d=s.maps[p];if(f.step){let g=e.steps[p].invert(e.docs[p]),y=f.selection&&f.selection.map(s.slice(a+1,p));y&&l++,n.push(new ve(d,g,y))}else n.push(new ve(d))},i);let c=[];for(let f=t;f<o;f++)c.push(new ve(s.maps[f]));let h=this.items.slice(0,i).append(c).append(n),u=new De(h,l);return u.emptyItemCount()>hf&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let a=o.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let h=o.selection&&o.selection.map(t.slice(n));h&&s++;let u=new ve(c.invert(),a,h),f,p=i.length-1;(f=i.length&&i[p].merge(u))?i[p]=f:i.push(u)}}else o.map&&n--},this.items.length,0),new De(J.from(i.reverse()),s)}}De.empty=new De(J.empty,0);function uf(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class ve{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new ve(t.getMap().invert(),t,this.selection)}}}class je{constructor(e,t,n,i,s){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=s}}const ff=20;function df(r,e,t,n){let i=t.getMeta(pt),s;if(i)return i.historyState;t.getMeta(gf)&&(r=new je(r.done,r.undone,null,0,-1));let o=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(o&&o.getMeta(pt))return o.getMeta(pt).redo?new je(r.done.addTransform(t,void 0,n,zn(e)),r.undone,co(t.mapping.maps),r.prevTime,r.prevComposition):new je(r.done,r.undone.addTransform(t,void 0,n,zn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!o&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!pf(t,r.prevRanges)),c=o?Lr(r.prevRanges,t.mapping):co(t.mapping.maps);return new je(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,zn(e)),De.empty,c,t.time,l??r.prevComposition)}else return(s=t.getMeta("rebased"))?new je(r.done.rebased(t,s),r.undone.rebased(t,s),Lr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new je(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),Lr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function pf(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let s=0;s<e.length;s+=2)n<=e[s+1]&&i>=e[s]&&(t=!0)}),t}function co(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,s,o)=>e.push(s,o));return e}function Lr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),s=e.map(r[n+1],-1);i<=s&&t.push(i,s)}return t}function mf(r,e,t){let n=zn(e),i=pt.get(e).spec.config,s=(t?r.undone:r.done).popEvent(e,n);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(t?r.done:r.undone).addTransform(s.transform,e.selection.getBookmark(),i,n),a=new je(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(pt,{redo:t,historyState:a})}let zr=!1,ho=null;function zn(r){let e=r.plugins;if(ho!=e){zr=!1,ho=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){zr=!0;break}}return zr}const pt=new dl("history"),gf=new dl("closeHistory");function yf(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new ce({key:pt,state:{init(){return new je(De.empty,De.empty,null,0,-1)},apply(e,t,n){return df(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?Bn:n=="historyRedo"?tn:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function aa(r,e){return(t,n)=>{let i=pt.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let s=mf(i,t,r);s&&n(e?s.scrollIntoView():s)}return!0}}const Bn=aa(!1,!0),tn=aa(!0,!0),uo=r=>typeof r=="function",ir=(r,e,t)=>[r,e,t];class Pi{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return uo(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(uo(e)){const n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(const e of this.bindings)e()}bindToEl(e,t={},n=[],i=[]){for(const s in t)this.bindProp(t[s],o=>{e[s]=o});for(const[s,o,l]of n)o&&e.addEventListener(s,l(o));for(const s of i)e.appendChild(s)}}const Ne=(r,e)=>{const t=document.createElement("div");return r.bindToEl(t,{className:e.className,slot:e.slot},[],e.children),t},bf=(r,e)=>{const t=document.createElement("a");return r.bindToEl(t,{href:e.href,target:e.target,rel:e.rel,className:e.className},[],e.children),t},ca=new WeakMap,ha=(r,e)=>{const t=r.rte.createComponent(vo.Tooltip);t.setAttribute("exportparts","vvd-theme-alternate"),r.bindToEl(t,{className:"ui-tooltip",text:e.label,placement:r.props.popupPlacement}),r.bindProp(e.enabled,i=>{i||(t.open=!1),t.anchor=i?e.anchor:void 0});const n=Ne(r,{className:"ui-tooltip-wrapper",slot:e.slot,children:[e.anchor,t]});return ca.set(n,e.anchor),n},q=(r,e)=>{const t=()=>r.evalProp(e.variant)??"toolbar",n=()=>t()==="toolbar"?"super-condensed":"condensed",i=()=>t()==="popover-primary"?"outlined":"ghost-light",s=()=>r.evalProp(e.active)?"filled":i(),o=r.rte.createComponent(Ao.Button);return r.bindToEl(o,{size:n,appearance:s,disabled:e.disabled,icon:e.icon,autofocus:e.autofocus,connotation:e.connotation,[e.icon?"ariaLabel":"label"]:e.label},[ir("click",e.onClick,l=>()=>{l()||r.view.focus()})]),ha(r,{enabled:()=>!!(r.evalProp(e.icon)&&!r.evalProp(e.noTooltip)&&!r.evalProp(e.disabled)),label:e.label,anchor:o,slot:e.slot})},Fi=(r,e)=>{const t=r.rte.createComponent(Io.Menu);r.bindToEl(t,{className:"ui-menu",autoDismiss:!0,ariaLabel:e.label,anchor:ca.get(e.trigger)??e.trigger,placement:r.props.popupPlacement},[],e.children);const n=document.createDocumentFragment();return n.appendChild(e.trigger),n.appendChild(t),n},kf=(r,e)=>{const t=r.rte.createComponent(Ro.MenuItem);return r.bindToEl(t,{text:e.text,checked:e.checked,disabled:e.disabled,controlType:"radio",checkedAppearance:"tick-only"},[ir("change",e.onSelect,n=>()=>{t.checked&&!t.disabled&&r.evalProp(e.checked)!==t.checked&&(n(),r.view.focus())})]),t},Sf=(r,e)=>Ne(r,{className:"ui-button-group",children:e.children});function xf(r,e){const{from:t,$from:n,to:i,empty:s}=r.selection;return s?!!e.isInSet(r.storedMarks||n.marks()):r.doc.rangeHasMark(t,i,e)}const bn=(r,e)=>q(r,{label:e.label,icon:e.icon,active:()=>xf(r.view.state,e.markType),disabled:()=>!Je(e.markType)(r.view.state),onClick:()=>{Je(e.markType)(r.view.state,r.view.dispatch)}}),Tf=(r,e)=>{const t=r.rte.createComponent(Do.ListboxOption);return r.bindToEl(t,{value:e.value,text:e.text,disabled:e.disabled}),t},Cf=(r,e)=>{const t=r.rte.createComponent(No.Select);t.setAttribute("data-class","ui-select"),r.bindToEl(t,{placeholder:" ",ariaLabel:e.label,scale:"condensed",appearance:"ghost"},[ir("change",e.onSelect,i=>()=>{const s=t.value;s&&(i(s),r.view.focus())})],e.children),queueMicrotask(()=>{r.bindProp(e.value,i=>t.value=i)});let n=!1;return t.addEventListener("vwc-popup:open",()=>{n=!0,r.updateBindings()}),t.addEventListener("vwc-popup:close",()=>{n=!1,r.updateBindings()}),ha(r,{enabled:()=>!n,label:e.label,anchor:t})},ci=r=>{const e=r.rte.createComponent(Ja.Divider);return r.bindToEl(e,{className:"ui-divider",orientation:"vertical"}),e},fo=(r,e)=>{const t=r.rte.createComponent(Po.TextField);return r.bindToEl(t,{label:e.label,value:e.value,placeholder:e.placeholder,slot:e.slot,autofocus:e.autofocus,type:e.type},[ir("input",e.onInput,n=>()=>{n(t.value)})]),t},po=(r,e)=>{const t=document.createTextNode("");return r.bindToEl(t,{textContent:e.text}),t},wf=(r,e)=>{const t=document.createElement("slot");t.name=e.name;let n=null;const i=[];function s(){for(const{el:a,type:c,handler:h}of i)a.removeEventListener(c,h);i.length=0,n=null}for(const[a,c]of Object.entries(e.assignedProps))r.bindProp(c,h=>{n&&(n[a]=h)});function o(a){for(const[c,h]of Object.entries(e.assignedProps))a[c]=r.evalProp(h);for(const[c,h]of Object.entries(e.assignedEvents)){const u=f=>{h(f),r.view.focus()};a.addEventListener(c,u),i.push({el:a,type:c,handler:u})}}const l=()=>{const c=t.assignedElements({flatten:!0})[0];c!==n&&(s(),c&&(n=c,o(c)))};return t.addEventListener("slotchange",l),queueMicrotask(l),t};class Mf extends ${constructor(){super(...arguments),this.name="RteHistoryFeature"}getPlugins(){return[this.contribution(yf()),this.contribution(Me({"Mod-z":Bn,"Ctrl-y":tn,"Cmd-Z":tn}))]}getToolbarItems(){return[this.contribution({section:"history",render:e=>q(e,{label:t=>t.rte.getLocale().richTextEditor.undo,icon:"undo-line",disabled:t=>!Bn(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;Bn(t,n)}})},1),this.contribution({section:"history",render:e=>q(e,{label:t=>t.rte.getLocale().richTextEditor.redo,icon:"redo-line",disabled:t=>!tn(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;tn(t,n)}})},2)]}}class Of extends ${constructor(){super(...arguments),this.name="RteForeignHtmlFeature"}getPlugins(e){return[this.contribution(new ce({props:{transformPastedHTML:t=>e.foreignHtmlParser[A].transform(t),clipboardParser:e.foreignHtmlParser[A].parser,clipboardSerializer:e.foreignHtmlSerializer[A].serializer}}))]}}const ln=new ce({state:{init(){return null},apply(r,e){const t=r.getMeta(ln);return t||e}}});class ua extends ${constructor(){super(...arguments),this.name="RteCore"}getStyles(){return[this.contribution(Yu),this.contribution(af),this.contribution(lf)]}getPlugins(e){return[this.contribution(Me({...ju,Enter:rr(Zl,Ql,ea,ta((t,n,i)=>n?{type:oa(i.node(i.depth-1).contentMatchAt(i.indexAfter(i.depth-1))),attrs:e.textblockAttrs.extractFromNode(t)}:{type:t.type,attrs:t.attrs}))})),this.contribution(Xu()),this.contribution(tf()),this.contribution(ln)]}getFeatures(){return[this,new Mf,new Of]}}H(ua);const Ef="h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);line-height:20px;margin-block:16px}.heading-step-1{font:var(--vvd-typography-heading-4);line-height:28px;margin-block:24px 12px}.heading-step-2{font:var(--vvd-typography-heading-3);line-height:36px;margin-block:24px 12px}.heading-step-3{font:var(--vvd-typography-heading-2);line-height:42px;margin-block:32px 16px}";class fa extends ${constructor(e){super(),this.enabledBlocks=e,this.name="RteBasicTextBlocks"}getStyles(){return[this.contribution(Ef)]}getSchema(e,t){const n={};this.enabledBlocks.paragraph&&(n.paragraph={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:"p",getAttrs:s=>e.fromDOM(s)}],marks:t.getAllowedMarksForNode("paragraph").join(" "),toDOM(s){return["p",{part:"node--paragraph",...e.getDOMAttrsProperties(s)},0]},serializeToDOM(s){return["p",...e.getDOMAttrs(s),0]}});let i=0;for(const s of[3,2,1]){const o=`heading${s}`,l=`h${s}`;if(!this.enabledBlocks[o])continue;i++;const a=i;n[o]={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:l,getAttrs:c=>e.fromDOM(c)}],marks:t.getAllowedMarksForNode(o).join(" "),defining:!0,toDOM(c){return[l,{class:`heading-step-${a}`,part:`node--${o}`,...e.getDOMAttrsProperties(c)},0]},serializeToDOM(c){return[l,...e.getDOMAttrs(c),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){const t={};this.enabledBlocks.paragraph&&(t["Mod-Alt-0"]=this.setBlockType(e,"paragraph"));for(const n of[1,2,3]){const i=`heading${n}`;this.enabledBlocks[i]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,i))}return[this.contribution(Me(t))]}getCurrentBlockType(e){const{$from:t,$to:n}=e.selection,i=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1),s=n.depth===0?e.doc.childBefore(n.pos).node:n.node(1);return i!==s||!(i.type.name in this.enabledBlocks)?null:i.type.name}setBlockType(e,t){return(n,i)=>{const{from:s,to:o}=n.selection,l=n.tr;let a=!1;return n.doc.nodesBetween(s,o,(c,h)=>(c.type.name in this.enabledBlocks&&(a=!0,l.setBlockType(h,h+c.nodeSize,n.schema.nodes[t],u=>e.textblockAttrs.extractFromNode(u))),!1)),a?(i?.(l),!0):!1}}}class da extends ${constructor(e){super(),this.config=e,this.name="RteBase"}getSchema(){return[this.contribution({nodes:{doc:{content:"block+"},text:{group:"inline"}}})]}getFeatures(){return[this,new ua,new fa({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0})]}}const Nf=H(da);var Df=Object.defineProperty,Af=Object.getOwnPropertyDescriptor,Wt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Af(e,t):e,s=r.length-1,o;s>=0;s--)(o=r[s])&&(i=(n?o(e,t,i):o(i))||i);return n&&i&&Df(e,t,i),i};const vf=r=>{const e=r.tagFor(Gr.Popup);return me.html`<${e}
|
|
5
|
+
`);return{dom:a,text:f,slice:e}}function Os(r,e,t,n,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(n||o||!t);if(a){if(r.someProp("transformPastedText",f=>{e=f(e,o||n,r)}),o)return l=new m.Slice(m.Fragment.from(r.state.schema.text(e.replace(/\r\n?/g,`
|
|
6
|
+
`))),0,0),r.someProp("transformPasted",f=>{l=f(l,r,!0)}),l;let u=r.someProp("clipboardTextParser",f=>f(e,i,n,r));if(u)l=u;else{let f=i.marks(),{schema:h}=r.state,p=m.DOMSerializer.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=s.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,f)))})}}else r.someProp("transformPastedHTML",u=>{t=u(t,r)}),s=sc(t),Zt&&lc(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||m.DOMParser.fromSchema(r.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!rc.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=ac(lo(l,+d[1],+d[2]),d[4]);else if(l=m.Slice.maxOpen(ic(l.content,i),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u<l.openStart&&!h.type.spec.isolating;u++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=lo(l,u,f)}return r.someProp("transformPasted",u=>{l=u(l,r,a)}),l}const rc=/^(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 ic(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(r.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Ns(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Es(s[s.length-1],o.length));let d=Ds(l,a);s.push(d),i=i.matchType(d.type),o=a}}),s)return m.Fragment.from(s)}return r}function Ds(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,m.Fragment.from(r));return r}function Ns(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let o=Ns(r,e,t,n.lastChild,i+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(m.Fragment.from(Ds(t,r,i+1))))}}function Es(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Es(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(m.Fragment.empty,!0);return r.copy(t.append(n))}function Ir(r,e,t,n,i,o){let s=e<0?r.firstChild:r.lastChild,l=s.content;return r.childCount>1&&(o=0),i<n-1&&(l=Ir(l,e,t,n,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(m.Fragment.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,s.copy(l))}function lo(r,e,t){return e<r.openStart&&(r=new m.Slice(Ir(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new m.Slice(Ir(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const ws={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ao=null;function As(){return ao||(ao=document.implementation.createHTMLDocument("title"))}let rr=null;function oc(r){let e=window.trustedTypes;return e?(rr||(rr=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),rr.createHTML(r)):r}function sc(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=As().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&ws[n[1].toLowerCase()])&&(r=i.map(o=>"<"+o+">").join("")+r+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=oc(r),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function lc(r){let e=r.querySelectorAll(X?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function ac(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:o,openEnd:s}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=m.Fragment.from(a.create(n[l+1],i)),o++,s++}return new m.Slice(i,o,s)}const oe={},se={},cc={touchstart:!0,touchmove:!0};class dc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,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.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function uc(r){for(let e in oe){let t=oe[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{hc(r,n)&&!Xr(r,n)&&(r.editable||!(n.type in se))&&t(r,n)},cc[e]?{passive:!0}:void 0)}ie&&r.dom.addEventListener("input",()=>null),Rr(r)}function Ke(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function fc(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function Rr(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>Xr(r,n))})}function Xr(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function hc(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function pc(r,e){!Xr(r,e)&&oe[e.type]&&(r.editable||!(e.type in se))&&oe[e.type](r,e)}se.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!Is(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(Le&&X&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),Dt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,et(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||nc(r,t)?t.preventDefault():Ke(r,"key")};se.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};se.keypress=(r,e)=>{let t=e;if(Is(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||pe&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),o=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i,o))&&r.dispatch(o()),t.preventDefault()}};function vn(r){return{left:r.clientX,top:r.clientY}}function mc(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function Zr(r,e,t,n,i){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(r.someProp(e,l=>s>o.depth?l(r,t,o.nodeAfter,o.before(s),i,!0):l(r,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Mt(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function gc(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&M.isSelectable(n)?(Mt(r,new M(t)),!0):!1}function bc(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof M&&(n=t.node);let o=r.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(M.isSelectable(l)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Mt(r,M.create(r.state.doc,i)),!0):!1}function yc(r,e,t,n,i){return Zr(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(i?bc(r,t):gc(r,t))}function Sc(r,e,t,n){return Zr(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function kc(r,e,t,n){return Zr(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||Tc(r,t,n)}function Tc(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Mt(r,O.create(n,0,n.content.size)),!0):!1;let i=n.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Mt(r,O.create(n,l+1,l+1+s.content.size));else if(M.isSelectable(s))Mt(r,M.create(n,l));else continue;return!0}}function Qr(r){return Cn(r)}const vs=pe?"metaKey":"ctrlKey";oe.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=Qr(r),i=Date.now(),o="singleClick";i-r.input.lastClick.time<500&&mc(t,r.input.lastClick)&&!t[vs]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=r.posAtCoords(vn(t));s&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Cc(r,s,t,!!n)):(o=="doubleClick"?Sc:kc)(r,s.pos,s.inside,t)?t.preventDefault():Ke(r,"pointer"))};class Cc{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[vs],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);o=d.parent,s=d.depth?d.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof M&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&be&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ke(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>ze(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(vn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ke(this.view,"pointer"):yc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ie&&this.mightDrag&&!this.mightDrag.node.isAtom||X&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Mt(this.view,N.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ke(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ke(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}oe.touchstart=r=>{r.input.lastTouch=Date.now(),Qr(r),Ke(r,"pointer")};oe.touchmove=r=>{r.input.lastTouch=Date.now(),Ke(r,"pointer")};oe.contextmenu=r=>Qr(r);function Is(r,e){return r.composing?!0:ie&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Mc=Le?5e3:-1;se.compositionstart=se.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof O&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))r.markCursor=r.state.storedMarks||t.marks(),Cn(r,!0),r.markCursor=null;else if(Cn(r,!e.selection.empty),be&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,o=n.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=r.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}r.input.composing=!0}Rs(r,Mc)};se.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Rs(r,20))};function Rs(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>Cn(r),e))}function Fs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Oc());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function xc(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=ga(e.focusNode,e.focusOffset),n=ba(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function Oc(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function Cn(r,e=!1){if(!(Le&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Fs(r),e||r.docView&&r.docView.dirty){let t=Gr(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function Dc(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const Gt=ue&&Je<15||Dt&&Ca<604;oe.copy=se.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let o=Gt?null:t.clipboardData,s=n.content(),{dom:l,text:a}=Yr(r,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):Dc(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Nc(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function Ec(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?jt(r,n.value,null,i,e):jt(r,n.textContent,n.innerHTML,i,e)},50)}function jt(r,e,t,n,i){let o=Os(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,o||m.Slice.empty)))return!0;if(!o)return!1;let s=Nc(o),l=s?r.state.tr.replaceSelectionWith(s,n):r.state.tr.replaceSelection(o);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ps(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}se.paste=(r,e)=>{let t=e;if(r.composing&&!Le)return;let n=Gt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&jt(r,Ps(n),n.getData("text/html"),i,t)?t.preventDefault():Ec(r,t)};class Ls{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const wc=pe?"altKey":"ctrlKey";function zs(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[wc]}oe.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,o=i.empty?null:r.posAtCoords(vn(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof M?i.to-1:i.to))){if(n&&n.mightDrag)s=M.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=r.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=r.docView&&(s=M.create(r.state.doc,u.posBefore))}}let l=(s||r.state.selection).content(),{dom:a,text:c,slice:d}=Yr(r,l);(!t.dataTransfer.files.length||!X||cs>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Gt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Gt||t.dataTransfer.setData("text/plain",c),r.dragging=new Ls(d,zs(r,t),s)};oe.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};se.dragover=se.dragenter=(r,e)=>e.preventDefault();se.drop=(r,e)=>{let t=e,n=r.dragging;if(r.dragging=null,!t.dataTransfer)return;let i=r.posAtCoords(vn(t));if(!i)return;let o=r.state.doc.resolve(i.pos),s=n&&n.slice;s?r.someProp("transformPasted",p=>{s=p(s,r,!1)}):s=Os(r,Ps(t.dataTransfer),Gt?null:t.dataTransfer.getData("text/html"),!1,o);let l=!!(n&&zs(r,t));if(r.someProp("handleDrop",p=>p(r,t,s||m.Slice.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?$r(r.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let c=r.state.tr;if(l){let{node:p}=n;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&M.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new M(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,C,R)=>p=R),c.setSelection(jr(r,h,c.doc.resolve(p)))}r.focus(),r.dispatch(c.setMeta("uiEvent","drop"))};oe.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&ze(r)},20))};oe.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};oe.beforeinput=(r,e)=>{if(X&&Le&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,et(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in se)oe[r]=se[r];function Yt(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class Mn{constructor(e,t){this.toDOM=e,this.spec=t||rt,this.side=this.spec.side||0}map(e,t,n,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new Z(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Mn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class je{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,n,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new Z(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof je&&Yt(this.attrs,e.attrs)&&Yt(this.spec,e.spec)}static is(e){return e.type instanceof je}destroy(){}}class ei{constructor(e,t){this.attrs=e,this.spec=t||rt}map(e,t,n,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new Z(o.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(n)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof ei&&Yt(this.attrs,e.attrs)&&Yt(this.spec,e.spec)}destroy(){}}class Z{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Z(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,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Z(e,e,new Mn(t,n))}static inline(e,t,n,i){return new Z(e,t,new je(n,i))}static node(e,t,n,i){return new Z(e,t,new ei(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof je}get widget(){return this.type instanceof Mn}}const kt=[],rt={};class v{constructor(e,t){this.local=e.length?e:kt,this.children=t.length?t:kt}static create(e,t){return t.length?xn(t,e,0,rt):j}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,n,i+l,o)}}map(e,t,n){return this==j||e.maps.length==0?this:this.mapInner(e,t,0,0,n||rt)}mapInner(e,t,n,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Ac(this.children,s||[],e,t,n,i,o):s?new v(s.sort(it),kt):j}add(e,t){return t.length?this==j?v.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,o=0;e.forEach((l,a)=>{let c=a+n,d;if(d=_s(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,d,c+1):i.splice(o,0,a,a+l.nodeSize,xn(d,l,c+1,rt)),o+=3}});let s=Bs(o?Vs(t):t,-n);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new v(s.length?this.local.concat(s).sort(it):this.local,i||this.children)}remove(e){return e.length==0||this==j?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let o=0;o<n.length;o+=3){let s,l=n[o]+t,a=n[o+1]+t;for(let d=0,u;d<e.length;d++)(u=e[d])&&u.from>l&&u.to<a&&(e[d]=null,(s||(s=[])).push(u));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,l+1);c!=j?n[o+2]=c:(n.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new v(i,n):j}forChild(e,t){if(this==j)return this;if(t.isLeaf)return v.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof je){let c=Math.max(o,a.from)-o,d=Math.min(s,a.to)-o;c<d&&(i||(i=[])).push(a.copy(c,d))}}if(i){let l=new v(i.sort(it),kt);return n?new Ue([l,n]):l}return n||j}eq(e){if(this==e)return!0;if(!(e instanceof v)||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 ti(this.localsInner(e))}localsInner(e){if(this==j)return kt;if(e.inlineContent||!this.local.some(je.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof je||t.push(this.local[n]);return t}forEachSet(e){e(this)}}v.empty=new v([],[]);v.removeOverlap=ti;const j=v.empty;class Ue{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,rt));return Ue.from(n)}forChild(e,t){if(t.isLeaf)return v.empty;let n=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=j&&(o instanceof Ue?n=n.concat(o.members):n.push(o))}return Ue.from(n)}eq(e){if(!(e instanceof Ue)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?ti(n?t:t.sort(it)):kt}static from(e){switch(e.length){case 0:return j;case 1:return e[0];default:return new Ue(e.every(t=>t instanceof v)?e:e.reduce((t,n)=>t.concat(n instanceof v?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Ac(r,e,t,n,i,o,s){let l=r.slice();for(let c=0,d=o;c<t.maps.length;c++){let u=0;t.maps[c].forEach((f,h,p,b)=>{let y=b-p-(h-f);for(let C=0;C<l.length;C+=3){let R=l[C+1];if(R<0||f>R+d-u)continue;let w=l[C]+d-u;h>=w?l[C+1]=f<=w?-2:-1:f>=d&&y&&(l[C]+=y,l[C+1]+=y)}u+=y}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let d=t.map(r[c]+o),u=d-i;if(u<0||u>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+o,-1),h=f-i,{index:p,offset:b}=n.content.findIndex(u),y=n.maybeChild(p);if(y&&b==u&&b+y.nodeSize==h){let C=l[c+2].mapInner(t,y,d+1,r[c]+o+1,s);C!=j?(l[c]=u,l[c+1]=h,l[c+2]=C):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=vc(l,r,e,t,i,o,s),d=xn(c,n,0,s);e=d.local;for(let u=0;u<l.length;u+=3)l[u+1]<0&&(l.splice(u,3),u-=3);for(let u=0,f=0;u<d.children.length;u+=3){let h=d.children[u];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,d.children[u],d.children[u+1],d.children[u+2])}}return new v(e.sort(it),l)}function Bs(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new Z(i.from+e,i.to+e,i.type))}return t}function vc(r,e,t,n,i,o,s){function l(a,c){for(let d=0;d<a.local.length;d++){let u=a.local[d].map(n,i,c);u?t.push(u):s.onRemove&&s.onRemove(a.local[d].spec)}for(let d=0;d<a.children.length;d+=3)l(a.children[d+2],a.children[d]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+o+1);return t}function _s(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let o=0,s;o<r.length;o++)(s=r[o])&&s.from>t&&s.to<n&&((i||(i=[])).push(s),r[o]=null);return i}function Vs(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function xn(r,e,t,n){let i=[],o=!1;e.forEach((l,a)=>{let c=_s(r,l,a+t);if(c){o=!0;let d=xn(c,l,t+a+1,n);d!=j&&i.push(a,a+l.nodeSize,d)}});let s=Bs(o?Vs(r):r,-t).sort(it);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(n.onRemove&&n.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new v(s,i):j}function it(r,e){return r.from-e.from||r.to-e.to}function ti(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[i]=o.copy(o.from,n.to),co(e,i+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),co(e,i,n.copy(o.from,n.to)));break}}}return e}function co(r,e,t){for(;e<r.length&&it(t,r[e])>0;)e++;r.splice(e,0,t)}function ir(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=j&&e.push(n)}),r.cursorWrapper&&e.push(v.create(r.state.doc,[r.cursorWrapper.deco])),Ue.from(e)}const Ic={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Rc=ue&&Je<=11;class Fc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Pc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Fc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);ue&&Je<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),Rc&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Ic)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(to(this.view)){if(this.suppressingSelectionUpdates)return ze(this.view);if(ue&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&<(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=Ot(o))t.add(o);for(let o=e.anchorNode;o;o=Ot(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&to(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;d<t.length;d++){let u=this.registerMutation(t[d],a);u&&(o=o<0?u.from:Math.min(u.from,o),s=s<0?u.to:Math.max(u.to,s),u.typeOver&&(l=!0))}if(be&&a.length){let d=a.filter(u=>u.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Bc(e,u)!=h)&&f.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&wn(n)&&(c=Gr(e))&&c.eq(N.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ze(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Lc(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||ze(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;d<e.addedNodes.length;d++){let u=e.addedNodes[d];t.push(u),u.nodeType==3&&(this.lastChangedTextNode=u)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(ue&&Je<=11&&e.addedNodes.length)for(let d=0;d<e.addedNodes.length;d++){let{previousSibling:u,nextSibling:f}=e.addedNodes[d];(!u||Array.prototype.indexOf.call(e.addedNodes,u)<0)&&(i=u),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let s=i&&i.parentNode==e.target?$(i)+1:0,l=n.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?$(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let uo=new WeakMap,fo=!1;function Lc(r){if(!uo.has(r)&&(uo.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=be,fo)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."),fo=!0}}function ho(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=r.domAtPos(r.state.selection.anchor);return lt(s.node,s.offset,i,o)&&([t,n,i,o]=[i,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}}function zc(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return ho(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?ho(r,t):null}function Bc(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function _c(r,e,t){let{node:n,fromOffset:i,toOffset:o,from:s,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,d=a.anchorNode;if(d&&r.dom.contains(d.nodeType==1?d:d.parentNode)&&(c=[{node:d,offset:a.anchorOffset}],wn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),X&&r.input.lastKeyCode===8)for(let y=o;y>i;y--){let C=n.childNodes[y-1],R=C.pmViewDesc;if(C.nodeName=="BR"&&!R){o=y;break}if(!R||R.size)break}let u=r.state.doc,f=r.someProp("domParser")||m.DOMParser.fromSchema(r.state.schema),h=u.resolve(s),p=null,b=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Vc,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,C=c[1]&&c[1].pos;C==null&&(C=y),p={anchor:y+s,head:C+s}}return{doc:b,sel:p,from:s,to:l}}function Vc(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ie&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||ie&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Hc=/^(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 Wc(r,e,t,n,i){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let D=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,P=Gr(r,D);if(P&&!r.state.selection.eq(P)){if(X&&Le&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",Fn=>Fn(r,et(13,"Enter"))))return;let J=r.state.tr.setSelection(P);D=="pointer"?J.setMeta("pointer",!0):D=="key"&&J.scrollIntoView(),o&&J.setMeta("composition",o),r.dispatch(J)}return}let s=r.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=_c(r,e,t),d=r.state.doc,u=d.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=qc(u.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(Dt&&r.input.lastIOSEnter>Date.now()-225||Le)&&i.some(D=>D.nodeType==1&&!Hc.test(D.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",D=>D(r,et(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let D=po(r,r.state.doc,c.sel);if(D&&!D.eq(r.state.selection)){let P=r.state.tr.setSelection(D);o&&P.setMeta("composition",o),r.dispatch(P)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof O&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),ue&&Je<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),C=d.resolve(p.start),R=b.sameParent(y)&&b.parent.inlineContent&&C.end()>=p.endA;if((Dt&&r.input.lastIOSEnter>Date.now()-225&&(!R||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!R&&b.pos<c.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&b.pos<y.pos&&!/\S/.test(c.doc.textBetween(b.pos,y.pos,"","")))&&r.someProp("handleKeyDown",D=>D(r,et(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&$c(d,p.start,p.endA,b,y)&&r.someProp("handleKeyDown",D=>D(r,et(8,"Backspace")))){Le&&X&&r.domObserver.suppressSelectionUpdates();return}X&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),Le&&!R&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(D){return D(r,et(13,"Enter"))})},20));let w=p.start,A=p.endA,ke=D=>{let P=D||r.state.tr.replace(w,A,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let J=po(r,P.doc,c.sel);J&&!(X&&r.composing&&J.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(J.head==w||J.head==P.mapping.map(A)-1)||ue&&J.empty&&J.head==w)&&P.setSelection(J)}return o&&P.setMeta("composition",o),P.scrollIntoView()},_e;if(R)if(b.pos==y.pos){ue&&Je<=11&&b.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>ze(r),20));let D=ke(r.state.tr.delete(w,A)),P=d.resolve(p.start).marksAcross(d.resolve(p.endA));P&&D.ensureMarks(P),r.dispatch(D)}else if(p.endA==p.endB&&(_e=Uc(b.parent.content.cut(b.parentOffset,y.parentOffset),C.parent.content.cut(C.parentOffset,p.endA-C.start())))){let D=ke(r.state.tr);_e.type=="add"?D.addMark(w,A,_e.mark):D.removeMark(w,A,_e.mark),r.dispatch(D)}else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let D=b.parent.textBetween(b.parentOffset,y.parentOffset),P=()=>ke(r.state.tr.insertText(D,w,A));r.someProp("handleTextInput",J=>J(r,w,A,D,P))||r.dispatch(P())}else r.dispatch(ke());else r.dispatch(ke())}function po(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:jr(r,e.resolve(t.anchor),e.resolve(t.head))}function Uc(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,o=n,s,l,a;for(let d=0;d<n.length;d++)i=n[d].removeFromSet(i);for(let d=0;d<t.length;d++)o=t[d].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=d=>d.mark(l.addToSet(d.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;d<e.childCount;d++)c.push(a(e.child(d)));if(m.Fragment.from(c).eq(r))return{mark:l,type:s}}function $c(r,e,t,n,i){if(t-e<=i.pos-n.pos||or(n,!0,!1)<i.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=r.resolve(or(o,!0,!0));return!s.parent.isTextblock||s.pos>t||or(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function or(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function qc(r,e,t,n,i){let o=r.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));n-=s+a-o}if(s<o&&r.size<e.size){let a=n<=o&&n>=s?o-n:0;o-=a,o&&o<e.size&&mo(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=n<=o&&n>=l?o-n:0;o-=a,o&&o<r.size&&mo(r.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function mo(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Hs{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 dc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ko),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=yo(this),bo(this),this.nodeViews=So(this),this.docView=ji(this.state.doc,go(this),ir(this),this.dom,this),this.domObserver=new Pc(this,(n,i,o,s)=>Wc(this,n,i,o,s)),this.domObserver.start(),uc(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&&Rr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ko),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Fs(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=So(this);Jc(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Rr(this),this.editable=yo(this),bo(this);let a=ir(this),c=go(this),d=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",u=o||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(i.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Oa(this);if(s){this.domObserver.stop();let h=u&&(ue||X)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Kc(i.selection,e.selection);if(u){let p=X?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=xc(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=ji(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&ja(this))?ze(this,h):(Cs(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Da(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ui(this,t.getBoundingClientRect(),e)}else Ui(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 n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new Ls(e.slice,e.move,i<0?void 0:M.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(ue){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&Na(this.dom),ze(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ia(this,e)}coordsAtPos(e,t=1){return ps(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,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return za(this,t||this.state,e)}pasteHTML(e,t){return jt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return jt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Yr(this,e)}destroy(){this.docView&&(fc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ir(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,pa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return pc(this,e)}domSelectionRange(){let e=this.domSelection();return e?ie&&this.root.nodeType===11&&Sa(this.dom.ownerDocument)==this.dom&&zc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Hs.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function go(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[Z.node(0,r.state.doc.content.size,e)]}function bo(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:Z.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function yo(r){return!r.someProp("editable",e=>e(r.state)===!1)}function Kc(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function So(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function Jc(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function ko(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class Gc{constructor(e){this.specs=e,this.attrs={};for(const t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join("; ")}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}}class jc{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(t=>t.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}}var Ye={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:"'"},On={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Yc=typeof navigator<"u"&&/Mac/.test(navigator.platform),Xc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var q=0;q<10;q++)Ye[48+q]=Ye[96+q]=String(q);for(var q=1;q<=24;q++)Ye[q+111]="F"+q;for(var q=65;q<=90;q++)Ye[q]=String.fromCharCode(q+32),On[q]=String.fromCharCode(q);for(var sr in Ye)On.hasOwnProperty(sr)||(On[sr]=Ye[sr]);function Zc(r){var e=Yc&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||Xc&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?On:Ye)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Qc=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ed=typeof navigator<"u"&&/Win/.test(navigator.platform);function td(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,o,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))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Qc?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function nd(r){let e=Object.create(null);for(let t in r)e[td(t)]=r[t];return e}function lr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function he(r){return new re({props:{handleKeyDown:Ws(r)}})}function Ws(r){let e=nd(r);return function(t,n){let i=Zc(n),o,s=e[lr(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[lr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(ed&&n.ctrlKey&&n.altKey)&&(o=Ye[n.keyCode])&&o!=i){let l=e[lr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Us=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function rd(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const id=(r,e,t)=>{let n=rd(r,t);if(!n)return!1;let i=$s(n);if(!i){let s=n.blockRange(),l=s&&Wr(s);return l==null?!1:(e&&e(r.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(Ys(r,i,e,-1))return!0;if(n.parent.content.size==0&&(Nt(o,"end")||M.isSelectable(o)))for(let s=n.depth;;s--){let l=qr(r.doc,n.before(s),n.after(s),m.Slice.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(Nt(o,"end")?N.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):M.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1};function Nt(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const od=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=$s(n)}let s=o&&o.nodeBefore;return!s||!M.isSelectable(s)?!1:(e&&e(r.tr.setSelection(M.create(r.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function $s(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function sd(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const ld=(r,e,t)=>{let n=sd(r,t);if(!n)return!1;let i=qs(n);if(!i)return!1;let o=i.nodeAfter;if(Ys(r,i,e,1))return!0;if(n.parent.content.size==0&&(Nt(o,"start")||M.isSelectable(o))){let s=qr(r.doc,n.before(),n.after(),m.Slice.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=r.tr.step(s);l.setSelection(Nt(o,"start")?N.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):M.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},ad=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=qs(n)}let s=o&&o.nodeAfter;return!s||!M.isSelectable(s)?!1:(e&&e(r.tr.setSelection(M.create(r.doc,o.pos)).scrollIntoView()),!0)};function qs(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const Ks=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
|
|
7
|
+
`).scrollIntoView()),!0)};function ni(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const cd=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=ni(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,s.createAndFill());a.setSelection(N.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Js=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof K||n.parent.inlineContent||i.parent.inlineContent)return!1;let o=ni(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(s,o.createAndFill());l.setSelection(O.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},Gs=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(gn(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Wr(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function js(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof M&&e.selection.node.isBlock)return!n.parentOffset||!gn(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=ni(n.node(h-1).contentMatchAt(n.indexAfter(h-1)));let b=r&&r(i.parent,a,n);o.unshift(b||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;o.unshift(null)}let d=e.tr;(e.selection instanceof O||e.selection instanceof K)&&d.deleteSelection();let u=d.mapping.map(n.pos),f=gn(d.doc,u,o.length,o);if(f||(o[0]=l?{type:l}:null,f=gn(d.doc,u,o.length,o)),!f)return!1;if(d.split(u,o.length,o),!a&&c&&n.node(s).type!=l){let h=d.mapping.map(n.before(s)),p=d.doc.resolve(h);l&&n.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(n.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}const dd=js(),ud=(r,e)=>(e&&e(r.tr.setSelection(new K(r.doc))),!0);function fd(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,o=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Ur(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function Ys(r,e,t,n){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&fd(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=m.Fragment.empty;for(let C=s.length-1;C>=0;C--)p=m.Fragment.from(s[C].create(null,p));p=m.Fragment.from(i.copy(p));let b=r.tr.step(new Q(e.pos-1,h,e.pos,h,new m.Slice(p,1,0),s.length,!0)),y=b.doc.resolve(h+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Ur(b.doc,y.pos)&&b.join(y.pos),t(b.scrollIntoView())}return!0}let d=o.type.spec.isolating||n>0&&a?null:N.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Wr(u);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(u,f).scrollIntoView()),!0;if(c&&Nt(o,"start",!0)&&Nt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let b=o,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let C=m.Fragment.empty;for(let w=p.length-1;w>=0;w--)C=m.Fragment.from(p[w].copy(C));let R=r.tr.step(new Q(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new m.Slice(C,p.length,0),0,!0));t(R.scrollIntoView())}return!0}}return!1}function Xs(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(O.create(e.doc,r<0?i.start(o):i.end(o)))),!0):!1}}const hd=Xs(-1),pd=Xs(1);function md(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,s.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function Be(r,e=null,t){return function(n,i){let{empty:o,$cursor:s,ranges:l}=n.selection;if(o&&!s||!md(n.doc,l,r))return!1;if(i)if(s)r.isInSet(n.storedMarks||s.marks())?i(n.tr.removeStoredMark(r)):i(n.tr.addStoredMark(r.create(e)));else{let a,c=n.tr;a=!l.some(d=>n.doc.rangeHasMark(d.$from.pos,d.$to.pos,r));for(let d=0;d<l.length;d++){let{$from:u,$to:f}=l[d];if(!a)c.removeMark(u.pos,f.pos,r);else{let h=u.pos,p=f.pos,b=u.nodeAfter,y=f.nodeBefore,C=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,R=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+C<p&&(h+=C,p-=R),c.addMark(h,p,r.create(e))}}i(c.scrollIntoView())}return!0}}function gd(r,e){return t=>{if(!t.isGeneric)return r(t);let n=[];for(let o=0;o<t.mapping.maps.length;o++){let s=t.mapping.maps[o];for(let l=0;l<n.length;l++)n[l]=s.map(n[l]);s.forEach((l,a,c,d)=>n.push(c,d))}let i=[];for(let o=0;o<n.length;o+=2){let s=n[o],l=n[o+1],a=t.doc.resolve(s),c=a.sharedDepth(l),d=a.node(c);for(let u=a.indexAfter(c),f=a.after(c+1);f<=l;++u){let h=d.maybeChild(u);if(!h)break;if(u&&i.indexOf(f)==-1){let p=d.child(u-1);p.type==h.type&&e(p,h)&&i.push(f)}f+=h.nodeSize}}i.sort((o,s)=>o-s);for(let o=i.length-1;o>=0;o--)Ur(t.doc,i[o])&&t.join(i[o]);r(t)}}function bd(r,e){let t=Array.isArray(e)?n=>e.indexOf(n.type.name)>-1:e;return(n,i,o)=>r(n,i&&gd(i,t),o)}function In(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}let ar=In(Us,id,od),To=In(Us,ld,ad);const Pe={Enter:In(Ks,Js,Gs,dd),"Mod-Enter":cd,Backspace:ar,"Mod-Backspace":ar,"Shift-Backspace":ar,Delete:To,"Mod-Delete":To,"Mod-a":ud},Zs={"Ctrl-h":Pe.Backspace,"Alt-Backspace":Pe["Mod-Backspace"],"Ctrl-d":Pe.Delete,"Ctrl-Alt-Backspace":Pe["Mod-Delete"],"Alt-Delete":Pe["Mod-Delete"],"Alt-d":Pe["Mod-Delete"],"Ctrl-a":hd,"Ctrl-e":pd};for(let r in Pe)Zs[r]=Pe[r];const yd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Sd=yd?Zs:Pe,kd='.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}';function Td(r={}){return new re({view(e){return new Cd(e,r)}})}class Cd{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):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,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let u=e.nodeBefore,f=e.nodeAfter;if(u||f){let h=this.editorView.nodeDOM(this.cursorPos-(u?u.nodeSize:0));if(h){let p=h.getBoundingClientRect(),b=u?p.bottom:p.top;u&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;n={left:p.left,right:p.right,top:b-y,bottom:b+y}}}}if(!n){let u=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;n={left:u.left-f,right:u.left+f,top:u.top,bottom:u.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,d;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,d=-pageYOffset;else{let u=a.getBoundingClientRect(),f=u.width/a.offsetWidth,h=u.height/a.offsetHeight;c=u.left-a.scrollLeft*f,d=u.top-a.scrollTop*h}this.element.style.left=(n.left-c)/s+"px",this.element.style.top=(n.top-d)/l+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=$r(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class I extends N{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return I.valid(n)?new I(n):N.near(n)}content(){return m.Slice.empty}eq(e){return e instanceof I&&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 I(e.resolve(t.pos))}getBookmark(){return new ri(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Md(e)||!xd(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&I.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(I.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!M.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(I.valid(l))return l}return null}}}I.prototype.visible=!1;I.findFrom=I.findGapCursorFrom;N.jsonID("gapcursor",I);class ri{constructor(e){this.pos=e}map(e){return new ri(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return I.valid(t)?new I(t):N.near(t)}}function Qs(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function Md(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Qs(i.type))return!0;if(i.inlineContent)return!1}}return!0}function xd(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Qs(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Od(){return new re({props:{decorations:wd,createSelectionBetween(r,e,t){return e.pos==t.pos&&I.valid(t)?new I(t):null},handleClick:Nd,handleKeyDown:Dd,handleDOMEvents:{beforeinput:Ed}}})}const Dd=Ws({ArrowLeft:un("horiz",-1),ArrowRight:un("horiz",1),ArrowUp:un("vert",-1),ArrowDown:un("vert",1)});function un(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof O){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=I.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new I(c))),!0):!1}}function Nd(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!I.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&M.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new I(n))),!0)}function Ed(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof I))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=m.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=m.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new m.Slice(i,0,0));return o.setSelection(O.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function wd(r){if(!(r.selection instanceof I))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",v.create(r.doc,[Z.widget(r.selection.head,e,{key:"gapcursor"})])}function el(r){for(let e=0;e<r.edgeCount;e++){const{type:t}=r.edge(e);/* v8 ignore if -- @preserve It's currently not possible to exercise this code in our RTE */if(t.isTextblock&&!t.hasRequiredAttrs())return t}/* v8 ignore next 1 -- @preserve*/throw new Error("No default textblock found.")}const Ad="[data-class=ui-select]{min-inline-size:120px}.ui-divider{block-size:20px}.ui-button-group{display:flex;gap:4px}.ui-tooltip,.ui-menu{display:contents;--_popup-display: contents}.ui-tooltip-wrapper{display:contents}",vd='.ProseMirror{flex:1;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none}.ProseMirror-selectednode{--focus-stroke-gap-color: transparent;--focus-border-radius: 2px;position:relative;outline:none}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in srgb,var(--focus-stroke-color, var(--vvd-color-cta-500)),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));position:absolute;display:block;border-radius:var(--focus-border-radius, inherit);block-size:calc(100% + var(--focus-block-size-addition, 4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition, 4px));inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}';var Dn=200,H=function(){};H.prototype.append=function(e){return e.length?(e=H.from(e),!this.length&&e||e.length<Dn&&this.leafAppend(e)||this.length<Dn&&e.leafPrepend(this)||this.appendInner(e)):this};H.prototype.prepend=function(e){return e.length?H.from(e).append(this):this};H.prototype.appendInner=function(e){return new Id(this,e)};H.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?H.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};H.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};H.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};H.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};H.from=function(e){return e instanceof H?e:e&&e.length?new tl(e):H.empty};var tl=function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Dn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Dn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(H);H.empty=new tl([]);var Id=function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e}(H);const Rd=500;class Me{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){i||(i=this.remapping(n,f+1),o=i.maps.length),o--,d.push(u);return}if(i){d.push(new Oe(u.map));let h=u.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Oe(p,void 0,void 0,c.length+d.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(u.step);if(u.selection)return l=i?u.selection.map(i.slice(o)):u.selection,a=new Me(this.items.slice(0,n).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let d=0;d<e.steps.length;d++){let u=e.steps[d].invert(e.docs[d]),f=new Oe(e.mapping.maps[d],u,t),h;(h=a&&a.merge(f))&&(f=h,d?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(s++,t=void 0),i||(a=f)}let c=s-n.depth;return c>Pd&&(l=Fd(l,c),s-=c),new Me(l.append(o),s)}remapping(e,t){let n=new Kt;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new Me(this.items.append(e.map(t=>new Oe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,n.push(new Oe(p,b,y))}else n.push(new Oe(p))},i);let c=[];for(let f=t;f<s;f++)c.push(new Oe(o.maps[f]));let d=this.items.slice(0,i).append(c).append(n),u=new Me(d,l);return u.emptyItemCount()>Rd&&(u=u.compress(this.items.length-n.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let d=s.selection&&s.selection.map(t.slice(n));d&&o++;let u=new Oe(c.invert(),a,d),f,h=i.length-1;(f=i.length&&i[h].merge(u))?i[h]=f:i.push(u)}}else s.map&&n--},this.items.length,0),new Me(H.from(i.reverse()),o)}}Me.empty=new Me(H.empty,0);function Fd(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Oe{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Oe(t.getMap().invert(),t,this.selection)}}}class We{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const Pd=20;function Ld(r,e,t,n){let i=t.getMeta(ot),o;if(i)return i.historyState;t.getMeta(_d)&&(r=new We(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(ot))return s.getMeta(ot).redo?new We(r.done.addTransform(t,void 0,n,bn(e)),r.undone,Co(t.mapping.maps),r.prevTime,r.prevComposition):new We(r.done,r.undone.addTransform(t,void 0,n,bn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!zd(t,r.prevRanges)),c=s?cr(r.prevRanges,t.mapping):Co(t.mapping.maps);return new We(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,bn(e)),Me.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new We(r.done.rebased(t,o),r.undone.rebased(t,o),cr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new We(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),cr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function zd(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Co(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function cr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function Bd(r,e,t){let n=bn(e),i=ot.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new We(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(ot,{redo:t,historyState:a})}let dr=!1,Mo=null;function bn(r){let e=r.plugins;if(Mo!=e){dr=!1,Mo=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){dr=!0;break}}return dr}const ot=new ls("history"),_d=new ls("closeHistory");function Vd(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new re({key:ot,state:{init(){return new We(Me.empty,Me.empty,null,0,-1)},apply(e,t,n){return Ld(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?yn:n=="historyRedo"?Wt:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function nl(r,e){return(t,n)=>{let i=ot.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=Bd(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const yn=nl(!1,!0),Wt=nl(!0,!0),xo=r=>typeof r=="function",Rn=(r,e,t)=>[r,e,t];class ii{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return xo(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(xo(e)){const n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(const e of this.bindings)e()}bindToEl(e,t={},n=[],i=[]){for(const o in t)this.bindProp(t[o],s=>{e[o]=s});for(const[o,s,l]of n)s&&e.addEventListener(o,l(s));for(const o of i)e.appendChild(o)}}const Ce=(r,e)=>{const t=document.createElement("div");return r.bindToEl(t,{className:e.className,slot:e.slot},[],e.children),t},Hd=(r,e)=>{const t=document.createElement("a");return r.bindToEl(t,{href:e.href,target:e.target,rel:e.rel,className:e.className},[],e.children),t},rl=new WeakMap,il=(r,e)=>{const t=r.rte.createComponent(Wo.Tooltip);t.setAttribute("exportparts","vvd-theme-alternate"),r.bindToEl(t,{className:"ui-tooltip",text:e.label,placement:r.props.popupPlacement}),r.bindProp(e.enabled,i=>{i||(t.open=!1),t.anchor=i?e.anchor:void 0});const n=Ce(r,{className:"ui-tooltip-wrapper",slot:e.slot,children:[e.anchor,t]});return rl.set(n,e.anchor),n},V=(r,e)=>{const t=()=>r.evalProp(e.variant)??"toolbar",n=()=>t()==="toolbar"?"super-condensed":"condensed",i=()=>t()==="popover-primary"?"outlined":"ghost-light",o=()=>r.evalProp(e.active)?"filled":i(),s=r.rte.createComponent(Ko.Button);return r.bindToEl(s,{size:n,appearance:o,disabled:e.disabled,icon:e.icon,autofocus:e.autofocus,connotation:e.connotation,[e.icon?"ariaLabel":"label"]:e.label},[Rn("click",e.onClick,l=>()=>{l()||r.view.focus()})]),il(r,{enabled:()=>!!(r.evalProp(e.icon)&&!r.evalProp(e.noTooltip)&&!r.evalProp(e.disabled)),label:e.label,anchor:s,slot:e.slot})},oi=(r,e)=>{const t=r.rte.createComponent(Uo.Menu);r.bindToEl(t,{className:"ui-menu",autoDismiss:!0,ariaLabel:e.label,anchor:rl.get(e.trigger)??e.trigger,placement:r.props.popupPlacement},[],e.children);const n=document.createDocumentFragment();return n.appendChild(e.trigger),n.appendChild(t),n},Wd=(r,e)=>{const t=r.rte.createComponent($o.MenuItem);return r.bindToEl(t,{text:e.text,checked:e.checked,disabled:e.disabled,controlType:"radio",checkedAppearance:"tick-only"},[Rn("change",e.onSelect,n=>()=>{t.checked&&!t.disabled&&r.evalProp(e.checked)!==t.checked&&(n(),r.view.focus())})]),t},Ud=(r,e)=>Ce(r,{className:"ui-button-group",children:e.children});function $d(r,e){const{from:t,$from:n,to:i,empty:o}=r.selection;return o?!!e.isInSet(r.storedMarks||n.marks()):r.doc.rangeHasMark(t,i,e)}const en=(r,e)=>V(r,{label:e.label,icon:e.icon,active:()=>$d(r.view.state,e.markType),disabled:()=>!Be(e.markType)(r.view.state),onClick:()=>{Be(e.markType)(r.view.state,r.view.dispatch)}}),qd=(r,e)=>{const t=r.rte.createComponent(Ho.ListboxOption);return r.bindToEl(t,{value:e.value,text:e.text,disabled:e.disabled}),t},Kd=(r,e)=>{const t=r.rte.createComponent(Vo.Select);t.setAttribute("data-class","ui-select"),r.bindToEl(t,{placeholder:" ",ariaLabel:e.label,scale:"condensed",appearance:"ghost"},[Rn("change",e.onSelect,i=>()=>{const o=t.value;o&&(i(o),r.view.focus())})],e.children),queueMicrotask(()=>{r.bindProp(e.value,i=>t.value=i)});let n=!1;return t.addEventListener("vwc-popup:open",()=>{n=!0,r.updateBindings()}),t.addEventListener("vwc-popup:close",()=>{n=!1,r.updateBindings()}),il(r,{enabled:()=>!n,label:e.label,anchor:t})},Fr=r=>{const e=r.rte.createComponent(_l.Divider);return r.bindToEl(e,{className:"ui-divider",orientation:"vertical"}),e},Oo=(r,e)=>{const t=r.rte.createComponent(qo.TextField);return r.bindToEl(t,{label:e.label,value:e.value,placeholder:e.placeholder,slot:e.slot,autofocus:e.autofocus,type:e.type},[Rn("input",e.onInput,n=>()=>{n(t.value)})]),t},Do=(r,e)=>{const t=document.createTextNode("");return r.bindToEl(t,{textContent:e.text}),t},Jd=(r,e)=>{const t=document.createElement("slot");t.name=e.name;let n=null;const i=[];function o(){for(const{el:a,type:c,handler:d}of i)a.removeEventListener(c,d);i.length=0,n=null}for(const[a,c]of Object.entries(e.assignedProps))r.bindProp(c,d=>{n&&(n[a]=d)});function s(a){for(const[c,d]of Object.entries(e.assignedProps))a[c]=r.evalProp(d);for(const[c,d]of Object.entries(e.assignedEvents)){const u=f=>{d(f),r.view.focus()};a.addEventListener(c,u),i.push({el:a,type:c,handler:u})}}const l=()=>{const c=t.assignedElements({flatten:!0})[0];c!==n&&(o(),c&&(n=c,s(c)))};return t.addEventListener("slotchange",l),queueMicrotask(l),t};class Gd extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteHistoryFeature"}getPlugins(){return[this.contribution(Vd()),this.contribution(he({"Mod-z":yn,"Ctrl-y":Wt,"Cmd-Z":Wt}))]}getToolbarItems(){return[this.contribution({section:"history",render:e=>V(e,{label:t=>t.rte.getLocale().richTextEditor.undo,icon:"undo-line",disabled:t=>!yn(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;yn(t,n)}})},1),this.contribution({section:"history",render:e=>V(e,{label:t=>t.rte.getLocale().richTextEditor.redo,icon:"redo-line",disabled:t=>!Wt(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;Wt(t,n)}})},2)]}}class jd extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteForeignHtmlFeature"}getPlugins(e){return[this.contribution(new re({props:{transformPastedHTML:t=>e.foreignHtmlParser[m.impl].transform(t),clipboardParser:e.foreignHtmlParser[m.impl].parser,clipboardSerializer:e.foreignHtmlSerializer[m.impl].serializer}}))]}}const qt=new re({state:{init(){return null},apply(r,e){const t=r.getMeta(qt);return t||e}}});class ol extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteCore"}getStyles(){return[this.contribution(kd),this.contribution(vd),this.contribution(Ad)]}getPlugins(e){return[this.contribution(he({...Sd,Enter:In(Ks,Js,Gs,js((t,n,i)=>n?{type:el(i.node(i.depth-1).contentMatchAt(i.indexAfter(i.depth-1))),attrs:e.textblockAttrs.extractFromNode(t)}:{type:t.type,attrs:t.attrs}))})),this.contribution(Td()),this.contribution(Od()),this.contribution(qt)]}getFeatures(){return[this,new Gd,new jd]}}m.featureFacade(ol);const Yd="h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);line-height:20px;margin-block:16px}.heading-step-1{font:var(--vvd-typography-heading-4);line-height:28px;margin-block:24px 12px}.heading-step-2{font:var(--vvd-typography-heading-3);line-height:36px;margin-block:24px 12px}.heading-step-3{font:var(--vvd-typography-heading-2);line-height:42px;margin-block:32px 16px}";class sl extends m.RteFeatureImpl{constructor(e){super(),this.enabledBlocks=e,this.name="RteBasicTextBlocks"}getStyles(){return[this.contribution(Yd)]}getSchema(e,t){const n={};this.enabledBlocks.paragraph&&(n.paragraph={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:"p",getAttrs:o=>e.fromDOM(o)}],marks:t.getAllowedMarksForNode("paragraph").join(" "),toDOM(o){return["p",{part:"node--paragraph",...e.getDOMAttrsProperties(o)},0]},serializeToDOM(o){return["p",...e.getDOMAttrs(o),0]}});let i=0;for(const o of[3,2,1]){const s=`heading${o}`,l=`h${o}`;if(!this.enabledBlocks[s])continue;i++;const a=i;n[s]={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:l,getAttrs:c=>e.fromDOM(c)}],marks:t.getAllowedMarksForNode(s).join(" "),defining:!0,toDOM(c){return[l,{class:`heading-step-${a}`,part:`node--${s}`,...e.getDOMAttrsProperties(c)},0]},serializeToDOM(c){return[l,...e.getDOMAttrs(c),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){const t={};this.enabledBlocks.paragraph&&(t["Mod-Alt-0"]=this.setBlockType(e,"paragraph"));for(const n of[1,2,3]){const i=`heading${n}`;this.enabledBlocks[i]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,i))}return[this.contribution(he(t))]}getCurrentBlockType(e){const{$from:t,$to:n}=e.selection,i=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1),o=n.depth===0?e.doc.childBefore(n.pos).node:n.node(1);return i!==o||!(i.type.name in this.enabledBlocks)?null:i.type.name}setBlockType(e,t){return(n,i)=>{const{from:o,to:s}=n.selection,l=n.tr;let a=!1;return n.doc.nodesBetween(o,s,(c,d)=>(c.type.name in this.enabledBlocks&&(a=!0,l.setBlockType(d,d+c.nodeSize,n.schema.nodes[t],u=>e.textblockAttrs.extractFromNode(u))),!1)),a?(i?.(l),!0):!1}}}class ll extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteBase"}getSchema(){return[this.contribution({nodes:{doc:{content:"block+"},text:{group:"inline"}}})]}getFeatures(){return[this,new ol,new sl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0})]}}const Xd=m.featureFacade(ll);var Zd=Object.defineProperty,Qd=Object.getOwnPropertyDescriptor,wt=(r,e,t,n)=>{for(var i=n>1?void 0:n?Qd(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Zd(e,t,i),i};const eu=r=>{const e=r.tagFor(Tr.Popup);return ce.html`<${e}
|
|
11
8
|
:anchor="${t=>t.anchorEl}"
|
|
12
|
-
:placementStrategy="${()=>
|
|
9
|
+
:placementStrategy="${()=>Tr.PlacementStrategy.AutoPlacementHorizontal}"
|
|
13
10
|
:open="${t=>t.open}"
|
|
14
11
|
:offset="${t=>t.offset}"
|
|
15
12
|
strategy="absolute"
|
|
16
13
|
exportparts="vvd-theme-alternate"
|
|
17
14
|
>
|
|
18
15
|
<slot></slot>
|
|
19
|
-
</${e}>`};class Fe extends me.VividElement{constructor(){super(...arguments),this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover==="true"||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?"true":"false";const n=new CustomEvent("block-popover-changed",{bubbles:!1,composed:!1});e.dispatchEvent(n)}anchorElChanged(e,t){e?.removeEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),t?.addEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorId&&this.isConnected?this.anchorEl=this.getRootNode().getElementById(this.anchorId)||void 0:this.anchorEl=void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(t=>Array.from(t.addedNodes).some(n=>n instanceof HTMLElement&&n.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}}Wt([me.observable],Fe.prototype,"offset",2);Wt([me.observable],Fe.prototype,"anchorBlocksPopover",2);Wt([me.observable],Fe.prototype,"anchorEl",2);Wt([me.observable],Fe.prototype,"anchorId",2);Wt([me.observable],Fe.prototype,"requestedOpenState",2);Wt([me.volatile],Fe.prototype,"open",1);const If=me.defineVividComponent("popover",Fe,vf,[Gr.popupDefinition],{}),Rf=".link-popover{display:flex;flex-direction:column;padding:16px;gap:8px;inline-size:450px}.link-popover-header{display:flex;align-items:center;justify-content:space-between}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{display:flex;flex-direction:column;gap:16px}.link,.editor a[href],.link:visited,.editor a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.editor a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.editor a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{display:flex;justify-content:end;gap:8px}.link-toolbar-menu{display:flex;flex-direction:column;padding:8px;gap:16px;inline-size:368px}";class pa extends ${constructor(){super(...arguments),this.name="RteLinkFeature",this.removeLink=(e,t)=>{const n=e.tr,i=this.getCurrentLink(e);return n.removeMark(i.start,i.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(Rf)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:"string"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(e){return{href:e.getAttribute("href")}}}],toDOM(e){const{href:t}=e.attrs;return["a",{href:t},0]}}}})]}getTextblockMarks(){return[this.contribution({markName:"link"})]}getPlugins(e){return[this.contribution(new ce({props:{decorations:t=>{const n=this.getCurrentLink(t);if(n){const i=ie.inline(n.start,n.end,{id:"current-link"});return P.create(t.doc,[i])}return null}},view:t=>{const n=new Pi(t,e,{popupPlacement:"bottom"}),i=e.createComponent(Fe);i.anchorId="current-link";const s=Ne(n,{className:"link-popover",children:[Ne(n,{className:"link-popover-header",children:[Ne(n,{className:"link-popover-label",children:[po(n,{text:()=>n.rte.getLocale().richTextEditor.clickHere})]}),q(n,{icon:"close-line",label:()=>n.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{i.requestOpenState(!1)}})]}),Ne(n,{className:"link-popover-content",children:[bf(n,{className:"link",href:()=>this.getCurrentLink(n.view.state)?.href||"",target:"_blank",rel:"noopener",children:[po(n,{text:()=>this.getCurrentLink(n.view.state)?.href||""})]}),Ne(n,{className:"link-action-bar",children:[q(n,{icon:"delete-line",label:()=>n.rte.getLocale().richTextEditor.delete,connotation:"alert",variant:"popover",noTooltip:!0,onClick:()=>{const{state:o,dispatch:l}=n.view;this.removeLink(o,l)}}),q(n,{icon:"edit-line",label:()=>n.rte.getLocale().richTextEditor.edit,variant:"popover",noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,i.requestOpenState(!1),!0)})]})]})]});return i.appendChild(s),t.dom.getRootNode().querySelector(".popovers").appendChild(i),{update:o=>{const l=o.state;n.updateBindings();const a=this.getCurrentLink(l);i.requestOpenState(!!a)},destroy:()=>{i.remove()}}}}))]}getToolbarItems(e){const t=i=>{const{from:s,to:o}=i.selection;return s===o?"":i.doc.textBetween(s,o," ")},n=i=>{try{return new URL(i),!0}catch{return!1}};return[this.contribution({section:"insert",render:i=>{const s=fo(i,{label:()=>i.rte.getLocale().richTextEditor.linkText,placeholder:()=>i.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:"header",autofocus:!0,value:()=>this.getCurrentLink(i.view.state)?.text||t(i.view.state)||"",onInput:()=>{a()}}),o=fo(i,{label:()=>i.rte.getLocale().richTextEditor.linkUrl,type:"url",placeholder:()=>i.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:"header",value:()=>this.getCurrentLink(i.view.state)?.href||"",onInput:()=>{a()}}),l=q(i,{label:()=>i.rte.getLocale().richTextEditor.apply,variant:"popover-primary",disabled:()=>{const h=this.getCurrentLink(i.view.state);return!(h&&h.text.length&&n(h.href))},onClick:()=>{const{state:h,dispatch:u}=i.view;this.insertLink(e,o.value,s.value)(h,u)}}),a=()=>{l.querySelector('[data-vvd-component="button"]').disabled=!(s.value.length&&n(o.value))},c=Fi(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,trigger:q(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,icon:"link-line"}),children:[Ne(i,{className:"link-toolbar-menu",slot:"header",children:[s,o,Ne(i,{className:"link-action-bar",slot:"header",children:[q(i,{label:()=>i.rte.getLocale().richTextEditor.cancel,variant:"popover",onClick:()=>{this.toolbarMenu.open=!1}}),l]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){const t=e.selection;if(!(t instanceof O&&t.empty))return null;const{$from:n}=t,s=e.schema.marks.link.isInSet(n.marks());if(!s)return null;const o=n.parent.childAfter(n.parentOffset),l=n.pos-n.parentOffset+o.offset,a=l+o.node.nodeSize;return{text:o.node.text,href:s.attrs.href,start:l,end:a}}insertLink(e,t,n){return(i,s)=>{let{from:o,to:l}=i.selection;const a=i.tr,c=this.getCurrentLink(i);return c&&(o=c.start,l=c.end),a.insertText(n,o,l),a.addMark(o,o+n.length,e.schema.marks.link.create({href:t})),s?.(a.scrollIntoView()),!0}}}const Pf=H(pa),Ff=".toolbar{display:flex;flex-wrap:wrap;align-items:center;padding:4px;background-color:var(--vvd-color-neutral-50);gap:8px}";class ma extends ${constructor(e){super(),this.config=e,this.name="RteToolbarFeature"}getStyles(){return[this.contribution(Ff)]}getPlugins(e){const t=["history","font","text-style","textblock","insert"],n=new Map(t.map(i=>[i,[]]));for(const i of Ft(e.features.flatMap(s=>s.getToolbarItems(e))))n.get(i.section).push(i);return[this.contribution(new ce({view:i=>{const s=new Pi(i,e,{popupPlacement:this.config?.popupDirection==="outward"?"bottom":"top"}),o=i.dom.getRootNode().querySelector(".toolbar");let l=!1;for(const a of t){const c=n.get(a);c.length&&l&&(o.appendChild(ci(s)),l=!1);for(const h of c)o.appendChild(h.render(s)),l=!0}return{update(){s.updateBindings()},destroy(){o.innerHTML=""}}}}))]}}const Lf=H(ma);class zf{constructor(e){this[A]=new Bf(e)}instantiateEditor(e){return new cd(this,e)}}class Bf{constructor(e){const t=s=>s.flatMap(o=>o.getFeatures().flatMap(l=>l===o?o:t([l])));this.features=t(e.map(s=>s[A])),this.featureMap=new Map;for(const s of this.features){const o=s.constructor;if(this.featureMap.has(o))throw new Error(`Duplicate feature: ${o.name}`);this.featureMap.set(o,s)}if(!this.featureMap.has(da))throw new Error("RteBase feature is required");if(this.featureMap.has(pa)&&!this.featureMap.has(ma))throw new Error("RteToolbarFeature is required for RteLinkFeature");this.textblockAttrs=new Cu(Ft(this.features.flatMap(s=>s.getTextblockAttrs()))),this.textblockMarks=new wu(Ft(this.features.flatMap(s=>s.getTextblockMarks())));const n=Ft(this.features.flatMap(s=>s.getSchema(this.textblockAttrs,this.textblockMarks))),i={nodes:{},marks:{}};for(const s of n)Object.assign(i.nodes,s.nodes??{}),Object.assign(i.marks,s.marks??{});for(const s of this.textblockMarks.getReferencedNodeNames())if(!(s in i.nodes))throw new Error(`Unknown node "${s}"`);this.schema=new Xo(i)}}/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:ga,setPrototypeOf:mo,isFrozen:_f,getPrototypeOf:Vf,getOwnPropertyDescriptor:Hf}=Object;let{freeze:de,seal:we,create:hi}=Object,{apply:ui,construct:fi}=typeof Reflect<"u"&&Reflect;de||(de=function(e){return e});we||(we=function(e){return e});ui||(ui=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),s=2;s<n;s++)i[s-2]=arguments[s];return e.apply(t,i)});fi||(fi=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const vn=pe(Array.prototype.forEach),Wf=pe(Array.prototype.lastIndexOf),go=pe(Array.prototype.pop),Kt=pe(Array.prototype.push),Uf=pe(Array.prototype.splice),_n=pe(String.prototype.toLowerCase),Br=pe(String.prototype.toString),_r=pe(String.prototype.match),Gt=pe(String.prototype.replace),qf=pe(String.prototype.indexOf),Jf=pe(String.prototype.trim),Ee=pe(Object.prototype.hasOwnProperty),ae=pe(RegExp.prototype.test),jt=$f(TypeError);function pe(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return ui(r,e,n)}}function $f(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return fi(r,t)}}function M(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_n;mo&&mo(r,null);let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const s=t(i);s!==i&&(_f(e)||(e[n]=s),i=s)}r[i]=!0}return r}function Kf(r){for(let e=0;e<r.length;e++)Ee(r,e)||(r[e]=null);return r}function Ve(r){const e=hi(null);for(const[t,n]of ga(r))Ee(r,t)&&(Array.isArray(n)?e[t]=Kf(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Ve(n):e[t]=n);return e}function Yt(r,e){for(;r!==null;){const n=Hf(r,e);if(n){if(n.get)return pe(n.get);if(typeof n.value=="function")return pe(n.value)}r=Vf(r)}function t(){return null}return t}const yo=de(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),Vr=de(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),Hr=de(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Gf=de(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),Wr=de(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),jf=de(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),bo=de(["#text"]),ko=de(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),Ur=de(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),So=de(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),In=de(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Yf=we(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Xf=we(/<%[\w\W]*|[\w\W]*%>/gm),Zf=we(/\$\{[\w\W]*/gm),Qf=we(/^data-[\-\w.\u00B7-\uFFFF]+$/),ed=we(/^aria-[\-\w]+$/),ya=we(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),td=we(/^(?:\w+script|data):/i),nd=we(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ba=we(/^html$/i),rd=we(/^[a-z][.\w]*(-[.\w]+)+$/i);var xo=Object.freeze({__proto__:null,ARIA_ATTR:ed,ATTR_WHITESPACE:nd,CUSTOM_ELEMENT:rd,DATA_ATTR:Qf,DOCTYPE_NAME:ba,ERB_EXPR:Xf,IS_ALLOWED_URI:ya,IS_SCRIPT_OR_DATA:td,MUSTACHE_EXPR:Yf,TMPLIT_EXPR:Zf});const Xt={element:1,text:3,progressingInstruction:7,comment:8,document:9},id=function(){return typeof window>"u"?null:window},sd=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const s="dompurify"+(n?"#"+n:"");try{return e.createPolicy(s,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+s+" could not be created."),null}},To=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ka(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:id();const e=T=>ka(T);if(e.version="3.3.0",e.removed=[],!r||!r.document||r.document.nodeType!==Xt.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r;const n=t,i=n.currentScript,{DocumentFragment:s,HTMLTemplateElement:o,Node:l,Element:a,NodeFilter:c,NamedNodeMap:h=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:p}=r,d=a.prototype,g=Yt(d,"cloneNode"),y=Yt(d,"remove"),C=Yt(d,"nextSibling"),L=Yt(d,"childNodes"),I=Yt(d,"parentNode");if(typeof o=="function"){const T=t.createElement("template");T.content&&T.content.ownerDocument&&(t=T.content.ownerDocument)}let R,Oe="";const{implementation:$e,createNodeIterator:E,createDocumentFragment:B,getElementsByTagName:Q}=t,{importNode:sr}=n;let le=To();e.isSupported=typeof ga=="function"&&typeof I=="function"&&$e&&$e.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:or,ERB_EXPR:lr,TMPLIT_EXPR:ar,DATA_ATTR:va,ARIA_ATTR:Ia,IS_SCRIPT_OR_DATA:Ra,ATTR_WHITESPACE:Bi,CUSTOM_ELEMENT:Pa}=xo;let{IS_ALLOWED_URI:_i}=xo,W=null;const Vi=M({},[...yo,...Vr,...Hr,...Wr,...bo]);let K=null;const Hi=M({},[...ko,...Ur,...So,...In]);let z=Object.seal(hi(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ut=null,cr=null;const St=Object.seal(hi(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Wi=!0,hr=!0,Ui=!1,qi=!0,xt=!1,Sn=!0,st=!1,ur=!1,fr=!1,Tt=!1,xn=!1,Tn=!1,Ji=!0,$i=!1;const Fa="user-content-";let dr=!0,qt=!1,Ct={},wt=null;const Ki=M({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Gi=null;const ji=M({},["audio","video","img","source","image","track"]);let pr=null;const Yi=M({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Cn="http://www.w3.org/1998/Math/MathML",wn="http://www.w3.org/2000/svg",Le="http://www.w3.org/1999/xhtml";let Mt=Le,mr=!1,gr=null;const La=M({},[Cn,wn,Le],Br);let Mn=M({},["mi","mo","mn","ms","mtext"]),On=M({},["annotation-xml"]);const za=M({},["title","style","font","a","script"]);let Jt=null;const Ba=["application/xhtml+xml","text/html"],_a="text/html";let U=null,Ot=null;const Va=t.createElement("form"),Xi=function(m){return m instanceof RegExp||m instanceof Function},yr=function(){let m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Ot&&Ot===m)){if((!m||typeof m!="object")&&(m={}),m=Ve(m),Jt=Ba.indexOf(m.PARSER_MEDIA_TYPE)===-1?_a:m.PARSER_MEDIA_TYPE,U=Jt==="application/xhtml+xml"?Br:_n,W=Ee(m,"ALLOWED_TAGS")?M({},m.ALLOWED_TAGS,U):Vi,K=Ee(m,"ALLOWED_ATTR")?M({},m.ALLOWED_ATTR,U):Hi,gr=Ee(m,"ALLOWED_NAMESPACES")?M({},m.ALLOWED_NAMESPACES,Br):La,pr=Ee(m,"ADD_URI_SAFE_ATTR")?M(Ve(Yi),m.ADD_URI_SAFE_ATTR,U):Yi,Gi=Ee(m,"ADD_DATA_URI_TAGS")?M(Ve(ji),m.ADD_DATA_URI_TAGS,U):ji,wt=Ee(m,"FORBID_CONTENTS")?M({},m.FORBID_CONTENTS,U):Ki,Ut=Ee(m,"FORBID_TAGS")?M({},m.FORBID_TAGS,U):Ve({}),cr=Ee(m,"FORBID_ATTR")?M({},m.FORBID_ATTR,U):Ve({}),Ct=Ee(m,"USE_PROFILES")?m.USE_PROFILES:!1,Wi=m.ALLOW_ARIA_ATTR!==!1,hr=m.ALLOW_DATA_ATTR!==!1,Ui=m.ALLOW_UNKNOWN_PROTOCOLS||!1,qi=m.ALLOW_SELF_CLOSE_IN_ATTR!==!1,xt=m.SAFE_FOR_TEMPLATES||!1,Sn=m.SAFE_FOR_XML!==!1,st=m.WHOLE_DOCUMENT||!1,Tt=m.RETURN_DOM||!1,xn=m.RETURN_DOM_FRAGMENT||!1,Tn=m.RETURN_TRUSTED_TYPE||!1,fr=m.FORCE_BODY||!1,Ji=m.SANITIZE_DOM!==!1,$i=m.SANITIZE_NAMED_PROPS||!1,dr=m.KEEP_CONTENT!==!1,qt=m.IN_PLACE||!1,_i=m.ALLOWED_URI_REGEXP||ya,Mt=m.NAMESPACE||Le,Mn=m.MATHML_TEXT_INTEGRATION_POINTS||Mn,On=m.HTML_INTEGRATION_POINTS||On,z=m.CUSTOM_ELEMENT_HANDLING||{},m.CUSTOM_ELEMENT_HANDLING&&Xi(m.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=m.CUSTOM_ELEMENT_HANDLING.tagNameCheck),m.CUSTOM_ELEMENT_HANDLING&&Xi(m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=m.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),m.CUSTOM_ELEMENT_HANDLING&&typeof m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(z.allowCustomizedBuiltInElements=m.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),xt&&(hr=!1),xn&&(Tt=!0),Ct&&(W=M({},bo),K=[],Ct.html===!0&&(M(W,yo),M(K,ko)),Ct.svg===!0&&(M(W,Vr),M(K,Ur),M(K,In)),Ct.svgFilters===!0&&(M(W,Hr),M(K,Ur),M(K,In)),Ct.mathMl===!0&&(M(W,Wr),M(K,So),M(K,In))),m.ADD_TAGS&&(typeof m.ADD_TAGS=="function"?St.tagCheck=m.ADD_TAGS:(W===Vi&&(W=Ve(W)),M(W,m.ADD_TAGS,U))),m.ADD_ATTR&&(typeof m.ADD_ATTR=="function"?St.attributeCheck=m.ADD_ATTR:(K===Hi&&(K=Ve(K)),M(K,m.ADD_ATTR,U))),m.ADD_URI_SAFE_ATTR&&M(pr,m.ADD_URI_SAFE_ATTR,U),m.FORBID_CONTENTS&&(wt===Ki&&(wt=Ve(wt)),M(wt,m.FORBID_CONTENTS,U)),dr&&(W["#text"]=!0),st&&M(W,["html","head","body"]),W.table&&(M(W,["tbody"]),delete Ut.tbody),m.TRUSTED_TYPES_POLICY){if(typeof m.TRUSTED_TYPES_POLICY.createHTML!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof m.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw jt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');R=m.TRUSTED_TYPES_POLICY,Oe=R.createHTML("")}else R===void 0&&(R=sd(p,i)),R!==null&&typeof Oe=="string"&&(Oe=R.createHTML(""));de&&de(m),Ot=m}},Zi=M({},[...Vr,...Hr,...Gf]),Qi=M({},[...Wr,...jf]),Ha=function(m){let k=I(m);(!k||!k.tagName)&&(k={namespaceURI:Mt,tagName:"template"});const x=_n(m.tagName),v=_n(k.tagName);return gr[m.namespaceURI]?m.namespaceURI===wn?k.namespaceURI===Le?x==="svg":k.namespaceURI===Cn?x==="svg"&&(v==="annotation-xml"||Mn[v]):!!Zi[x]:m.namespaceURI===Cn?k.namespaceURI===Le?x==="math":k.namespaceURI===wn?x==="math"&&On[v]:!!Qi[x]:m.namespaceURI===Le?k.namespaceURI===wn&&!On[v]||k.namespaceURI===Cn&&!Mn[v]?!1:!Qi[x]&&(za[x]||!Zi[x]):!!(Jt==="application/xhtml+xml"&&gr[m.namespaceURI]):!1},Ae=function(m){Kt(e.removed,{element:m});try{I(m).removeChild(m)}catch{y(m)}},ot=function(m,k){try{Kt(e.removed,{attribute:k.getAttributeNode(m),from:k})}catch{Kt(e.removed,{attribute:null,from:k})}if(k.removeAttribute(m),m==="is")if(Tt||xn)try{Ae(k)}catch{}else try{k.setAttribute(m,"")}catch{}},es=function(m){let k=null,x=null;if(fr)m="<remove></remove>"+m;else{const _=_r(m,/^[\r\n\t ]+/);x=_&&_[0]}Jt==="application/xhtml+xml"&&Mt===Le&&(m='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+m+"</body></html>");const v=R?R.createHTML(m):m;if(Mt===Le)try{k=new f().parseFromString(v,Jt)}catch{}if(!k||!k.documentElement){k=$e.createDocument(Mt,"template",null);try{k.documentElement.innerHTML=mr?Oe:v}catch{}}const ee=k.body||k.documentElement;return m&&x&&ee.insertBefore(t.createTextNode(x),ee.childNodes[0]||null),Mt===Le?Q.call(k,st?"html":"body")[0]:st?k.documentElement:ee},ts=function(m){return E.call(m.ownerDocument||m,m,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},br=function(m){return m instanceof u&&(typeof m.nodeName!="string"||typeof m.textContent!="string"||typeof m.removeChild!="function"||!(m.attributes instanceof h)||typeof m.removeAttribute!="function"||typeof m.setAttribute!="function"||typeof m.namespaceURI!="string"||typeof m.insertBefore!="function"||typeof m.hasChildNodes!="function")},ns=function(m){return typeof l=="function"&&m instanceof l};function ze(T,m,k){vn(T,x=>{x.call(e,m,k,Ot)})}const rs=function(m){let k=null;if(ze(le.beforeSanitizeElements,m,null),br(m))return Ae(m),!0;const x=U(m.nodeName);if(ze(le.uponSanitizeElement,m,{tagName:x,allowedTags:W}),Sn&&m.hasChildNodes()&&!ns(m.firstElementChild)&&ae(/<[/\w!]/g,m.innerHTML)&&ae(/<[/\w!]/g,m.textContent)||m.nodeType===Xt.progressingInstruction||Sn&&m.nodeType===Xt.comment&&ae(/<[/\w]/g,m.data))return Ae(m),!0;if(!(St.tagCheck instanceof Function&&St.tagCheck(x))&&(!W[x]||Ut[x])){if(!Ut[x]&&ss(x)&&(z.tagNameCheck instanceof RegExp&&ae(z.tagNameCheck,x)||z.tagNameCheck instanceof Function&&z.tagNameCheck(x)))return!1;if(dr&&!wt[x]){const v=I(m)||m.parentNode,ee=L(m)||m.childNodes;if(ee&&v){const _=ee.length;for(let ge=_-1;ge>=0;--ge){const Be=g(ee[ge],!0);Be.__removalCount=(m.__removalCount||0)+1,v.insertBefore(Be,C(m))}}}return Ae(m),!0}return m instanceof a&&!Ha(m)||(x==="noscript"||x==="noembed"||x==="noframes")&&ae(/<\/no(script|embed|frames)/i,m.innerHTML)?(Ae(m),!0):(xt&&m.nodeType===Xt.text&&(k=m.textContent,vn([or,lr,ar],v=>{k=Gt(k,v," ")}),m.textContent!==k&&(Kt(e.removed,{element:m.cloneNode()}),m.textContent=k)),ze(le.afterSanitizeElements,m,null),!1)},is=function(m,k,x){if(Ji&&(k==="id"||k==="name")&&(x in t||x in Va))return!1;if(!(hr&&!cr[k]&&ae(va,k))){if(!(Wi&&ae(Ia,k))){if(!(St.attributeCheck instanceof Function&&St.attributeCheck(k,m))){if(!K[k]||cr[k]){if(!(ss(m)&&(z.tagNameCheck instanceof RegExp&&ae(z.tagNameCheck,m)||z.tagNameCheck instanceof Function&&z.tagNameCheck(m))&&(z.attributeNameCheck instanceof RegExp&&ae(z.attributeNameCheck,k)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(k,m))||k==="is"&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&ae(z.tagNameCheck,x)||z.tagNameCheck instanceof Function&&z.tagNameCheck(x))))return!1}else if(!pr[k]){if(!ae(_i,Gt(x,Bi,""))){if(!((k==="src"||k==="xlink:href"||k==="href")&&m!=="script"&&qf(x,"data:")===0&&Gi[m])){if(!(Ui&&!ae(Ra,Gt(x,Bi,"")))){if(x)return!1}}}}}}}return!0},ss=function(m){return m!=="annotation-xml"&&_r(m,Pa)},ls=function(m){ze(le.beforeSanitizeAttributes,m,null);const{attributes:k}=m;if(!k||br(m))return;const x={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:K,forceKeepAttr:void 0};let v=k.length;for(;v--;){const ee=k[v],{name:_,namespaceURI:ge,value:Be}=ee,Et=U(_),kr=Be;let G=_==="value"?kr:Jf(kr);if(x.attrName=Et,x.attrValue=G,x.keepAttr=!0,x.forceKeepAttr=void 0,ze(le.uponSanitizeAttribute,m,x),G=x.attrValue,$i&&(Et==="id"||Et==="name")&&(ot(_,m),G=Fa+G),Sn&&ae(/((--!?|])>)|<\/(style|title|textarea)/i,G)){ot(_,m);continue}if(Et==="attributename"&&_r(G,"href")){ot(_,m);continue}if(x.forceKeepAttr)continue;if(!x.keepAttr){ot(_,m);continue}if(!qi&&ae(/\/>/i,G)){ot(_,m);continue}xt&&vn([or,lr,ar],cs=>{G=Gt(G,cs," ")});const as=U(m.nodeName);if(!is(as,Et,G)){ot(_,m);continue}if(R&&typeof p=="object"&&typeof p.getAttributeType=="function"&&!ge)switch(p.getAttributeType(as,Et)){case"TrustedHTML":{G=R.createHTML(G);break}case"TrustedScriptURL":{G=R.createScriptURL(G);break}}if(G!==kr)try{ge?m.setAttributeNS(ge,_,G):m.setAttribute(_,G),br(m)?Ae(m):go(e.removed)}catch{ot(_,m)}}ze(le.afterSanitizeAttributes,m,null)},Wa=function T(m){let k=null;const x=ts(m);for(ze(le.beforeSanitizeShadowDOM,m,null);k=x.nextNode();)ze(le.uponSanitizeShadowNode,k,null),rs(k),ls(k),k.content instanceof s&&T(k.content);ze(le.afterSanitizeShadowDOM,m,null)};return e.sanitize=function(T){let m=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},k=null,x=null,v=null,ee=null;if(mr=!T,mr&&(T="<!-->"),typeof T!="string"&&!ns(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw jt("dirty is not a string, aborting")}else throw jt("toString is not a function");if(!e.isSupported)return T;if(ur||yr(m),e.removed=[],typeof T=="string"&&(qt=!1),qt){if(T.nodeName){const Be=U(T.nodeName);if(!W[Be]||Ut[Be])throw jt("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)k=es("<!---->"),x=k.ownerDocument.importNode(T,!0),x.nodeType===Xt.element&&x.nodeName==="BODY"||x.nodeName==="HTML"?k=x:k.appendChild(x);else{if(!Tt&&!xt&&!st&&T.indexOf("<")===-1)return R&&Tn?R.createHTML(T):T;if(k=es(T),!k)return Tt?null:Tn?Oe:""}k&&fr&&Ae(k.firstChild);const _=ts(qt?T:k);for(;v=_.nextNode();)rs(v),ls(v),v.content instanceof s&&Wa(v.content);if(qt)return T;if(Tt){if(xn)for(ee=B.call(k.ownerDocument);k.firstChild;)ee.appendChild(k.firstChild);else ee=k;return(K.shadowroot||K.shadowrootmode)&&(ee=sr.call(n,ee,!0)),ee}let ge=st?k.outerHTML:k.innerHTML;return st&&W["!doctype"]&&k.ownerDocument&&k.ownerDocument.doctype&&k.ownerDocument.doctype.name&&ae(ba,k.ownerDocument.doctype.name)&&(ge="<!DOCTYPE "+k.ownerDocument.doctype.name+`>
|
|
20
|
-
`+
|
|
16
|
+
</${e}>`};class Ee extends ce.VividElement{constructor(){super(...arguments),this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover==="true"||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?"true":"false";const n=new CustomEvent("block-popover-changed",{bubbles:!1,composed:!1});e.dispatchEvent(n)}anchorElChanged(e,t){e?.removeEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),t?.addEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorId&&this.isConnected?this.anchorEl=this.getRootNode().getElementById(this.anchorId)||void 0:this.anchorEl=void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(t=>Array.from(t.addedNodes).some(n=>n instanceof HTMLElement&&n.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}}wt([ce.observable],Ee.prototype,"offset",2);wt([ce.observable],Ee.prototype,"anchorBlocksPopover",2);wt([ce.observable],Ee.prototype,"anchorEl",2);wt([ce.observable],Ee.prototype,"anchorId",2);wt([ce.observable],Ee.prototype,"requestedOpenState",2);wt([ce.volatile],Ee.prototype,"open",1);const tu=ce.defineVividComponent("popover",Ee,eu,[Tr.popupDefinition],{}),nu=".link-popover{display:flex;flex-direction:column;padding:16px;gap:8px;inline-size:450px}.link-popover-header{display:flex;align-items:center;justify-content:space-between}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{display:flex;flex-direction:column;gap:16px}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{display:flex;justify-content:end;gap:8px}.link-toolbar-menu{display:flex;flex-direction:column;padding:8px;gap:16px;inline-size:368px}";class al extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteLinkFeature",this.removeLink=(e,t)=>{const n=e.tr,i=this.getCurrentLink(e);return n.removeMark(i.start,i.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(nu)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:"string"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(e){return{href:e.getAttribute("href")}}}],toDOM(e){const{href:t}=e.attrs;return["a",{href:t},0]}}}},m.contributionPriority.high)]}getTextblockMarks(){return[this.contribution({markName:"link"})]}getPlugins(e){const t=()=>(this.toolbarMenu.open=!0,!0);return[this.contribution(new re({props:{decorations:n=>{const i=this.getCurrentLink(n);if(i){const o=Z.inline(i.start,i.end,{id:"current-link"});return v.create(n.doc,[o])}return null}},view:n=>{const i=new ii(n,e,{popupPlacement:"bottom"}),o=e.createComponent(Ee);o.anchorId="current-link";const s=Ce(i,{className:"link-popover",children:[Ce(i,{className:"link-popover-header",children:[Ce(i,{className:"link-popover-label",children:[Do(i,{text:()=>this.getCurrentLink(i.view.state)?.text||""})]}),V(i,{icon:"close-line",label:()=>i.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{o.requestOpenState(!1)}})]}),Ce(i,{className:"link-popover-content",children:[Hd(i,{className:"link",href:()=>this.getCurrentLink(i.view.state)?.href||"",target:"_blank",rel:"noopener",children:[Do(i,{text:()=>this.getCurrentLink(i.view.state)?.href||""})]}),Ce(i,{className:"link-action-bar",children:[V(i,{icon:"delete-line",label:()=>i.rte.getLocale().richTextEditor.delete,connotation:"alert",variant:"popover",noTooltip:!0,onClick:()=>{const{state:l,dispatch:a}=i.view;this.removeLink(l,a)}}),V(i,{icon:"edit-line",label:()=>i.rte.getLocale().richTextEditor.edit,variant:"popover",noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,o.requestOpenState(!1),!0)})]})]})]});return o.appendChild(s),n.dom.getRootNode().querySelector(".popovers").appendChild(o),{update:l=>{const a=l.state;i.updateBindings();const c=this.getCurrentLink(a);o.requestOpenState(!!c)},destroy:()=>{o.remove()}}}})),this.contribution(he({"Mod-k":t}))]}getToolbarItems(e){const t=i=>{const{from:o,to:s}=i.selection;return o===s?"":i.doc.textBetween(o,s," ")},n=i=>{try{return new URL(i),!0}catch{return!1}};return[this.contribution({section:"insert",render:i=>{const o=Oo(i,{label:()=>i.rte.getLocale().richTextEditor.linkText,placeholder:()=>i.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:"header",autofocus:!0,value:()=>this.getCurrentLink(i.view.state)?.text||t(i.view.state)||"",onInput:()=>{a()}}),s=Oo(i,{label:()=>i.rte.getLocale().richTextEditor.linkUrl,type:"url",placeholder:()=>i.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:"header",value:()=>this.getCurrentLink(i.view.state)?.href||"",onInput:()=>{a()}}),l=V(i,{label:()=>i.rte.getLocale().richTextEditor.apply,variant:"popover-primary",disabled:()=>{const d=this.getCurrentLink(i.view.state);return!(d&&d.text.length&&n(d.href))},onClick:()=>{const{state:d,dispatch:u}=i.view;this.insertLink(e,s.value,o.value)(d,u)}}),a=()=>{l.querySelector('[data-vvd-component="button"]').disabled=!(o.value.length&&n(s.value))},c=oi(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,trigger:V(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,icon:"link-line"}),children:[Ce(i,{className:"link-toolbar-menu",slot:"header",children:[o,s,Ce(i,{className:"link-action-bar",slot:"header",children:[V(i,{label:()=>i.rte.getLocale().richTextEditor.cancel,variant:"popover",onClick:()=>{this.toolbarMenu.open=!1}}),l]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){const t=e.selection;if(!(t instanceof O))return null;const n=e.schema.marks.link,{$from:i,$to:o}=t,s=e.selection.empty?i.marks():i.nodeAfter?.marks??[],l=n.isInSet(s)?.attrs.href;if(!l)return null;const a=h=>n.isInSet(h.marks)?.attrs.href===l;let c=-1,d=-1,u=!0;return e.doc.nodesBetween(i.start(),o.end(),(h,p)=>{if(!h.isText)return!0;const b=p+h.nodeSize;return a(h)?(c===-1&&(c=p),d=b):b>t.from&&p<t.to&&(u=!1),!1}),!u||c===-1?null:{text:e.doc.textBetween(c,d," "),href:l,start:c,end:d}}insertLink(e,t,n){return(i,o)=>{let{from:s,to:l}=i.selection;const a=i.tr,c=this.getCurrentLink(i);return c&&(s=c.start,l=c.end),a.insertText(n,s,l),a.addMark(s,s+n.length,e.schema.marks.link.create({href:t})),o?.(a.scrollIntoView()),!0}}}const ru=m.featureFacade(al),iu=".toolbar{display:flex;flex-wrap:wrap;align-items:center;padding:4px;background-color:var(--vvd-color-neutral-50);gap:8px}";class cl extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteToolbarFeature"}getStyles(){return[this.contribution(iu)]}getPlugins(e){const t=["history","font","text-style","textblock","insert"],n=new Map(t.map(i=>[i,[]]));for(const i of m.sortedContributions(e.features.flatMap(o=>o.getToolbarItems(e))))n.get(i.section).push(i);return[this.contribution(new re({view:i=>{const o=new ii(i,e,{popupPlacement:this.config?.popupDirection==="outward"?"bottom":"top"}),s=i.dom.getRootNode().querySelector(".toolbar");let l=!1;for(const a of t){const c=n.get(a);c.length&&l&&(s.appendChild(Fr(o)),l=!1);for(const d of c)s.appendChild(d.render(o)),l=!0}return{update(){o.updateBindings()},destroy(){s.innerHTML=""}}}}))]}}const ou=m.featureFacade(cl),su=(r,e)=>{const t=e.config[m.impl].schema,n=s=>t.marks[s.type].rank,i=(s,l)=>{if(s.type!==l.type)return!1;const a=s.attrs,c=l.attrs;if(a===c)return!0;/* v8 ignore next -- not currently reachable since all attrs are required @preserve */if(!a||!c)return!1;const d=Object.keys(a),u=Object.keys(c);/* v8 ignore next -- not currently reachable since all attrs are required @preserve */if(d.length!==u.length)return!1;for(const f of d)if(a[f]!==c[f])return!1;return!0},o=s=>{const l=[],a=[],c=[l];for(const d of s){const u=[...d.marks??[]].sort((p,b)=>n(p)-n(b));let f=0,h=0;for(;f<a.length&&h<u.length&&i(a[f],u[h]);)f++,h++;for(;a.length>f;)a.pop(),c.pop();for(;h<u.length;){const p=u[h],b=[];c[c.length-1].push({type:"mark",mark:p,children:{type:"fragment",content:b,[m.impl]:e},[m.impl]:e}),a.push(p),c.push(b),h++}c[c.length-1].push({type:"node",node:d,children:o(d.content??[]),[m.impl]:e})}return{type:"fragment",content:l,[m.impl]:e}};return{type:"node",node:r,children:o(r.content),[m.impl]:e}};class lu{constructor(e){this[m.impl]=new au(e)}instantiateEditor(e){return new Ru(this,e)}instantiateView(e,t){return su(e,{config:this,options:{...t}})}}class au{constructor(e){const t=o=>o.flatMap(s=>s.getFeatures().flatMap(l=>l===s?s:t([l])));this.features=t(e.map(o=>o[m.impl])),this.featureMap=new Map;for(const o of this.features){const s=o.constructor;if(this.featureMap.has(s))throw new Error(`Duplicate feature: ${s.name}`);this.featureMap.set(s,o)}if(!this.featureMap.has(ll))throw new Error("RteBase feature is required");if(this.featureMap.has(al)&&!this.featureMap.has(cl))throw new Error("RteToolbarFeature is required for RteLinkFeature");this.textblockAttrs=new Gc(m.sortedContributions(this.features.flatMap(o=>o.getTextblockAttrs()))),this.textblockMarks=new jc(m.sortedContributions(this.features.flatMap(o=>o.getTextblockMarks())));const n=m.sortedContributions(this.features.flatMap(o=>o.getSchema(this.textblockAttrs,this.textblockMarks))),i={nodes:{},marks:{}};for(const o of n)Object.assign(i.nodes,o.nodes??{}),Object.assign(i.marks,o.marks??{});for(const o of this.textblockMarks.getReferencedNodeNames())if(!(o in i.nodes))throw new Error(`Unknown node "${o}"`);this.schema=new m.Schema(i)}}/*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */const{entries:dl,setPrototypeOf:No,isFrozen:cu,getPrototypeOf:du,getOwnPropertyDescriptor:uu}=Object;let{freeze:le,seal:Se,create:Pr}=Object,{apply:Lr,construct:zr}=typeof Reflect<"u"&&Reflect;le||(le=function(e){return e});Se||(Se=function(e){return e});Lr||(Lr=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)});zr||(zr=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const fn=ae(Array.prototype.forEach),fu=ae(Array.prototype.lastIndexOf),Eo=ae(Array.prototype.pop),Ft=ae(Array.prototype.push),hu=ae(Array.prototype.splice),Sn=ae(String.prototype.toLowerCase),ur=ae(String.prototype.toString),fr=ae(String.prototype.match),Pt=ae(String.prototype.replace),pu=ae(String.prototype.indexOf),mu=ae(String.prototype.trim),Te=ae(Object.prototype.hasOwnProperty),ne=ae(RegExp.prototype.test),Lt=gu(TypeError);function ae(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return Lr(r,e,n)}}function gu(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return zr(r,t)}}function x(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Sn;No&&No(r,null);let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(cu(e)||(e[n]=o),i=o)}r[i]=!0}return r}function bu(r){for(let e=0;e<r.length;e++)Te(r,e)||(r[e]=null);return r}function Re(r){const e=Pr(null);for(const[t,n]of dl(r))Te(r,t)&&(Array.isArray(n)?e[t]=bu(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=Re(n):e[t]=n);return e}function zt(r,e){for(;r!==null;){const n=uu(r,e);if(n){if(n.get)return ae(n.get);if(typeof n.value=="function")return ae(n.value)}r=du(r)}function t(){return null}return t}const wo=le(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hr=le(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),pr=le(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),yu=le(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),mr=le(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Su=le(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Ao=le(["#text"]),vo=le(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),gr=le(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Io=le(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),hn=le(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),ku=Se(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Tu=Se(/<%[\w\W]*|[\w\W]*%>/gm),Cu=Se(/\$\{[\w\W]*/gm),Mu=Se(/^data-[\-\w.\u00B7-\uFFFF]+$/),xu=Se(/^aria-[\-\w]+$/),ul=Se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ou=Se(/^(?:\w+script|data):/i),Du=Se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),fl=Se(/^html$/i),Nu=Se(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ro=Object.freeze({__proto__:null,ARIA_ATTR:xu,ATTR_WHITESPACE:Du,CUSTOM_ELEMENT:Nu,DATA_ATTR:Mu,DOCTYPE_NAME:fl,ERB_EXPR:Tu,IS_ALLOWED_URI:ul,IS_SCRIPT_OR_DATA:Ou,MUSTACHE_EXPR:ku,TMPLIT_EXPR:Cu});const Bt={element:1,text:3,progressingInstruction:7,comment:8,document:9},Eu=function(){return typeof window>"u"?null:window},wu=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},Fo=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function hl(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Eu();const e=T=>hl(T);if(e.version="3.3.0",e.removed=[],!r||!r.document||r.document.nodeType!==Bt.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r;const n=t,i=n.currentScript,{DocumentFragment:o,HTMLTemplateElement:s,Node:l,Element:a,NodeFilter:c,NamedNodeMap:d=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:u,DOMParser:f,trustedTypes:h}=r,p=a.prototype,b=zt(p,"cloneNode"),y=zt(p,"remove"),C=zt(p,"nextSibling"),R=zt(p,"childNodes"),w=zt(p,"parentNode");if(typeof s=="function"){const T=t.createElement("template");T.content&&T.content.ownerDocument&&(t=T.content.ownerDocument)}let A,ke="";const{implementation:_e,createNodeIterator:D,createDocumentFragment:P,getElementsByTagName:J}=t,{importNode:Fn}=n;let te=Fo();e.isSupported=typeof dl=="function"&&typeof w=="function"&&_e&&_e.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:Pn,ERB_EXPR:Ln,TMPLIT_EXPR:zn,DATA_ATTR:Ol,ARIA_ATTR:Dl,IS_SCRIPT_OR_DATA:Nl,ATTR_WHITESPACE:ai,CUSTOM_ELEMENT:El}=Ro;let{IS_ALLOWED_URI:ci}=Ro,B=null;const di=x({},[...wo,...hr,...pr,...mr,...Ao]);let W=null;const ui=x({},[...vo,...gr,...Io,...hn]);let F=Object.seal(Pr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),At=null,Bn=null;const ct=Object.seal(Pr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let fi=!0,_n=!0,hi=!1,pi=!0,dt=!1,nn=!0,Ze=!1,Vn=!1,Hn=!1,ut=!1,rn=!1,on=!1,mi=!0,gi=!1;const wl="user-content-";let Wn=!0,vt=!1,ft={},ht=null;const bi=x({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let yi=null;const Si=x({},["audio","video","img","source","image","track"]);let Un=null;const ki=x({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),sn="http://www.w3.org/1998/Math/MathML",ln="http://www.w3.org/2000/svg",we="http://www.w3.org/1999/xhtml";let pt=we,$n=!1,qn=null;const Al=x({},[sn,ln,we],ur);let an=x({},["mi","mo","mn","ms","mtext"]),cn=x({},["annotation-xml"]);const vl=x({},["title","style","font","a","script"]);let It=null;const Il=["application/xhtml+xml","text/html"],Rl="text/html";let _=null,mt=null;const Fl=t.createElement("form"),Ti=function(g){return g instanceof RegExp||g instanceof Function},Kn=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(mt&&mt===g)){if((!g||typeof g!="object")&&(g={}),g=Re(g),It=Il.indexOf(g.PARSER_MEDIA_TYPE)===-1?Rl:g.PARSER_MEDIA_TYPE,_=It==="application/xhtml+xml"?ur:Sn,B=Te(g,"ALLOWED_TAGS")?x({},g.ALLOWED_TAGS,_):di,W=Te(g,"ALLOWED_ATTR")?x({},g.ALLOWED_ATTR,_):ui,qn=Te(g,"ALLOWED_NAMESPACES")?x({},g.ALLOWED_NAMESPACES,ur):Al,Un=Te(g,"ADD_URI_SAFE_ATTR")?x(Re(ki),g.ADD_URI_SAFE_ATTR,_):ki,yi=Te(g,"ADD_DATA_URI_TAGS")?x(Re(Si),g.ADD_DATA_URI_TAGS,_):Si,ht=Te(g,"FORBID_CONTENTS")?x({},g.FORBID_CONTENTS,_):bi,At=Te(g,"FORBID_TAGS")?x({},g.FORBID_TAGS,_):Re({}),Bn=Te(g,"FORBID_ATTR")?x({},g.FORBID_ATTR,_):Re({}),ft=Te(g,"USE_PROFILES")?g.USE_PROFILES:!1,fi=g.ALLOW_ARIA_ATTR!==!1,_n=g.ALLOW_DATA_ATTR!==!1,hi=g.ALLOW_UNKNOWN_PROTOCOLS||!1,pi=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,dt=g.SAFE_FOR_TEMPLATES||!1,nn=g.SAFE_FOR_XML!==!1,Ze=g.WHOLE_DOCUMENT||!1,ut=g.RETURN_DOM||!1,rn=g.RETURN_DOM_FRAGMENT||!1,on=g.RETURN_TRUSTED_TYPE||!1,Hn=g.FORCE_BODY||!1,mi=g.SANITIZE_DOM!==!1,gi=g.SANITIZE_NAMED_PROPS||!1,Wn=g.KEEP_CONTENT!==!1,vt=g.IN_PLACE||!1,ci=g.ALLOWED_URI_REGEXP||ul,pt=g.NAMESPACE||we,an=g.MATHML_TEXT_INTEGRATION_POINTS||an,cn=g.HTML_INTEGRATION_POINTS||cn,F=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&Ti(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&Ti(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(F.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(F.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),dt&&(_n=!1),rn&&(ut=!0),ft&&(B=x({},Ao),W=[],ft.html===!0&&(x(B,wo),x(W,vo)),ft.svg===!0&&(x(B,hr),x(W,gr),x(W,hn)),ft.svgFilters===!0&&(x(B,pr),x(W,gr),x(W,hn)),ft.mathMl===!0&&(x(B,mr),x(W,Io),x(W,hn))),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?ct.tagCheck=g.ADD_TAGS:(B===di&&(B=Re(B)),x(B,g.ADD_TAGS,_))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?ct.attributeCheck=g.ADD_ATTR:(W===ui&&(W=Re(W)),x(W,g.ADD_ATTR,_))),g.ADD_URI_SAFE_ATTR&&x(Un,g.ADD_URI_SAFE_ATTR,_),g.FORBID_CONTENTS&&(ht===bi&&(ht=Re(ht)),x(ht,g.FORBID_CONTENTS,_)),Wn&&(B["#text"]=!0),Ze&&x(B,["html","head","body"]),B.table&&(x(B,["tbody"]),delete At.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw Lt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Lt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');A=g.TRUSTED_TYPES_POLICY,ke=A.createHTML("")}else A===void 0&&(A=wu(h,i)),A!==null&&typeof ke=="string"&&(ke=A.createHTML(""));le&&le(g),mt=g}},Ci=x({},[...hr,...pr,...yu]),Mi=x({},[...mr,...Su]),Pl=function(g){let S=w(g);(!S||!S.tagName)&&(S={namespaceURI:pt,tagName:"template"});const k=Sn(g.tagName),E=Sn(S.tagName);return qn[g.namespaceURI]?g.namespaceURI===ln?S.namespaceURI===we?k==="svg":S.namespaceURI===sn?k==="svg"&&(E==="annotation-xml"||an[E]):!!Ci[k]:g.namespaceURI===sn?S.namespaceURI===we?k==="math":S.namespaceURI===ln?k==="math"&&cn[E]:!!Mi[k]:g.namespaceURI===we?S.namespaceURI===ln&&!cn[E]||S.namespaceURI===sn&&!an[E]?!1:!Mi[k]&&(vl[k]||!Ci[k]):!!(It==="application/xhtml+xml"&&qn[g.namespaceURI]):!1},xe=function(g){Ft(e.removed,{element:g});try{w(g).removeChild(g)}catch{y(g)}},Qe=function(g,S){try{Ft(e.removed,{attribute:S.getAttributeNode(g),from:S})}catch{Ft(e.removed,{attribute:null,from:S})}if(S.removeAttribute(g),g==="is")if(ut||rn)try{xe(S)}catch{}else try{S.setAttribute(g,"")}catch{}},xi=function(g){let S=null,k=null;if(Hn)g="<remove></remove>"+g;else{const L=fr(g,/^[\r\n\t ]+/);k=L&&L[0]}It==="application/xhtml+xml"&&pt===we&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const E=A?A.createHTML(g):g;if(pt===we)try{S=new f().parseFromString(E,It)}catch{}if(!S||!S.documentElement){S=_e.createDocument(pt,"template",null);try{S.documentElement.innerHTML=$n?ke:E}catch{}}const G=S.body||S.documentElement;return g&&k&&G.insertBefore(t.createTextNode(k),G.childNodes[0]||null),pt===we?J.call(S,Ze?"html":"body")[0]:Ze?S.documentElement:G},Oi=function(g){return D.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Jn=function(g){return g instanceof u&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof d)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},Di=function(g){return typeof l=="function"&&g instanceof l};function Ae(T,g,S){fn(T,k=>{k.call(e,g,S,mt)})}const Ni=function(g){let S=null;if(Ae(te.beforeSanitizeElements,g,null),Jn(g))return xe(g),!0;const k=_(g.nodeName);if(Ae(te.uponSanitizeElement,g,{tagName:k,allowedTags:B}),nn&&g.hasChildNodes()&&!Di(g.firstElementChild)&&ne(/<[/\w!]/g,g.innerHTML)&&ne(/<[/\w!]/g,g.textContent)||g.nodeType===Bt.progressingInstruction||nn&&g.nodeType===Bt.comment&&ne(/<[/\w]/g,g.data))return xe(g),!0;if(!(ct.tagCheck instanceof Function&&ct.tagCheck(k))&&(!B[k]||At[k])){if(!At[k]&&wi(k)&&(F.tagNameCheck instanceof RegExp&&ne(F.tagNameCheck,k)||F.tagNameCheck instanceof Function&&F.tagNameCheck(k)))return!1;if(Wn&&!ht[k]){const E=w(g)||g.parentNode,G=R(g)||g.childNodes;if(G&&E){const L=G.length;for(let de=L-1;de>=0;--de){const ve=b(G[de],!0);ve.__removalCount=(g.__removalCount||0)+1,E.insertBefore(ve,C(g))}}}return xe(g),!0}return g instanceof a&&!Pl(g)||(k==="noscript"||k==="noembed"||k==="noframes")&&ne(/<\/no(script|embed|frames)/i,g.innerHTML)?(xe(g),!0):(dt&&g.nodeType===Bt.text&&(S=g.textContent,fn([Pn,Ln,zn],E=>{S=Pt(S,E," ")}),g.textContent!==S&&(Ft(e.removed,{element:g.cloneNode()}),g.textContent=S)),Ae(te.afterSanitizeElements,g,null),!1)},Ei=function(g,S,k){if(mi&&(S==="id"||S==="name")&&(k in t||k in Fl))return!1;if(!(_n&&!Bn[S]&&ne(Ol,S))){if(!(fi&&ne(Dl,S))){if(!(ct.attributeCheck instanceof Function&&ct.attributeCheck(S,g))){if(!W[S]||Bn[S]){if(!(wi(g)&&(F.tagNameCheck instanceof RegExp&&ne(F.tagNameCheck,g)||F.tagNameCheck instanceof Function&&F.tagNameCheck(g))&&(F.attributeNameCheck instanceof RegExp&&ne(F.attributeNameCheck,S)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(S,g))||S==="is"&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&ne(F.tagNameCheck,k)||F.tagNameCheck instanceof Function&&F.tagNameCheck(k))))return!1}else if(!Un[S]){if(!ne(ci,Pt(k,ai,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&g!=="script"&&pu(k,"data:")===0&&yi[g])){if(!(hi&&!ne(Nl,Pt(k,ai,"")))){if(k)return!1}}}}}}}return!0},wi=function(g){return g!=="annotation-xml"&&fr(g,El)},Ai=function(g){Ae(te.beforeSanitizeAttributes,g,null);const{attributes:S}=g;if(!S||Jn(g))return;const k={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let E=S.length;for(;E--;){const G=S[E],{name:L,namespaceURI:de,value:ve}=G,gt=_(L),Gn=ve;let U=L==="value"?Gn:mu(Gn);if(k.attrName=gt,k.attrValue=U,k.keepAttr=!0,k.forceKeepAttr=void 0,Ae(te.uponSanitizeAttribute,g,k),U=k.attrValue,gi&&(gt==="id"||gt==="name")&&(Qe(L,g),U=wl+U),nn&&ne(/((--!?|])>)|<\/(style|title|textarea)/i,U)){Qe(L,g);continue}if(gt==="attributename"&&fr(U,"href")){Qe(L,g);continue}if(k.forceKeepAttr)continue;if(!k.keepAttr){Qe(L,g);continue}if(!pi&&ne(/\/>/i,U)){Qe(L,g);continue}dt&&fn([Pn,Ln,zn],Ii=>{U=Pt(U,Ii," ")});const vi=_(g.nodeName);if(!Ei(vi,gt,U)){Qe(L,g);continue}if(A&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!de)switch(h.getAttributeType(vi,gt)){case"TrustedHTML":{U=A.createHTML(U);break}case"TrustedScriptURL":{U=A.createScriptURL(U);break}}if(U!==Gn)try{de?g.setAttributeNS(de,L,U):g.setAttribute(L,U),Jn(g)?xe(g):Eo(e.removed)}catch{Qe(L,g)}}Ae(te.afterSanitizeAttributes,g,null)},Ll=function T(g){let S=null;const k=Oi(g);for(Ae(te.beforeSanitizeShadowDOM,g,null);S=k.nextNode();)Ae(te.uponSanitizeShadowNode,S,null),Ni(S),Ai(S),S.content instanceof o&&T(S.content);Ae(te.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(T){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,k=null,E=null,G=null;if($n=!T,$n&&(T="<!-->"),typeof T!="string"&&!Di(T))if(typeof T.toString=="function"){if(T=T.toString(),typeof T!="string")throw Lt("dirty is not a string, aborting")}else throw Lt("toString is not a function");if(!e.isSupported)return T;if(Vn||Kn(g),e.removed=[],typeof T=="string"&&(vt=!1),vt){if(T.nodeName){const ve=_(T.nodeName);if(!B[ve]||At[ve])throw Lt("root node is forbidden and cannot be sanitized in-place")}}else if(T instanceof l)S=xi("<!---->"),k=S.ownerDocument.importNode(T,!0),k.nodeType===Bt.element&&k.nodeName==="BODY"||k.nodeName==="HTML"?S=k:S.appendChild(k);else{if(!ut&&!dt&&!Ze&&T.indexOf("<")===-1)return A&&on?A.createHTML(T):T;if(S=xi(T),!S)return ut?null:on?ke:""}S&&Hn&&xe(S.firstChild);const L=Oi(vt?T:S);for(;E=L.nextNode();)Ni(E),Ai(E),E.content instanceof o&&Ll(E.content);if(vt)return T;if(ut){if(rn)for(G=P.call(S.ownerDocument);S.firstChild;)G.appendChild(S.firstChild);else G=S;return(W.shadowroot||W.shadowrootmode)&&(G=Fn.call(n,G,!0)),G}let de=Ze?S.outerHTML:S.innerHTML;return Ze&&B["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&ne(fl,S.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
|
|
17
|
+
`+de),dt&&fn([Pn,Ln,zn],ve=>{de=Pt(de,ve," ")}),A&&on?A.createHTML(de):de},e.setConfig=function(){let T=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Kn(T),Vn=!0},e.clearConfig=function(){mt=null,Vn=!1},e.isValidAttribute=function(T,g,S){mt||Kn({});const k=_(T),E=_(g);return Ei(k,E,S)},e.addHook=function(T,g){typeof g=="function"&&Ft(te[T],g)},e.removeHook=function(T,g){if(g!==void 0){const S=fu(te[T],g);return S===-1?void 0:hu(te[T],S,1)[0]}return Eo(te[T])},e.removeHooks=function(T){te[T]=[]},e.removeAllHooks=function(){te=Fo()},e}var pl=hl();const Nn=r=>({...r}),Au=r=>({nodes:Object.fromEntries(Object.keys(r.nodes).map(e=>[e,(r.nodes[e].spec.parseDOM??[]).map(Nn)])),marks:Object.fromEntries(Object.keys(r.marks).map(e=>[e,(r.marks[e].spec.parseDOM??[]).map(Nn)]))});class ml{constructor(e,t){this[m.impl]=new vu(e[m.impl],t)}parseDocument(e,t){return this[m.impl].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[m.impl].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){const n=pl.sanitize(e,{RETURN_DOM:!0}),i=document.createDocumentFragment();return i.appendChild(n),t?.modifyDom?.(i),i}}class vu{constructor(e,t){const n=Au(e.schema);t?.modifyParseRules?.(n),this.parser=Iu(e.schema,n)}transform(e){return pl.sanitize(e)}}const Iu=(r,{marks:e,nodes:t})=>{const n=[],i=s=>s.priority??50;function o(s){let l=0;for(;l<n.length;l++){const a=n[l];if(i(a)<i(s))break}n.splice(l,0,s)}for(const s in e)e[s]?.forEach(l=>{o(l=Nn(l)),l.mark||l.ignore||l.clearMark||(l.mark=s)});for(const s in t)t[s]?.forEach(l=>{o(l=Nn(l)),l.node||l.ignore||l.mark||(l.node=s)});return new m.DOMParser(r,n)};class gl{constructor(e,t){this[m.impl]=new si(e[m.impl],t)}serializeDocument(e,t){return this[m.impl].serializeFragment(e.content,t)}serializeFragment(e,t){return this[m.impl].serializeFragment(e,t)}}class si{constructor(e,t){this.config=e;const n=si.domSerializersFromSchema(e.schema);Object.assign(n.nodes,t?.serializers?.nodes??{}),Object.assign(n.marks,t?.serializers?.marks??{}),this.serializer=new m.DOMSerializer(n.nodes,n.marks)}static domSerializersFromSchema(e){const t={nodes:{},marks:{}};for(const n in e.marks){const i=e.marks[n].spec.toDOM;i&&(t.marks[n]=i)}for(const n in e.nodes){const i=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;i&&(t.nodes[n]=i)}return t.nodes.text=n=>document.createTextNode(n.text),t}serializeFragment(e,t){const n=m.Fragment.fromJSON(this.config.schema,e),i=this.serializer.serializeFragment(n),o=document.createDocumentFragment();o.appendChild(i),t?.modifyDom?.(o);const s=document.createElement("div");return s.appendChild(o),s.innerHTML}}const bl=(r,e)=>{const t=r.topNodeType.createAndFill(null,e?m.Fragment.fromJSON(r,e.content):null);if(!t)throw new Error("Document could not be parsed");return t.check(),t};class Ru{constructor(e,t){this.options=t,this[m.impl]=new Fu(e,t)}getDocument(){return this[m.impl].state.doc.toJSON()}reset(e){this[m.impl].reset(e)}replaceSelection(e,t){const{state:n,tr:i,schema:o,dispatchTransaction:s}=this[m.impl];i.replaceSelection(new m.Slice(m.Fragment.fromJSON(o,e),0,0)),i.doc.check();const l=i.doc.resolve(i.mapping.map(n.selection.from)),a=i.doc.resolve(i.selection.to),[c,d]=t?.cursorPlacement==="start"?[l,a]:[a,l];t?.selectContent?i.setSelection(n.selection instanceof K?new K(i.doc):O.between(d,c)):i.setSelection(O.between(c,c)),s(i)}replaceDocument(e,t){const{state:n,tr:i,schema:o,dispatchTransaction:s}=this[m.impl];i.replaceWith(0,n.doc.content.size,bl(o,e)),t?.selectContent?i.setSelection(new K(i.doc)):t?.cursorPlacement==="end"?i.setSelection(O.atEnd(i.doc)):i.setSelection(O.atStart(i.doc)),s(i)}}class Fu{constructor(e,t){this.options=t,this.view=null,this.dispatchTransaction=i=>{const o=this.state;return this.state=this.state.apply(i),this.view?.updateState(this.state),o.doc!==this.state.doc&&this.options?.onChange?.(),this.state};const n=e[m.impl];this.config=n,this.schema=n.schema,this.textblockAttrs=n.textblockAttrs,this.features=n.features,this.foreignHtmlParser=t?.foreignHtmlParser??new ml(e),this.foreignHtmlSerializer=t?.foreignHtmlSerializer??new gl(e),this.styles=new ce.ElementStyles(m.sortedContributions(n.features.flatMap(i=>i.getStyles()))),this.initState(t?.initialDocument)}getFeature(e){const t=this.config.featureMap.get(e);if(!t)throw new Error(`Feature not found: ${e.name}`);return t}initState(e){this.state=Tt.create({doc:bl(this.schema,e),schema:this.config.schema,plugins:m.sortedContributions(this.config.features.flatMap(t=>t.getPlugins(this)))})}reset(e){const t=qt.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){this.view=new Hs(e,{state:this.state,dispatchTransaction:this.dispatchTransaction})}destroyViewIfNeeded(){this.view&&(this.view.destroy(),this.view=null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){const e=qt.getState(this.state);if(!e)throw new Error("No host state available");return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(qt,e))}}var Pu=Object.defineProperty,Lu=(r,e,t,n)=>{for(var i=void 0,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(e,t,i)||i);return i&&Pu(e,t,i),i};class yl extends zl.WithObservableLocale(ce.VividElement){instanceChanged(e){e?.[m.impl].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[m.impl].styles.removeStylesFrom(this.shadowRoot),this.instance?.[m.impl].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){const e=this.instance?.[m.impl];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[m.impl].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[m.impl].updateHostState({locale:this.locale,ctx:this._ctx})}}Lu([ce.observable],yl.prototype,"instance");const zu=r=>ce.html`<template :_ctx="${()=>r}">
|
|
21
18
|
<div class="rte">
|
|
22
|
-
<div class="editor-viewport" ${
|
|
19
|
+
<div class="editor-viewport" ${Ri.ref("editorViewportElement")}>
|
|
23
20
|
<div class="editor-scroll-area">
|
|
24
21
|
<slot name="editor-start"></slot>
|
|
25
|
-
<div class="editor" ${
|
|
22
|
+
<div class="editor rich-text" ${Ri.ref("_editorEl")}></div>
|
|
26
23
|
<div class="popovers"></div>
|
|
27
24
|
<slot name="editor-end"></slot>
|
|
28
25
|
</div>
|
|
@@ -30,4 +27,4 @@
|
|
|
30
27
|
<slot name="status"></slot>
|
|
31
28
|
<div class="toolbar"></div>
|
|
32
29
|
</div>
|
|
33
|
-
</template>`;class pd extends ${constructor(e){super(),this.config=e,this.name="RteTextBlockPickerFeature"}getToolbarItems(e){const t=e.getFeature(fa);return[this.contribution({section:"font",render:n=>Cf(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:i=>t.getCurrentBlockType(i.view.state)??"",onSelect:i=>{const{state:s,dispatch:o}=n.view;t.setBlockType(e,i)(s,o)},children:this.config.options.map(i=>Tf(n,{text:i.label,value:i.node,disabled:()=>!t.setBlockType(e,i.node)(n.view.state)}))})},1)]}}const md=H(pd),gd=".placeholder{display:contents}.placeholder:before{position:absolute;color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size, inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none}";class yd extends ${constructor(e){super(),this.config=e,this.name="RtePlaceholderFeature"}getStyles(){return[this.contribution(gd)]}getPlugins(){const e=new ce({props:{decorations:t=>{if(t.doc.nodeSize===4){const i=t.schema.marks.fontSize?.isInSet(t.storedMarks??[])?.attrs.size;return P.create(t.doc,[ie.widget(1,()=>{const s=document.createElement("span");return s.className="placeholder",s.dataset.placeholder=this.config.text,i&&s.style.setProperty("--placeholder-font-size",i),s})])}return null}}});return[this.contribution(e)]}}const bd=H(yd);class kd extends ${constructor(){super(...arguments),this.name="RteHardBreakFeature"}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}}})]}getPlugins(e){const n={"Shift-Enter":(i,s)=>(s?.(i.tr.replaceSelectionWith(i.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0)};return[this.contribution(Me(n))]}}const Sd=H(kd),qr=Symbol("mixedFontSize");class xd extends ${constructor(e){if(super(),this.config=e,this.name="RteFontSizePickerFeature",this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(const t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"fontSize",onNodeName:e.node})):[this.contribution({markName:"fontSize"})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:"string"}},parseDOM:[{tag:"span[style*='font-size']",getAttrs:e=>{const n=e.getAttribute("style").match(/font-size:\s*([^;]+)/)?.[1]?.trim();return n?{size:n}:!1}}],toDOM:e=>["span",{style:`font-size: ${e.attrs.size};`},0],fontSizes:this.fontSizes}}})]}getPlugins(e){return[this.contribution(new ce({props:{decorations:t=>{const{$from:n}=t.selection,s=t.storedMarks?.find(o=>o.type===e.schema.marks.fontSize)?.attrs.size??(t.storedMarks?.length===0?this.defaultFontSizeForNode?.[n.parent.type.name]:null);return s?P.create(t.doc,[ie.widget(n.pos,()=>{const o=document.createElement("span");return o.style.fontSize=s,o.innerText="",o},{side:-1})]):null}}})),this.contribution(Me({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:"font",render:t=>Fi(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:q(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:"text-size-line"}),children:this.fontSizes.map(n=>kf(t,{text:n.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===n.size,disabled:()=>!this.setFontSize(n.size)(t.view.state),onSelect:()=>{const{state:i,dispatch:s}=t.view;this.setFontSize(n.size)(i,s)}}))})},2)]}getFontSizeFromSelection(e){const{from:t,to:n,$from:i,empty:s}=e.selection,{fontSize:o}=e.schema.marks;if(s){const c=this.defaultFontSizeForNode?.[i.parent.type.name]??null;return o.isInSet(e.storedMarks||i.marks())?.attrs.size??c}let l=null;const a=c=>{l===null?l=c??null:c!==l&&(l=qr)};return e.doc.nodesBetween(t,n,(c,h,u)=>l===qr?!1:c.isLeaf?(a(o.isInSet(c.marks)?.attrs.size??(u&&this.defaultFontSizeForNode?.[u.type.name])),!0):(c.type.allowsMarkType(o)&&c.childCount===0&&a(this.defaultFontSizeForNode?.[c.type.name]),!0)),l}setFontSize(e){return(t,n)=>{const{from:i,to:s,empty:o,$from:l}=t.selection,{fontSize:a}=t.schema.marks;if(!Je(a,{size:e})(t))return!1;const c=t.tr;if(o){const u=(t.storedMarks||[]).filter(p=>p.type!==a),f=this.defaultFontSizeForNode?.[l.parent.type.name];e!==f&&u.push(a.create({size:e})),c.setStoredMarks(u)}else c.addMark(i,s,a.create({size:e})),c.doc.nodesBetween(i,s,(h,u,f)=>{if(!h.isInline)return;const p=a.isInSet(h.marks),d=this.defaultFontSizeForNode?.[f.type.name];p&&p.attrs.size===d&&c.step(new xe(u,u+h.nodeSize,p))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{const i=this.getFontSizeFromSelection(t);if(i===null||i===qr)return!1;const o=this.fontSizes.findIndex(l=>l.size===i)+e;return o<0||o>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[o].size)(t,n)}}}const Td=H(xd),Cd=["p",0],wd=["blockquote",0],Md=["hr"],Od=["pre",["code",0]],Ed=["br"],Nd={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Cd}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return wd}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Md}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Od}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Ed}}},Dd=["em",0],Ad=["strong",0],vd=["code",0],zi={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return Dd}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return Ad}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return vd}}};new Xo({nodes:Nd,marks:zi});class kn extends ${constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}}class Id extends kn{constructor(){super(...arguments),this.name="RteBoldFeature",this.markName="bold"}getSchema(){return[this.contribution({marks:{bold:zi.strong}})]}getPlugins(e){return[this.contribution(Me({"Mod-b":Je(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>bn(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:"bold-line",markType:e.schema.marks.bold})},1)]}}const Rd=H(Id);class Pd extends kn{constructor(){super(...arguments),this.name="RteItalicFeature",this.markName="italic"}getSchema(){return[this.contribution({marks:{italic:zi.em}})]}getPlugins(e){return[this.contribution(Me({"Mod-i":Je(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>bn(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:"italic-line",markType:e.schema.marks.italic})},2)]}}const Fd=H(Pd);class Ld extends kn{constructor(){super(...arguments),this.name="RteUnderlineFeature",this.markName="underline"}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:"u"}],toDOM(){return["u",0]}}}})]}getPlugins(e){return[this.contribution(Me({"Mod-u":Je(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>bn(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:"underline-line",markType:e.schema.marks.underline})},3)]}}const zd=H(Ld);class Bd extends kn{constructor(){super(...arguments),this.name="RteStrikethroughFeature",this.markName="strikethrough"}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"del"}],toDOM(){return["s",0]}}}})]}getPlugins(e){return[this.contribution(Me({"Alt-Shift-5":Je(e.schema.marks.strikethrough),"Cmd-Shift-X":Je(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>bn(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:"strikethrough-line",markType:e.schema.marks.strikethrough})},4)]}}const _d=H(Bd),Vd="tt{font:var(--vvd-typography-base-code);font-size:unset;font-weight:unset;line-height:unset}";class Hd extends kn{constructor(){super(...arguments),this.name="RteMonospaceFeature",this.markName="monospace"}getStyles(){return[this.contribution(Vd)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:"tt"},{tag:"code"}],toDOM(){return["tt",0]}}}})]}getPlugins(e){return[this.contribution(Me({"Mod-M":Je(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>bn(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:"monospace-line",markType:e.schema.marks.monospace})},5)]}}const Wd=H(Hd);function Ud(r,e,t){for(let n=0;n<e.length;n++){const{$from:i,$to:s}=e[n];let o=i.depth==0?r.type.allowsMarkType(t):!1;if(r.nodesBetween(i.pos,s.pos,l=>o?!1:(o=l.inlineContent&&l.type.allowsMarkType(t),!0)),o)return!0}return!1}const Jr=Symbol("mixedColor");class qd extends ${constructor(e){if(super(),this.config=e,this.name="RteTextColorPicker",e?.onBlocks){this.defaultColorForNode={};for(const t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"textColor",onNodeName:e.node})):[this.contribution({markName:"textColor"})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:"string"}},parseDOM:[{tag:"span[data-text-color]",getAttrs:e=>({color:e.getAttribute("data-text-color")})},{style:"color",getAttrs:e=>({color:e})}],toDOM(e){const{color:t}=e.attrs;return["span",{style:`color: ${t}`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:"text-style",render:e=>{const t=q(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor("any")(e.view.state),icon:"textcolor-line"}),n=t.firstElementChild;return Ne(e,{children:[t,wf(e,{name:"text-color-picker",assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||""},assignedEvents:{change:i=>{const s=i.currentTarget.value;this.setColor(s)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){const{selection:t}=e,{textColor:n}=e.schema.marks,{from:i,to:s,$from:o,empty:l}=t;if(l){const h=this.defaultColorForNode?.[o.parent.type.name]??null;return n.isInSet(e.storedMarks||o.marks())?.attrs.color??h}let a=null;const c=h=>{a===null?a=h??null:h!==a&&(a=Jr)};return e.doc.nodesBetween(i,s,(h,u,f)=>a===Jr?!1:h.isLeaf?(c(n.isInSet(h.marks)?.attrs.color??(f&&this.defaultColorForNode?.[f.type.name])),!0):(h.type.allowsMarkType(n)&&h.childCount===0&&c(this.defaultColorForNode?.[h.type.name]),!0)),a===Jr?null:a}setColor(e){return(t,n)=>{const{textColor:i}=t.schema.marks,{from:s,to:o,empty:l,$from:a}=t.selection;if(!Ud(t.doc,t.selection.ranges,i))return!1;const c=t.tr;if(l){const u=(t.storedMarks||[]).filter(p=>p.type!==i),f=this.defaultColorForNode?.[a.parent.type.name];e!==f&&u.push(i.create({color:e})),c.setStoredMarks(u)}else c.addMark(s,o,i.create({color:e})),c.doc.nodesBetween(s,o,(h,u,f)=>{if(!h.isInline)return;const p=i.isInSet(h.marks),d=this.defaultColorForNode?.[f.type.name];p&&p.attrs.color===d&&c.step(new xe(u,u+h.nodeSize,p))});return n?.(c.scrollIntoView()),!0}}}const Jd=H(qd),$d=".editor ul,.editor ol{padding-inline-start:1.5em}.editor li{list-style-position:inside}",$r=r=>r.parentOffset===0,Kd=r=>r.nodeSize===2,Ht=r=>r.depth-1,di=r=>r.depth-2,Ma=r=>r.parent,pi=r=>r.node(Ht(r)),Oa=r=>r.depth>2,Ea=(r,e)=>r.index(e)===0,Gd=(r,e)=>r.index(e)===r.node(e).childCount-1,Na=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n-1)},jd=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n+1)},Co=r=>{let{$from:e,$to:t}=r;if(r instanceof Z){const n=O.between(r.$from,r.$to);e=n.$from,t=n.$to}return{$from:e,$to:t}},wo=(r,e)=>r.sameParent(e)?r.node(-1):r.node(r.sharedDepth(e.pos)),Rn=r=>{const{$cursor:e}=r.selection;return e?.parent.type===r.schema.nodes.listItem?e:null},Mo=(r,e,t,n)=>{let i,s=!0;return r.doc.nodesBetween(e.pos,t.pos,o=>{o.type.isInGroup("list")&&(i=o.type),o.type===r.schema.nodes.listItem&&i!==n&&(s=!1)}),s},Kr=(r,e,t)=>{Oa(e)?Da(e,t):Yd(r,e,t)},Da=(r,e)=>{const t=new Wo(r.doc.resolve(r.before()),r.doc.resolve(r.after()),r.depth-1);e.lift(t,r.depth-2)},Yd=(r,e,t)=>{const n=pi(e),i=e.index(di(e)),s=oa(e.node(di(e)).contentMatchAt(i+1)),o=Ea(e,Ht(e)),l=Gd(e,Ht(e));t.step(new se(e.before()-(o?1:0),e.after()+(l?1:0),e.start(),e.end(),new S((o?b.empty:b.from(n.copy(b.empty))).append(b.from(s.create(r.textblockAttrs.extractFromNode(Ma(e))))).append(l?b.empty:b.from(n.copy(b.empty))),o?0:1,l?0:1),(o?0:1)+1))},Xd=(r,e,t,n)=>{t.parent.type===r.schema.nodes.listItem?Aa(e,t,n):Zd(r,e,t,n)},Aa=(r,e,t)=>{const n=Na(e,Ht(e))?.type===r,i=jd(e,Ht(e))?.type===r,s=n?1:0,o=i?1:0;t.step(new se(e.before()-(n?1:0),e.after()+(i?1:0),e.before(),e.after(),new S(b.from(r.create(null,[])),s,o),1-s))},Zd=(r,e,t,n)=>{n.step(new se(t.before(),t.after(),t.start(),t.end(),new S(b.from(e.create(null,[r.schema.nodes.listItem.create(r.textblockAttrs.extractFromNode(t.parent))])),0,0),2))};class Qd extends ${constructor(e){if(super(),this.config=e,this.name="RteListFeature",!e.bulletList&&!e.numberedList)throw new Error("RteListFeature requires at least one of bulletList or numberedList to be enabled")}getStyles(){return[this.contribution($d)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:"inline*",attrs:e.attrs,defining:!0,parseDOM:[{tag:"li",getAttrs:t=>e.fromDOM(t)}],toDOM(t){return["li",...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ul"}],toDOM(){return["ul",0]}}}:{},...this.config.numberedList?{numberedList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ol"}],toDOM(){return["ol",0]}}}:{}}})]}getPlugins(e){this.rte=e;const t=(o,l)=>{const a=Rn(o);if(a&&$r(a)){const c=o.tr;return Aa(pi(a).type,a,c),l?.(c.scrollIntoView()),!0}return!1},n=(o,l)=>{const a=Rn(o);if(a&&$r(a)&&Oa(a)){const c=o.tr;return Da(a,c),l?.(c.scrollIntoView()),!0}return!1},i=(o,l)=>{const a=Rn(o);if(a&&Kd(Ma(a))){const c=o.tr;return Kr(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1},s=(o,l)=>{const a=Rn(o);if(a&&$r(a)){if(Ea(a,Ht(a))&&Na(a,di(a))?.type===pi(a).type)return!1;const c=o.tr;return Kr(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1};return[this.contribution(Me({Enter:i,Backspace:s,Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),vi.high)]}getToolbarItems(e){const t=[];return this.config.bulletList&&t.push(this.contribution({section:"textblock",render:n=>q(n,{label:()=>n.rte.getLocale().richTextEditor.bulletList,icon:"bullet-list-2-line",active:()=>this.isSelectionInList(e.schema.nodes.bulletList,n.rte.state),onClick:()=>{const{state:i,dispatch:s}=n.view;this.toggleList(e.schema.nodes.bulletList)(i,s)}})},1)),this.config.numberedList&&t.push(this.contribution({section:"textblock",render:n=>q(n,{label:()=>n.rte.getLocale().richTextEditor.numberedList,icon:"list-numbered-line",active:()=>this.isSelectionInList(e.schema.nodes.numberedList,n.rte.state),onClick:()=>{const{state:i,dispatch:s}=n.view;this.toggleList(e.schema.nodes.numberedList)(i,s)}})},2)),t}toggleList(e){return Ku((t,n)=>{const{$from:i,$to:s}=Co(t.selection);if(wo(i,s).type.isInGroup("list"))if(Mo(t,i,s,e)){const l=t.tr;return t.doc.nodesBetween(i.pos,s.pos,(a,c)=>{if(a.type===t.schema.nodes.listItem){const h=l.doc.resolve(l.mapping.map(c+1));Kr(this.rte,h,l)}}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,s.pos,(a,c)=>{a.type.isInGroup("list")&&a.type!==e&&l.setNodeMarkup(c,e,a.attrs)}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,s.pos,(a,c)=>{if(!a.isTextblock)return;const h=l.doc.resolve(l.mapping.map(c+1));Xd(this.rte,e,h,l)}),n?.(l.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){const{$from:n,$to:i}=Co(t.selection);return wo(n,i).type.isInGroup("list")?Mo(t,n,i,e):!1}}const ep=H(Qd),Oo=[{value:"left",icon:"align-left-line",label:"left"},{value:"center",icon:"align-center-line",label:"center"},{value:"right",icon:"align-right-line",label:"right"}];class tp extends ${constructor(){super(...arguments),this.name="RteAlignmentFeature"}getTextblockAttrs(){return[this.contribution({name:"textAlign",default:"left",fromDOM(e){return e.style.textAlign||"left"},toStyles(e){return[`text-align: ${e.attrs.textAlign}`]}})]}getPlugins(){return[this.contribution(Me({"Mod-L":this.setAlignment("left"),"Mod-E":this.setAlignment("center"),"Mod-R":this.setAlignment("right")}))]}getToolbarItems(){return[this.contribution({section:"textblock",render:e=>Fi(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:q(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{const t=this.getAlignmentFromSelection(e.view.state);return Oo.find(n=>n.value===t)?.icon??"align-left-line"}}),children:[Sf(e,{children:Oo.map((t,n)=>q(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:"header",noTooltip:!0,autofocus:()=>{const i=this.getAlignmentFromSelection(e.view.state);return(i==="mixed"||i===null)&&n===0?!0:t.value===i},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{const{state:i,dispatch:s}=e.view;this.setAlignment(t.value)(i,s)}}))})]})},3)]}getAlignmentFromSelection(e){const{selection:t}=e,{from:n,to:i}=t;let s=null;return e.doc.nodesBetween(n,i,o=>{s!=="mixed"&&o.type.isTextblock&&(s?s!==o.attrs.textAlign&&(s="mixed"):s=o.attrs.textAlign)}),s}setAlignment(e){return(t,n)=>{const{tr:i,selection:s}=t,{from:o,to:l}=s;return t.doc.nodesBetween(o,l,(a,c)=>{a.type.isTextblock&&i.setNodeMarkup(c,a.type,{...a.attrs,textAlign:e})}),n?.(i.scrollIntoView()),!0}}}const np=H(tp),rp=".inline-image-wrapper{display:inline-block;vertical-align:text-bottom}.inline-image{display:block;block-size:auto}.inline-image-popover{display:flex;align-items:center;padding:8px;gap:4px}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}",Eo=r=>r!==null&&!!r.next;let ip=1;const sp=()=>ip++;class op{constructor(e,t,n,i){this.view=t,this.getPos=n,this.config=i,this.content=null,this.dom=document.createElement("div"),this.dom.className="inline-image-wrapper",this.img=document.createElement("img"),this.initializeImg(e);const s=this.config.resolveUrl?this.config.resolveUrl(e.attrs.imageUrl):e.attrs.imageUrl,o=Eo(s)?null:s;this.handleResolvedUrl(o),Eo(s)&&this.handleResolvedUrlGenerator(s)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),Fe.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){const t=e[Symbol.asyncIterator]();let n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e=="string")this.renderImg(e);else if(e?.type==="placeholder"){const t=`inline-image-placeholder-${sp()}`,n=document.createElement("slot");n.className="inline-image-placeholder",n.name=t;const i=e.create(t);this.setContent(n,{onDestroy:i})}else this.setContent(null)}initializeImg(e){this.img.className="inline-image",this.update(e),this.img.addEventListener("load",()=>{const t=this.getPos?.();if(t){const{state:n,dispatch:i}=this.view,s=n.doc.nodeAt(t);if(!s||s.attrs.naturalWidth===this.img.naturalWidth&&s.attrs.naturalHeight===this.img.naturalHeight)return;const o=n.tr;o.setNodeAttribute(t,"naturalWidth",this.img.naturalWidth),o.setNodeAttribute(t,"naturalHeight",this.img.naturalHeight),o.setMeta("addToHistory",!1),i(o)}})}renderImg(e){this.img.src=e,this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}}class lp extends ${constructor(e={}){super(),this.config=e,this.name="RteInlineImageFeature"}getStyles(){return[this.contribution(rp)]}getSchema(){const e={inline:!0,group:"inline",selectable:!0,atom:!0,attrs:{imageUrl:{validate:"string"},alt:{validate:"string",default:""},size:{validate:"string|null",default:null},naturalWidth:{validate:"number|null",default:null},naturalHeight:{validate:"number|null",default:null}},parseDOM:[{tag:"img[src]",getAttrs:t=>{const n=o=>{const l=parseInt(o??"",10);return isNaN(l)?null:l},i=t.getAttribute("src"),s=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(i):i;return s===null?!1:{imageUrl:s,alt:t.getAttribute("alt")||"",size:t.style.maxWidth||null,naturalWidth:n(t.getAttribute("width")),naturalHeight:n(t.getAttribute("height"))}}}],toDOM:t=>{const{imageUrl:n,alt:i,size:s,naturalWidth:o,naturalHeight:l}=t.attrs,a=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(n):n;if(a===null)return document.createTextNode("");const c={src:a,alt:i};return s&&(c.style=`max-width: ${s};`),o&&(c.width=o),l&&(c.height=l),["img",c]}};return[this.contribution({nodes:{inlineImage:e}})]}getPlugins(e){return[this.contribution(new ce({props:{nodeViews:{inlineImage:(t,n,i)=>new op(t,n,i,this.config)}},view:t=>{const n=new Pi(t,e,{popupPlacement:"bottom"}),i=e.createComponent(Fe);i.offset=4;const s=Ne(n,{className:"inline-image-popover",children:[q(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="small",onClick:()=>{this.setSelectedImageSize("small")(n.view.state,n.view.dispatch)}}),ci(n),q(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="fit",onClick:()=>{this.setSelectedImageSize("fit")(n.view.state,n.view.dispatch)}}),ci(n),q(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="original",onClick:()=>{this.setSelectedImageSize("original")(n.view.state,n.view.dispatch)}})]});return i.appendChild(s),t.dom.getRootNode().querySelector(".popovers").appendChild(i),{update:o=>{n.updateBindings();const l=this.getSelectedInlineImage(o.state);l?(i.anchorEl=o.nodeDOM(l.pos),i.requestOpenState(!0)):(i.anchorEl=void 0,i.requestOpenState(!1))},destroy:()=>{i.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+"px"}getSelectedInlineImage(e){const t=e.selection;return t instanceof w&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{const i=this.getSelectedInlineImage(t);if(!i)return!1;const{naturalWidth:s}=i.node.attrs;if(e==="small"&&s===null)return!1;const o=t.tr;return o.setNodeAttribute(i.pos,"size",e==="small"?this.calculateSmallWidth(s):e==="fit"?"100%":null),n?.(o.scrollIntoView()),!0}}getSelectedImageSize(e){const t=this.getSelectedInlineImage(e);if(!t)return null;const{size:n,naturalWidth:i}=t.node.attrs;return i!==null&&n===this.calculateSmallWidth(i)?"small":n==="100%"?"fit":n===null?"original":null}}const ap=H(lp),cp=async r=>{try{return{type:"ok",result:await r}}catch(e){return{type:"error",error:e}}};class hp extends ${constructor(e){super(),this.config=e,this.name="RteFileHandlerFeature"}getPlugins(e){const t=new ce({state:{init(){return P.empty},apply(a,c){c=c.map(a.mapping,a.doc);const h=a.getMeta(t);if(h&&h.add){const u=document.createElement("placeholder"),f=ie.widget(h.add.pos,u,{id:h.add.id,relaxedSide:!0});c=c.add(a.doc,[f])}else h&&h.remove&&(c=c.remove(c.find(void 0,void 0,u=>u.id==h.remove.id)));return c}},props:{decorations(a){return this.getState(a)}}}),n=(a,c)=>{const h=$a.generateRandomId();return a.setMeta(t,{add:{id:h,pos:c}}),{getPos:u=>{const p=t.getState(u).find(void 0,void 0,d=>d.id==h);return p.length?p[0].from:null},remove:u=>{u.setMeta(t,{remove:{id:h}})}}},i=(a,c,h)=>{if(h.type==="selection"){const u=S.fromJSON(e.schema,{content:c});a.replaceSelection(u)}else{const u=b.fromJSON(e.schema,c);a.insert(h.pos,u)}},s=(a,c)=>{const h=this.config.handleFiles(a);h!==null&&(h instanceof Promise?l(h,c):o(h,c))},o=(a,c)=>{const h=e.state.tr;i(h,a,c),e.dispatchTransaction(h)},l=async(a,c)=>{const h=e.state.tr;c.type==="selection"&&!h.selection.empty&&h.deleteSelection();const u=c.type==="selection"?h.selection.from:c.pos,f=n(h,u);e.dispatchTransaction(h);const p=await cp(a),d=f.getPos(e.state),g=e.state.tr;f.remove(g),d!==null&&p.type==="ok"&&i(g,p.result,{type:"pos",pos:d}),e.dispatchTransaction(g),p.type==="error"&&console.error("Error in handleFiles handler:",p.error)};return[this.contribution(t),this.contribution(new ce({props:{handlePaste:(a,c)=>{const h=Array.from(c.clipboardData.files);return h.length?(s(h,{type:"selection"}),!0):!1},handleDrop:(a,c,h,u)=>{const f=Array.from(c.dataTransfer.files);if(!f.length)return!1;let p=a.posAtCoords({left:c.clientX,top:c.clientY}).pos;if(a.dragging&&a.dragging.slice){const d=ki(a.state.doc,p,a.dragging.slice);d!=null&&(p=d)}return s(f,{type:"pos",pos:p}),!0}}}))]}}const up=H(hp);class fp extends ${constructor(e){super(),this.config=e,this.name="RteDebugFeature"}getPlugins(e){const t=new WeakMap;let n=!1;const i=h=>{t.get(h)===void 0&&(n=this.config.onViewportDragOver?.(h)??!1)},s=h=>{this.config.onViewportDrop?.(h),this.config.onViewportDragFinish?.()},o=()=>{this.config.onViewportDragFinish?.()};let l=!1;const a=()=>{l=!0,window.setTimeout(()=>l=!1,0)},c=()=>{l||this.config.onViewportDragFinish?.()};return[this.contribution(new ce({view:h=>{const u=h.root.host.editorViewportElement;return u.addEventListener("dragover",i),u.addEventListener("drop",s),u.addEventListener("dragend",o),u.addEventListener("dragenter",a),u.addEventListener("dragleave",c),{destroy(){u.removeEventListener("dragover",i),u.removeEventListener("drop",s),u.removeEventListener("dragend",o),u.removeEventListener("dragenter",a),u.removeEventListener("dragleave",c)}}}})),this.contribution(new ce({props:{handleDOMEvents:{dragover:(h,u)=>{const f=this.config.onViewportDragOver?.(u)??!1;return t.set(u,f),n=f,f?(u.stopImmediatePropagation(),u.preventDefault(),!0):!1},drop:(h,u)=>n}}}),vi.high)]}}const dp=H(fp),pp=me.defineVividComponent("rich-text-editor",wa,dd,[qa.dividerDefinition,No.selectDefinition,Do.listboxOptionDefinition,Ao.buttonDefinition,vo.tooltipDefinition,Io.menuDefinition,Ro.menuItemDefinition,Po.textFieldDefinition,If],{styles:Ka,shadowOptions:{delegatesFocus:!0}}),mp=me.createRegisterFunction(pp);mp();exports.RteAlignmentFeature=np;exports.RteBase=Nf;exports.RteBoldFeature=Rd;exports.RteConfig=zf;exports.RteDropHandlerFeature=dp;exports.RteFileHandlerFeature=up;exports.RteFontSizePickerFeature=Td;exports.RteHardBreakFeature=Sd;exports.RteHtmlParser=xa;exports.RteHtmlSerializer=Ta;exports.RteInlineImageFeature=ap;exports.RteItalicFeature=Fd;exports.RteLinkFeature=Pf;exports.RteListFeature=ep;exports.RteMonospaceFeature=Wd;exports.RtePlaceholderFeature=bd;exports.RteStrikethroughFeature=_d;exports.RteTextBlockPickerFeature=md;exports.RteTextColorPickerFeature=Jd;exports.RteToolbarFeature=Lf;exports.RteUnderlineFeature=zd;
|
|
30
|
+
</template>`;class Bu extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteTextBlockPickerFeature"}getToolbarItems(e){const t=e.getFeature(sl);return[this.contribution({section:"font",render:n=>Kd(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:i=>t.getCurrentBlockType(i.view.state)??"",onSelect:i=>{const{state:o,dispatch:s}=n.view;t.setBlockType(e,i)(o,s)},children:this.config.options.map(i=>qd(n,{text:i.label,value:i.node,disabled:()=>!t.setBlockType(e,i.node)(n.view.state)}))})},1)]}}const _u=m.featureFacade(Bu),Vu=".placeholder{display:contents}.placeholder:before{position:absolute;color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size, inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none}";class Hu extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RtePlaceholderFeature"}getStyles(){return[this.contribution(Vu)]}getPlugins(){const e=new re({props:{decorations:t=>{if(t.doc.nodeSize===4){const i=t.schema.marks.fontSize?.isInSet(t.storedMarks??[])?.attrs.size;return v.create(t.doc,[Z.widget(1,()=>{const o=document.createElement("span");return o.className="placeholder",o.dataset.placeholder=this.config.text,i&&o.style.setProperty("--placeholder-font-size",i),o})])}return null}}});return[this.contribution(e)]}}const Wu=m.featureFacade(Hu);class Uu extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteHardBreakFeature"}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}}})]}getPlugins(e){const n={"Shift-Enter":(i,o)=>(o?.(i.tr.replaceSelectionWith(i.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0)};return[this.contribution(he(n))]}}const $u=m.featureFacade(Uu),br=Symbol("mixedFontSize");class qu extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteFontSizePickerFeature",this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(const t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"fontSize",onNodeName:e.node})):[this.contribution({markName:"fontSize"})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:"string"}},parseDOM:[{tag:"span[style*='font-size']",getAttrs:e=>{const n=e.getAttribute("style").match(/font-size:\s*([^;]+)/)?.[1]?.trim();return n?{size:n}:!1}}],toDOM:e=>["span",{style:`font-size: ${e.attrs.size};`},0],fontSizes:this.fontSizes}}})]}getPlugins(e){return[this.contribution(new re({props:{decorations:t=>{const{$from:n}=t.selection,o=t.storedMarks?.find(s=>s.type===e.schema.marks.fontSize)?.attrs.size??(t.storedMarks?.length===0?this.defaultFontSizeForNode?.[n.parent.type.name]:null);return o?v.create(t.doc,[Z.widget(n.pos,()=>{const s=document.createElement("span");return s.style.fontSize=o,s.innerText="",s},{side:-1})]):null}}})),this.contribution(he({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:"font",render:t=>oi(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:V(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:"text-size-line"}),children:this.fontSizes.map(n=>Wd(t,{text:n.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===n.size,disabled:()=>!this.setFontSize(n.size)(t.view.state),onSelect:()=>{const{state:i,dispatch:o}=t.view;this.setFontSize(n.size)(i,o)}}))})},2)]}getFontSizeFromSelection(e){const{from:t,to:n,$from:i,empty:o}=e.selection,{fontSize:s}=e.schema.marks;if(o){const c=this.defaultFontSizeForNode?.[i.parent.type.name]??null;return s.isInSet(e.storedMarks||i.marks())?.attrs.size??c}let l=null;const a=c=>{l===null?l=c??null:c!==l&&(l=br)};return e.doc.nodesBetween(t,n,(c,d,u)=>l===br?!1:c.isLeaf?(a(s.isInSet(c.marks)?.attrs.size??(u&&this.defaultFontSizeForNode?.[u.type.name])),!0):(c.type.allowsMarkType(s)&&c.childCount===0&&a(this.defaultFontSizeForNode?.[c.type.name]),!0)),l}setFontSize(e){return(t,n)=>{const{from:i,to:o,empty:s,$from:l}=t.selection,{fontSize:a}=t.schema.marks;if(!Be(a,{size:e})(t))return!1;const c=t.tr;if(s){const u=(t.storedMarks||[]).filter(h=>h.type!==a),f=this.defaultFontSizeForNode?.[l.parent.type.name];e!==f&&u.push(a.create({size:e})),c.setStoredMarks(u)}else c.addMark(i,o,a.create({size:e})),c.doc.nodesBetween(i,o,(d,u,f)=>{if(!d.isInline)return;const h=a.isInSet(d.marks),p=this.defaultFontSizeForNode?.[f.type.name];h&&h.attrs.size===p&&c.step(new ge(u,u+d.nodeSize,h))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{const i=this.getFontSizeFromSelection(t);if(i===null||i===br)return!1;const s=this.fontSizes.findIndex(l=>l.size===i)+e;return s<0||s>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[s].size)(t,n)}}}const Ku=m.featureFacade(qu),Ju=["p",0],Gu=["blockquote",0],ju=["hr"],Yu=["pre",["code",0]],Xu=["br"],Zu={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Ju}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Gu}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return ju}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Yu}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Xu}}},Qu=["em",0],ef=["strong",0],tf=["code",0],li={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return Qu}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return ef}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return tf}}};new m.Schema({nodes:Zu,marks:li});class tn extends m.RteFeatureImpl{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}}class nf extends tn{constructor(){super(...arguments),this.name="RteBoldFeature",this.markName="bold"}getSchema(){return[this.contribution({marks:{bold:li.strong}})]}getPlugins(e){return[this.contribution(he({"Mod-b":Be(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>en(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:"bold-line",markType:e.schema.marks.bold})},1)]}}const rf=m.featureFacade(nf);class of extends tn{constructor(){super(...arguments),this.name="RteItalicFeature",this.markName="italic"}getSchema(){return[this.contribution({marks:{italic:li.em}})]}getPlugins(e){return[this.contribution(he({"Mod-i":Be(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>en(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:"italic-line",markType:e.schema.marks.italic})},2)]}}const sf=m.featureFacade(of);class lf extends tn{constructor(){super(...arguments),this.name="RteUnderlineFeature",this.markName="underline"}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:"u"}],toDOM(){return["u",0]}}}})]}getPlugins(e){return[this.contribution(he({"Mod-u":Be(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>en(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:"underline-line",markType:e.schema.marks.underline})},3)]}}const af=m.featureFacade(lf);class cf extends tn{constructor(){super(...arguments),this.name="RteStrikethroughFeature",this.markName="strikethrough"}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"del"}],toDOM(){return["s",0]}}}})]}getPlugins(e){return[this.contribution(he({"Alt-Shift-5":Be(e.schema.marks.strikethrough),"Cmd-Shift-X":Be(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>en(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:"strikethrough-line",markType:e.schema.marks.strikethrough})},4)]}}const df=m.featureFacade(cf),uf="tt{font:var(--vvd-typography-base-code);font-size:unset;font-weight:unset;line-height:unset}";class ff extends tn{constructor(){super(...arguments),this.name="RteMonospaceFeature",this.markName="monospace"}getStyles(){return[this.contribution(uf)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:"tt"},{tag:"code"}],toDOM(){return["tt",0]}}}})]}getPlugins(e){return[this.contribution(he({"Mod-M":Be(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>en(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:"monospace-line",markType:e.schema.marks.monospace})},5)]}}const hf=m.featureFacade(ff);function pf(r,e,t){for(let n=0;n<e.length;n++){const{$from:i,$to:o}=e[n];let s=i.depth==0?r.type.allowsMarkType(t):!1;if(r.nodesBetween(i.pos,o.pos,l=>s?!1:(s=l.inlineContent&&l.type.allowsMarkType(t),!0)),s)return!0}return!1}const yr=Symbol("mixedColor");class mf extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteTextColorPicker",e?.onBlocks){this.defaultColorForNode={};for(const t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"textColor",onNodeName:e.node})):[this.contribution({markName:"textColor"})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:"string"}},parseDOM:[{tag:"span[data-text-color]",getAttrs:e=>({color:e.getAttribute("data-text-color")})},{style:"color",getAttrs:e=>({color:e})}],toDOM(e){const{color:t}=e.attrs;return["span",{style:`color: ${t}`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:"text-style",render:e=>{const t=V(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor("any")(e.view.state),icon:"textcolor-line"}),n=t.firstElementChild;return Ce(e,{children:[t,Jd(e,{name:"text-color-picker",assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||""},assignedEvents:{change:i=>{const o=i.currentTarget.value;this.setColor(o)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){const{selection:t}=e,{textColor:n}=e.schema.marks,{from:i,to:o,$from:s,empty:l}=t;if(l){const d=this.defaultColorForNode?.[s.parent.type.name]??null;return n.isInSet(e.storedMarks||s.marks())?.attrs.color??d}let a=null;const c=d=>{a===null?a=d??null:d!==a&&(a=yr)};return e.doc.nodesBetween(i,o,(d,u,f)=>a===yr?!1:d.isLeaf?(c(n.isInSet(d.marks)?.attrs.color??(f&&this.defaultColorForNode?.[f.type.name])),!0):(d.type.allowsMarkType(n)&&d.childCount===0&&c(this.defaultColorForNode?.[d.type.name]),!0)),a===yr?null:a}setColor(e){return(t,n)=>{const{textColor:i}=t.schema.marks,{from:o,to:s,empty:l,$from:a}=t.selection;if(!pf(t.doc,t.selection.ranges,i))return!1;const c=t.tr;if(l){const u=(t.storedMarks||[]).filter(h=>h.type!==i),f=this.defaultColorForNode?.[a.parent.type.name];e!==f&&u.push(i.create({color:e})),c.setStoredMarks(u)}else c.addMark(o,s,i.create({color:e})),c.doc.nodesBetween(o,s,(d,u,f)=>{if(!d.isInline)return;const h=i.isInSet(d.marks),p=this.defaultColorForNode?.[f.type.name];h&&h.attrs.color===p&&c.step(new ge(u,u+d.nodeSize,h))});return n?.(c.scrollIntoView()),!0}}}const gf=m.featureFacade(mf),bf=".rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}",Sr=r=>r.parentOffset===0,yf=r=>r.nodeSize===2,Et=r=>r.depth-1,Br=r=>r.depth-2,Sl=r=>r.parent,_r=r=>r.node(Et(r)),kl=r=>r.depth>2,Tl=(r,e)=>r.index(e)===0,Sf=(r,e)=>r.index(e)===r.node(e).childCount-1,Cl=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n-1)},kf=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n+1)},Po=r=>{let{$from:e,$to:t}=r;if(r instanceof K){const n=O.between(r.$from,r.$to);e=n.$from,t=n.$to}return{$from:e,$to:t}},Lo=(r,e)=>r.sameParent(e)?r.node(-1):r.node(r.sharedDepth(e.pos)),pn=r=>{const{$cursor:e}=r.selection;return e?.parent.type===r.schema.nodes.listItem?e:null},zo=(r,e,t,n)=>{let i,o=!0;return r.doc.nodesBetween(e.pos,t.pos,s=>{s.type.isInGroup("list")&&(i=s.type),s.type===r.schema.nodes.listItem&&i!==n&&(o=!1)}),o},kr=(r,e,t)=>{kl(e)?Ml(e,t):Tf(r,e,t)},Ml=(r,e)=>{const t=new m.NodeRange(r.doc.resolve(r.before()),r.doc.resolve(r.after()),r.depth-1);e.lift(t,r.depth-2)},Tf=(r,e,t)=>{const n=_r(e),i=e.index(Br(e)),o=el(e.node(Br(e)).contentMatchAt(i+1)),s=Tl(e,Et(e)),l=Sf(e,Et(e));t.step(new Q(e.before()-(s?1:0),e.after()+(l?1:0),e.start(),e.end(),new m.Slice((s?m.Fragment.empty:m.Fragment.from(n.copy(m.Fragment.empty))).append(m.Fragment.from(o.create(r.textblockAttrs.extractFromNode(Sl(e))))).append(l?m.Fragment.empty:m.Fragment.from(n.copy(m.Fragment.empty))),s?0:1,l?0:1),(s?0:1)+1))},Cf=(r,e,t,n)=>{t.parent.type===r.schema.nodes.listItem?xl(e,t,n):Mf(r,e,t,n)},xl=(r,e,t)=>{const n=Cl(e,Et(e))?.type===r,i=kf(e,Et(e))?.type===r,o=n?1:0,s=i?1:0;t.step(new Q(e.before()-(n?1:0),e.after()+(i?1:0),e.before(),e.after(),new m.Slice(m.Fragment.from(r.create(null,[])),o,s),1-o))},Mf=(r,e,t,n)=>{n.step(new Q(t.before(),t.after(),t.start(),t.end(),new m.Slice(m.Fragment.from(e.create(null,[r.schema.nodes.listItem.create(r.textblockAttrs.extractFromNode(t.parent))])),0,0),2))};class xf extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteListFeature",!e.bulletList&&!e.numberedList)throw new Error("RteListFeature requires at least one of bulletList or numberedList to be enabled")}getStyles(){return[this.contribution(bf)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:"inline*",attrs:e.attrs,defining:!0,parseDOM:[{tag:"li",getAttrs:t=>e.fromDOM(t)}],toDOM(t){return["li",...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ul"}],toDOM(){return["ul",0]}}}:{},...this.config.numberedList?{numberedList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ol"}],toDOM(){return["ol",0]}}}:{}}})]}getPlugins(e){this.rte=e;const t=(s,l)=>{const a=pn(s);if(a&&Sr(a)){const c=s.tr;return xl(_r(a).type,a,c),l?.(c.scrollIntoView()),!0}return!1},n=(s,l)=>{const a=pn(s);if(a&&Sr(a)&&kl(a)){const c=s.tr;return Ml(a,c),l?.(c.scrollIntoView()),!0}return!1},i=(s,l)=>{const a=pn(s);if(a&&yf(Sl(a))){const c=s.tr;return kr(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1},o=(s,l)=>{const a=pn(s);if(a&&Sr(a)){if(Tl(a,Et(a))&&Cl(a,Br(a))?.type===_r(a).type)return!1;const c=s.tr;return kr(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1};return[this.contribution(he({Enter:i,Backspace:o,Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),m.contributionPriority.high)]}getToolbarItems(e){const t=[];return this.config.bulletList&&t.push(this.contribution({section:"textblock",render:n=>V(n,{label:()=>n.rte.getLocale().richTextEditor.bulletList,icon:"bullet-list-2-line",active:()=>this.isSelectionInList(e.schema.nodes.bulletList,n.rte.state),onClick:()=>{const{state:i,dispatch:o}=n.view;this.toggleList(e.schema.nodes.bulletList)(i,o)}})},1)),this.config.numberedList&&t.push(this.contribution({section:"textblock",render:n=>V(n,{label:()=>n.rte.getLocale().richTextEditor.numberedList,icon:"list-numbered-line",active:()=>this.isSelectionInList(e.schema.nodes.numberedList,n.rte.state),onClick:()=>{const{state:i,dispatch:o}=n.view;this.toggleList(e.schema.nodes.numberedList)(i,o)}})},2)),t}toggleList(e){return bd((t,n)=>{const{$from:i,$to:o}=Po(t.selection);if(Lo(i,o).type.isInGroup("list"))if(zo(t,i,o,e)){const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{if(a.type===t.schema.nodes.listItem){const d=l.doc.resolve(l.mapping.map(c+1));kr(this.rte,d,l)}}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{a.type.isInGroup("list")&&a.type!==e&&l.setNodeMarkup(c,e,a.attrs)}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{if(!a.isTextblock)return;const d=l.doc.resolve(l.mapping.map(c+1));Cf(this.rte,e,d,l)}),n?.(l.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){const{$from:n,$to:i}=Po(t.selection);return Lo(n,i).type.isInGroup("list")?zo(t,n,i,e):!1}}const Of=m.featureFacade(xf),Bo=[{value:"left",icon:"align-left-line",label:"left"},{value:"center",icon:"align-center-line",label:"center"},{value:"right",icon:"align-right-line",label:"right"}];class Df extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteAlignmentFeature"}getTextblockAttrs(){return[this.contribution({name:"textAlign",default:"left",fromDOM(e){return e.style.textAlign||"left"},toStyles(e){return[`text-align: ${e.attrs.textAlign}`]}})]}getPlugins(){return[this.contribution(he({"Mod-L":this.setAlignment("left"),"Mod-E":this.setAlignment("center"),"Mod-R":this.setAlignment("right")}))]}getToolbarItems(){return[this.contribution({section:"textblock",render:e=>oi(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:V(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{const t=this.getAlignmentFromSelection(e.view.state);return Bo.find(n=>n.value===t)?.icon??"align-left-line"}}),children:[Ud(e,{children:Bo.map((t,n)=>V(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:"header",noTooltip:!0,autofocus:()=>{const i=this.getAlignmentFromSelection(e.view.state);return(i==="mixed"||i===null)&&n===0?!0:t.value===i},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{const{state:i,dispatch:o}=e.view;this.setAlignment(t.value)(i,o)}}))})]})},3)]}getAlignmentFromSelection(e){const{selection:t}=e,{from:n,to:i}=t;let o=null;return e.doc.nodesBetween(n,i,s=>{o!=="mixed"&&s.type.isTextblock&&(o?o!==s.attrs.textAlign&&(o="mixed"):o=s.attrs.textAlign)}),o}setAlignment(e){return(t,n)=>{const{tr:i,selection:o}=t,{from:s,to:l}=o;return t.doc.nodesBetween(s,l,(a,c)=>{a.type.isTextblock&&i.setNodeMarkup(c,a.type,{...a.attrs,textAlign:e})}),n?.(i.scrollIntoView()),!0}}}const Nf=m.featureFacade(Df),Ef=".inline-image-wrapper{display:inline-block;vertical-align:text-bottom}.inline-image{display:block;block-size:auto}.inline-image-popover{display:flex;align-items:center;padding:8px;gap:4px}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}",_o=r=>r!==null&&!!r.next;let wf=1;const Af=()=>wf++;class vf{constructor(e,t,n,i){this.view=t,this.getPos=n,this.config=i,this.content=null,this.dom=document.createElement("div"),this.dom.className="inline-image-wrapper",this.img=document.createElement("img"),this.initializeImg(e);const o=this.config.resolveUrl?this.config.resolveUrl(e.attrs.imageUrl):e.attrs.imageUrl,s=_o(o)?null:o;this.handleResolvedUrl(s),_o(o)&&this.handleResolvedUrlGenerator(o)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),Ee.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){const t=e[Symbol.asyncIterator]();let n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e=="string")this.renderImg(e);else if(e?.type==="placeholder"){const t=`inline-image-placeholder-${Af()}`,n=document.createElement("slot");n.className="inline-image-placeholder",n.name=t;const i=e.create(t);this.setContent(n,{onDestroy:i})}else this.setContent(null)}initializeImg(e){this.img.className="inline-image",this.update(e),this.img.addEventListener("load",()=>{const t=this.getPos?.();if(t){const{state:n,dispatch:i}=this.view,o=n.doc.nodeAt(t);if(!o||o.attrs.naturalWidth===this.img.naturalWidth&&o.attrs.naturalHeight===this.img.naturalHeight)return;const s=n.tr;s.setNodeAttribute(t,"naturalWidth",this.img.naturalWidth),s.setNodeAttribute(t,"naturalHeight",this.img.naturalHeight),s.setMeta("addToHistory",!1),i(s)}})}renderImg(e){this.img.src=e,this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}}class If extends m.RteFeatureImpl{constructor(e={}){super(),this.config=e,this.name="RteInlineImageFeature"}getStyles(){return[this.contribution(Ef)]}getSchema(){const e={inline:!0,group:"inline",selectable:!0,atom:!0,attrs:{imageUrl:{validate:"string"},alt:{validate:"string",default:""},size:{validate:"string|null",default:null},naturalWidth:{validate:"number|null",default:null},naturalHeight:{validate:"number|null",default:null}},parseDOM:[{tag:"img[src]",getAttrs:t=>{const n=s=>{const l=parseInt(s??"",10);return isNaN(l)?null:l},i=t.getAttribute("src"),o=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(i):i;return o===null?!1:{imageUrl:o,alt:t.getAttribute("alt")||"",size:t.style.maxWidth||null,naturalWidth:n(t.getAttribute("width")),naturalHeight:n(t.getAttribute("height"))}}}],toDOM:t=>{const{imageUrl:n,alt:i,size:o,naturalWidth:s,naturalHeight:l}=t.attrs,a=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(n):n;if(a===null)return document.createTextNode("");const c={src:a,alt:i};return o&&(c.style=`max-width: ${o}; height: auto;`),s&&(c.width=s),l&&(c.height=l),["img",c]}};return[this.contribution({nodes:{inlineImage:e}})]}getPlugins(e){return[this.contribution(new re({props:{nodeViews:{inlineImage:(t,n,i)=>new vf(t,n,i,this.config)}},view:t=>{const n=new ii(t,e,{popupPlacement:"bottom"}),i=e.createComponent(Ee);i.offset=4;const o=Ce(n,{className:"inline-image-popover",children:[V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="small",onClick:()=>{this.setSelectedImageSize("small")(n.view.state,n.view.dispatch)}}),Fr(n),V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="fit",onClick:()=>{this.setSelectedImageSize("fit")(n.view.state,n.view.dispatch)}}),Fr(n),V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="original",onClick:()=>{this.setSelectedImageSize("original")(n.view.state,n.view.dispatch)}})]});return i.appendChild(o),t.dom.getRootNode().querySelector(".popovers").appendChild(i),{update:s=>{n.updateBindings();const l=this.getSelectedInlineImage(s.state);l?(i.anchorEl=s.nodeDOM(l.pos),i.requestOpenState(!0)):(i.anchorEl=void 0,i.requestOpenState(!1))},destroy:()=>{i.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+"px"}getSelectedInlineImage(e){const t=e.selection;return t instanceof M&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{const i=this.getSelectedInlineImage(t);if(!i)return!1;const{naturalWidth:o}=i.node.attrs;if(e==="small"&&o===null)return!1;const s=t.tr;return s.setNodeAttribute(i.pos,"size",e==="small"?this.calculateSmallWidth(o):e==="fit"?"100%":null),n?.(s.scrollIntoView()),!0}}getSelectedImageSize(e){const t=this.getSelectedInlineImage(e);if(!t)return null;const{size:n,naturalWidth:i}=t.node.attrs;return i!==null&&n===this.calculateSmallWidth(i)?"small":n==="100%"?"fit":n===null?"original":null}}const Rf=m.featureFacade(If),Ff=async r=>{try{return{type:"ok",result:await r}}catch(e){return{type:"error",error:e}}};class Pf extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteFileHandlerFeature"}getPlugins(e){const t=new re({state:{init(){return v.empty},apply(a,c){c=c.map(a.mapping,a.doc);const d=a.getMeta(t);if(d&&d.add){const u=document.createElement("placeholder"),f=Z.widget(d.add.pos,u,{id:d.add.id,relaxedSide:!0});c=c.add(a.doc,[f])}else d&&d.remove&&(c=c.remove(c.find(void 0,void 0,u=>u.id==d.remove.id)));return c}},props:{decorations(a){return this.getState(a)}}}),n=(a,c)=>{const d=Vl.generateRandomId();return a.setMeta(t,{add:{id:d,pos:c}}),{getPos:u=>{const h=t.getState(u).find(void 0,void 0,p=>p.id==d);return h.length?h[0].from:null},remove:u=>{u.setMeta(t,{remove:{id:d}})}}},i=(a,c,d)=>{if(d.type==="selection"){const u=m.Slice.fromJSON(e.schema,{content:c});a.replaceSelection(u)}else{const u=m.Fragment.fromJSON(e.schema,c);a.insert(d.pos,u)}},o=(a,c)=>{const d=this.config.handleFiles(a);d!==null&&(d instanceof Promise?l(d,c):s(d,c))},s=(a,c)=>{const d=e.state.tr;i(d,a,c),e.dispatchTransaction(d)},l=async(a,c)=>{const d=e.state.tr;c.type==="selection"&&!d.selection.empty&&d.deleteSelection();const u=c.type==="selection"?d.selection.from:c.pos,f=n(d,u);e.dispatchTransaction(d);const h=await Ff(a),p=f.getPos(e.state),b=e.state.tr;f.remove(b),p!==null&&h.type==="ok"&&i(b,h.result,{type:"pos",pos:p}),e.dispatchTransaction(b),h.type==="error"&&console.error("Error in handleFiles handler:",h.error)};return[this.contribution(t),this.contribution(new re({props:{handlePaste:(a,c)=>{const d=Array.from(c.clipboardData.files);return d.length?(o(d,{type:"selection"}),!0):!1},handleDrop:(a,c,d,u)=>{const f=Array.from(c.dataTransfer.files);if(!f.length)return!1;let h=a.posAtCoords({left:c.clientX,top:c.clientY}).pos;if(a.dragging&&a.dragging.slice){const p=$r(a.state.doc,h,a.dragging.slice);p!=null&&(h=p)}return o(f,{type:"pos",pos:h}),!0}}}))]}}const Lf=m.featureFacade(Pf);class zf extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteDebugFeature"}getPlugins(e){const t=new WeakMap;let n=!1;const i=d=>{t.get(d)===void 0&&(n=this.config.onViewportDragOver?.(d)??!1)},o=d=>{this.config.onViewportDrop?.(d),this.config.onViewportDragFinish?.()},s=()=>{this.config.onViewportDragFinish?.()};let l=!1;const a=()=>{l=!0,window.setTimeout(()=>l=!1,0)},c=()=>{l||this.config.onViewportDragFinish?.()};return[this.contribution(new re({view:d=>{const u=d.root.host.editorViewportElement;return u.addEventListener("dragover",i),u.addEventListener("drop",o),u.addEventListener("dragend",s),u.addEventListener("dragenter",a),u.addEventListener("dragleave",c),{destroy(){u.removeEventListener("dragover",i),u.removeEventListener("drop",o),u.removeEventListener("dragend",s),u.removeEventListener("dragenter",a),u.removeEventListener("dragleave",c)}}}})),this.contribution(new re({props:{handleDOMEvents:{dragover:(d,u)=>{const f=this.config.onViewportDragOver?.(u)??!1;return t.set(u,f),n=f,f?(u.stopImmediatePropagation(),u.preventDefault(),!0):!1},drop:(d,u)=>n}}}),m.contributionPriority.high)]}}const Bf=m.featureFacade(zf),_f=ce.defineVividComponent("rich-text-editor",yl,zu,[Bl.dividerDefinition,Vo.selectDefinition,Ho.listboxOptionDefinition,Ko.buttonDefinition,Wo.tooltipDefinition,Uo.menuDefinition,$o.menuItemDefinition,qo.textFieldDefinition,tu],{styles:Hl,shadowOptions:{delegatesFocus:!0}}),Vf=ce.createRegisterFunction(_f);Vf();exports.RteAlignmentFeature=Nf;exports.RteBase=Xd;exports.RteBoldFeature=rf;exports.RteConfig=lu;exports.RteDropHandlerFeature=Bf;exports.RteFileHandlerFeature=Lf;exports.RteFontSizePickerFeature=Ku;exports.RteHardBreakFeature=$u;exports.RteHtmlParser=ml;exports.RteHtmlSerializer=gl;exports.RteInlineImageFeature=Rf;exports.RteItalicFeature=sf;exports.RteLinkFeature=ru;exports.RteListFeature=Of;exports.RteMonospaceFeature=hf;exports.RtePlaceholderFeature=Wu;exports.RteStrikethroughFeature=df;exports.RteTextBlockPickerFeature=_u;exports.RteTextColorPickerFeature=gf;exports.RteToolbarFeature=ou;exports.RteUnderlineFeature=af;
|