@nextblock-cms/editor 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.css +1 -0
  2. package/index.js +532 -0
  3. package/index.mjs +39717 -0
  4. package/package.json +7 -0
package/index.js ADDED
@@ -0,0 +1,532 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const C=require("react"),vd=require("react-dom"),$e=require("@nextblock-cms/utils"),vt=require("@nextblock-cms/ui/popover"),ce=require("@nextblock-cms/ui/button"),ps=require("@nextblock-cms/ui/input"),Jt=require("@nextblock-cms/ui/separator"),Ke=require("@nextblock-cms/ui/dropdown-menu"),ft=require("@nextblock-cms/ui/card"),Jw=require("@nextblock-cms/ui/badge");function cg(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const ne=cg(C),Yw=cg(vd);function ug(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Ai={exports:{}},Js={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var af;function Xw(){if(af)return Js;af=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,o){var i=null;if(o!==void 0&&(i=""+o),s.key!==void 0&&(i=""+s.key),"key"in s){o={};for(var l in s)l!=="key"&&(o[l]=s[l])}else o=s;return s=o.ref,{$$typeof:t,type:r,key:i,ref:s!==void 0?s:null,props:o}}return Js.Fragment=e,Js.jsx=n,Js.jsxs=n,Js}var Ys={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var cf;function Zw(){return cf||(cf=1,process.env.NODE_ENV!=="production"&&(function(){function t(A){if(A==null)return null;if(typeof A=="function")return A.$$typeof===F?null:A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case w:return"Fragment";case M:return"Portal";case k:return"Profiler";case T:return"StrictMode";case P:return"Suspense";case L:return"SuspenseList"}if(typeof A=="object")switch(typeof A.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),A.$$typeof){case R:return(A.displayName||"Context")+".Provider";case N:return(A._context.displayName||"Context")+".Consumer";case B:var W=A.render;return A=A.displayName,A||(A=W.displayName||W.name||"",A=A!==""?"ForwardRef("+A+")":"ForwardRef"),A;case H:return W=A.displayName||null,W!==null?W:t(A.type)||"Memo";case se:W=A._payload,A=A._init;try{return t(A(W))}catch{}}return null}function e(A){return""+A}function n(A){try{e(A);var W=!1}catch{W=!0}if(W){W=console;var V=W.error,ue=typeof Symbol=="function"&&Symbol.toStringTag&&A[Symbol.toStringTag]||A.constructor.name||"Object";return V.call(W,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",ue),e(A)}}function r(){}function s(){if(Cn===0){Cr=console.log,pi=console.info,mi=console.warn,gi=console.error,oc=console.group,Er=console.groupCollapsed,yi=console.groupEnd;var A={configurable:!0,enumerable:!0,value:r,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}Cn++}function o(){if(Cn--,Cn===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Te({},A,{value:Cr}),info:Te({},A,{value:pi}),warn:Te({},A,{value:mi}),error:Te({},A,{value:gi}),group:Te({},A,{value:oc}),groupCollapsed:Te({},A,{value:Er}),groupEnd:Te({},A,{value:yi})})}0>Cn&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function i(A){if(Vs===void 0)try{throw Error()}catch(V){var W=V.stack.trim().match(/\n( *(at )?)/);Vs=W&&W[1]||"",bi=-1<V.stack.indexOf(`
18
+ at`)?" (<anonymous>)":-1<V.stack.indexOf("@")?"@unknown:0:0":""}return`
19
+ `+Vs+A+bi}function l(A,W){if(!A||Ws)return"";var V=qs.get(A);if(V!==void 0)return V;Ws=!0,V=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var ue=null;ue=le.H,le.H=null,s();try{var Xe={DetermineComponentFrameRoot:function(){try{if(W){var un=function(){throw Error()};if(Object.defineProperty(un.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(un,[])}catch(Kt){var Ar=Kt}Reflect.construct(A,[],un)}else{try{un.call()}catch(Kt){Ar=Kt}A.call(un.prototype)}}else{try{throw Error()}catch(Kt){Ar=Kt}(un=A())&&typeof un.catch=="function"&&un.catch(function(){})}}catch(Kt){if(Kt&&Ar&&typeof Kt.stack=="string")return[Kt.stack,Ar.stack]}return[null,null]}};Xe.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var ve=Object.getOwnPropertyDescriptor(Xe.DetermineComponentFrameRoot,"name");ve&&ve.configurable&&Object.defineProperty(Xe.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var te=Xe.DetermineComponentFrameRoot(),Ht=te[0],Wn=te[1];if(Ht&&Wn){var ot=Ht.split(`
20
+ `),En=Wn.split(`
21
+ `);for(te=ve=0;ve<ot.length&&!ot[ve].includes("DetermineComponentFrameRoot");)ve++;for(;te<En.length&&!En[te].includes("DetermineComponentFrameRoot");)te++;if(ve===ot.length||te===En.length)for(ve=ot.length-1,te=En.length-1;1<=ve&&0<=te&&ot[ve]!==En[te];)te--;for(;1<=ve&&0<=te;ve--,te--)if(ot[ve]!==En[te]){if(ve!==1||te!==1)do if(ve--,te--,0>te||ot[ve]!==En[te]){var Mr=`
22
+ `+ot[ve].replace(" at new "," at ");return A.displayName&&Mr.includes("<anonymous>")&&(Mr=Mr.replace("<anonymous>",A.displayName)),typeof A=="function"&&qs.set(A,Mr),Mr}while(1<=ve&&0<=te);break}}}finally{Ws=!1,le.H=ue,o(),Error.prepareStackTrace=V}return ot=(ot=A?A.displayName||A.name:"")?i(ot):"",typeof A=="function"&&qs.set(A,ot),ot}function a(A){if(A==null)return"";if(typeof A=="function"){var W=A.prototype;return l(A,!(!W||!W.isReactComponent))}if(typeof A=="string")return i(A);switch(A){case P:return i("Suspense");case L:return i("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case B:return A=l(A.render,!1),A;case H:return a(A.type);case se:W=A._payload,A=A._init;try{return a(A(W))}catch{}}return""}function c(){var A=le.A;return A===null?null:A.getOwner()}function u(A){if(Se.call(A,"key")){var W=Object.getOwnPropertyDescriptor(A,"key").get;if(W&&W.isReactWarning)return!1}return A.key!==void 0}function d(A,W){function V(){xi||(xi=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",W))}V.isReactWarning=!0,Object.defineProperty(A,"key",{get:V,configurable:!0})}function h(){var A=t(this.type);return wi[A]||(wi[A]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),A=this.props.ref,A!==void 0?A:null}function f(A,W,V,ue,Xe,ve){return V=ve.ref,A={$$typeof:S,type:A,key:W,props:ve,_owner:Xe},(V!==void 0?V:null)!==null?Object.defineProperty(A,"ref",{enumerable:!1,get:h}):Object.defineProperty(A,"ref",{enumerable:!1,value:null}),A._store={},Object.defineProperty(A._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(A,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(A.props),Object.freeze(A)),A}function p(A,W,V,ue,Xe,ve){if(typeof A=="string"||typeof A=="function"||A===w||A===k||A===T||A===P||A===L||A===oe||typeof A=="object"&&A!==null&&(A.$$typeof===se||A.$$typeof===H||A.$$typeof===R||A.$$typeof===N||A.$$typeof===B||A.$$typeof===Mt||A.getModuleId!==void 0)){var te=W.children;if(te!==void 0)if(ue)if(dt(te)){for(ue=0;ue<te.length;ue++)g(te[ue],A);Object.freeze&&Object.freeze(te)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else g(te,A)}else te="",(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(te+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),A===null?ue="null":dt(A)?ue="array":A!==void 0&&A.$$typeof===S?(ue="<"+(t(A.type)||"Unknown")+" />",te=" Did you accidentally export a JSX literal instead of a component?"):ue=typeof A,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ue,te);if(Se.call(W,"key")){te=t(A);var Ht=Object.keys(W).filter(function(ot){return ot!=="key"});ue=0<Ht.length?"{key: someKey, "+Ht.join(": ..., ")+": ...}":"{key: someKey}",vi[te+ue]||(Ht=0<Ht.length?"{"+Ht.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
23
+ let props = %s;
24
+ <%s {...props} />
25
+ React keys must be passed directly to JSX without using spread:
26
+ let props = %s;
27
+ <%s key={someKey} {...props} />`,ue,te,Ht,te),vi[te+ue]=!0)}if(te=null,V!==void 0&&(n(V),te=""+V),u(W)&&(n(W.key),te=""+W.key),"key"in W){V={};for(var Wn in W)Wn!=="key"&&(V[Wn]=W[Wn])}else V=W;return te&&d(V,typeof A=="function"?A.displayName||A.name||"Unknown":A),f(A,te,ve,Xe,c(),V)}function g(A,W){if(typeof A=="object"&&A&&A.$$typeof!==ic){if(dt(A))for(var V=0;V<A.length;V++){var ue=A[V];y(ue)&&b(ue,W)}else if(y(A))A._store&&(A._store.validated=1);else if(A===null||typeof A!="object"?V=null:(V=we&&A[we]||A["@@iterator"],V=typeof V=="function"?V:null),typeof V=="function"&&V!==A.entries&&(V=V.call(A),V!==A))for(;!(A=V.next()).done;)y(A.value)&&b(A.value,W)}}function y(A){return typeof A=="object"&&A!==null&&A.$$typeof===S}function b(A,W){if(A._store&&!A._store.validated&&A.key==null&&(A._store.validated=1,W=x(W),!Ks[W])){Ks[W]=!0;var V="";A&&A._owner!=null&&A._owner!==c()&&(V=null,typeof A._owner.tag=="number"?V=t(A._owner.type):typeof A._owner.name=="string"&&(V=A._owner.name),V=" It was passed a child from "+V+".");var ue=le.getCurrentStack;le.getCurrentStack=function(){var Xe=a(A.type);return ue&&(Xe+=ue()||""),Xe},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',W,V),le.getCurrentStack=ue}}function x(A){var W="",V=c();return V&&(V=t(V.type))&&(W=`
28
+
29
+ Check the render method of \``+V+"`."),W||(A=t(A))&&(W=`
30
+
31
+ Check the top-level render call using <`+A+">."),W}var E=C,S=Symbol.for("react.transitional.element"),M=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),R=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),H=Symbol.for("react.memo"),se=Symbol.for("react.lazy"),oe=Symbol.for("react.offscreen"),we=Symbol.iterator,F=Symbol.for("react.client.reference"),le=E.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Se=Object.prototype.hasOwnProperty,Te=Object.assign,Mt=Symbol.for("react.client.reference"),dt=Array.isArray,Cn=0,Cr,pi,mi,gi,oc,Er,yi;r.__reactDisabledLog=!0;var Vs,bi,Ws=!1,qs=new(typeof WeakMap=="function"?WeakMap:Map),ic=Symbol.for("react.client.reference"),xi,wi={},vi={},Ks={};Ys.Fragment=w,Ys.jsx=function(A,W,V,ue,Xe){return p(A,W,V,!1,ue,Xe)},Ys.jsxs=function(A,W,V,ue,Xe){return p(A,W,V,!0,ue,Xe)}})()),Ys}var uf;function Qw(){return uf||(uf=1,process.env.NODE_ENV==="production"?Ai.exports=Xw():Ai.exports=Zw()),Ai.exports}var m=Qw(),Ti={exports:{}},pc={};/**
32
+ * @license React
33
+ * use-sync-external-store-shim.production.js
34
+ *
35
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */var df;function e1(){if(df)return pc;df=1;var t=C;function e(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,o=t.useLayoutEffect,i=t.useDebugValue;function l(d,h){var f=h(),p=r({inst:{value:f,getSnapshot:h}}),g=p[0].inst,y=p[1];return o(function(){g.value=f,g.getSnapshot=h,a(g)&&y({inst:g})},[d,f,h]),s(function(){return a(g)&&y({inst:g}),d(function(){a(g)&&y({inst:g})})},[d]),i(f),f}function a(d){var h=d.getSnapshot;d=d.value;try{var f=h();return!n(d,f)}catch{return!0}}function c(d,h){return h()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:l;return pc.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:u,pc}var mc={};/**
40
+ * @license React
41
+ * use-sync-external-store-shim.development.js
42
+ *
43
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
44
+ *
45
+ * This source code is licensed under the MIT license found in the
46
+ * LICENSE file in the root directory of this source tree.
47
+ */var hf;function t1(){return hf||(hf=1,process.env.NODE_ENV!=="production"&&(function(){function t(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}function e(f,p){u||s.startTransition===void 0||(u=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=p();if(!d){var y=p();o(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=i({inst:{value:g,getSnapshot:p}});var b=y[0].inst,x=y[1];return a(function(){b.value=g,b.getSnapshot=p,n(b)&&x({inst:b})},[f,g,p]),l(function(){return n(b)&&x({inst:b}),f(function(){n(b)&&x({inst:b})})},[f]),c(g),g}function n(f){var p=f.getSnapshot;f=f.value;try{var g=p();return!o(f,g)}catch{return!0}}function r(f,p){return p()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=C,o=typeof Object.is=="function"?Object.is:t,i=s.useState,l=s.useEffect,a=s.useLayoutEffect,c=s.useDebugValue,u=!1,d=!1,h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:e;mc.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:h,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),mc}var ff;function kd(){return ff||(ff=1,process.env.NODE_ENV==="production"?Ti.exports=e1():Ti.exports=t1()),Ti.exports}var dg=kd();function lt(t){this.content=t}lt.prototype={constructor:lt,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,s=r.find(t),o=r.content.slice();return s==-1?o.push(n||t,e):(o[s+1]=e,n&&(o[s]=n)),new lt(o)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new lt(n)},addToStart:function(t,e){return new lt([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new lt(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),o=r.find(t);return s.splice(o==-1?s.length:o,0,e,n),new lt(s)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=lt.from(t),t.size?new lt(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=lt.from(t),t.size?new lt(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=lt.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};lt.from=function(t){if(t instanceof lt)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new lt(e)};function hg(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let s=t.child(r),o=e.child(r);if(s==o){n+=s.nodeSize;continue}if(!s.sameMarkup(o))return n;if(s.isText&&s.text!=o.text){for(let i=0;s.text[i]==o.text[i];i++)n++;return n}if(s.content.size||o.content.size){let i=hg(s.content,o.content,n+1);if(i!=null)return i}n+=s.nodeSize}}function fg(t,e,n,r){for(let s=t.childCount,o=e.childCount;;){if(s==0||o==0)return s==o?null:{a:n,b:r};let i=t.child(--s),l=e.child(--o),a=i.nodeSize;if(i==l){n-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:n,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,n--,r--;return{a:n,b:r}}if(i.content.size||l.content.size){let c=fg(i.content,l.content,n-1,r-1);if(c)return c}n-=a,r-=a}}class O{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,s=0,o){for(let i=0,l=0;l<n;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,s+l,o||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,n-u),r,s+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let o="",i=!0;return this.nodesBetween(e,n,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?s?typeof s=="function"?s(l):s:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:o+=r),o+=c},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)s.push(e.content[o]);return new O(s,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],s=0;if(n>e)for(let o=0,i=0;i<n;o++){let l=this.content[o],a=i+l.nodeSize;a>e&&((i<e||a>n)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,n-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,n-i-1))),r.push(l),s+=l.nodeSize),i=a}return new O(r,s)}cutByIndex(e,n){return e==n?O.empty:e==0&&n==this.content.length?this:new O(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new O(s,o)}addToStart(e){return new O([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new O(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))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 n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let s=this.content[n];e(s,r,n),r+=s.nodeSize}}findDiffStart(e,n=0){return hg(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return fg(this,e,n,r)}findIndex(e){if(e==0)return Ni(0,e);if(e==this.size)return Ni(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let s=this.child(n),o=r+s.nodeSize;if(o>=e)return o==e?Ni(n+1,o):Ni(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return O.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new O(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return O.empty;let n,r=0;for(let s=0;s<e.length;s++){let o=e[s];r+=o.nodeSize,s&&o.isText&&e[s-1].sameMarkup(o)?(n||(n=e.slice(0,s)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new O(n||e,r)}static from(e){if(!e)return O.empty;if(e instanceof O)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new O([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}O.empty=new O([],0);const gc={index:0,offset:0};function Ni(t,e){return gc.index=t,gc.offset=e,gc}function ml(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ml(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ml(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ae=class au{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let o=e[s];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,s));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ml(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let s=r.create(n.attrs);return r.checkAttrs(s.attrs),s}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return au.none;if(e instanceof au)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};Ae.none=[];class gl extends Error{}class j{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=mg(this.content,e+this.openStart,n);return r&&new j(r,this.openStart,this.openEnd)}removeBetween(e,n){return new j(pg(this.content,e+this.openStart,n+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,n){if(!n)return j.empty;let r=n.openStart||0,s=n.openEnd||0;if(typeof r!="number"||typeof s!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new j(O.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)s++;return new j(e,r,s)}}j.empty=new j(O.empty,0,0);function pg(t,e,n){let{index:r,offset:s}=t.findIndex(e),o=t.maybeChild(r),{index:i,offset:l}=t.findIndex(n);if(s==e||o.isText){if(l!=n&&!t.child(i).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=i)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(pg(o.content,e-s-1,n-s-1)))}function mg(t,e,n,r){let{index:s,offset:o}=t.findIndex(e),i=t.maybeChild(s);if(o==e||i.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=mg(i.content,e-o-1,n,i);return l&&t.replaceChild(s,i.copy(l))}function n1(t,e,n){if(n.openStart>t.depth)throw new gl("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new gl("Inconsistent open depths");return gg(t,e,n,0)}function gg(t,e,n,r){let s=t.index(r),o=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let i=gg(t,e,n,r+1);return o.copy(o.content.replaceChild(s,i))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let i=t.parent,l=i.content;return Pr(i,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=r1(n,t);return Pr(o,bg(t,i,l,e,r))}else return Pr(o,yl(t,e,r))}function yg(t,e){if(!e.type.compatibleContent(t.type))throw new gl("Cannot join "+e.type.name+" onto "+t.type.name)}function cu(t,e,n){let r=t.node(n);return yg(r,e.node(n)),r}function jr(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function oo(t,e,n,r){let s=(e||t).node(n),o=0,i=e?e.index(n):s.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(jr(t.nodeAfter,r),o++));for(let l=o;l<i;l++)jr(s.child(l),r);e&&e.depth==n&&e.textOffset&&jr(e.nodeBefore,r)}function Pr(t,e){return t.type.checkContent(e),t.copy(e)}function bg(t,e,n,r,s){let o=t.depth>s&&cu(t,e,s+1),i=r.depth>s&&cu(n,r,s+1),l=[];return oo(null,t,s,l),o&&i&&e.index(s)==n.index(s)?(yg(o,i),jr(Pr(o,bg(t,e,n,r,s+1)),l)):(o&&jr(Pr(o,yl(t,e,s+1)),l),oo(e,n,s,l),i&&jr(Pr(i,yl(n,r,s+1)),l)),oo(r,null,s,l),new O(l)}function yl(t,e,n){let r=[];if(oo(null,t,n,r),t.depth>n){let s=cu(t,e,n+1);jr(Pr(s,yl(t,e,n+1)),r)}return oo(e,null,n,r),new O(r)}function r1(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)s=e.node(o).copy(O.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class vo{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],s=e.child(n);return r?e.child(n).cut(r):s}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],s=n==0?0:this.path[n*3-1]+1;for(let o=0;o<e;o++)s+=r.child(o).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Ae.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let l=r;r=s,s=l}let o=r.marks;for(var i=0;i<o.length;i++)o[i].type.spec.inclusive===!1&&(!s||!o[i].isInSet(s.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,s=e.parent.maybeChild(e.index());for(var o=0;o<r.length;o++)r[o].type.spec.inclusive===!1&&(!s||!r[o].isInSet(s.marks))&&(r=r[o--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new ko(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],s=0,o=n;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(o),c=o-a;if(r.push(i,l,s+a),!c||(i=i.child(l),i.isText))break;o=c-1,s+=a+1}return new vo(n,r,o)}static resolveCached(e,n){let r=pf.get(e);if(r)for(let o=0;o<r.elts.length;o++){let i=r.elts[o];if(i.pos==n)return i}else pf.set(e,r=new s1);let s=r.elts[r.i]=vo.resolve(e,n);return r.i=(r.i+1)%o1,s}}class s1{constructor(){this.elts=[],this.i=0}}const o1=12,pf=new WeakMap;class ko{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const i1=Object.create(null);let cr=class uu{constructor(e,n,r,s=Ae.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||O.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,n,r,s=0){this.content.nodesBetween(e,n,r,s,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,s){return this.content.textBetween(e,n,r,s)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&ml(this.attrs,n||e.defaultAttrs||i1)&&Ae.sameSet(this.marks,r||Ae.none)}copy(e=null){return e==this.content?this:new uu(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new uu(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return j.empty;let s=this.resolve(e),o=this.resolve(n),i=r?0:s.sharedDepth(n),l=s.start(i),c=s.node(i).content.cut(s.pos-l,o.pos-l);return new j(c,s.depth-i,o.depth-i)}replace(e,n,r){return n1(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:s}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(s==e||n.isText)return n;e-=s+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let s=this.content.child(n-1);return{node:s,index:n-1,offset:r-s.nodeSize}}resolve(e){return vo.resolveCached(this,e)}resolveNoCache(e){return vo.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(s=!0),!s)),s}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),xg(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=O.empty,s=0,o=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,s,o),l=i&&i.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=s;a<o;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let o=this.contentMatchAt(e).matchType(r),i=o&&o.matchFragment(this.content,n);return i?i.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=Ae.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!Ae.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let s=O.fromJSON(e,n.content),o=e.nodeType(n.type).create(n.attrs,s,r);return o.type.checkAttrs(o.attrs),o}};cr.prototype.text=void 0;class bl extends cr{constructor(e,n,r,s){if(super(e,n,null,s),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):xg(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new bl(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new bl(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function xg(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ur{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new l1(e,n);if(r.next==null)return Ur.empty;let s=wg(r);r.next&&r.err("Unexpected trailing text");let o=p1(f1(s));return m1(o,r),o}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let s=this;for(let o=n;s&&o<r;o++)s=s.matchType(e.child(o).type);return s}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let s=[this];function o(i,l){let a=i.matchFragment(e,r);if(a&&(!n||a.validEnd))return O.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:d}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&s.indexOf(d)==-1){s.push(d);let h=o(d,l.concat(u));if(h)return h}}return null}return o(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let s=r.shift(),o=s.match;if(o.matchType(e)){let i=[];for(let l=s;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<o.next.length;i++){let{type:l,next:a}=o.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!s.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:s}),n[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 n(r){e.push(r);for(let s=0;s<r.next.length;s++)e.indexOf(r.next[s].next)==-1&&n(r.next[s].next)}return n(this),e.map((r,s)=>{let o=s+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)o+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return o}).join(`
48
+ `)}}Ur.empty=new Ur(!0);class l1{constructor(e,n){this.string=e,this.nodeTypes=n,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 wg(t){let e=[];do e.push(a1(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function a1(t){let e=[];do e.push(c1(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function c1(t){let e=h1(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=u1(t,e);else break;return e}function mf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function u1(t,e){let n=mf(t),r=n;return t.eat(",")&&(t.next!="}"?r=mf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function d1(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let o in n){let i=n[o];i.isInGroup(e)&&s.push(i)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function h1(t){if(t.eat("(")){let e=wg(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=d1(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function f1(t){let e=[[]];return s(o(t,0),n()),e;function n(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function s(i,l){i.forEach(a=>a.to=l)}function o(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(o(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=o(i.exprs[a],l);if(a==i.exprs.length-1)return c;s(c,l=n())}else if(i.type=="star"){let a=n();return r(l,a),s(o(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=n();return s(o(i.expr,l),a),s(o(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(o(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=n();s(o(i.expr,a),u),a=u}if(i.max==-1)s(o(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=n();r(a,u),s(o(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function vg(t,e){return e-t}function gf(t,e){let n=[];return r(e),n.sort(vg);function r(s){let o=t[s];if(o.length==1&&!o[0].term)return r(o[0].to);n.push(s);for(let i=0;i<o.length;i++){let{term:l,to:a}=o[i];!l&&n.indexOf(a)==-1&&r(a)}}}function p1(t){let e=Object.create(null);return n(gf(t,0));function n(r){let s=[];r.forEach(i=>{t[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<s.length;u++)s[u][0]==l&&(c=s[u][1]);gf(t,a).forEach(u=>{c||s.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let o=e[r.join(",")]=new Ur(r.indexOf(t.length-1)>-1);for(let i=0;i<s.length;i++){let l=s[i][1].sort(vg);o.next.push({type:s[i][0],next:e[l.join(",")]||n(l)})}return o}}function m1(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],o=!s.validEnd,i=[];for(let l=0;l<s.next.length;l++){let{type:a,next:c}=s.next[l];i.push(a.name),o&&!(a.isText||a.hasRequiredAttrs())&&(o=!1),r.indexOf(c)==-1&&r.push(c)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function kg(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function Sg(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let o=t[r];if(o.hasDefault)s=o.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function Cg(t,e,n,r){for(let s in e)if(!(s in t))throw new RangeError(`Unsupported attribute ${s} for ${n} of type ${s}`);for(let s in t){let o=t[s];o.validate&&o.validate(e[s])}}function Eg(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new y1(t,r,e[r]);return n}let yf=class Mg{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Eg(e,r.attrs),this.defaultAttrs=kg(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ur.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:Sg(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new cr(this,this.computeAttrs(e),O.from(n),Ae.setFrom(r))}createChecked(e=null,n,r){return n=O.from(n),this.checkContent(n),new cr(this,this.computeAttrs(e),n,Ae.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=O.from(n),n.size){let i=this.contentMatch.fillBefore(n);if(!i)return null;n=i.append(n)}let s=this.contentMatch.matchFragment(n),o=s&&s.fillBefore(O.empty,!0);return o?new cr(this,e,n.append(o),Ae.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Cg(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 n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:Ae.none:e}static compile(e,n){let r=Object.create(null);e.forEach((o,i)=>r[o]=new Mg(o,n,i));let s=n.spec.topNode||"doc";if(!r[s])throw new RangeError("Schema is missing its top node type ('"+s+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function g1(t,e,n){let r=n.split("|");return s=>{let o=s===null?"null":typeof s;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}class y1{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?g1(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class wa{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=Eg(e,s.attrs),this.excluded=null;let o=kg(this.attrs);this.instance=o?new Ae(this,o):null}create(e=null){return!e&&this.instance?this.instance:new Ae(this,Sg(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((o,i)=>r[o]=new wa(o,s++,n,i)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Cg(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Ag{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let s in e)n[s]=e[s];n.nodes=lt.from(e.nodes),n.marks=lt.from(e.marks||{}),this.nodes=yf.compile(this.spec.nodes,this),this.marks=wa.compile(this.spec.marks,this);let r=Object.create(null);for(let s in this.nodes){if(s in this.marks)throw new RangeError(s+" can not be both a node and a mark");let o=this.nodes[s],i=o.spec.content||"",l=o.spec.marks;if(o.contentMatch=r[i]||(r[i]=Ur.parse(i,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!o.isInline||!o.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=o}o.markSet=l=="_"?null:l?bf(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let s in this.marks){let o=this.marks[s],i=o.spec.excludes;o.excluded=i==null?[o]:i==""?[]:bf(this,i.split(" "))}this.nodeFromJSON=s=>cr.fromJSON(this,s),this.markFromJSON=s=>Ae.fromJSON(this,s),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,s){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof yf){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(n,r,s)}text(e,n){let r=this.nodes.text;return new bl(r,r.defaultAttrs,e,Ae.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function bf(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],o=t.marks[s],i=o;if(o)n.push(o);else for(let l in t.marks){let a=t.marks[l];(s=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(s)>-1)&&n.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function b1(t){return t.tag!=null}function x1(t){return t.style!=null}let io=class du{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(b1(s))this.tags.push(s);else if(x1(s)){let o=/[^=]*/.exec(s.style)[0];r.indexOf(o)<0&&r.push(o),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let o=e.nodes[s.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new wf(this,n,!1);return r.addAll(e,Ae.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new wf(this,n,!0);return r.addAll(e,Ae.none,n.from,n.to),j.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let o=this.tags[s];if(k1(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let i=o.getAttrs(e);if(i===!1)continue;o.attrs=i||void 0}return o}}}matchStyle(e,n,r,s){for(let o=s?this.styles.indexOf(s)+1:0;o<this.styles.length;o++){let i=this.styles[o],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(i.getAttrs){let a=i.getAttrs(n);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let n=[];function r(s){let o=s.priority==null?50:s.priority,i=0;for(;i<n.length;i++){let l=n[i];if((l.priority==null?50:l.priority)<o)break}n.splice(i,0,s)}for(let s in e.marks){let o=e.marks[s].spec.parseDOM;o&&o.forEach(i=>{r(i=vf(i)),i.mark||i.ignore||i.clearMark||(i.mark=s)})}for(let s in e.nodes){let o=e.nodes[s].spec.parseDOM;o&&o.forEach(i=>{r(i=vf(i)),i.node||i.ignore||i.mark||(i.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new du(e,du.schemaRules(e)))}};const Tg={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},w1={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ng={ol:!0,ul:!0},So=1,hu=2,lo=4;function xf(t,e,n){return e!=null?(e?So:0)|(e==="full"?hu:0):t&&t.whitespace=="pre"?So|hu:n&~lo}class Ri{constructor(e,n,r,s,o,i){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=i,this.content=[],this.activeMarks=Ae.none,this.match=o||(i&lo?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(O.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,s;return(s=r.findWrapping(e.type))?(this.match=r,s):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&So)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-s[0].length))}}let n=O.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(O.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Tg.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class wf{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,o,i=xf(null,n.preserveWhitespace,0)|(r?lo:0);s?o=new Ri(s.type,s.attrs,Ae.none,!0,n.topMatch||s.type.contentMatch,i):r?o=new Ri(null,null,Ae.none,!0,null,i):o=new Ri(e.schema.topNodeType,null,Ae.none,!0,null,i),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,s=this.top,o=s.options&hu?"full":this.localPreserveWS||(s.options&So)>0;if(o==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o)o!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
49
+ `);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],l=e.previousSibling;(!i||l&&l.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,o=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Ng.hasOwnProperty(i)&&this.parser.normalizeLists&&v1(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:w1.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,n);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Tg.hasOwnProperty(i))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),c=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let d=a&&a.skip?n:this.readStyles(e,n);d&&this.addAll(e,d),c&&this.sync(o),this.needsBlock=u}else{let c=this.readStyles(e,n);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
50
+ `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let s=0;s<this.parser.matchedStyles.length;s++){let o=this.parser.matchedStyles[s],i=r.getPropertyValue(o);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(o,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?n=n.filter(c=>!a.clearMark(c)):n=n.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return n}addElementByRule(e,n,r,s){let o,i;if(n.node)if(i=this.parser.schema.nodes[n.node],i.isLeaf)this.insertNode(i.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,n.attrs||null,r,n.preserveWhitespace);a&&(o=!0,r=a)}else{let a=this.parser.schema.marks[n.mark];r=r.concat(a.create(n.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(s)this.addElement(e,r,s);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}o&&this.sync(l)&&this.open--}addAll(e,n,r,s){let o=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=s==null?null:e.childNodes[s];i!=l;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,n);this.findAtPoint(e,o)}findPlace(e,n,r){let s,o;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!s||s.length>c.length+l)&&(s=c,o=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!s)return null;this.sync(o);for(let i=0;i<s.length;i++)n=this.enterInner(s[i],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(n=this.enterInner(o,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let i=Ae.none;for(let l of s.concat(e.marks))(o.type?o.type.allowsMarkType(l.type):kf(l.type,e.type))&&(i=l.addToSet(i));return o.content.push(e.mark(i)),!0}return!1}enter(e,n,r,s){let o=this.findPlace(e.create(n),r,!1);return o&&(o=this.enterInner(e,n,r,!0,s)),o}enterInner(e,n,r,s=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=xf(e,o,i.options);i.options&lo&&i.content.length==0&&(l|=lo);let a=Ae.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):kf(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Ri(e,n,a,s,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=So)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let s=r.length-1;s>=0;s--)e+=r[s].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let s=0;s<this.find.length;s++)this.find[s].pos==null&&e.nodeType==1&&e.contains(this.find[s].node)&&n.compareDocumentPosition(this.find[s].node)&(r?2:4)&&(this.find[s].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,s=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(s?0:1),i=(l,a)=>{for(;l>=0;l--){let c=n[l];if(c==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&s?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function v1(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ng.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function k1(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function vf(t){let e={};for(let n in t)e[n]=t[n];return e}function kf(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let o=[],i=l=>{o.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||o.indexOf(u)<0&&i(u))return!0}};if(i(s.contentMatch))return!0}}class ts{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=yc(n).createDocumentFragment());let s=r,o=[];return e.forEach(i=>{if(o.length||i.marks.length){let l=0,a=0;for(;l<o.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(o[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<o.length;)s=o.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,n);u&&(o.push([c,s]),s.appendChild(u.dom),s=u.contentDOM||u.dom)}}s.appendChild(this.serializeNodeInner(i,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=el(yc(n),this.nodes[e.type.name](e),null,e.attrs);if(s){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,s)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let s=e.marks.length-1;s>=0;s--){let o=this.serializeMark(e.marks[s],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&el(yc(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return el(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ts(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Sf(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Sf(e.marks)}}function Sf(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function yc(t){return t.document||window.document}const Cf=new WeakMap;function S1(t){let e=Cf.get(t);return e===void 0&&Cf.set(t,e=C1(t)),e}function C1(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let s=0;s<r.length;s++)n(r[s]);else for(let s in r)n(r[s])}return n(t),e}function el(t,e,n,r){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let s=e[0],o;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=S1(r))&&o.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 i=s.indexOf(" ");i>0&&(n=s.slice(0,i),s=s.slice(i+1));let l,a=n?t.createElementNS(n,s):t.createElement(s),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let d in c)if(c[d]!=null){let h=d.indexOf(" ");h>0?a.setAttributeNS(d.slice(0,h),d.slice(h+1),c[d]):d=="style"&&a.style?a.style.cssText=c[d]:a.setAttribute(d,c[d])}}for(let d=u;d<e.length;d++){let h=e[d];if(h===0){if(d<e.length-1||d>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:f,contentDOM:p}=el(t,h,n,r);if(a.appendChild(f),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Rg=65535,_g=Math.pow(2,16);function E1(t,e){return t+e*_g}function Ef(t){return t&Rg}function M1(t){return(t-(t&Rg))/_g}const Og=1,Dg=2,tl=4,Lg=8;class fu{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Lg)>0}get deletedBefore(){return(this.delInfo&(Og|tl))>0}get deletedAfter(){return(this.delInfo&(Dg|tl))>0}get deletedAcross(){return(this.delInfo&tl)>0}}class jt{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&jt.empty)return jt.empty}recover(e){let n=0,r=Ef(e);if(!this.inverted)for(let s=0;s<r;s++)n+=this.ranges[s*3+2]-this.ranges[s*3+1];return this.ranges[r*3]+n+M1(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let s=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?s:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+i],d=a+c;if(e<=d){let h=c?e==a?-1:e==d?1:n:n,f=a+s+(h<0?0:u);if(r)return f;let p=e==(n<0?a:d)?null:E1(l/3,e-a),g=e==a?Dg:e==d?Og:tl;return(n<0?e!=a:e!=d)&&(g|=Lg),new fu(f,g,p)}s+=u-c}return r?e+s:new fu(e+s,0,null)}touches(e,n){let r=0,s=Ef(n),o=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==s*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,o=0;s<this.ranges.length;s+=3){let i=this.ranges[s],l=i-(this.inverted?o:0),a=i+(this.inverted?0:o),c=this.ranges[s+n],u=this.ranges[s+r];e(l,l+c,a,a+u),o+=u-c}}invert(){return new jt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?jt.empty:new jt(e<0?[0,-e,0]:[0,0,e])}}jt.empty=new jt([]);class Co{constructor(e,n,r=0,s=e?e.length:0){this.mirror=n,this.from=r,this.to=s,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Co(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let s=e.getMirror(n);this.appendMap(e._maps[n],s!=null&&s<n?r+s:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let s=e.getMirror(n);this.appendMap(e._maps[n].invert(),s!=null&&s>n?r-s-1:void 0)}}invert(){let e=new Co;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let s=0;for(let o=this.from;o<this.to;o++){let i=this._maps[o],l=i.mapResult(e,n);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}}s|=l.delInfo,e=l.pos}return r?e:new fu(e,s,null)}}const bc=Object.create(null);class wt{getMap(){return jt.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=bc[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in bc)throw new RangeError("Duplicate use of step JSON ID "+e);return bc[e]=n,n.prototype.jsonID=e,n}}class Ge{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new Ge(e,null)}static fail(e){return new Ge(null,e)}static fromReplace(e,n,r,s){try{return Ge.ok(e.replace(n,r,s))}catch(o){if(o instanceof gl)return Ge.fail(o.message);throw o}}}function Sd(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let o=t.child(s);o.content.size&&(o=o.copy(Sd(o.content,e,o))),o.isInline&&(o=e(o,n,s)),r.push(o)}return O.fromArray(r)}class sr extends wt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),s=r.node(r.sharedDepth(this.to)),o=new j(Sd(n.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),s),n.openStart,n.openEnd);return Ge.fromReplace(e,this.from,this.to,o)}invert(){return new Zt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new sr(n.pos,r.pos,this.mark)}merge(e){return e instanceof sr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new sr(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new sr(n.from,n.to,e.markFromJSON(n.mark))}}wt.jsonID("addMark",sr);class Zt extends wt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new j(Sd(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return Ge.fromReplace(e,this.from,this.to,r)}invert(){return new sr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Zt(n.pos,r.pos,this.mark)}merge(e){return e instanceof Zt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Zt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Zt(n.from,n.to,e.markFromJSON(n.mark))}}wt.jsonID("removeMark",Zt);class or extends wt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new j(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let s=0;s<n.marks.length;s++)if(!n.marks[s].isInSet(r))return new or(this.pos,n.marks[s]);return new or(this.pos,this.mark)}}return new Vr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new or(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new or(n.pos,e.markFromJSON(n.mark))}}wt.jsonID("addNodeMark",or);class Vr extends wt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ge.fromReplace(e,this.pos,this.pos+1,new j(O.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new or(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Vr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Vr(n.pos,e.markFromJSON(n.mark))}}wt.jsonID("removeNodeMark",Vr);class tt extends wt{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&pu(e,this.from,this.to)?Ge.fail("Structure replace would overwrite content"):Ge.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new jt([this.from,this.to-this.from,this.slice.size])}invert(e){return new tt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new tt(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof tt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?j.empty:new j(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new tt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?j.empty:new j(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new tt(e.from,this.to,n,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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new tt(n.from,n.to,j.fromJSON(e,n.slice),!!n.structure)}}wt.jsonID("replace",tt);class nt extends wt{constructor(e,n,r,s,o,i,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=o,this.insert=i,this.structure=l}apply(e){if(this.structure&&(pu(e,this.from,this.gapFrom)||pu(e,this.gapTo,this.to)))return Ge.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ge.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Ge.fromReplace(e,this.from,this.to,r):Ge.fail("Content does not fit in gap")}getMap(){return new jt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new nt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),s=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||o>r.pos?null:new nt(n.pos,r.pos,s,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,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new nt(n.from,n.to,n.gapFrom,n.gapTo,j.fromJSON(e,n.slice),n.insert,!!n.structure)}}wt.jsonID("replaceAround",nt);function pu(t,e,n){let r=t.resolve(e),s=n-e,o=r.depth;for(;s>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,s--;if(s>0){let i=r.node(o).maybeChild(r.indexAfter(o));for(;s>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,s--}}return!1}function A1(t,e,n,r){let s=[],o=[],i,l;t.doc.nodesBetween(e,n,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let h=Math.max(c,e),f=Math.min(c+a.nodeSize,n),p=r.addToSet(d);for(let g=0;g<d.length;g++)d[g].isInSet(p)||(i&&i.to==h&&i.mark.eq(d[g])?i.to=f:s.push(i=new Zt(h,f,d[g])));l&&l.to==h?l.to=f:o.push(l=new sr(h,f,r))}}),s.forEach(a=>t.step(a)),o.forEach(a=>t.step(a))}function T1(t,e,n,r){let s=[],o=0;t.doc.nodesBetween(e,n,(i,l)=>{if(!i.isInline)return;o++;let a=null;if(r instanceof wa){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,n);for(let u=0;u<a.length;u++){let d=a[u],h;for(let f=0;f<s.length;f++){let p=s[f];p.step==o-1&&d.eq(s[f].style)&&(h=p)}h?(h.to=c,h.step=o):s.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),s.forEach(i=>t.step(new Zt(i.from,i.to,i.style)))}function Cd(t,e,n,r=n.contentMatch,s=!0){let o=t.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new tt(l,u,j.empty));else{r=d;for(let h=0;h<c.marks.length;h++)n.allowsMarkType(c.marks[h].type)||t.step(new Zt(l,u,c.marks[h]));if(s&&c.isText&&n.whitespace!="pre"){let h,f=/\r?\n|\r/g,p;for(;h=f.exec(c.text);)p||(p=new j(O.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),i.push(new tt(l+h.index,l+h.index+h[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(O.empty,!0);t.replace(l,l,new j(a,0,0))}for(let a=i.length-1;a>=0;a--)t.step(i[a])}function N1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Is(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let s=t.$from.node(r),o=t.$from.index(r),i=t.$to.indexAfter(r);if(r<t.depth&&s.canReplace(o,i,n))return r;if(r==0||s.type.spec.isolating||!N1(s,o,i))break}return null}function R1(t,e,n){let{$from:r,$to:s,depth:o}=e,i=r.before(o+1),l=s.after(o+1),a=i,c=l,u=O.empty,d=0;for(let p=o,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,u=O.from(r.node(p).copy(u)),d++):a--;let h=O.empty,f=0;for(let p=o,g=!1;p>n;p--)g||s.after(p+1)<s.end(p)?(g=!0,h=O.from(s.node(p).copy(h)),f++):c++;t.step(new nt(a,c,i,l,new j(u.append(h),d,f),u.size-d,!0))}function Ed(t,e,n=null,r=t){let s=_1(t,e),o=s&&O1(r,e);return o?s.map(Mf).concat({type:e,attrs:n}).concat(o.map(Mf)):null}function Mf(t){return{type:t,attrs:null}}function _1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.contentMatchAt(r).findWrapping(e);if(!o)return null;let i=o.length?o[0]:e;return n.canReplaceWith(r,s,i)?o:null}function O1(t,e){let{parent:n,startIndex:r,endIndex:s}=t,o=n.child(r),i=e.contentMatch.findWrapping(o.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<s;c++)a=a.matchType(n.child(c).type);return!a||!a.validEnd?null:i}function D1(t,e,n){let r=O.empty;for(let i=n.length-1;i>=0;i--){if(r.size){let l=n[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=O.from(n[i].type.create(n[i].attrs,r))}let s=e.start,o=e.end;t.step(new nt(s,o,s,o,new j(r,0,0),n.length,!0))}function L1(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(i,l)=>{let a=typeof s=="function"?s(i):s;if(i.isTextblock&&!i.hasMarkup(r,a)&&I1(t.doc,t.mapping.slice(o).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!p?c=!1:!f&&p&&(c=!0)}c===!1&&jg(t,i,l,o),Cd(t,t.mapping.slice(o).map(l,1),r,void 0,c===null);let u=t.mapping.slice(o),d=u.map(l,1),h=u.map(l+i.nodeSize,1);return t.step(new nt(d,h,d+1,h-1,new j(O.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ig(t,i,l,o),!1}})}function Ig(t,e,n,r){e.forEach((s,o)=>{if(s.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(s.text);){let a=t.mapping.slice(r).map(n+1+o+i.index);t.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function jg(t,e,n,r){e.forEach((s,o)=>{if(s.type==s.type.schema.linebreakReplacement){let i=t.mapping.slice(r).map(n+1+o);t.replaceWith(i,i+1,e.type.schema.text(`
51
+ `))}})}function I1(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function j1(t,e,n,r,s){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let i=n.create(r,null,s||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,i);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new nt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new j(O.from(i),0,0),1,!0))}function Pn(t,e,n=1,r){let s=t.resolve(e),o=s.depth-n,i=r&&r[r.length-1]||s.parent;if(o<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!i.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let c=s.depth-1,u=n-2;c>o;c--,u--){let d=s.node(c),h=s.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[u+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[u]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(f))return!1}let l=s.indexAfter(o),a=r&&r[0];return s.node(o).canReplaceWith(l,l,a?a.type:s.node(o+1).type)}function P1(t,e,n=1,r){let s=t.doc.resolve(e),o=O.empty,i=O.empty;for(let l=s.depth,a=s.depth-n,c=n-1;l>a;l--,c--){o=O.from(s.node(l).copy(o));let u=r&&r[c];i=O.from(u?u.type.create(u.attrs,i):s.node(l).copy(i))}t.step(new tt(e,e,new j(o.append(i),n,n),!0))}function kr(t,e){let n=t.resolve(e),r=n.index();return Pg(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function B1(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let s=0;s<e.childCount;s++){let o=e.child(s),i=o.type==r?t.type.schema.nodes.text:o.type;if(n=n.matchType(i),!n||!t.type.allowsMarks(o.marks))return!1}return n.validEnd}function Pg(t,e){return!!(t&&e&&!t.isLeaf&&B1(t,e))}function va(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let o,i,l=r.index(s);if(s==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(s+1),l++,i=r.node(s).maybeChild(l)):(o=r.node(s).maybeChild(l-1),i=r.node(s+1)),o&&!o.isTextblock&&Pg(o,i)&&r.node(s).canReplace(l,l+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function H1(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,o=t.doc.resolve(e-n),i=o.node().type;if(s&&i.inlineContent){let u=i.whitespace=="pre",d=!!i.contentMatch.matchType(s);u&&!d?r=!1:!u&&d&&(r=!0)}let l=t.steps.length;if(r===!1){let u=t.doc.resolve(e+n);jg(t,u.node(),u.before(),l)}i.inlineContent&&Cd(t,e+n-1,i,o.node().contentMatchAt(o.index()),r==null);let a=t.mapping.slice(l),c=a.map(e-n);if(t.step(new tt(c,a.map(e+n,-1),j.empty,!0)),r===!0){let u=t.doc.resolve(c);Ig(t,u.node(),u.before(),t.steps.length)}return t}function $1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let s=r.depth-1;s>=0;s--){let o=r.index(s);if(r.node(s).canReplaceWith(o,o,n))return r.before(s+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let o=r.indexAfter(s);if(r.node(s).canReplaceWith(o,o,n))return r.after(s+1);if(o<r.node(s).childCount)return null}return null}function Bg(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let o=0;o<n.openStart;o++)s=s.firstChild.content;for(let o=1;o<=(n.openStart==0&&n.size?2:1);o++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(o==1)u=c.canReplace(a,a,s);else{let d=c.contentMatchAt(a).findWrapping(s.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function ka(t,e,n=e,r=j.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),o=t.resolve(n);return Hg(s,o,r)?new tt(e,n,r):new z1(s,o,r).fit()}function Hg(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class z1{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=O.empty;for(let s=0;s<=e.depth;s++){let o=e.node(s);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=O.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,s=this.close(e<0?this.$to:r.doc.resolve(e));if(!s)return null;let o=this.placed,i=r.depth,l=s.depth;for(;i&&l&&o.childCount==1;)o=o.firstChild.content,i--,l--;let a=new j(o,i,l);return e>-1?new nt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new tt(r.pos,s.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let o=n.firstChild;if(n.childCount>1&&(s=0),o.type.spec.isolating&&s<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,o=null;r?(o=xc(this.unplaced.content,r-1).firstChild,s=o.content):s=this.unplaced.content;let i=s.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(n==1&&(i?c.matchType(i.type)||(d=c.fillBefore(O.from(i),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:d};if(n==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=xc(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new j(e,n+1,Math.max(r,s.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=xc(e,n);if(s.childCount<=1&&n>0){let o=e.size-n<=n+s.size;this.unplaced=new j(to(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new j(to(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let g=0;g<o.length;g++)this.openFrontierNode(o[g]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:h}=this.frontier[n];if(s){for(let g=0;g<s.childCount;g++)u.push(s.child(g));d=d.matchFragment(s)}let f=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let g=l.child(c),y=d.matchType(g.type);if(!y)break;c++,(c>1||a==0||g.content.size)&&(d=y,u.push($g(g.mark(h.allowedMarks(g.marks)),c==1?a:0,c==l.childCount?f:-1)))}let p=c==l.childCount;p||(f=-1),this.placed=no(this.placed,n,O.from(u)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,y=l;g<f;g++){let b=y.lastChild;this.frontier.push({type:b.type,match:b.contentMatchAt(b.childCount)}),y=b.content}this.unplaced=p?e==0?j.empty:new j(to(i.content,e-1,1),e-1,f<0?i.openEnd:e-1):new j(to(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!wc(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:r}=this.$to,s=this.$to.after(r);for(;r>1&&s==this.$to.end(--r);)++s;return s}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:s}=this.frontier[n],o=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),i=wc(e,n,s,r,o);if(i){for(let l=n-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=wc(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:n,fit:i,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=no(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),o=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,o)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=no(this.placed,this.depth,O.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(O.empty,!0);n.childCount&&(this.placed=no(this.placed,this.frontier.length,n))}}function to(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(to(t.firstChild.content,e-1,n)))}function no(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(no(t.lastChild.content,e-1,n)))}function xc(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function $g(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,$g(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(O.empty,!0)))),t.copy(r)}function wc(t,e,n,r,s){let o=t.node(e),i=s?t.indexAfter(e):t.index(e);if(i==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,i);return l&&!F1(n,o.content,i)?l:null}function F1(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function U1(t){return t.spec.defining||t.spec.definingForContent}function V1(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),o=t.doc.resolve(n);if(Hg(s,o,r))return t.step(new tt(e,n,r));let i=Fg(s,t.doc.resolve(n));i[i.length-1]==0&&i.pop();let l=-(s.depth+1);i.unshift(l);for(let h=s.depth,f=s.pos-1;h>0;h--,f--){let p=s.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(h)>-1?l=h:s.before(h)==f&&i.splice(1,0,-h)}let a=i.indexOf(l),c=[],u=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(c.push(p),f==r.openStart)break;h=p.content}for(let h=u-1;h>=0;h--){let f=c[h],p=U1(f.type);if(p&&!f.sameMarkup(s.node(Math.abs(l)-1)))u=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+u+1)%(r.openStart+1),p=c[f];if(p)for(let g=0;g<i.length;g++){let y=i[(g+a)%i.length],b=!0;y<0&&(b=!1,y=-y);let x=s.node(y-1),E=s.index(y-1);if(x.canReplaceWith(E,E,p.type,p.marks))return t.replace(s.before(y),b?o.after(y):n,new j(zg(r.content,0,r.openStart,f),f,r.openEnd))}}let d=t.steps.length;for(let h=i.length-1;h>=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=i[h];f<0||(e=s.before(f),n=o.after(f))}}function zg(t,e,n,r,s){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(zg(o.content,e+1,n,r,o)))}if(e>r){let o=s.contentMatchAt(0),i=o.fillBefore(t).append(t);t=i.append(o.matchFragment(i).fillBefore(O.empty,!0))}return t}function W1(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=$1(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new j(O.from(r),0,0))}function q1(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),o=Fg(r,s);for(let i=0;i<o.length;i++){let l=o[i],a=i==o.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),s.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),s.indexAfter(l-1))))return t.delete(r.before(l),s.after(l))}for(let i=1;i<=r.depth&&i<=s.depth;i++)if(e-r.start(i)==r.depth-i&&n>r.end(i)&&s.end(i)-n!=s.depth-i&&r.start(i-1)==s.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),s.index(i-1)))return t.delete(r.before(i),n);t.delete(e,n)}function Fg(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let o=t.start(s);if(o<t.pos-(t.depth-s)||e.end(s)>e.pos+(e.depth-s)||t.node(s).type.spec.isolating||e.node(s).type.spec.isolating)break;(o==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==o-1)&&n.push(s)}return n}class ms extends wt{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ge.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return Ge.fromReplace(e,this.pos,this.pos+1,new j(O.from(s),0,n.isLeaf?0:1))}getMap(){return jt.empty}invert(e){return new ms(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new ms(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new ms(n.pos,n.attr,n.value)}}wt.jsonID("attr",ms);class Eo extends wt{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let s in e.attrs)n[s]=e.attrs[s];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Ge.ok(r)}getMap(){return jt.empty}invert(e){return new Eo(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Eo(n.attr,n.value)}}wt.jsonID("docAttr",Eo);let ks=class extends Error{};ks=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};ks.prototype=Object.create(Error.prototype);ks.prototype.constructor=ks;ks.prototype.name="TransformError";class Md{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Co}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new ks(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=j.empty){let s=ka(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new j(O.from(r),0,0))}delete(e,n){return this.replace(e,n,j.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return V1(this,e,n,r),this}replaceRangeWith(e,n,r){return W1(this,e,n,r),this}deleteRange(e,n){return q1(this,e,n),this}lift(e,n){return R1(this,e,n),this}join(e,n=1){return H1(this,e,n),this}wrap(e,n){return D1(this,e,n),this}setBlockType(e,n=e,r,s=null){return L1(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return j1(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new ms(e,n,r)),this}setDocAttribute(e,n){return this.step(new Eo(e,n)),this}addNodeMark(e,n){return this.step(new or(e,n)),this}removeNodeMark(e,n){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n instanceof Ae)n.isInSet(r.marks)&&this.step(new Vr(e,n));else{let s=r.marks,o,i=[];for(;o=n.isInSet(s);)i.push(new Vr(e,o)),s=o.removeFromSet(s);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,n=1,r){return P1(this,e,n,r),this}addMark(e,n,r){return A1(this,e,n,r),this}removeMark(e,n,r){return T1(this,e,n,r),this}clearIncompatible(e,n,r){return Cd(this,e,n,r),this}}const vc=Object.create(null);class Q{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Ad(e.min(n),e.max(n))]}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 n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=j.empty){let r=n.content.lastChild,s=null;for(let l=0;l<n.openEnd;l++)s=r,r=r.lastChild;let o=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?j.empty:n),l==0&&Nf(e,o,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:i,$to:l}=s[o],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,n),Nf(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Y(e):cs(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let o=e.depth-1;o>=0;o--){let i=n<0?cs(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):cs(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(i)return i}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Nt(e.node(0))}static atStart(e){return cs(e,e,0,0,1)||new Nt(e)}static atEnd(e){return cs(e,e,e.content.size,e.childCount,-1)||new Nt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=vc[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in vc)throw new RangeError("Duplicate use of selection JSON ID "+e);return vc[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Y.between(this.$anchor,this.$head).getBookmark()}}Q.prototype.visible=!0;class Ad{constructor(e,n){this.$from=e,this.$to=n}}let Af=!1;function Tf(t){!Af&&!t.parent.inlineContent&&(Af=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Y extends Q{constructor(e,n=e){Tf(e),Tf(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Q.near(r);let s=e.resolve(n.map(this.anchor));return new Y(s.parent.inlineContent?s:r,r)}replace(e,n=j.empty){if(super.replace(e,n),n==j.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Y&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sa(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Y(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let s=e.resolve(n);return new this(s,r==n?s:e.resolve(r))}static between(e,n,r){let s=e.pos-n.pos;if((!r||s)&&(r=s>=0?1:-1),!n.parent.inlineContent){let o=Q.findFrom(n,r,!0)||Q.findFrom(n,-r,!0);if(o)n=o.$head;else return Q.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Q.findFrom(e,-r,!0)||Q.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Y(e,n)}}Q.jsonID("text",Y);class Sa{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Sa(e.map(this.anchor),e.map(this.head))}resolve(e){return Y.between(e.resolve(this.anchor),e.resolve(this.head))}}class K extends Q{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:s}=n.mapResult(this.anchor),o=e.resolve(s);return r?Q.near(o):new K(o)}content(){return new j(O.from(this.node),0,0)}eq(e){return e instanceof K&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Td(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new K(e.resolve(n.anchor))}static create(e,n){return new K(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}K.prototype.visible=!1;Q.jsonID("node",K);class Td{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Sa(r,r):new Td(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&K.isSelectable(r)?new K(n):Q.near(n)}}class Nt extends Q{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=j.empty){if(n==j.empty){e.delete(0,e.doc.content.size);let r=Q.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Nt(e)}map(e){return new Nt(e)}eq(e){return e instanceof Nt}getBookmark(){return K1}}Q.jsonID("all",Nt);const K1={map(){return this},resolve(t){return new Nt(t)}};function cs(t,e,n,r,s,o=!1){if(e.inlineContent)return Y.create(t,n);for(let i=r-(s>0?0:1);s>0?i<e.childCount:i>=0;i+=s){let l=e.child(i);if(l.isAtom){if(!o&&K.isSelectable(l))return K.create(t,n-(s<0?l.nodeSize:0))}else{let a=cs(t,l,n+s,s<0?l.childCount:0,s,o);if(a)return a}n+=l.nodeSize*s}return null}function Nf(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof tt||s instanceof nt))return;let o=t.mapping.maps[r],i;o.forEach((l,a,c,u)=>{i==null&&(i=u)}),t.setSelection(Q.near(t.doc.resolve(i),n))}const Rf=1,_i=2,_f=4;let G1=class extends Md{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|Rf)&~_i,this.storedMarks=null,this}get selectionSet(){return(this.updated&Rf)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=_i,this}ensureMarks(e){return Ae.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&_i)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~_i,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ae.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let s=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(s.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let i=this.doc.resolve(n);o=r==n?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,o)),this.selection.empty||this.setSelection(Q.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,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|=_f,this}get scrolledIntoView(){return(this.updated&_f)>0}};function Of(t,e){return!e||!t?t:t.bind(e)}class ro{constructor(e,n,r){this.name=e,this.init=Of(n.init,r),this.apply=Of(n.apply,r)}}const J1=[new ro("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new ro("selection",{init(t,e){return t.selection||Q.atStart(e.doc)},apply(t){return t.selection}}),new ro("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new ro("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class kc{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=J1.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new ro(r.key,r.spec.state,r))})}}class fs{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,n=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=n){let s=this.config.plugins[r];if(s.spec.filterTransaction&&!s.spec.filterTransaction.call(s,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),s=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=s?s[i].n:0,c=s?s[i].state:this,u=a<n.length&&l.spec.appendTransaction.call(l,a?n.slice(a):n,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!s){s=[];for(let d=0;d<this.config.plugins.length;d++)s.push(d<i?{state:r,n:n.length}:{state:this,n:0})}n.push(u),r=r.applyInner(u),o=!0}s&&(s[i]={state:r,n:n.length})}}if(!o)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new fs(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let o=r[s];n[o.name]=o.apply(e,this[o.name],this,n)}return n}get tr(){return new G1(this)}static create(e){let n=new kc(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new fs(n);for(let s=0;s<n.fields.length;s++)r[n.fields[s].name]=n.fields[s].init(e,r);return r}reconfigure(e){let n=new kc(this.schema,e.plugins),r=n.fields,s=new fs(n);for(let o=0;o<r.length;o++){let i=r[o].name;s[i]=this.hasOwnProperty(i)?this[i]:r[o].init(e,s)}return s}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let s=e[r],o=s.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(s,this[s.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let s=new kc(e.schema,e.plugins),o=new fs(s);return s.fields.forEach(i=>{if(i.name=="doc")o.doc=cr.fromJSON(e.schema,n.doc);else if(i.name=="selection")o.selection=Q.fromJSON(o.doc,n.selection);else if(i.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[i.name]=c.fromJSON.call(a,e,n[l],o);return}}o[i.name]=i.init(e,o)}}),o}}function Ug(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Ug(s,e,{})),n[r]=s}return n}class me{constructor(e){this.spec=e,this.props={},e.props&&Ug(e.props,this,this.props),this.key=e.key?e.key.key:Vg("plugin")}getState(e){return e[this.key]}}const Sc=Object.create(null);function Vg(t){return t in Sc?t+"$"+ ++Sc[t]:(Sc[t]=0,t+"$")}class ye{constructor(e="key"){this.key=Vg(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const at=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ss=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let mu=null;const Dn=function(t,e,n){let r=mu||(mu=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Y1=function(){mu=null},Wr=function(t,e,n,r){return n&&(Df(t,e,n,r,-1)||Df(t,e,n,r,1))},X1=/^(img|br|input|textarea|hr)$/i;function Df(t,e,n,r,s){for(var o;;){if(t==n&&e==r)return!0;if(e==(s<0?0:Vt(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Ko(t)||X1.test(t.nodeName)||t.contentEditable=="false")return!1;e=at(t)+(s<0?0:1),t=i}else if(t.nodeType==1){let i=t.childNodes[e+(s<0?-1:0)];if(i.nodeType==1&&i.contentEditable=="false")if(!((o=i.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=s;else return!1;else t=i,e=s<0?Vt(t):0}else return!1}}function Vt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Z1(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=Vt(t)}else if(t.parentNode&&!Ko(t))e=at(t),t=t.parentNode;else return null}}function Q1(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Ko(t))e=at(t)+1,t=t.parentNode;else return null}}function ev(t,e,n){for(let r=e==0,s=e==Vt(t);r||s;){if(t==n)return!0;let o=at(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,s=s&&o==Vt(t)}}function Ko(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const Ca=function(t){return t.focusNode&&Wr(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Rr(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function tv(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function nv(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Vt(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Vt(r.startContainer),r.startOffset)}}}const xn=typeof navigator<"u"?navigator:null,Lf=typeof document<"u"?document:null,Sr=xn&&xn.userAgent||"",gu=/Edge\/(\d+)/.exec(Sr),Wg=/MSIE \d/.exec(Sr),yu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Sr),Rt=!!(Wg||yu||gu),ur=Wg?document.documentMode:yu?+yu[1]:gu?+gu[1]:0,nn=!Rt&&/gecko\/(\d+)/i.test(Sr);nn&&+(/Firefox\/(\d+)/.exec(Sr)||[0,0])[1];const bu=!Rt&&/Chrome\/(\d+)/.exec(Sr),mt=!!bu,qg=bu?+bu[1]:0,St=!Rt&&!!xn&&/Apple Computer/.test(xn.vendor),Cs=St&&(/Mobile\/\w+/.test(Sr)||!!xn&&xn.maxTouchPoints>2),Ut=Cs||(xn?/Mac/.test(xn.platform):!1),rv=xn?/Win/.test(xn.platform):!1,In=/Android \d/.test(Sr),Go=!!Lf&&"webkitFontSmoothing"in Lf.documentElement.style,sv=Go?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ov(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function An(t,e){return typeof t=="number"?t:t[e]}function iv(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function If(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let i=n||t.dom;i;){if(i.nodeType!=1){i=Ss(i);continue}let l=i,a=l==o.body,c=a?ov(o):iv(l),u=0,d=0;if(e.top<c.top+An(r,"top")?d=-(c.top-e.top+An(s,"top")):e.bottom>c.bottom-An(r,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+An(s,"top")-c.top:e.bottom-c.bottom+An(s,"bottom")),e.left<c.left+An(r,"left")?u=-(c.left-e.left+An(s,"left")):e.right>c.right-An(r,"right")&&(u=e.right-c.right+An(s,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let f=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let g=l.scrollLeft-f,y=l.scrollTop-p;e={left:e.left-g,top:e.top-y,right:e.right-g,bottom:e.bottom-y}}let h=a?"fixed":getComputedStyle(i).position;if(/^(fixed|sticky)$/.test(h))break;i=h=="absolute"?i.offsetParent:Ss(i)}}function lv(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let o=(e.left+e.right)/2,i=n+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=t.root.elementFromPoint(o,i);if(!l||l==t.dom||!t.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=n-20){r=l,s=a.top;break}}return{refDOM:r,refTop:s,stack:Kg(t.dom)}}function Kg(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ss(r));return e}function av({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Gg(n,r==0?0:r-e)}function Gg(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:o}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=o&&(r.scrollLeft=o)}}let ls=null;function cv(t){if(t.setActive)return t.setActive();if(ls)return t.focus(ls);let e=Kg(t);t.focus(ls==null?{get preventScroll(){return ls={preventScroll:!0},!0}}:void 0),ls||(ls=!1,Gg(e,0))}function Jg(t,e){let n,r=2e8,s,o=0,i=e.top,l=e.top,a,c;for(let u=t.firstChild,d=0;u;u=u.nextSibling,d++){let h;if(u.nodeType==1)h=u.getClientRects();else if(u.nodeType==3)h=Dn(u).getClientRects();else continue;for(let f=0;f<h.length;f++){let p=h[f];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(g<r){n=u,r=g,s=g&&n.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&g&&(o=d+(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=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=d+1)}}return!n&&a&&(n=a,s=c,r=0),n&&n.nodeType==3?uv(n,s):!n||r&&n.nodeType==1?{node:t,offset:o}:Jg(n,s)}function uv(t,e){let n=t.nodeValue.length,r=document.createRange();for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=Yn(r,1);if(o.top!=o.bottom&&Nd(e,o))return{node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)}}return{node:t,offset:0}}function Nd(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function dv(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function hv(t,e,n){let{node:r,offset:s}=Jg(e,n),o=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();o=i.left!=i.right&&n.left>(i.left+i.right)/2?1:-1}return t.docView.posFromDOM(r,s,o)}function fv(t,e,n,r){let s=-1;for(let o=e,i=!1;o!=t.dom;){let l=t.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)&&(!i&&a.left>r.left||a.top>r.top?s=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(s=l.posAfter),i=!0),!l.contentDOM&&s<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function Yg(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let s=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),o=s;;){let i=t.childNodes[o];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Nd(e,c))return Yg(i,e,c)}}if((o=(o+1)%r)==s)break}return t}function pv(t,e){let n=t.dom.ownerDocument,r,s=0,o=nv(n,e.left,e.top);o&&({node:r,offset:s}=o);let i=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!i||!t.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=t.dom.getBoundingClientRect();if(!Nd(e,c)||(i=Yg(t.dom,e,c),!i))return null}if(St)for(let c=i;r&&c;c=Ss(c))c.draggable&&(r=void 0);if(i=dv(i,e),r){if(nn&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let u=r.childNodes[s],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&s++}let c;Go&&s&&r.nodeType==1&&(c=r.childNodes[s-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(l=fv(t,r,s,e))}l==null&&(l=hv(t,i,e));let a=t.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function jf(t){return t.top<t.bottom||t.left<t.right}function Yn(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(jf(r))return r}return Array.prototype.find.call(n,jf)||t.getBoundingClientRect()}const mv=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Xg(t,e,n){let{node:r,offset:s,atom:o}=t.docView.domFromPos(e,n<0?-1:1),i=Go||nn;if(r.nodeType==3)if(i&&(mv.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let a=Yn(Dn(r,s,s),n);if(nn&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let c=Yn(Dn(r,s-1,s-1),-1);if(c.top==a.top){let u=Yn(Dn(r,s,s+1),-1);if(u.top!=a.top)return Xs(u,u.left<c.left)}}return a}else{let a=s,c=s,u=n<0?1:-1;return n<0&&!s?(c++,u=-1):n>=0&&s==r.nodeValue.length?(a--,u=1):n<0?a--:c++,Xs(Yn(Dn(r,a,c),u),u<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&s&&(n<0||s==Vt(r))){let a=r.childNodes[s-1];if(a.nodeType==1)return Cc(a.getBoundingClientRect(),!1)}if(o==null&&s<Vt(r)){let a=r.childNodes[s];if(a.nodeType==1)return Cc(a.getBoundingClientRect(),!0)}return Cc(r.getBoundingClientRect(),n>=0)}if(o==null&&s&&(n<0||s==Vt(r))){let a=r.childNodes[s-1],c=a.nodeType==3?Dn(a,Vt(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Xs(Yn(c,1),!1)}if(o==null&&s<Vt(r)){let a=r.childNodes[s];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Dn(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return Xs(Yn(c,-1),!0)}return Xs(Yn(r.nodeType==3?Dn(r):r,-n),n>=0)}function Xs(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Cc(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Zg(t,e,n){let r=t.state,s=t.root.activeElement;r!=e&&t.updateState(e),s!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),s!=t.dom&&s&&s.focus()}}function gv(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Zg(t,e,()=>{let{node:o}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let i=Xg(t,s.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=Dn(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(n=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const yv=/[\u0590-\u08ac]/;function bv(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,o=!s,i=s==r.parent.content.size,l=t.domSelection();return l?!yv.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:i:Zg(t,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),y=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==g;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return h!=null&&(l.caretBidiLevel=h),y}):r.pos==r.start()||r.pos==r.end()}let Pf=null,Bf=null,Hf=!1;function xv(t,e,n){return Pf==e&&Bf==n?Hf:(Pf=e,Bf=n,Hf=n=="up"||n=="down"?gv(t,e,n):bv(t,e,n))}const qt=0,$f=1,Or=2,wn=3;class Jo{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=qt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].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 n=0,r=this.posAtStart;;n++){let s=this.children[n];if(s==e)return r;r+=s.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let o,i;if(e==this.contentDOM)o=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(i)+i.size:this.posAtStart}else{let o,i;if(e==this.contentDOM)o=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((i=o.pmViewDesc)&&i.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(i):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>at(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))s=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!1;break}if(o.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){s=!0;break}if(o.nextSibling)break}}return s??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,s=e;s;s=s.parentNode){let o=this.getDesc(s),i;if(o&&(!n||o.node))if(r&&(i=o.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let s=e;s;s=s.parentNode){let o=this.getDesc(s);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],o=r+s.size;if(r==e&&o!=r){for(;!s.border&&s.children.length;)for(let i=0;i<s.children.length;i++){let l=s.children[i];if(l.size){s=l;break}}return s}if(e<o)return s.descAt(e-r-s.border);r=o}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let o=0;r<this.children.length;r++){let i=this.children[r],l=o+i.size;if(l>e||i instanceof ey){s=e-o;break}o=l}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Qg&&o.side>=0;r--);if(n<=0){let o,i=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,i=!1);return o&&n&&i&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?at(o.dom)+1:0}}else{let o,i=!0;for(;o=r<this.children.length?this.children[r]:null,!(!o||o.dom.parentNode==this.contentDOM);r++,i=!1);return o&&i&&!o.border&&!o.domAtom?o.domFromPos(0,n):{node:this.contentDOM,offset:o?at(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let s=-1,o=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(s==-1&&e<=c){let u=i+a.border;if(e>=u&&n<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,u);e=i;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){s=at(h.dom)+1;break}e-=h.size}s==-1&&(s=0)}if(s>-1&&(c>n||l==this.children.length-1)){n=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=at(d.dom);break}n+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:r}=this.domFromPos(e,0);if(n.nodeType!=1||r==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[r]}setSelection(e,n,r,s=!1){let o=Math.min(e,n),i=Math.max(e,n);for(let f=0,p=0;f<this.children.length;f++){let g=this.children[f],y=p+g.size;if(o>p&&i<y)return g.setSelection(e-p-g.border,n-p-g.border,r,s);p=y}let l=this.domFromPos(e,e?-1:1),a=n==e?l:this.domFromPos(n,n?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),d=!1;if((nn||St)&&e==n){let{node:f,offset:p}=l;if(f.nodeType==3){if(d=!!(p&&f.nodeValue[p-1]==`
52
+ `),d&&p==f.nodeValue.length)for(let g=f,y;g;g=g.parentNode){if(y=g.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:at(y)+1});break}let b=g.pmViewDesc;if(b&&b.node&&b.node.isBlock)break}}else{let g=f.childNodes[p-1];d=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(nn&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let f=u.focusNode.childNodes[u.focusOffset];f&&f.contentEditable=="false"&&(s=!0)}if(!(s||d&&St)&&Wr(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Wr(a.node,a.offset,u.focusNode,u.focusOffset))return;let h=!1;if((c.extend||e==n)&&!d){c.collapse(l.node,l.offset);try{e!=n&&c.extend(a.node,a.offset),h=!0}catch{}}if(!h){if(e>n){let p=l;l=a,a=p}let f=document.createRange();f.setEnd(a.node,a.offset),f.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(f)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,s=0;s<this.children.length;s++){let o=this.children[s],i=r+o.size;if(r==i?e<=i&&n>=r:e<i&&n>r){let l=r+o.border,a=i-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==i?Or:$f,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=wn:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Or:wn}r=i}this.dirty=Or}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Or:$f;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Qg extends Jo{constructor(e,n,r,s){let o,i=n.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!o)return s;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==qt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(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 wv extends Jo{constructor(e,n,r,s){super(e,[],n,null),this.textDOM=r,this.text=s}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class qr extends Jo{constructor(e,n,r,s,o){super(e,[],r,s),this.mark=n,this.spec=o}static create(e,n,r,s){let o=s.nodeViews[n.type.name],i=o&&o(n,s,r);return(!i||!i.dom)&&(i=ts.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new qr(e,n,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&wn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=wn&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=qt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=qt}}slice(e,n,r){let s=qr.create(this.parent,this.mark,!0,r),o=this.children,i=this.size;n<i&&(o=wu(o,n,i,r)),e>0&&(o=wu(o,0,e,r));for(let l=0;l<o.length;l++)o[l].parent=s;return s.children=o,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class dr extends Jo{constructor(e,n,r,s,o,i,l,a,c){super(e,[],o,i),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=l}static create(e,n,r,s,o,i){let l=o.nodeViews[n.type.name],a,c=l&&l(n,o,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,s),u=c&&c.dom,d=c&&c.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=ts.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!d&&!n.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),n.type.spec.draggable&&(u.draggable=!0));let h=u;return u=ry(u,r,n),c?a=new vv(e,n,r,s,u,d||null,h,c,o,i+1):n.isText?new Ea(e,n,r,s,u,h,o):new dr(e,n,r,s,u,d||null,h,o,i+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 n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>O.empty)}return e}matchesNode(e,n,r){return this.dirty==qt&&e.eq(this.node)&&xl(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,s=n,o=e.composing?this.localCompositionInfo(e,n):null,i=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Sv(this,i&&i.node,e);Mv(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?Ae.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,s)},(c,u,d,h)=>{a.syncToMarks(c.marks,r,e);let f;a.findNodeMatch(c,u,d,h)||l&&e.state.selection.from>s&&e.state.selection.to<s+c.nodeSize&&(f=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,f,e)||a.updateNextNode(c,u,d,e,h,s)||a.addNode(c,u,d,e,s),s+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Or)&&(i&&this.protectLocalComposition(e,i),ty(this.contentDOM,this.children,e),Cs&&Av(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof Y)||r<n||s>n+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 i=o.nodeValue,l=Tv(this.node.content,i,r-n,s-n);return l<0?null:{node:o,pos:l,text:i}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let o=n;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 i=new wv(this,o,n,s);e.input.compositionNodes.push(i),this.children=wu(this.children,r,r+s.length,e,i)}update(e,n,r,s){return this.dirty==wn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,s),!0)}updateInner(e,n,r,s){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(s,this.posAtStart),this.dirty=qt}updateOuterDeco(e){if(xl(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ny(this.dom,this.nodeDOM,xu(this.outerDeco,this.node,n),xu(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function zf(t,e,n,r,s){ry(r,e,t);let o=new dr(void 0,t,e,n,r,r,r,s,0);return o.contentDOM&&o.updateChildren(s,0),o}class Ea extends dr{constructor(e,n,r,s,o,i,l){super(e,n,r,s,o,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,s){return this.dirty==wn||this.dirty!=qt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=qt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,s.trackWrites==this.nodeDOM&&(s.trackWrites=null)),this.node=e,this.dirty=qt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let s=this.node.cut(e,n),o=document.createTextNode(s.text);return new Ea(this.parent,s,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=wn)}get domAtom(){return!1}isText(e){return this.node.text==e}}class ey extends Jo{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class vv extends dr{constructor(e,n,r,s,o,i,l,a,c,u){super(e,n,r,s,o,i,l,c,u),this.spec=a}update(e,n,r,s){if(this.dirty==wn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,s),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,s)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,s){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,s)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function ty(t,e,n){let r=t.firstChild,s=!1;for(let o=0;o<e.length;o++){let i=e[o],l=i.dom;if(l.parentNode==t){for(;l!=r;)r=Ff(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(l,r);if(i instanceof qr){let a=r?r.previousSibling:t.lastChild;ty(i.contentDOM,i.children,n),r=a?a.nextSibling:t.firstChild}}for(;r;)r=Ff(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const ao=function(t){t&&(this.nodeName=t)};ao.prototype=Object.create(null);const Dr=[new ao];function xu(t,e,n){if(t.length==0)return Dr;let r=n?Dr[0]:new ao,s=[r];for(let o=0;o<t.length;o++){let i=t[o].type.attrs;if(i){i.nodeName&&s.push(r=new ao(i.nodeName));for(let l in i){let a=i[l];a!=null&&(n&&s.length==1&&s.push(r=new ao(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return s}function ny(t,e,n,r){if(n==Dr&&r==Dr)return e;let s=e;for(let o=0;o<r.length;o++){let i=r[o],l=n[o];if(o){let a;l&&l.nodeName==i.nodeName&&s!=t&&(a=s.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(s),l=Dr[0]),s=a}kv(s,l||Dr[0],i)}return s}function kv(t,e,n){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in n)&&t.removeAttribute(r);for(let r in n)r!="class"&&r!="style"&&r!="nodeName"&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],s=n.class?n.class.split(" ").filter(Boolean):[];for(let o=0;o<r.length;o++)s.indexOf(r[o])==-1&&t.classList.remove(r[o]);for(let o=0;o<s.length;o++)r.indexOf(s[o])==-1&&t.classList.add(s[o]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,s;for(;s=r.exec(e.style);)t.style.removeProperty(s[1])}n.style&&(t.style.cssText+=n.style)}}function ry(t,e,n){return ny(t,t,Dr,xu(e,n,t.nodeType!=1))}function xl(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Ff(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class Sv{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Cv(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let r=e;r<n;r++)this.top.children[r].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,r){let s=0,o=this.stack.length>>1,i=Math.min(o,e.length);for(;s<i&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=qt,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=qr.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,s){let o=-1,i;if(s>=this.preMatch.index&&(i=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&i.matchesNode(e,n,r))o=this.top.children.indexOf(i,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,n,r)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,n,r,s,o){let i=this.top.children[s];return i.dirty==wn&&i.dom==i.contentDOM&&(i.dirty=Or),i.update(e,n,r,o)?(this.destroyBetween(this.index,s),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let s=this.index;s<this.top.children.length;s++)if(this.top.children[s]==r)return s}return-1}e=n}}updateNextNode(e,n,r,s,o,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof dr){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,h=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=wn&&xl(n,a.outerDeco));if(!h&&a.update(e,n,r,s))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!h&&(d=this.recreateWrapper(a,e,n,r,s,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=Or,d.updateChildren(s,i+1),d.dirty=qt),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,o,i){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!xl(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let l=dr.create(this.top,n,r,s,o,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,n,r,s,o){let i=dr.create(this.top,e,n,r,s,o);i.contentDOM&&i.updateChildren(s,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,n,r){let s=this.index<this.top.children.length?this.top.children[this.index]:null;if(s&&s.matchesWidget(e)&&(e==s.widget||!s.widget.type.toDOM.parentNode))this.index++;else{let o=new Qg(this.top,e,n,r);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof qr;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Ea)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((St||mt)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let s=new ey(this.top,[],r,null);n!=this.top?n.children.push(s):n.children.splice(this.index++,0,s),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Cv(t,e){let n=e,r=n.children.length,s=t.childCount,o=new Map,i=[];e:for(;s>0;){let l;for(;;)if(r){let c=n.children[r-1];if(c instanceof qr)n=c,r=c.children.length;else{l=c,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(s-1))break;--s,o.set(l,s),i.push(l)}}return{index:s,matched:o,matches:i.reverse()}}function Ev(t,e){return t.type.side-e.type.side}function Mv(t,e,n,r){let s=e.locals(t),o=0;if(s.length==0){for(let c=0;c<t.childCount;c++){let u=t.child(c);r(u,s,e.forChild(o,u),c),o+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,d;for(;i<s.length&&s[i].to==o;){let y=s[i++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(Ev);for(let y=0;y<d.length;y++)n(d[y],c,!!a)}else n(u,c,!!a);let h,f;if(a)f=-1,h=a,a=null;else if(c<t.childCount)f=c,h=t.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;i<s.length&&s[i].from<=o&&s[i].to>o;)l.push(s[i++]);let p=o+h.nodeSize;if(h.isText){let y=p;i<s.length&&s[i].from<y&&(y=s[i].from);for(let b=0;b<l.length;b++)l[b].to<y&&(y=l[b].to);y<p&&(a=h.cut(y-o),h=h.cut(0,y-o),p=y,f=-1)}else for(;i<s.length&&s[i].to<p;)i++;let g=h.isInline&&!h.isLeaf?l.filter(y=>!y.inline):l.slice();r(h,g,e.forChild(o,h),f),o=p}}function Av(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function Tv(t,e,n,r){for(let s=0,o=0;s<t.childCount&&o<=r;){let i=t.child(s++),l=o;if(o+=i.nodeSize,!i.isText)continue;let a=i.text;for(;s<t.childCount;){let c=t.child(s++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=n)return l+c;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function wu(t,e,n,r,s){let o=[];for(let i=0,l=0;i<t.length;i++){let a=t[i],c=l,u=l+=a.size;c>=n||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,r)),s&&(o.push(s),s=void 0),u>n&&o.push(a.slice(n-c,a.size,r)))}return o}function Rd(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),o=s&&s.size==0,i=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ca(n)){for(a=i;s&&!s.node;)s=s.parent;let d=s.node;if(s&&d.isAtom&&K.isSelectable(d)&&s.parent&&!(d.isInline&&ev(n.focusNode,n.focusOffset,s.dom))){let h=s.posBefore;c=new K(i==h?l:r.resolve(h))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let d=i,h=i;for(let f=0;f<n.rangeCount;f++){let p=n.getRangeAt(f);d=Math.min(d,t.docView.posFromDOM(p.startContainer,p.startOffset,1)),h=Math.max(h,t.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,i]=h==t.state.selection.anchor?[h,d]:[d,h],l=r.resolve(i)}else a=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let d=e=="pointer"||t.state.selection.head<l.pos&&!o?1:-1;c=_d(t,u,l,d)}return c}function sy(t){return t.editable?t.hasFocus():iy(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Bn(t,e=!1){let n=t.state.selection;if(oy(t,n),!!sy(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&mt){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Wr(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Rv(t);else{let{anchor:r,head:s}=n,o,i;Uf&&!(n instanceof Y)&&(n.$from.parent.inlineContent||(o=Vf(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(i=Vf(t,n.to))),t.docView.setSelection(r,s,t,e),Uf&&(o&&Wf(o),i&&Wf(i)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Nv(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Uf=St||mt&&qg<63;function Vf(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,o=r?n.childNodes[r-1]:null;if(St&&s&&s.contentEditable=="false")return Ec(s);if((!s||s.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(s)return Ec(s);if(o)return Ec(o)}}function Ec(t){return t.contentEditable="true",St&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Wf(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Nv(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,s=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=s)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!sy(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function Rv(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,s=r.nodeName=="IMG";s?n.setStart(r.parentNode,at(r)+1):n.setStart(r,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!s&&!t.state.selection.visible&&Rt&&ur<=11&&(r.disabled=!0,r.disabled=!1)}function oy(t,e){if(e instanceof K){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(qf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else qf(t)}function qf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function _d(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Y.between(e,n,r)}function Kf(t){return t.editable&&!t.hasFocus()?!1:iy(t)}function iy(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function _v(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wr(e.node,e.offset,n.anchorNode,n.anchorOffset)}function vu(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),o=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return o&&Q.findFrom(o,e)}function Zn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Gf(t,e,n){let r=t.state.selection;if(r instanceof Y)if(n.indexOf("s")>-1){let{$head:s}=r,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(s.pos+o.nodeSize*(e<0?-1:1));return Zn(t,new Y(r.$anchor,i))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=vu(t.state,e);return s&&s instanceof K?Zn(t,s):!1}else if(!(Ut&&n.indexOf("m")>-1)){let s=r.$head,o=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,i;if(!o||o.isText)return!1;let l=e<0?s.pos-o.nodeSize:s.pos;return o.isAtom||(i=t.docView.descAt(l))&&!i.contentDOM?K.isSelectable(o)?Zn(t,new K(e<0?t.state.doc.resolve(s.pos-o.nodeSize):s)):Go?Zn(t,new Y(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof K&&r.node.isInline)return Zn(t,new Y(e>0?r.$to:r.$from));{let s=vu(t.state,e);return s?Zn(t,s):!1}}}function wl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function co(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function as(t,e){return e<0?Ov(t):Dv(t)}function Ov(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,o,i=!1;for(nn&&n.nodeType==1&&r<wl(n)&&co(n.childNodes[r],-1)&&(i=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(co(l,-1))s=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(ly(n))break;{let l=n.previousSibling;for(;l&&co(l,-1);)s=n.parentNode,o=at(l),l=l.previousSibling;if(l)n=l,r=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}i?ku(t,n,r):s&&ku(t,s,o)}function Dv(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=wl(n),o,i;for(;;)if(r<s){if(n.nodeType!=1)break;let l=n.childNodes[r];if(co(l,1))o=n,i=++r;else break}else{if(ly(n))break;{let l=n.nextSibling;for(;l&&co(l,1);)o=l.parentNode,i=at(l)+1,l=l.nextSibling;if(l)n=l,r=0,s=wl(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&ku(t,o,i)}function ly(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function Lv(t,e){for(;t&&e==t.childNodes.length&&!Ko(t);)e=at(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function Iv(t,e){for(;t&&!e&&!Ko(t);)e=at(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function ku(t,e,n){if(e.nodeType!=3){let o,i;(i=Lv(e,n))?(e=i,n=0):(o=Iv(e,n))&&(e=o,n=o.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Ca(r)){let o=document.createRange();o.setEnd(e,n),o.setStart(e,n),r.removeAllRanges(),r.addRange(o)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&Bn(t)},50)}function Jf(t,e){let n=t.state.doc.resolve(e);if(!(mt||rv)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left<s.left?"ltr":"rtl"}if(e<n.end()){let o=t.coordsAtPos(e+1),i=(o.top+o.bottom)/2;if(i>s.top&&i<s.bottom&&Math.abs(o.left-s.left)>1)return o.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function Yf(t,e,n){let r=t.state.selection;if(r instanceof Y&&!r.empty||n.indexOf("s")>-1||Ut&&n.indexOf("m")>-1)return!1;let{$from:s,$to:o}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let i=vu(t.state,e);if(i&&i instanceof K)return Zn(t,i)}if(!s.parent.inlineContent){let i=e<0?s:o,l=r instanceof Nt?Q.near(i,e):Q.findFrom(i,e);return l?Zn(t,l):!1}return!1}function Xf(t,e){if(!(t.state.selection instanceof Y))return!0;let{$head:n,$anchor:r,empty:s}=t.state.selection;if(!n.sameParent(r))return!0;if(!s)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let i=t.state.tr;return e<0?i.delete(n.pos-o.nodeSize,n.pos):i.delete(n.pos,n.pos+o.nodeSize),t.dispatch(i),!0}return!1}function Zf(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function jv(t){if(!St||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;Zf(t,r,"true"),setTimeout(()=>Zf(t,r,"false"),20)}return!1}function Pv(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Bv(t,e){let n=e.keyCode,r=Pv(e);if(n==8||Ut&&n==72&&r=="c")return Xf(t,-1)||as(t,-1);if(n==46&&!e.shiftKey||Ut&&n==68&&r=="c")return Xf(t,1)||as(t,1);if(n==13||n==27)return!0;if(n==37||Ut&&n==66&&r=="c"){let s=n==37?Jf(t,t.state.selection.from)=="ltr"?-1:1:-1;return Gf(t,s,r)||as(t,s)}else if(n==39||Ut&&n==70&&r=="c"){let s=n==39?Jf(t,t.state.selection.from)=="ltr"?1:-1:1;return Gf(t,s,r)||as(t,s)}else{if(n==38||Ut&&n==80&&r=="c")return Yf(t,-1,r)||as(t,-1);if(n==40||Ut&&n==78&&r=="c")return jv(t)||Yf(t,1,r)||as(t,1);if(r==(Ut?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Od(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:s,openEnd:o}=e;for(;s>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,o--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let i=t.someProp("clipboardSerializer")||ts.fromSchema(t.state.schema),l=fy(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=hy[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let p=l.createElement(u[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${s} ${o}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
53
+
54
+ `);return{dom:a,text:h,slice:e}}function ay(t,e,n,r,s){let o=s.parent.type.spec.code,i,l;if(!n&&!e)return null;let a=e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",h=>{e=h(e,o||r,t)}),o)return e?new j(O.from(t.state.schema.text(e.replace(/\r\n?/g,`
55
+ `))),0,0):j.empty;let d=t.someProp("clipboardTextParser",h=>h(e,s,r,t));if(d)l=d;else{let h=s.marks(),{schema:f}=t.state,p=ts.fromSchema(f);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(g=>{let y=i.appendChild(document.createElement("p"));g&&y.appendChild(p.serializeNode(f.text(g,h)))})}}else t.someProp("transformPastedHTML",d=>{n=d(n,t)}),i=Fv(n),Go&&Uv(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let h=i.firstChild;for(;h&&h.nodeType!=1;)h=h.nextSibling;if(!h)break;i=h}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||io.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:s,ruleFromNode(h){return h.nodeName=="BR"&&!h.nextSibling&&h.parentNode&&!Hv.test(h.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Vv(Qf(l,+u[1],+u[2]),u[4]);else if(l=j.maxOpen($v(l.content,s),!0),l.openStart||l.openEnd){let d=0,h=0;for(let f=l.content.firstChild;d<l.openStart&&!f.type.spec.isolating;d++,f=f.firstChild);for(let f=l.content.lastChild;h<l.openEnd&&!f.type.spec.isolating;h++,f=f.lastChild);l=Qf(l,d,h)}return t.someProp("transformPasted",d=>{l=d(l,t)}),l}const Hv=/^(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 $v(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let s=e.node(n).contentMatchAt(e.index(n)),o,i=[];if(t.forEach(l=>{if(!i)return;let a=s.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&o.length&&uy(a,o,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=dy(i[i.length-1],o.length));let u=cy(l,a);i.push(u),s=s.matchType(u.type),o=a}}),i)return O.from(i)}return t}function cy(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,O.from(t));return t}function uy(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let o=uy(t,e,n,r.lastChild,s+1);if(o)return r.copy(r.content.replaceChild(r.childCount-1,o));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(O.from(cy(n,t,s+1))))}}function dy(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,dy(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(O.empty,!0);return t.copy(n.append(r))}function Su(t,e,n,r,s,o){let i=e<0?t.firstChild:t.lastChild,l=i.content;return t.childCount>1&&(o=0),s<r-1&&(l=Su(l,e,n,r,s+1,o)),s>=n&&(l=e<0?i.contentMatchAt(0).fillBefore(l,o<=s).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(O.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,i.copy(l))}function Qf(t,e,n){return e<t.openStart&&(t=new j(Su(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new j(Su(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const hy={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 ep=null;function fy(){return ep||(ep=document.implementation.createHTMLDocument("title"))}let Mc=null;function zv(t){let e=window.trustedTypes;return e?(Mc||(Mc=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Mc.createHTML(t)):t}function Fv(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=fy().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&hy[r[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),n.innerHTML=zv(t),s)for(let o=0;o<s.length;o++)n=n.querySelector(s[o])||n;return n}function Uv(t){let e=t.querySelectorAll(mt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}function Vv(t,e){if(!t.size)return t;let n=t.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return t}let{content:s,openStart:o,openEnd:i}=t;for(let l=r.length-2;l>=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;s=O.from(a.create(r[l+1],s)),o++,i++}return new j(s,o,i)}const Ct={},Et={},Wv={touchstart:!0,touchmove:!0};class qv{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 Kv(t){for(let e in Ct){let n=Ct[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{Jv(t,r)&&!Dd(t,r)&&(t.editable||!(r.type in Et))&&n(t,r)},Wv[e]?{passive:!0}:void 0)}St&&t.dom.addEventListener("input",()=>null),Cu(t)}function ir(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function Gv(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function Cu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Dd(t,r))})}function Dd(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function Jv(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function Yv(t,e){!Dd(t,e)&&Ct[e.type]&&(t.editable||!(e.type in Et))&&Ct[e.type](t,e)}Et.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!my(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(In&&mt&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Cs&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",s=>s(t,Rr(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Bv(t,n)?n.preventDefault():ir(t,"key")};Et.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Et.keypress=(t,e)=>{let n=e;if(my(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ut&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Y)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),o=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",i=>i(t,r.$from.pos,r.$to.pos,s,o))&&t.dispatch(o()),n.preventDefault()}};function Ma(t){return{left:t.clientX,top:t.clientY}}function Xv(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ld(t,e,n,r,s){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let i=o.depth+1;i>0;i--)if(t.someProp(e,l=>i>o.depth?l(t,n,o.nodeAfter,o.before(i),s,!0):l(t,n,o.node(i),o.before(i),s,!1)))return!0;return!1}function gs(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);r.setMeta("pointer",!0),t.dispatch(r)}function Zv(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&K.isSelectable(r)?(gs(t,new K(n)),!0):!1}function Qv(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof K&&(r=n.node);let o=t.state.doc.resolve(e);for(let i=o.depth+1;i>0;i--){let l=i>o.depth?o.nodeAfter:o.node(i);if(K.isSelectable(l)){r&&n.$from.depth>0&&i>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?s=o.before(n.$from.depth):s=o.before(i);break}}return s!=null?(gs(t,K.create(t.state.doc,s)),!0):!1}function ek(t,e,n,r,s){return Ld(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(s?Qv(t,n):Zv(t,n))}function tk(t,e,n,r){return Ld(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function nk(t,e,n,r){return Ld(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||rk(t,n,r)}function rk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gs(t,Y.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let o=s.depth+1;o>0;o--){let i=o>s.depth?s.nodeAfter:s.node(o),l=s.before(o);if(i.inlineContent)gs(t,Y.create(r,l+1,l+1+i.content.size));else if(K.isSelectable(i))gs(t,K.create(r,l));else continue;return!0}}function Id(t){return vl(t)}const py=Ut?"metaKey":"ctrlKey";Ct.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Id(t),s=Date.now(),o="singleClick";s-t.input.lastClick.time<500&&Xv(n,t.input.lastClick)&&!n[py]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:o,button:n.button};let i=t.posAtCoords(Ma(n));i&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new sk(t,i,n,!!r)):(o=="doubleClick"?tk:nk)(t,i.pos,i.inside,n)?n.preventDefault():ir(t,"pointer"))};class sk{constructor(e,n,r,s){this.view=e,this.pos=n,this.event=r,this.flushed=s,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[py],this.allowDefault=r.shiftKey;let o,i;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),i=n.inside;else{let u=e.state.doc.resolve(n.pos);o=u.parent,i=u.depth?u.before():0}const l=s?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof K&&c.from<=i&&c.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&nn&&!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)),ir(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(()=>Bn(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(Ma(e))),this.updateAllowDefault(e),this.allowDefault||!n?ir(this.view,"pointer"):ek(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||St&&this.mightDrag&&!this.mightDrag.node.isAtom||mt&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(gs(this.view,Q.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ir(this.view,"pointer")}move(e){this.updateAllowDefault(e),ir(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)}}Ct.touchstart=t=>{t.input.lastTouch=Date.now(),Id(t),ir(t,"pointer")};Ct.touchmove=t=>{t.input.lastTouch=Date.now(),ir(t,"pointer")};Ct.contextmenu=t=>Id(t);function my(t,e){return t.composing?!0:St&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const ok=In?5e3:-1;Et.compositionstart=Et.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Y&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),vl(t,!0),t.markCursor=null;else if(vl(t,!e.selection.empty),nn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,o=r.focusOffset;s&&s.nodeType==1&&o!=0;){let i=o<0?s.lastChild:s.childNodes[o-1];if(!i)break;if(i.nodeType==3){let l=t.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else s=i,o=-1}}t.input.composing=!0}gy(t,ok)};Et.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,gy(t,20))};function gy(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>vl(t),e))}function yy(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=lk());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ik(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=Z1(e.focusNode,e.focusOffset),r=Q1(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let i=n.pmViewDesc;if(!(!i||!i.isText(n.nodeValue)))return r}}return n||r}function lk(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function vl(t,e=!1){if(!(In&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),yy(t),e||t.docView&&t.docView.dirty){let n=Rd(t),r=t.state.selection;return n&&!n.eq(r)?t.dispatch(t.state.tr.setSelection(n)):(t.markCursor||e)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?t.dispatch(t.state.tr.deleteSelection()):t.updateState(t.state),!0}return!1}}function ak(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),s=document.createRange();s.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(s),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Mo=Rt&&ur<15||Cs&&sv<604;Ct.copy=Et.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let o=Mo?null:n.clipboardData,i=r.content(),{dom:l,text:a}=Od(t,i);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):ak(t,l),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function ck(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function uk(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let s=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Ao(t,r.value,null,s,e):Ao(t,r.textContent,r.innerHTML,s,e)},50)}function Ao(t,e,n,r,s){let o=ay(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,s,o||j.empty)))return!0;if(!o)return!1;let i=ck(o),l=i?t.state.tr.replaceSelectionWith(i,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function by(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Et.paste=(t,e)=>{let n=e;if(t.composing&&!In)return;let r=Mo?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Ao(t,by(r),r.getData("text/html"),s,n)?n.preventDefault():uk(t,n)};class xy{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const dk=Ut?"altKey":"ctrlKey";function wy(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[dk]}Ct.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,o=s.empty?null:t.posAtCoords(Ma(n)),i;if(!(o&&o.pos>=s.from&&o.pos<=(s instanceof K?s.to-1:s.to))){if(r&&r.mightDrag)i=K.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let d=t.docView.nearestDesc(n.target,!0);d&&d.node.type.spec.draggable&&d!=t.docView&&(i=K.create(t.state.doc,d.posBefore))}}let l=(i||t.state.selection).content(),{dom:a,text:c,slice:u}=Od(t,l);(!n.dataTransfer.files.length||!mt||qg>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Mo?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Mo||n.dataTransfer.setData("text/plain",c),t.dragging=new xy(u,wy(t,n),i)};Ct.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Et.dragover=Et.dragenter=(t,e)=>e.preventDefault();Et.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let s=t.posAtCoords(Ma(n));if(!s)return;let o=t.state.doc.resolve(s.pos),i=r&&r.slice;i?t.someProp("transformPasted",p=>{i=p(i,t)}):i=ay(t,by(n.dataTransfer),Mo?null:n.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&wy(t,n));if(t.someProp("handleDrop",p=>p(t,n,i||j.empty,l))){n.preventDefault();return}if(!i)return;n.preventDefault();let a=i?Bg(t.state.doc,o.pos,i):o.pos;a==null&&(a=o.pos);let c=t.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,h=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(h))return;let f=c.doc.resolve(u);if(d&&K.isSelectable(i.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new K(f));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((g,y,b,x)=>p=x),c.setSelection(_d(t,f,c.doc.resolve(p)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))};Ct.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&Bn(t)},20))};Ct.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ct.beforeinput=(t,e)=>{if(mt&&In&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,Rr(8,"Backspace")))))return;let{$cursor:s}=t.state.selection;s&&s.pos>0&&t.dispatch(t.state.tr.delete(s.pos-1,s.pos).scrollIntoView())},50)}};for(let t in Et)Ct[t]=Et[t];function To(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class kl{constructor(e,n){this.toDOM=e,this.spec=n||Br,this.side=this.spec.side||0}map(e,n,r,s){let{pos:o,deleted:i}=e.mapResult(n.from+s,this.side<0?-1:1);return i?null:new De(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&To(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class hr{constructor(e,n){this.attrs=e,this.spec=n||Br}map(e,n,r,s){let o=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,i=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return o>=i?null:new De(o,i,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof hr&&To(this.attrs,e.attrs)&&To(this.spec,e.spec)}static is(e){return e.type instanceof hr}destroy(){}}class jd{constructor(e,n){this.attrs=e,this.spec=n||Br}map(e,n,r,s){let o=e.mapResult(n.from+s,1);if(o.deleted)return null;let i=e.mapResult(n.to+s,-1);return i.deleted||i.pos<=o.pos?null:new De(o.pos-r,i.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),o;return s==n.from&&!(o=e.child(r)).isText&&s+o.nodeSize==n.to}eq(e){return this==e||e instanceof jd&&To(this.attrs,e.attrs)&&To(this.spec,e.spec)}destroy(){}}class De{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new De(e,n,this.type)}eq(e,n=0){return this.type.eq(e.type)&&this.from+n==e.from&&this.to+n==e.to}map(e,n,r){return this.type.map(e,this,n,r)}static widget(e,n,r){return new De(e,e,new kl(n,r))}static inline(e,n,r,s){return new De(e,n,new hr(r,s))}static node(e,n,r,s){return new De(e,n,new jd(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof hr}get widget(){return this.type instanceof kl}}const us=[],Br={};class be{constructor(e,n){this.local=e.length?e:us,this.children=n.length?n:us}static create(e,n){return n.length?Sl(n,e,0,Br):pt}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,o){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=n&&l.to>=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+s,l.to+s))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<n&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,n-l,r,s+l,o)}}map(e,n,r){return this==pt||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Br)}mapInner(e,n,r,s,o){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,s);a&&a.type.valid(n,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?hk(this.children,i||[],e,n,r,s,o):i?new be(i.sort(Hr),us):pt}add(e,n){return n.length?this==pt?be.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,o=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ky(n,l,c)){for(s||(s=this.children.slice());o<s.length&&s[o]<a;)o+=3;s[o]==a?s[o+2]=s[o+2].addInner(l,u,c+1):s.splice(o,0,a,a+l.nodeSize,Sl(u,l,c+1,Br)),o+=3}});let i=vy(o?Sy(n):n,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new be(i.length?this.local.concat(i).sort(Hr):this.local,s||this.children)}remove(e){return e.length==0||this==pt?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let o=0;o<r.length;o+=3){let i,l=r[o]+n,a=r[o+1]+n;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[o+2].removeInner(i,l+1);c!=pt?r[o+2]=c:(r.splice(o,3),o-=3)}if(s.length){for(let o=0,i;o<e.length;o++)if(i=e[o])for(let l=0;l<s.length;l++)s[l].eq(i,n)&&(s==this.local&&(s=this.local.slice()),s.splice(l--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new be(s,r):pt}forChild(e,n){if(this==pt)return this;if(n.isLeaf)return be.empty;let r,s;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,i=o+n.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>o&&a.type instanceof hr){let c=Math.max(o,a.from)-o,u=Math.min(i,a.to)-o;c<u&&(s||(s=[])).push(a.copy(c,u))}}if(s){let l=new be(s.sort(Hr),us);return r?new tr([l,r]):l}return r||pt}eq(e){if(this==e)return!0;if(!(e instanceof be)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let n=0;n<this.local.length;n++)if(!this.local[n].eq(e.local[n]))return!1;for(let n=0;n<this.children.length;n+=3)if(this.children[n]!=e.children[n]||this.children[n+1]!=e.children[n+1]||!this.children[n+2].eq(e.children[n+2]))return!1;return!0}locals(e){return Pd(this.localsInner(e))}localsInner(e){if(this==pt)return us;if(e.inlineContent||!this.local.some(hr.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof hr||n.push(this.local[r]);return n}forEachSet(e){e(this)}}be.empty=new be([],[]);be.removeOverlap=Pd;const pt=be.empty;class tr{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,Br));return tr.from(r)}forChild(e,n){if(n.isLeaf)return be.empty;let r=[];for(let s=0;s<this.members.length;s++){let o=this.members[s].forChild(e,n);o!=pt&&(o instanceof tr?r=r.concat(o.members):r.push(o))}return tr.from(r)}eq(e){if(!(e instanceof tr)||e.members.length!=this.members.length)return!1;for(let n=0;n<this.members.length;n++)if(!this.members[n].eq(e.members[n]))return!1;return!0}locals(e){let n,r=!0;for(let s=0;s<this.members.length;s++){let o=this.members[s].localsInner(e);if(o.length)if(!n)n=o;else{r&&(n=n.slice(),r=!1);for(let i=0;i<o.length;i++)n.push(o[i])}}return n?Pd(r?n:n.sort(Hr)):us}static from(e){switch(e.length){case 0:return pt;case 1:return e[0];default:return new tr(e.every(n=>n instanceof be)?e:e.reduce((n,r)=>n.concat(r instanceof be?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function hk(t,e,n,r,s,o,i){let l=t.slice();for(let c=0,u=o;c<n.maps.length;c++){let d=0;n.maps[c].forEach((h,f,p,g)=>{let y=g-p-(f-h);for(let b=0;b<l.length;b+=3){let x=l[b+1];if(x<0||h>x+u-d)continue;let E=l[b]+u-d;f>=E?l[b+1]=h<=E?-2:-1:h>=u&&y&&(l[b]+=y,l[b+1]+=y)}d+=y}),u=n.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=n.map(t[c]+o),d=u-s;if(d<0||d>=r.content.size){a=!0;continue}let h=n.map(t[c+1]+o,-1),f=h-s,{index:p,offset:g}=r.content.findIndex(d),y=r.maybeChild(p);if(y&&g==d&&g+y.nodeSize==f){let b=l[c+2].mapInner(n,y,u+1,t[c]+o+1,i);b!=pt?(l[c]=d,l[c+1]=f,l[c+2]=b):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=fk(l,t,e,n,s,o,i),u=Sl(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,h=0;d<u.children.length;d+=3){let f=u.children[d];for(;h<l.length&&l[h]<f;)h+=3;l.splice(h,0,u.children[d],u.children[d+1],u.children[d+2])}}return new be(e.sort(Hr),l)}function vy(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let s=t[r];n.push(new De(s.from+e,s.to+e,s.type))}return n}function fk(t,e,n,r,s,o,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,s,c);d?n.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<t.length;a+=3)t[a+1]==-1&&l(t[a+2],e[a]+o+1);return n}function ky(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let o=0,i;o<t.length;o++)(i=t[o])&&i.from>n&&i.to<r&&((s||(s=[])).push(i),t[o]=null);return s}function Sy(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Sl(t,e,n,r){let s=[],o=!1;e.forEach((l,a)=>{let c=ky(t,l,a+n);if(c){o=!0;let u=Sl(c,l,n+a+1,r);u!=pt&&s.push(a,a+l.nodeSize,u)}});let i=vy(o?Sy(t):t,-n).sort(Hr);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||s.length?new be(i,s):pt}function Hr(t,e){return t.from-e.from||t.to-e.to}function Pd(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let s=n+1;s<e.length;s++){let o=e[s];if(o.from==r.from){o.to!=r.to&&(e==t&&(e=t.slice()),e[s]=o.copy(o.from,r.to),tp(e,s+1,o.copy(r.to,o.to)));continue}else{o.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,o.from),tp(e,s,r.copy(o.from,r.to)));break}}}return e}function tp(t,e,n){for(;e<t.length&&Hr(n,t[e])>0;)e++;t.splice(e,0,n)}function Ac(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=pt&&e.push(r)}),t.cursorWrapper&&e.push(be.create(t.state.doc,[t.cursorWrapper.deco])),tr.from(e)}const pk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},mk=Rt&&ur<=11;class gk{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 yk{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new gk,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let s=0;s<r.length;s++)this.queue.push(r[s]);Rt&&ur<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():this.flush()}),mk&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,pk)),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 n=0;n<e.length;n++)this.queue.push(e[n]);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(Kf(this.view)){if(this.suppressingSelectionUpdates)return Bn(this.view);if(Rt&&ur<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wr(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 n=new Set,r;for(let o=e.focusNode;o;o=Ss(o))n.add(o);for(let o=e.anchorNode;o;o=Ss(o))if(n.has(o)){r=o;break}let s=r&&this.view.docView.nearestDesc(r);if(s&&s.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))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 n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),s=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Kf(e)&&!this.ignoreSelectionChange(r),o=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<n.length;u++){let d=this.registerMutation(n[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),i=i<0?d.to:Math.max(d.to,i),d.typeOver&&(l=!0))}if(nn&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,h]=u;d.parentNode&&d.parentNode.parentNode==h.parentNode?h.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let h of u){let f=h.parentNode;f&&f.nodeName=="LI"&&(!d||wk(e,d)!=f)&&h.remove()}}}let c=null;o<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ca(r)&&(c=Rd(e))&&c.eq(Q.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Bn(e),this.currentSelection.set(r),e.scrollToSelection()):(o>-1||s)&&(o>-1&&(e.docView.markDirty(o,i),bk(e)),this.handleDOMChange(o,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Bn(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];n.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,o=e.nextSibling;if(Rt&&ur<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:h}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d),(!h||Array.prototype.indexOf.call(e.addedNodes,h)<0)&&(o=h)}let i=s&&s.parentNode==e.target?at(s)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?at(o):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let np=new WeakMap,rp=!1;function bk(t){if(!np.has(t)&&(np.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=nn,rp)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."),rp=!0}}function sp(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,o=e.endOffset,i=t.domAtPos(t.state.selection.anchor);return Wr(i.node,i.offset,s,o)&&([n,r,s,o]=[s,o,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:o}}function xk(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return sp(t,s)}let n;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?sp(t,n):null}function wk(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let r=t.docView.nearestDesc(n,!0);if(r&&r.node.isBlock)return n}return null}function vk(t,e,n){let{node:r,fromOffset:s,toOffset:o,from:i,to:l}=t.docView.parseRange(e,n),a=t.domSelectionRange(),c,u=a.anchorNode;if(u&&t.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Ca(a)||c.push({node:a.focusNode,offset:a.focusOffset})),mt&&t.input.lastKeyCode===8)for(let y=o;y>s;y--){let b=r.childNodes[y-1],x=b.pmViewDesc;if(b.nodeName=="BR"&&!x){o=y;break}if(!x||x.size)break}let d=t.state.doc,h=t.someProp("domParser")||io.fromSchema(t.state.schema),f=d.resolve(i),p=null,g=h.parse(r,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:s,to:o,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:kk,context:f});if(c&&c[0].pos!=null){let y=c[0].pos,b=c[1]&&c[1].pos;b==null&&(b=y),p={anchor:y+i,head:b+i}}return{doc:g,sel:p,from:i,to:l}}function kk(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(St&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||St&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Sk=/^(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 Ck(t,e,n,r,s){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let k=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,N=Rd(t,k);if(N&&!t.state.selection.eq(N)){if(mt&&In&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",B=>B(t,Rr(13,"Enter"))))return;let R=t.state.tr.setSelection(N);k=="pointer"?R.setMeta("pointer",!0):k=="key"&&R.scrollIntoView(),o&&R.setMeta("composition",o),t.dispatch(R)}return}let i=t.state.doc.resolve(e),l=i.sharedDepth(n);e=i.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,c=vk(t,e,n),u=t.state.doc,d=u.slice(c.from,c.to),h,f;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(h=t.state.selection.to,f="end"):(h=t.state.selection.from,f="start"),t.input.lastKeyCode=null;let p=Ak(d.content,c.doc.content,c.from,h,f);if(p&&t.input.domChangeCount++,(Cs&&t.input.lastIOSEnter>Date.now()-225||In)&&s.some(k=>k.nodeType==1&&!Sk.test(k.nodeName))&&(!p||p.endA>=p.endB)&&t.someProp("handleKeyDown",k=>k(t,Rr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof Y&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let k=op(t,t.state.doc,c.sel);if(k&&!k.eq(t.state.selection)){let N=t.state.tr.setSelection(k);o&&N.setMeta("composition",o),t.dispatch(N)}}return}t.state.selection.from<t.state.selection.to&&p.start==p.endB&&t.state.selection instanceof Y&&(p.start>t.state.selection.from&&p.start<=t.state.selection.from+2&&t.state.selection.from>=c.from?p.start=t.state.selection.from:p.endA<t.state.selection.to&&p.endA>=t.state.selection.to-2&&t.state.selection.to<=c.to&&(p.endB+=t.state.selection.to-p.endA,p.endA=t.state.selection.to)),Rt&&ur<=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 g=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),b=u.resolve(p.start),x=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=p.endA,E;if((Cs&&t.input.lastIOSEnter>Date.now()-225&&(!x||s.some(k=>k.nodeName=="DIV"||k.nodeName=="P"))||!x&&g.pos<c.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&!/\S/.test(c.doc.textBetween(g.pos,y.pos,"",""))&&(E=Q.findFrom(c.doc.resolve(g.pos+1),1,!0))&&E.head>g.pos)&&t.someProp("handleKeyDown",k=>k(t,Rr(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>p.start&&Mk(u,p.start,p.endA,g,y)&&t.someProp("handleKeyDown",k=>k(t,Rr(8,"Backspace")))){In&&mt&&t.domObserver.suppressSelectionUpdates();return}mt&&p.endB==p.start&&(t.input.lastChromeDelete=Date.now()),In&&!x&&g.start()!=y.start()&&y.parentOffset==0&&g.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(()=>{t.someProp("handleKeyDown",function(k){return k(t,Rr(13,"Enter"))})},20));let S=p.start,M=p.endA,w=k=>{let N=k||t.state.tr.replace(S,M,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let R=op(t,N.doc,c.sel);R&&!(mt&&t.composing&&R.empty&&(p.start!=p.endB||t.input.lastChromeDelete<Date.now()-100)&&(R.head==S||R.head==N.mapping.map(M)-1)||Rt&&R.empty&&R.head==S)&&N.setSelection(R)}return o&&N.setMeta("composition",o),N.scrollIntoView()},T;if(x){if(g.pos==y.pos){Rt&&ur<=11&&g.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Bn(t),20));let k=w(t.state.tr.delete(S,M)),N=u.resolve(p.start).marksAcross(u.resolve(p.endA));N&&k.ensureMarks(N),t.dispatch(k)}else if(p.endA==p.endB&&(T=Ek(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,p.endA-b.start())))){let k=w(t.state.tr);T.type=="add"?k.addMark(S,M,T.mark):k.removeMark(S,M,T.mark),t.dispatch(k)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let k=g.parent.textBetween(g.parentOffset,y.parentOffset),N=()=>w(t.state.tr.insertText(k,S,M));t.someProp("handleTextInput",R=>R(t,S,M,k,N))||t.dispatch(N())}}else t.dispatch(w())}function op(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:_d(t,e.resolve(n.anchor),e.resolve(n.head))}function Ek(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,o=r,i,l,a;for(let u=0;u<r.length;u++)s=r[u].removeFromSet(s);for(let u=0;u<n.length;u++)o=n[u].removeFromSet(o);if(s.length==1&&o.length==0)l=s[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(s.length==0&&o.length==1)l=o[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(O.from(c).eq(t))return{mark:l,type:i}}function Mk(t,e,n,r,s){if(n-e<=s.pos-r.pos||Tc(r,!0,!1)<s.pos)return!1;let o=t.resolve(e);if(!r.parent.isTextblock){let l=o.nodeAfter;return l!=null&&n==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let i=t.resolve(Tc(o,!0,!0));return!i.parent.isTextblock||i.pos>n||Tc(i,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function Tc(t,e,n){let r=t.depth,s=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,s++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,s++}return s}function Ak(t,e,n,r,s){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:i,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let a=Math.max(0,o-Math.min(i,l));r-=i+a-o}if(i<o&&t.size<e.size){let a=r<=o&&r>=i?o-r:0;o-=a,o&&o<e.size&&ip(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-i),i=o}else if(l<o){let a=r<=o&&r>=l?o-r:0;o-=a,o&&o<t.size&&ip(t.textBetween(o-1,o+1))&&(o+=a?1:-1),i=o+(i-l),l=o}return{start:o,endA:i,endB:l}}function ip(t){if(t.length!=2)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class Cy{constructor(e,n){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 qv,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(dp),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=cp(this),ap(this),this.nodeViews=up(this),this.docView=zf(this.state.doc,lp(this),Ac(this),this.dom,this),this.domObserver=new yk(this,(r,s,o,i)=>Ck(this,r,s,o,i)),this.domObserver.start(),Kv(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 n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Cu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(dp),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let s=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(yy(this),i=!0),this.state=e;let l=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let f=up(this);Nk(f,this.nodeViews)&&(this.nodeViews=f,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Cu(this),this.editable=cp(this),ap(this);let a=Ac(this),c=lp(this),u=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(s.selection))&&(i=!0);let h=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&lv(this);if(i){this.domObserver.stop();let f=d&&(Rt||mt)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&Tk(s.selection,e.selection);if(d){let p=mt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ik(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=zf(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(f=!0)}f||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&_v(this))?Bn(this,f):(oy(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(s),!((r=this.dragging)===null||r===void 0)&&r.node&&!s.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,s),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():h&&av(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof K){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&If(this,n.getBoundingClientRect(),e)}else If(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 n=0;n<this.directPlugins.length;n++){let r=this.directPlugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let n=0;n<this.state.plugins.length;n++){let r=this.state.plugins[n];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let n=0;n<this.pluginViews.length;n++){let r=this.pluginViews[n];r.update&&r.update(this,e)}}updateDraggedNode(e,n){let r=e.node,s=-1;if(this.state.doc.nodeAt(r.from)==r.node)s=r.from;else{let o=r.from+(this.state.doc.content.size-n.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==r.node&&(s=o)}this.dragging=new xy(e.slice,e.move,s<0?void 0:K.create(this.state.doc,s))}someProp(e,n){let r=this._props&&this._props[e],s;if(r!=null&&(s=n?n(r):r))return s;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(s=n?n(l):l))return s}let o=this.state.plugins;if(o)for(let i=0;i<o.length;i++){let l=o[i].props[e];if(l!=null&&(s=n?n(l):l))return s}}hasFocus(){if(Rt){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&&cv(this.dom),Bn(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let n=this.dom.parentNode;n;n=n.parentNode)if(n.nodeType==9||n.nodeType==11&&n.host)return n.getSelection||(Object.getPrototypeOf(n).getSelection=()=>n.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return pv(this,e)}coordsAtPos(e,n=1){return Xg(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let s=this.docView.posFromDOM(e,n,r);if(s==null)throw new RangeError("DOM position not inside the editor");return s}endOfTextblock(e,n){return xv(this,n||this.state,e)}pasteHTML(e,n){return Ao(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Ao(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Od(this,e)}destroy(){this.docView&&(Gv(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ac(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Y1())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yv(this,e)}domSelectionRange(){let e=this.domSelection();return e?St&&this.root.nodeType===11&&tv(this.dom.ownerDocument)==this.dom&&xk(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}Cy.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function lp(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[De.node(0,t.state.doc.content.size,e)]}function ap(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:De.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function cp(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Tk(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function up(t){let e=Object.create(null);function n(r){for(let s in r)Object.prototype.hasOwnProperty.call(e,s)||(e[s]=r[s])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Nk(t,e){let n=0,r=0;for(let s in t){if(t[s]!=e[s])return!0;n++}for(let s in e)r++;return n!=r}function dp(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var fr={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:"'"},Cl={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Rk=typeof navigator<"u"&&/Mac/.test(navigator.platform),_k=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var ct=0;ct<10;ct++)fr[48+ct]=fr[96+ct]=String(ct);for(var ct=1;ct<=24;ct++)fr[ct+111]="F"+ct;for(var ct=65;ct<=90;ct++)fr[ct]=String.fromCharCode(ct+32),Cl[ct]=String.fromCharCode(ct);for(var Nc in fr)Cl.hasOwnProperty(Nc)||(Cl[Nc]=fr[Nc]);function Ok(t){var e=Rk&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||_k&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Cl:fr)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Dk=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Lk=typeof navigator<"u"&&/Win/.test(navigator.platform);function Ik(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,o,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Dk?i=!0:s=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),i&&(n="Meta-"+n),o&&(n="Shift-"+n),n}function jk(t){let e=Object.create(null);for(let n in t)e[Ik(n)]=t[n];return e}function Rc(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Pk(t){return new me({props:{handleKeyDown:Bd(t)}})}function Bd(t){let e=jk(t);return function(n,r){let s=Ok(r),o,i=e[Rc(s,r)];if(i&&i(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let l=e[Rc(s,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(Lk&&r.ctrlKey&&r.altKey)&&(o=fr[r.keyCode])&&o!=s){let l=e[Rc(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const Hd=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ey(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const My=(t,e,n)=>{let r=Ey(t,n);if(!r)return!1;let s=$d(r);if(!s){let i=r.blockRange(),l=i&&Is(i);return l==null?!1:(e&&e(t.tr.lift(i,l).scrollIntoView()),!0)}let o=s.nodeBefore;if(Iy(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Es(o,"end")||K.isSelectable(o)))for(let i=r.depth;;i--){let l=ka(t.doc,r.before(i),r.after(i),j.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=t.tr.step(l);a.setSelection(Es(o,"end")?Q.findFrom(a.doc.resolve(a.mapping.map(s.pos,-1)),-1):K.create(a.doc,s.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-o.nodeSize,s.pos).scrollIntoView()),!0):!1},Bk=(t,e,n)=>{let r=Ey(t,n);if(!r)return!1;let s=$d(r);return s?Ay(t,s,e):!1},Hk=(t,e,n)=>{let r=Ny(t,n);if(!r)return!1;let s=zd(r);return s?Ay(t,s,e):!1};function Ay(t,e,n){let r=e.nodeBefore,s=r,o=e.pos-1;for(;!s.isTextblock;o--){if(s.type.spec.isolating)return!1;let u=s.lastChild;if(!u)return!1;s=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=ka(t.doc,o,a,j.empty);if(!c||c.from!=o||c instanceof tt&&c.slice.size>=a-o)return!1;if(n){let u=t.tr.step(c);u.setSelection(Y.create(u.doc,o)),n(u.scrollIntoView())}return!0}function Es(t,e,n=!1){for(let r=t;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}const Ty=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=$d(r)}let i=o&&o.nodeBefore;return!i||!K.isSelectable(i)?!1:(e&&e(t.tr.setSelection(K.create(t.doc,o.pos-i.nodeSize)).scrollIntoView()),!0)};function $d(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ny(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Ry=(t,e,n)=>{let r=Ny(t,n);if(!r)return!1;let s=zd(r);if(!s)return!1;let o=s.nodeAfter;if(Iy(t,s,e,1))return!0;if(r.parent.content.size==0&&(Es(o,"start")||K.isSelectable(o))){let i=ka(t.doc,r.before(),r.after(),j.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=t.tr.step(i);l.setSelection(Es(o,"start")?Q.findFrom(l.doc.resolve(l.mapping.map(s.pos)),1):K.create(l.doc,l.mapping.map(s.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+o.nodeSize).scrollIntoView()),!0):!1},_y=(t,e,n)=>{let{$head:r,empty:s}=t.selection,o=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;o=zd(r)}let i=o&&o.nodeAfter;return!i||!K.isSelectable(i)?!1:(e&&e(t.tr.setSelection(K.create(t.doc,o.pos)).scrollIntoView()),!0)};function zd(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}const $k=(t,e)=>{let n=t.selection,r=n instanceof K,s;if(r){if(n.node.isTextblock||!kr(t.doc,n.from))return!1;s=n.from}else if(s=va(t.doc,n.from,-1),s==null)return!1;if(e){let o=t.tr.join(s);r&&o.setSelection(K.create(o.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(o.scrollIntoView())}return!0},zk=(t,e)=>{let n=t.selection,r;if(n instanceof K){if(n.node.isTextblock||!kr(t.doc,n.to))return!1;r=n.to}else if(r=va(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},Fk=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),o=s&&Is(s);return o==null?!1:(e&&e(t.tr.lift(s,o).scrollIntoView()),!0)},Oy=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
56
+ `).scrollIntoView()),!0)};function Fd(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Uk=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let s=n.node(-1),o=n.indexAfter(-1),i=Fd(s.contentMatchAt(o));if(!i||!s.canReplaceWith(o,o,i))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,i.createAndFill());a.setSelection(Q.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Dy=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof Nt||r.parent.inlineContent||s.parent.inlineContent)return!1;let o=Fd(s.parent.contentMatchAt(s.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let i=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,l=t.tr.insert(i,o.createAndFill());l.setSelection(Y.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Ly=(t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(Pn(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Is(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function Vk(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof K&&e.selection.node.isBlock)return!r.parentOffset||!Pn(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let o=[],i,l,a=!1,c=!1;for(let f=r.depth;;f--)if(r.node(f).isBlock){a=r.end(f)==r.pos+(r.depth-f),c=r.start(f)==r.pos-(r.depth-f),l=Fd(r.node(f-1).contentMatchAt(r.indexAfter(f-1))),o.unshift(a&&l?{type:l}:null),i=f;break}else{if(f==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof Y||e.selection instanceof Nt)&&u.deleteSelection();let d=u.mapping.map(r.pos),h=Pn(u.doc,d,o.length,o);if(h||(o[0]=l?{type:l}:null,h=Pn(u.doc,d,o.length,o)),!h)return!1;if(u.split(d,o.length,o),!a&&c&&r.node(i).type!=l){let f=u.mapping.map(r.before(i)),p=u.doc.resolve(f);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return n&&n(u.scrollIntoView()),!0}}const Wk=Vk(),qk=(t,e)=>{let{$from:n,to:r}=t.selection,s,o=n.sharedDepth(r);return o==0?!1:(s=n.before(o),e&&e(t.tr.setSelection(K.create(t.doc,s))),!0)};function Kk(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,o=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(s.isTextblock||kr(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function Iy(t,e,n,r){let s=e.nodeBefore,o=e.nodeAfter,i,l,a=s.type.spec.isolating||o.type.spec.isolating;if(!a&&Kk(t,e,n))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=s.contentMatchAt(s.childCount)).findWrapping(o.type))&&l.matchType(i[0]||o.type).validEnd){if(n){let f=e.pos+o.nodeSize,p=O.empty;for(let b=i.length-1;b>=0;b--)p=O.from(i[b].create(null,p));p=O.from(s.copy(p));let g=t.tr.step(new nt(e.pos-1,f,e.pos,f,new j(p,1,0),i.length,!0)),y=g.doc.resolve(f+2*i.length);y.nodeAfter&&y.nodeAfter.type==s.type&&kr(g.doc,y.pos)&&g.join(y.pos),n(g.scrollIntoView())}return!0}let u=o.type.spec.isolating||r>0&&a?null:Q.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),h=d&&Is(d);if(h!=null&&h>=e.depth)return n&&n(t.tr.lift(d,h).scrollIntoView()),!0;if(c&&Es(o,"start",!0)&&Es(s,"end")){let f=s,p=[];for(;p.push(f),!f.isTextblock;)f=f.lastChild;let g=o,y=1;for(;!g.isTextblock;g=g.firstChild)y++;if(f.canReplace(f.childCount,f.childCount,g.content)){if(n){let b=O.empty;for(let E=p.length-1;E>=0;E--)b=O.from(p[E].copy(b));let x=t.tr.step(new nt(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new j(b,p.length,0),0,!0));n(x.scrollIntoView())}return!0}}return!1}function jy(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,o=s.depth;for(;s.node(o).isInline;){if(!o)return!1;o--}return s.node(o).isTextblock?(n&&n(e.tr.setSelection(Y.create(e.doc,t<0?s.start(o):s.end(o)))),!0):!1}}const Gk=jy(-1),Jk=jy(1);function Yk(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o),l=i&&Ed(i,t,e);return l?(r&&r(n.tr.wrap(i,l).scrollIntoView()),!0):!1}}function hp(t,e=null){return function(n,r){let s=!1;for(let o=0;o<n.selection.ranges.length&&!s;o++){let{$from:{pos:i},$to:{pos:l}}=n.selection.ranges[o];n.doc.nodesBetween(i,l,(a,c)=>{if(s)return!1;if(!(!a.isTextblock||a.hasMarkup(t,e)))if(a.type==t)s=!0;else{let u=n.doc.resolve(c),d=u.index();s=u.parent.canReplaceWith(d,d+1,t)}})}if(!s)return!1;if(r){let o=n.tr;for(let i=0;i<n.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=n.selection.ranges[i];o.setBlockType(l,a,t,e)}r(o.scrollIntoView())}return!0}}function Ud(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}Ud(Hd,My,Ty);Ud(Hd,Ry,_y);Ud(Oy,Dy,Ly,Wk);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Xk(t,e=null){return function(n,r){let{$from:s,$to:o}=n.selection,i=s.blockRange(o);if(!i)return!1;let l=r?n.tr:null;return Zk(l,i,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Zk(t,e,n,r=null){let s=!1,o=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(n)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);o=new ko(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ko(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let l=Ed(o,n,r,e);return l?(t&&Qk(t,e,l,s,n),!0):!1}function Qk(t,e,n,r,s){let o=O.empty;for(let u=n.length-1;u>=0;u--)o=O.from(n[u].type.create(n[u].attrs,o));t.step(new nt(e.start-(r?2:0),e.end,e.start,e.end,new j(o,0,0),n.length,!0));let i=0;for(let u=0;u<n.length;u++)n[u].type==s&&(i=u+1);let l=n.length-i,a=e.start+n.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,h=!0;u<d;u++,h=!1)!h&&Pn(t.doc,a,l)&&(t.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return t}function eS(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,i=>i.childCount>0&&i.firstChild.type==t);return o?n?r.node(o.depth-1).type==t?tS(e,n,t,o):nS(e,n,o):!0:!1}}function tS(t,e,n,r){let s=t.tr,o=r.end,i=r.$to.end(r.depth);o<i&&(s.step(new nt(o-1,i,o,i,new j(O.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new ko(s.doc.resolve(r.$from.pos),s.doc.resolve(i),r.depth));const l=Is(r);if(l==null)return!1;s.lift(r,l);let a=s.doc.resolve(s.mapping.map(o,-1)-1);return kr(s.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&s.join(a.pos),e(s.scrollIntoView()),!0}function nS(t,e,n){let r=t.tr,s=n.parent;for(let f=n.end,p=n.endIndex-1,g=n.startIndex;p>g;p--)f-=s.child(p).nodeSize,r.delete(f-1,f+1);let o=r.doc.resolve(n.start),i=o.nodeAfter;if(r.mapping.map(n.end)!=n.start+o.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,a=n.endIndex==s.childCount,c=o.node(-1),u=o.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?O.empty:O.from(s))))return!1;let d=o.pos,h=d+i.nodeSize;return r.step(new nt(d-(l?1:0),h+(a?1:0),d+1,h-1,new j((l?O.empty:O.from(s.copy(O.empty))).append(a?O.empty:O.from(s.copy(O.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rS(t){return function(e,n){let{$from:r,$to:s}=e.selection,o=r.blockRange(s,c=>c.childCount>0&&c.firstChild.type==t);if(!o)return!1;let i=o.startIndex;if(i==0)return!1;let l=o.parent,a=l.child(i-1);if(a.type!=t)return!1;if(n){let c=a.lastChild&&a.lastChild.type==l.type,u=O.from(c?t.create():null),d=new j(O.from(t.create(null,O.from(l.type.create(null,u)))),c?3:1,0),h=o.start,f=o.end;n(e.tr.step(new nt(h-(c?3:1),f,h,f,d,1,!0)).scrollIntoView())}return!0}}var sS=Object.defineProperty,Py=(t,e)=>{for(var n in e)sS(t,n,{get:e[n],enumerable:!0})};function Aa(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,o=n.storedMarks,n}}}var Ta=class{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:s}=n,o=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([i,l])=>[i,(...c)=>{const u=l(...c)(o);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i=[],l=!!t,a=t||s.tr,c=()=>(!l&&e&&!a.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(a),i.every(d=>d===!0)),u={...Object.fromEntries(Object.entries(n).map(([d,h])=>[d,(...p)=>{const g=this.buildProps(a,e),y=h(...p)(g);return i.push(y),u}])),run:c};return u}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,o=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...c)=>a(...c)({...o,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:o}=r,i={tr:t,editor:r,view:o,state:Aa({state:s,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,a])=>[l,(...c)=>a(...c)(i)]))}};return i}},oS=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function By(t,e){const n=new Md(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}var Hy=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):r.nodeType===1&&Hy(r)}return t};function Oi(t){if(typeof window>"u")throw new Error("[tiptap error]: there is no window object available, so this function cannot be used");const e=`<body>${t}</body>`,n=new window.DOMParser().parseFromString(e,"text/html").body;return Hy(n)}function No(t,e,n){if(t instanceof cr||t instanceof O)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,s=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return O.fromArray(t.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(t);return n.errorOnInvalidContent&&i.check(),i}catch(o){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:o});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",o),No("",e,n)}if(s){if(n.errorOnInvalidContent){let i=!1,l="";const a=new Ag({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(n.slice?io.fromSchema(a).parseSlice(Oi(t),n.parseOptions):io.fromSchema(a).parse(Oi(t),n.parseOptions),n.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const o=io.fromSchema(e);return n.slice?o.parseSlice(Oi(t),n.parseOptions).content:o.parse(Oi(t),n.parseOptions)}return No("",e,n)}function Eu(t,e,n={},r={}){return No(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function iS(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Mu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function lS(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,o)=>{n(s)&&r.push({node:s,pos:o})}),r}function $y(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function Na(t){return e=>$y(e.$from,t)}function J(t,e,n){return t.config[e]===void 0&&t.parent?J(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?J(t.parent,e,n):null}):t.config[e]}function Vd(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=J(e,"addExtensions",n);return r?[e,...Vd(r())]:e}).flat(10)}function Wd(t,e){const n=ts.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function zy(t){return typeof t=="function"}function ke(t,e=void 0,...n){return zy(t)?e?t.bind(e)(...n):t(...n):t}function aS(t={}){return Object.keys(t).length===0&&t.constructor===Object}function Ro(t){const e=t.filter(s=>s.type==="extension"),n=t.filter(s=>s.type==="node"),r=t.filter(s=>s.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function Fy(t){const e=[],{nodeExtensions:n,markExtensions:r}=Ro(t),s=[...n,...r],o={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage,extensions:s},a=J(i,"addGlobalAttributes",l);if(!a)return;a().forEach(u=>{u.types.forEach(d=>{Object.entries(u.attributes).forEach(([h,f])=>{e.push({type:d,name:h,attribute:{...o,...f}})})})})}),s.forEach(i=>{const l={name:i.name,options:i.options,storage:i.storage},a=J(i,"addAttributes",l);if(!a)return;const c=a();Object.entries(c).forEach(([u,d])=>{const h={...o,...d};typeof(h==null?void 0:h.default)=="function"&&(h.default=h.default()),h!=null&&h.isRequired&&(h==null?void 0:h.default)===void 0&&delete h.default,e.push({type:i.name,name:u,attribute:h})})}),e}function xe(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,o])=>{if(!r[s]){r[s]=o;return}if(s==="class"){const l=o?String(o).split(" "):[],a=r[s]?r[s].split(" "):[],c=l.filter(u=>!a.includes(u));r[s]=[...a,...c].join(" ")}else if(s==="style"){const l=o?o.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[s]?r[s].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[d,h]=u.split(":").map(f=>f.trim());c.set(d,h)}),l.forEach(u=>{const[d,h]=u.split(":").map(f=>f.trim());c.set(d,h)}),r[s]=Array.from(c.entries()).map(([u,d])=>`${u}: ${d}`).join("; ")}else r[s]=o}),r},{})}function _o(t,e){return e.filter(n=>n.type===t.type.name).filter(n=>n.attribute.rendered).map(n=>n.attribute.renderHTML?n.attribute.renderHTML(t.attrs)||{}:{[n.name]:t.attrs[n.name]}).reduce((n,r)=>xe(n,r),{})}function cS(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function fp(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(r===!1)return!1;const s=e.reduce((o,i)=>{const l=i.attribute.parseHTML?i.attribute.parseHTML(n):cS(n.getAttribute(i.name));return l==null?o:{...o,[i.name]:l}},{});return{...r,...s}}}}function pp(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&aS(n)?!1:n!=null))}function uS(t,e){var n;const r=Fy(t),{nodeExtensions:s,markExtensions:o}=Ro(t),i=(n=s.find(c=>J(c,"topNode")))==null?void 0:n.name,l=Object.fromEntries(s.map(c=>{const u=r.filter(b=>b.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((b,x)=>{const E=J(x,"extendNodeSchema",d);return{...b,...E?E(c):{}}},{}),f=pp({...h,content:ke(J(c,"content",d)),marks:ke(J(c,"marks",d)),group:ke(J(c,"group",d)),inline:ke(J(c,"inline",d)),atom:ke(J(c,"atom",d)),selectable:ke(J(c,"selectable",d)),draggable:ke(J(c,"draggable",d)),code:ke(J(c,"code",d)),whitespace:ke(J(c,"whitespace",d)),linebreakReplacement:ke(J(c,"linebreakReplacement",d)),defining:ke(J(c,"defining",d)),isolating:ke(J(c,"isolating",d)),attrs:Object.fromEntries(u.map(b=>{var x,E;return[b.name,{default:(x=b==null?void 0:b.attribute)==null?void 0:x.default,validate:(E=b==null?void 0:b.attribute)==null?void 0:E.validate}]}))}),p=ke(J(c,"parseHTML",d));p&&(f.parseDOM=p.map(b=>fp(b,u)));const g=J(c,"renderHTML",d);g&&(f.toDOM=b=>g({node:b,HTMLAttributes:_o(b,u)}));const y=J(c,"renderText",d);return y&&(f.toText=y),[c.name,f]})),a=Object.fromEntries(o.map(c=>{const u=r.filter(y=>y.type===c.name),d={name:c.name,options:c.options,storage:c.storage,editor:e},h=t.reduce((y,b)=>{const x=J(b,"extendMarkSchema",d);return{...y,...x?x(c):{}}},{}),f=pp({...h,inclusive:ke(J(c,"inclusive",d)),excludes:ke(J(c,"excludes",d)),group:ke(J(c,"group",d)),spanning:ke(J(c,"spanning",d)),code:ke(J(c,"code",d)),attrs:Object.fromEntries(u.map(y=>{var b,x;return[y.name,{default:(b=y==null?void 0:y.attribute)==null?void 0:b.default,validate:(x=y==null?void 0:y.attribute)==null?void 0:x.validate}]}))}),p=ke(J(c,"parseHTML",d));p&&(f.parseDOM=p.map(y=>fp(y,u)));const g=J(c,"renderHTML",d);return g&&(f.toDOM=y=>g({mark:y,HTMLAttributes:_o(y,u)})),[c.name,f]}));return new Ag({topNode:i,nodes:l,marks:a})}function dS(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function qd(t){return t.sort((n,r)=>{const s=J(n,"priority")||100,o=J(r,"priority")||100;return s>o?-1:s<o?1:0})}function Uy(t){const e=qd(Vd(t)),n=dS(e.map(r=>r.name));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map(r=>`'${r}'`).join(", ")}]. This can lead to issues.`),e}function Vy(t,e,n){const{from:r,to:s}=e,{blockSeparator:o=`
57
+
58
+ `,textSerializers:i={}}=n||{};let l="";return t.nodesBetween(r,s,(a,c,u,d)=>{var h;a.isBlock&&c>r&&(l+=o);const f=i==null?void 0:i[a.type.name];if(f)return u&&(l+=f({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(h=a==null?void 0:a.text)==null?void 0:h.slice(Math.max(r,c)-c,s-c))}),l}function hS(t,e){const n={from:0,to:t.content.size};return Vy(t,n,e)}function Wy(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Fn(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function qy(t,e){const n=Fn(e,t.schema),{from:r,to:s,empty:o}=t.selection,i=[];o?(t.storedMarks&&i.push(...t.storedMarks),i.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===n.name);return l?{...l.attrs}:{}}function Je(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function fS(t,e){const n=Je(e,t.schema),{from:r,to:s}=t.selection,o=[];t.doc.nodesBetween(r,s,l=>{o.push(l)});const i=o.reverse().find(l=>l.type.name===n.name);return i?{...i.attrs}:{}}function Ra(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Ky(t,e){const n=Ra(typeof e=="string"?e:e.name,t.schema);return n==="node"?fS(t,e):n==="mark"?qy(t,e):{}}function pS(t,e=JSON.stringify){const n={};return t.filter(r=>{const s=e(r);return Object.prototype.hasOwnProperty.call(n,s)?!1:n[s]=!0})}function mS(t){const e=pS(t);return e.length===1?e:e.filter((n,r)=>!e.filter((o,i)=>i!==r).some(o=>n.oldRange.from>=o.oldRange.from&&n.oldRange.to<=o.oldRange.to&&n.newRange.from>=o.newRange.from&&n.newRange.to<=o.newRange.to))}function Gy(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,o)=>{const i=[];if(s.ranges.length)s.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=n[o];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(o).map(l,-1),u=e.slice(o).map(a),d=e.invert().map(c,-1),h=e.invert().map(u);r.push({oldRange:{from:d,to:h},newRange:{from:c,to:u}})})}),mS(r)}function Kd(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function El(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:Kd(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Jy(t,e,n={}){return t.find(r=>r.type===e&&El(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function mp(t,e,n={}){return!!Jy(t,e,n)}function Gd(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(u=>u.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(u=>u.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Jy([...s.node.marks],e,n)))return;let i=s.index,l=t.start()+s.offset,a=i+1,c=l+s.node.nodeSize;for(;i>0&&mp([...t.parent.child(i-1).marks],e,n);)i-=1,l-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&mp([...t.parent.child(a).marks],e,n);)c+=t.parent.child(a).nodeSize,a+=1;return{from:l,to:c}}function Jd(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const o=n.resolve(t),i=Gd(o,s.type);i&&r.push({mark:s,...i})}):n.nodesBetween(t,e,(s,o)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(i=>({from:o,to:o+s.nodeSize,mark:i})))}),r}var gS=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let o=r,i=null;for(;o>0&&i===null;){const l=s.node(o);(l==null?void 0:l.type.name)===e?i=l:o-=1}return[i,o]};function _c(t,e){return e.nodes[t]||e.marks[t]||null}function nl(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(o=>o.type===e&&o.name===r);return s?s.attribute.keepOnSplit:!1}))}var yS=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,o,i,l)=>{var a,c;const u=((c=(a=s.type.spec).toText)==null?void 0:c.call(a,{node:s,pos:o,parent:i,index:l}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?u:u.slice(0,Math.max(0,r-o))}),n};function Au(t,e,n={}){const{empty:r,ranges:s}=t.selection,o=e?Fn(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(d=>o?o.name===d.type.name:!0).find(d=>El(d.attrs,n,{strict:!1}));let i=0;const l=[];if(s.forEach(({$from:d,$to:h})=>{const f=d.pos,p=h.pos;t.doc.nodesBetween(f,p,(g,y)=>{if(!g.isText&&!g.marks.length)return;const b=Math.max(f,y),x=Math.min(p,y+g.nodeSize),E=x-b;i+=E,l.push(...g.marks.map(S=>({mark:S,from:b,to:x})))})}),i===0)return!1;const a=l.filter(d=>o?o.name===d.mark.type.name:!0).filter(d=>El(d.mark.attrs,n,{strict:!1})).reduce((d,h)=>d+h.to-h.from,0),c=l.filter(d=>o?d.mark.type!==o&&d.mark.type.excludes(o):!0).reduce((d,h)=>d+h.to-h.from,0);return(a>0?a+c:a)>=i}function pr(t,e,n={}){const{from:r,to:s,empty:o}=t.selection,i=e?Je(e,t.schema):null,l=[];t.doc.nodesBetween(r,s,(d,h)=>{if(d.isText)return;const f=Math.max(r,h),p=Math.min(s,h+d.nodeSize);l.push({node:d,from:f,to:p})});const a=s-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>El(d.node.attrs,n,{strict:!1}));return o?!!c.length:c.reduce((d,h)=>d+h.to-h.from,0)>=a}function bS(t,e,n={}){if(!e)return pr(t,null,n)||Au(t,null,n);const r=Ra(e,t.schema);return r==="node"?pr(t,e,n):r==="mark"?Au(t,e,n):!1}var xS=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const o=Na(l=>l.type.name===e)(t.selection);if(!o)return!1;const i=t.doc.resolve(o.pos+1);return s.pos+1===i.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},wS=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function gp(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function yp(t,e){const{nodeExtensions:n}=Ro(e),r=n.find(i=>i.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},o=ke(J(r,"group",s));return typeof o!="string"?!1:o.split(" ").includes("list")}function Yo(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return/^\s*$/m.test((r=t.text)!=null?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(t.content.childCount===0)return!0;if(e){let s=!0;return t.content.forEach(o=>{s!==!1&&(Yo(o,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Yy(t){return t instanceof K}function Xy(t){return t instanceof Y}function Lr(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Zy(t,e=null){if(!e)return null;const n=Q.atStart(t),r=Q.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,o=r.to;return e==="all"?Y.create(t,Lr(0,s,o),Lr(t.content.size,s,o)):Y.create(t,Lr(e,s,o),Lr(e,s,o))}function vS(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof tt||s instanceof nt))return;const o=t.mapping.maps[r];let i=0;o.forEach((l,a,c,u)=>{i===0&&(i=u)}),t.setSelection(Q.near(t.doc.resolve(i),n))}var Xo=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},kS=(t,e)=>{if(Kd(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function Di(t){var e;const{editor:n,from:r,to:s,text:o,rules:i,plugin:l}=t,{view:a}=n;if(a.composing)return!1;const c=a.state.doc.resolve(r);if(c.parent.type.spec.code||(e=c.nodeBefore||c.nodeAfter)!=null&&e.marks.find(h=>h.type.spec.code))return!1;let u=!1;const d=yS(c)+o;return i.forEach(h=>{if(u)return;const f=kS(d,h.find);if(!f)return;const p=a.state.tr,g=Aa({state:a.state,transaction:p}),y={from:r-(f[0].length-o.length),to:s},{commands:b,chain:x,can:E}=new Ta({editor:n,state:g});h.handler({state:g,range:y,match:f,commands:b,chain:x,can:E})===null||!p.steps.length||(h.undoable&&p.setMeta(l,{transform:p,from:r,to:s,text:o}),a.dispatch(p),u=!0)}),u}function SS(t){const{editor:e,rules:n}=t,r=new me({state:{init(){return null},apply(s,o,i){const l=s.getMeta(r);if(l)return l;const a=s.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:u}=a;typeof u=="string"?u=u:u=Wd(O.from(u),i.schema);const{from:d}=a,h=d+u.length;Di({editor:e,from:d,to:h,text:u,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:o}},props:{handleTextInput(s,o,i,l){return Di({editor:e,from:o,to:i,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:o}=s.state.selection;o&&Di({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,o){if(o.key!=="Enter")return!1;const{$cursor:i}=s.state.selection;return i?Di({editor:e,from:i.pos,to:i.pos,text:`
59
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function CS(t){return Object.prototype.toString.call(t).slice(8,-1)}function Li(t){return CS(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Qy(t,e){const n={...t};return Li(t)&&Li(e)&&Object.keys(e).forEach(r=>{Li(e[r])&&Li(t[r])?n[r]=Qy(t[r],e[r]):n[r]=e[r]}),n}var Yd=class{constructor(t={}){this.type="extendable",this.parent=null,this.child=null,this.name="",this.config={name:this.name},this.config={...this.config,...t},this.name=this.config.name}get options(){return{...ke(J(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...ke(J(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Qy(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new this.constructor({...this.config,...t});return e.parent=this,this.child=e,e.name="name"in t?t.name:e.parent.name,e}},ln=class eb extends Yd{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new eb(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const i=s.marks();if(!!!i.find(c=>(c==null?void 0:c.type.name)===n.name))return!1;const a=i.find(c=>(c==null?void 0:c.type.name)===n.name);return a&&r.removeStoredMark(a),r.insertText(" ",s.pos),e.view.dispatch(r),!0}return!1}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function ES(t){return typeof t=="number"}var MS=class{constructor(t){this.find=t.find,this.handler=t.handler}},AS=(t,e,n)=>{if(Kd(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const o=[s.text];return o.index=s.index,o.input=t,o.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),o.push(s.replaceWith)),o}):[]};function TS(t){const{editor:e,state:n,from:r,to:s,rule:o,pasteEvent:i,dropEvent:l}=t,{commands:a,chain:c,can:u}=new Ta({editor:e,state:n}),d=[];return n.doc.nodesBetween(r,s,(f,p)=>{var g,y,b,x,E;if((y=(g=f.type)==null?void 0:g.spec)!=null&&y.code||!(f.isText||f.isTextblock||f.isInline))return;const S=(E=(x=(b=f.content)==null?void 0:b.size)!=null?x:f.nodeSize)!=null?E:0,M=Math.max(r,p),w=Math.min(s,p+S);if(M>=w)return;const T=f.isText?f.text||"":f.textBetween(M-p,w-p,void 0,"");AS(T,o.find,i).forEach(N=>{if(N.index===void 0)return;const R=M+N.index+1,B=R+N[0].length,P={from:n.tr.mapping.map(R),to:n.tr.mapping.map(B)},L=o.handler({state:n,range:P,match:N,commands:a,chain:c,can:u,pasteEvent:i,dropEvent:l});d.push(L)})}),d.every(f=>f!==null)}var Ii=null,NS=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function RS(t){const{editor:e,rules:n}=t;let r=null,s=!1,o=!1,i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const a=({state:u,from:d,to:h,rule:f,pasteEvt:p})=>{const g=u.tr,y=Aa({state:u,transaction:g});if(!(!TS({editor:e,state:y,from:Math.max(d-1,0),to:h.b-1,rule:f,pasteEvent:p,dropEvent:l})||!g.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return i=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,g}};return n.map(u=>new me({view(d){const h=p=>{var g;r=(g=d.dom.parentElement)!=null&&g.contains(p.target)?d.dom.parentElement:null,r&&(Ii=e)},f=()=>{Ii&&(Ii=null)};return window.addEventListener("dragstart",h),window.addEventListener("dragend",f),{destroy(){window.removeEventListener("dragstart",h),window.removeEventListener("dragend",f)}}},props:{handleDOMEvents:{drop:(d,h)=>{if(o=r===d.dom.parentElement,l=h,!o){const f=Ii;f!=null&&f.isEditable&&setTimeout(()=>{const p=f.state.selection;p&&f.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(d,h)=>{var f;const p=(f=h.clipboardData)==null?void 0:f.getData("text/html");return i=h,s=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(d,h,f)=>{const p=d[0],g=p.getMeta("uiEvent")==="paste"&&!s,y=p.getMeta("uiEvent")==="drop"&&!o,b=p.getMeta("applyPasteRules"),x=!!b;if(!g&&!y&&!x)return;if(x){let{text:M}=b;typeof M=="string"?M=M:M=Wd(O.from(M),f.schema);const{from:w}=b,T=w+M.length,k=NS(M);return a({rule:u,state:f,from:w,to:{b:T},pasteEvt:k})}const E=h.doc.content.findDiffStart(f.doc.content),S=h.doc.content.findDiffEnd(f.doc.content);if(!(!ES(E)||!S||E===S.b))return a({rule:u,state:f,from:E,to:S,pasteEvt:i})}}))}var _a=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=Uy(t),this.schema=uS(this.extensions,e),this.setupExtensions()}get commands(){return this.extensions.reduce((t,e)=>{const n={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:_c(e.name,this.schema)},r=J(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return qd([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:_c(r.name,this.schema)},o=[],i=J(r,"addKeyboardShortcuts",s);let l={};if(r.type==="mark"&&J(r,"exitable",s)&&(l.ArrowRight=()=>ln.handleExit({editor:t,mark:r})),i){const h=Object.fromEntries(Object.entries(i()).map(([f,p])=>[f,()=>p({editor:t})]));l={...l,...h}}const a=Pk(l);o.push(a);const c=J(r,"addInputRules",s);if(gp(r,t.options.enableInputRules)&&c){const h=c();if(h&&h.length){const f=SS({editor:t,rules:h}),p=Array.isArray(f)?f:[f];o.push(...p)}}const u=J(r,"addPasteRules",s);if(gp(r,t.options.enablePasteRules)&&u){const h=u();if(h&&h.length){const f=RS({editor:t,rules:h});o.push(...f)}}const d=J(r,"addProseMirrorPlugins",s);if(d){const h=d();o.push(...h)}return o})}get attributes(){return Fy(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Ro(this.extensions);return Object.fromEntries(e.filter(n=>!!J(n,"addNodeView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Je(n.name,this.schema)},o=J(n,"addNodeView",s);if(!o)return[];const i=(l,a,c,u,d)=>{const h=_o(l,r);return o()({node:l,view:a,getPos:c,decorations:u,innerDecorations:d,editor:t,extension:n,HTMLAttributes:h})};return[n.name,i]}))}get markViews(){const{editor:t}=this,{markExtensions:e}=Ro(this.extensions);return Object.fromEntries(e.filter(n=>!!J(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:Fn(n.name,this.schema)},o=J(n,"addMarkView",s);if(!o)return[];const i=(l,a,c)=>{const u=_o(l,r);return o()({mark:l,view:a,inline:c,editor:t,extension:n,HTMLAttributes:u,updateAttributes:d=>{WC(l,t,d)}})};return[n.name,i]}))}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n;const r={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:_c(e.name,this.schema)};e.type==="mark"&&((n=ke(J(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=J(e,"onBeforeCreate",r),o=J(e,"onCreate",r),i=J(e,"onUpdate",r),l=J(e,"onSelectionUpdate",r),a=J(e,"onTransaction",r),c=J(e,"onFocus",r),u=J(e,"onBlur",r),d=J(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),i&&this.editor.on("update",i),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),u&&this.editor.on("blur",u),d&&this.editor.on("destroy",d)})}};_a.resolve=Uy;_a.sort=qd;_a.flatten=Vd;var _S={};Py(_S,{ClipboardTextSerializer:()=>nb,Commands:()=>ib,Delete:()=>lb,Drop:()=>ab,Editable:()=>cb,FocusEvents:()=>db,Keymap:()=>hb,Paste:()=>fb,Tabindex:()=>pb,focusEventsPluginKey:()=>ub});var fe=class tb extends Yd{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new tb(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},nb=fe.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new me({key:new ye("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:o}=s,i=Math.min(...o.map(u=>u.$from.pos)),l=Math.max(...o.map(u=>u.$to.pos)),a=Wy(n);return Vy(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}}),rb={};Py(rb,{blur:()=>OS,clearContent:()=>DS,clearNodes:()=>LS,command:()=>IS,createParagraphNear:()=>jS,cut:()=>PS,deleteCurrentNode:()=>BS,deleteNode:()=>HS,deleteRange:()=>$S,deleteSelection:()=>zS,enter:()=>FS,exitCode:()=>US,extendMarkRange:()=>VS,first:()=>WS,focus:()=>qS,forEach:()=>KS,insertContent:()=>GS,insertContentAt:()=>YS,joinBackward:()=>QS,joinDown:()=>ZS,joinForward:()=>eC,joinItemBackward:()=>tC,joinItemForward:()=>nC,joinTextblockBackward:()=>rC,joinTextblockForward:()=>sC,joinUp:()=>XS,keyboardShortcut:()=>iC,lift:()=>lC,liftEmptyBlock:()=>aC,liftListItem:()=>cC,newlineInCode:()=>uC,resetAttributes:()=>dC,scrollIntoView:()=>hC,selectAll:()=>fC,selectNodeBackward:()=>pC,selectNodeForward:()=>mC,selectParentNode:()=>gC,selectTextblockEnd:()=>yC,selectTextblockStart:()=>bC,setContent:()=>xC,setMark:()=>vC,setMeta:()=>kC,setNode:()=>SC,setNodeSelection:()=>CC,setTextSelection:()=>EC,sinkListItem:()=>MC,splitBlock:()=>AC,splitListItem:()=>TC,toggleList:()=>NC,toggleMark:()=>RC,toggleNode:()=>_C,toggleWrap:()=>OC,undoInputRule:()=>DC,unsetAllMarks:()=>LC,unsetMark:()=>IC,updateAttributes:()=>jC,wrapIn:()=>PC,wrapInList:()=>BC});var OS=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),DS=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),LS=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:o,$to:i})=>{t.doc.nodesBetween(o.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),h=c.resolve(u.map(a+l.nodeSize)),f=d.blockRange(h);if(!f)return;const p=Is(f);if(l.type.isTextblock){const{defaultType:g}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(f.start,g)}(p||p===0)&&e.lift(f,p)})}),!0},IS=t=>e=>t(e),jS=()=>({state:t,dispatch:e})=>Dy(t,e),PS=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,o=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const i=r.mapping.map(e);return r.insert(i,o.content),r.setSelection(new Y(r.doc.resolve(Math.max(i-1,0)))),!0},BS=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const s=t.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===r.type){if(e){const l=s.before(o),a=s.after(o);t.delete(l,a).scrollIntoView()}return!0}return!1},HS=t=>({tr:e,state:n,dispatch:r})=>{const s=Je(t,n.schema),o=e.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===s){if(r){const a=o.before(i),c=o.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},$S=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},zS=()=>({state:t,dispatch:e})=>Hd(t,e),FS=()=>({commands:t})=>t.keyboardShortcut("Enter"),US=()=>({state:t,dispatch:e})=>Uk(t,e),VS=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const o=Fn(t,r.schema),{doc:i,selection:l}=n,{$from:a,from:c,to:u}=l;if(s){const d=Gd(a,o,e);if(d&&d.from<=c&&d.to>=u){const h=Y.create(i,d.from,d.to);n.setSelection(h)}}return!0},WS=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function sb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function Oa(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}var qS=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:o})=>{e={scrollIntoView:!0,...e};const i=()=>{(Oa()||sb())&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!Xy(n.state.selection))return i(),!0;const l=Zy(s.doc,t)||n.state.selection,a=n.state.selection.eq(l);return o&&(a||s.setSelection(l),a&&s.storedMarks&&s.setStoredMarks(s.storedMarks),i()),!0},KS=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),GS=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),JS=t=>!("type"in t),YS=(t,e,n)=>({tr:r,dispatch:s,editor:o})=>{var i;if(s){n={parseOptions:o.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const a=y=>{o.emit("contentError",{editor:o,error:y,disableCollaboration:()=>{"collaboration"in o.storage&&typeof o.storage.collaboration=="object"&&o.storage.collaboration&&(o.storage.collaboration.isDisabled=!0)}})},c={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!o.options.enableContentCheck&&o.options.emitContentError)try{No(e,o.schema,{parseOptions:c,errorOnInvalidContent:!0})}catch(y){a(y)}try{l=No(e,o.schema,{parseOptions:c,errorOnInvalidContent:(i=n.errorOnInvalidContent)!=null?i:o.options.enableContentCheck})}catch(y){return a(y),!1}let{from:u,to:d}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},h=!0,f=!0;if((JS(l)?l:[l]).forEach(y=>{y.check(),h=h?y.isText&&y.marks.length===0:!1,f=f?y.isBlock:!1}),u===d&&f){const{parent:y}=r.doc.resolve(u);y.isTextblock&&!y.type.spec.code&&!y.childCount&&(u-=1,d+=1)}let g;if(h){if(Array.isArray(e))g=e.map(y=>y.text||"").join("");else if(e instanceof O){let y="";e.forEach(b=>{b.text&&(y+=b.text)}),g=y}else typeof e=="object"&&e&&e.text?g=e.text:g=e;r.insertText(g,u,d)}else{g=l;const y=r.doc.resolve(u),b=y.node(),x=y.parentOffset===0,E=b.isText||b.isTextblock,S=b.content.size>0;x&&E&&S&&(u=Math.max(0,u-1)),r.replaceWith(u,d,g)}n.updateSelection&&vS(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:u,text:g}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:u,text:g})}return!0},XS=()=>({state:t,dispatch:e})=>$k(t,e),ZS=()=>({state:t,dispatch:e})=>zk(t,e),QS=()=>({state:t,dispatch:e})=>My(t,e),eC=()=>({state:t,dispatch:e})=>Ry(t,e),tC=()=>({state:t,dispatch:e,tr:n})=>{try{const r=va(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},nC=()=>({state:t,dispatch:e,tr:n})=>{try{const r=va(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},rC=()=>({state:t,dispatch:e})=>Bk(t,e),sC=()=>({state:t,dispatch:e})=>Hk(t,e);function ob(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function oC(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,o,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))s=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))Oa()||ob()?i=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),i&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}var iC=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const o=oC(t).split(/-(?!$)/),i=o.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{n.someProp("handleKeyDown",c=>c(n,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&s&&r.maybeStep(u)}),!0},lC=(t,e={})=>({state:n,dispatch:r})=>{const s=Je(t,n.schema);return pr(n,s,e)?Fk(n,r):!1},aC=()=>({state:t,dispatch:e})=>Ly(t,e),cC=t=>({state:e,dispatch:n})=>{const r=Je(t,e.schema);return eS(r)(e,n)},uC=()=>({state:t,dispatch:e})=>Oy(t,e);function bp(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,s)=>(n.includes(s)||(r[s]=t[s]),r),{})}var dC=(t,e)=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=Ra(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(o=Je(t,r.schema)),l==="mark"&&(i=Fn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{o&&o===c.type&&n.setNodeMarkup(u,void 0,bp(c.attrs,e)),i&&c.marks.length&&c.marks.forEach(d=>{i===d.type&&n.addMark(u,u+c.nodeSize,i.create(bp(d.attrs,e)))})})}),!0):!1},hC=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),fC=()=>({tr:t,dispatch:e})=>{if(e){const n=new Nt(t.doc);t.setSelection(n)}return!0},pC=()=>({state:t,dispatch:e})=>Ty(t,e),mC=()=>({state:t,dispatch:e})=>_y(t,e),gC=()=>({state:t,dispatch:e})=>qk(t,e),yC=()=>({state:t,dispatch:e})=>Jk(t,e),bC=()=>({state:t,dispatch:e})=>Gk(t,e),xC=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:o,dispatch:i,commands:l})=>{const{doc:a}=o;if(r.preserveWhitespace!=="full"){const c=Eu(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return i&&o.replaceWith(0,a.content.size,c).setMeta("preventUpdate",!n),!0}return i&&o.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:a.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function wC(t,e,n){var r;const{selection:s}=e;let o=null;if(Xy(s)&&(o=s.$cursor),o){const l=(r=t.storedMarks)!=null?r:o.marks();return o.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(c=>c.type.excludes(n)))}const{ranges:i}=s;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,a.pos,(u,d,h)=>{if(c)return!1;if(u.isInline){const f=!h||h.type.allowsMarkType(n),p=!!n.isInSet(u.marks)||!u.marks.some(g=>g.type.excludes(n));c=f&&p}return!c}),c})}var vC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:o}=n,{empty:i,ranges:l}=o,a=Fn(t,r.schema);if(s)if(i){const c=qy(r,a);n.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(h,f)=>{const p=Math.max(f,u),g=Math.min(f+h.nodeSize,d);h.marks.find(b=>b.type===a)?h.marks.forEach(b=>{a===b.type&&n.addMark(p,g,a.create({...b.attrs,...e}))}):n.addMark(p,g,a.create(e))})});return wC(r,n,a)},kC=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),SC=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const o=Je(t,n.schema);let i;return n.selection.$anchor.sameParent(n.selection.$head)&&(i=n.selection.$anchor.parent.attrs),o.isTextblock?s().command(({commands:l})=>hp(o,{...i,...e})(n)?!0:l.clearNodes()).command(({state:l})=>hp(o,{...i,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},CC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Lr(t,0,r.content.size),o=K.create(r,s);e.setSelection(o)}return!0},EC=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:o}=typeof t=="number"?{from:t,to:t}:t,i=Y.atStart(r).from,l=Y.atEnd(r).to,a=Lr(s,i,l),c=Lr(o,i,l),u=Y.create(r,a,c);e.setSelection(u)}return!0},MC=t=>({state:e,dispatch:n})=>{const r=Je(t,e.schema);return rS(r)(e,n)};function xp(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(s=>e==null?void 0:e.includes(s.type.name));t.tr.ensureMarks(r)}}var AC=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:o,doc:i}=e,{$from:l,$to:a}=o,c=s.extensionManager.attributes,u=nl(c,l.node().type.name,l.node().attrs);if(o instanceof K&&o.node.isBlock)return!l.parentOffset||!Pn(i,l.pos)?!1:(r&&(t&&xp(n,s.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const d=a.parentOffset===a.parent.content.size,h=l.depth===0?void 0:iS(l.node(-1).contentMatchAt(l.indexAfter(-1)));let f=d&&h?[{type:h,attrs:u}]:void 0,p=Pn(e.doc,e.mapping.map(l.pos),1,f);if(!f&&!p&&Pn(e.doc,e.mapping.map(l.pos),1,h?[{type:h}]:void 0)&&(p=!0,f=h?[{type:h,attrs:u}]:void 0),r){if(p&&(o instanceof Y&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,f),h&&!d&&!l.parentOffset&&l.parent.type!==h)){const g=e.mapping.map(l.before()),y=e.doc.resolve(g);l.node(-1).canReplaceWith(y.index(),y.index()+1,h)&&e.setNodeMarkup(e.mapping.map(l.before()),h)}t&&xp(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return p},TC=(t,e={})=>({tr:n,state:r,dispatch:s,editor:o})=>{var i;const l=Je(t,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const d=a.node(-1);if(d.type!==l)return!1;const h=o.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(s){let b=O.empty;const x=a.index(-1)?1:a.index(-2)?2:3;for(let k=a.depth-x;k>=a.depth-3;k-=1)b=O.from(a.node(k).copy(b));const E=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,S={...nl(h,a.node().type.name,a.node().attrs),...e},M=((i=l.contentMatch.defaultType)==null?void 0:i.createAndFill(S))||void 0;b=b.append(O.from(l.createAndFill(null,M)||void 0));const w=a.before(a.depth-(x-1));n.replace(w,a.after(-E),new j(b,4-x,0));let T=-1;n.doc.nodesBetween(w,n.doc.content.size,(k,N)=>{if(T>-1)return!1;k.isTextblock&&k.content.size===0&&(T=N+1)}),T>-1&&n.setSelection(Y.near(n.doc.resolve(T))),n.scrollIntoView()}return!0}const f=c.pos===a.end()?d.contentMatchAt(0).defaultType:null,p={...nl(h,d.type.name,d.attrs),...e},g={...nl(h,a.node().type.name,a.node().attrs),...e};n.delete(a.pos,c.pos);const y=f?[{type:l,attrs:p},{type:f,attrs:g}]:[{type:l,attrs:p}];if(!Pn(n.doc,a.pos,2))return!1;if(s){const{selection:b,storedMarks:x}=r,{splittableMarks:E}=o.extensionManager,S=x||b.$to.parentOffset&&b.$from.marks();if(n.split(a.pos,2,y).scrollIntoView(),!S||!s)return!0;const M=S.filter(w=>E.includes(w.type.name));n.ensureMarks(M)}return!0},Oc=(t,e)=>{const n=Na(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&kr(t.doc,n.pos)&&t.join(n.pos),!0},Dc=(t,e)=>{const n=Na(i=>i.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const s=t.doc.nodeAt(r);return n.node.type===(s==null?void 0:s.type)&&kr(t.doc,r)&&t.join(r),!0},NC=(t,e,n,r={})=>({editor:s,tr:o,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:h}=s.extensionManager,f=Je(t,i.schema),p=Je(e,i.schema),{selection:g,storedMarks:y}=i,{$from:b,$to:x}=g,E=b.blockRange(x),S=y||g.$to.parentOffset&&g.$from.marks();if(!E)return!1;const M=Na(w=>yp(w.type.name,d))(g);if(E.depth>=1&&M&&E.depth-M.depth<=1){if(M.node.type===f)return c.liftListItem(p);if(yp(M.node.type.name,d)&&f.validContent(M.node.content)&&l)return a().command(()=>(o.setNodeMarkup(M.pos,f),!0)).command(()=>Oc(o,f)).command(()=>Dc(o,f)).run()}return!n||!S||!l?a().command(()=>u().wrapInList(f,r)?!0:c.clearNodes()).wrapInList(f,r).command(()=>Oc(o,f)).command(()=>Dc(o,f)).run():a().command(()=>{const w=u().wrapInList(f,r),T=S.filter(k=>h.includes(k.type.name));return o.ensureMarks(T),w?!0:c.clearNodes()}).wrapInList(f,r).command(()=>Oc(o,f)).command(()=>Dc(o,f)).run()},RC=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:o=!1}=n,i=Fn(t,r.schema);return Au(r,i,e)?s.unsetMark(i,{extendEmptyMarkRange:o}):s.setMark(i,e)},_C=(t,e,n={})=>({state:r,commands:s})=>{const o=Je(t,r.schema),i=Je(e,r.schema),l=pr(r,o,n);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?s.setNode(i,a):s.setNode(o,{...a,...n})},OC=(t,e={})=>({state:n,commands:r})=>{const s=Je(t,n.schema);return pr(n,s,e)?r.lift(s):r.wrapIn(s,e)},DC=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let o;if(s.spec.isInputRules&&(o=s.getState(t))){if(e){const i=t.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(o.text){const a=i.doc.resolve(o.from).marks();i.replaceWith(o.from,o.to,t.schema.text(o.text,a))}else i.delete(o.from,o.to)}return!0}}return!1},LC=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},IC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var o;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=n,a=Fn(t,r.schema),{$from:c,empty:u,ranges:d}=l;if(!s)return!0;if(u&&i){let{from:h,to:f}=l;const p=(o=c.marks().find(y=>y.type===a))==null?void 0:o.attrs,g=Gd(c,a,p);g&&(h=g.from,f=g.to),n.removeMark(h,f,a)}else d.forEach(h=>{n.removeMark(h.$from.pos,h.$to.pos,a)});return n.removeStoredMark(a),!0},jC=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let o=null,i=null;const l=Ra(typeof t=="string"?t:t.name,r.schema);return l?(l==="node"&&(o=Je(t,r.schema)),l==="mark"&&(i=Fn(t,r.schema)),s&&n.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;let d,h,f,p;n.selection.empty?r.doc.nodesBetween(c,u,(g,y)=>{o&&o===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,h=g)}):r.doc.nodesBetween(c,u,(g,y)=>{y<c&&o&&o===g.type&&(f=Math.max(y,c),p=Math.min(y+g.nodeSize,u),d=y,h=g),y>=c&&y<=u&&(o&&o===g.type&&n.setNodeMarkup(y,void 0,{...g.attrs,...e}),i&&g.marks.length&&g.marks.forEach(b=>{if(i===b.type){const x=Math.max(y,c),E=Math.min(y+g.nodeSize,u);n.addMark(x,E,i.create({...b.attrs,...e}))}}))}),h&&(d!==void 0&&n.setNodeMarkup(d,void 0,{...h.attrs,...e}),i&&h.marks.length&&h.marks.forEach(g=>{i===g.type&&n.addMark(f,p,i.create({...g.attrs,...e}))}))}),!0):!1},PC=(t,e={})=>({state:n,dispatch:r})=>{const s=Je(t,n.schema);return Yk(s,e)(n,r)},BC=(t,e={})=>({state:n,dispatch:r})=>{const s=Je(t,n.schema);return Xk(s,e)(n,r)},ib=fe.create({name:"commands",addCommands(){return{...rb}}}),lb=fe.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const o=()=>{var i,l,a,c;if((c=(a=(l=(i=this.editor.options.coreExtensionOptions)==null?void 0:i.delete)==null?void 0:l.filterTransaction)==null?void 0:a.call(l,t))!=null?c:t.getMeta("y-sync$"))return;const u=By(t.before,[t,...e]);Gy(u).forEach(f=>{u.mapping.mapResult(f.oldRange.from).deletedAfter&&u.mapping.mapResult(f.oldRange.to).deletedBefore&&u.before.nodesBetween(f.oldRange.from,f.oldRange.to,(p,g)=>{const y=g+p.nodeSize-2,b=f.oldRange.from<=g&&y<=f.oldRange.to;this.editor.emit("delete",{type:"node",node:p,from:g,to:y,newFrom:u.mapping.map(g),newTo:u.mapping.map(y),deletedRange:f.oldRange,newRange:f.newRange,partial:!b,editor:this.editor,transaction:t,combinedTransform:u})})});const h=u.mapping;u.steps.forEach((f,p)=>{var g,y;if(f instanceof Zt){const b=h.slice(p).map(f.from,-1),x=h.slice(p).map(f.to),E=h.invert().map(b,-1),S=h.invert().map(x),M=(g=u.doc.nodeAt(b-1))==null?void 0:g.marks.some(T=>T.eq(f.mark)),w=(y=u.doc.nodeAt(x))==null?void 0:y.marks.some(T=>T.eq(f.mark));this.editor.emit("delete",{type:"mark",mark:f.mark,from:f.from,to:f.to,deletedRange:{from:E,to:S},newRange:{from:b,to:x},partial:!!(w||M),editor:this.editor,transaction:t,combinedTransform:u})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(o,0):o()}}),ab=fe.create({name:"drop",addProseMirrorPlugins(){return[new me({key:new ye("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),cb=fe.create({name:"editable",addProseMirrorPlugins(){return[new me({key:new ye("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ub=new ye("focusEvents"),db=fe.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new me({key:ub,props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),hb=fe.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:h,parent:f}=d,p=d.parent.isTextblock&&h>0?l.doc.resolve(h-1):d,g=p.parent.type.spec.isolating,y=d.pos-d.parentOffset,b=g&&p.parent.childCount===1?y===d.pos:Q.atStart(c).from===h;return!u||!f.type.isTextblock||f.textContent.length||!b||b&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},s={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Oa()||ob()?o:s},addProseMirrorPlugins(){return[new me({key:new ye("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(g=>g.getMeta("composition")))return;const r=t.some(g=>g.docChanged)&&!e.doc.eq(n.doc),s=t.some(g=>g.getMeta("preventClearDocument"));if(!r||s)return;const{empty:o,from:i,to:l}=e.selection,a=Q.atStart(e.doc).from,c=Q.atEnd(e.doc).to;if(o||!(i===a&&l===c)||!Yo(n.doc))return;const h=n.tr,f=Aa({state:n,transaction:h}),{commands:p}=new Ta({editor:this.editor,state:f});if(p.clearNodes(),!!h.steps.length)return h}})]}}),fb=fe.create({name:"paste",addProseMirrorPlugins(){return[new me({key:new ye("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),pb=fe.create({name:"tabindex",addProseMirrorPlugins(){return[new me({key:new ye("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),HC=class ds{constructor(e,n,r=!1,s=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=s}get name(){return this.node.type.name}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!=null?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let n=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}n=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:n,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;const e=this.resolvedPos.start(this.resolvedPos.depth-1),n=this.resolvedPos.doc.resolve(e);return new ds(n,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new ds(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new ds(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,o=n.isAtom&&!n.isText,i=this.pos+r+(o?0:1);if(i<0||i>this.resolvedPos.doc.nodeSize-2)return;const l=this.resolvedPos.doc.resolve(i);if(!s&&l.depth<=this.depth)return;const a=new ds(l,this.editor,s,s?n:null);s&&(a.actualDepth=this.depth+1),e.push(new ds(l,this.editor,s,s?n:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){const e=this.children;return e[e.length-1]||null}closest(e,n={}){let r=null,s=this.parent;for(;s&&!r;){if(s.node.type.name===e)if(Object.keys(n).length>0){const o=s.node.attrs,i=Object.keys(n);for(let l=0;l<i.length;l+=1){const a=i[l];if(o[a]!==n[a])break}}else r=s;s=s.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let s=[];if(!this.children||this.children.length===0)return s;const o=Object.keys(n);return this.children.forEach(i=>{r&&s.length>0||(i.node.type.name===e&&o.every(a=>n[a]===i.node.attrs[a])&&s.push(i),!(r&&s.length>0)&&(s=s.concat(i.querySelectorAll(e,n,r))))}),s}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},$C=`.ProseMirror {
60
+ position: relative;
61
+ }
62
+
63
+ .ProseMirror {
64
+ word-wrap: break-word;
65
+ white-space: pre-wrap;
66
+ white-space: break-spaces;
67
+ -webkit-font-variant-ligatures: none;
68
+ font-variant-ligatures: none;
69
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
70
+ }
71
+
72
+ .ProseMirror [contenteditable="false"] {
73
+ white-space: normal;
74
+ }
75
+
76
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
77
+ white-space: pre-wrap;
78
+ }
79
+
80
+ .ProseMirror pre {
81
+ white-space: pre-wrap;
82
+ }
83
+
84
+ img.ProseMirror-separator {
85
+ display: inline !important;
86
+ border: none !important;
87
+ margin: 0 !important;
88
+ width: 0 !important;
89
+ height: 0 !important;
90
+ }
91
+
92
+ .ProseMirror-gapcursor {
93
+ display: none;
94
+ pointer-events: none;
95
+ position: absolute;
96
+ margin: 0;
97
+ }
98
+
99
+ .ProseMirror-gapcursor:after {
100
+ content: "";
101
+ display: block;
102
+ position: absolute;
103
+ top: -2px;
104
+ width: 20px;
105
+ border-top: 1px solid black;
106
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
107
+ }
108
+
109
+ @keyframes ProseMirror-cursor-blink {
110
+ to {
111
+ visibility: hidden;
112
+ }
113
+ }
114
+
115
+ .ProseMirror-hideselection *::selection {
116
+ background: transparent;
117
+ }
118
+
119
+ .ProseMirror-hideselection *::-moz-selection {
120
+ background: transparent;
121
+ }
122
+
123
+ .ProseMirror-hideselection * {
124
+ caret-color: transparent;
125
+ }
126
+
127
+ .ProseMirror-focused .ProseMirror-gapcursor {
128
+ display: block;
129
+ }`;function zC(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const s=document.createElement("style");return e&&s.setAttribute("nonce",e),s.setAttribute("data-tiptap-style",""),s.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(s),s}var FC=class extends oS{constructor(e={}){super(),this.css=null,this.editorView=null,this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.instanceId=Math.random().toString(36).slice(2,9),this.options={element:typeof document<"u"?document.createElement("div"):null,content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,emitContentError:!1,onBeforeCreate:()=>null,onCreate:()=>null,onMount:()=>null,onUnmount:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:s})=>{throw s},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("mount",this.options.onMount),this.on("unmount",this.options.onUnmount),this.on("contentError",this.options.onContentError),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:s,slice:o,moved:i})=>this.options.onDrop(s,o,i)),this.on("paste",({event:s,slice:o})=>this.options.onPaste(s,o)),this.on("delete",this.options.onDelete);const n=this.createDoc(),r=Zy(n,this.options.autofocus);this.editorState=fs.create({doc:n,schema:this.schema,selection:r||void 0}),this.options.element&&this.mount(this.options.element)}mount(e){if(typeof document>"u")throw new Error("[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.");this.createView(e),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const e=this.editorView.dom;e!=null&&e.editor&&delete e.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(e){console.warn("Failed to remove CSS element:",e)}this.css=null,this.emit("unmount",{editor:this})}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&typeof document<"u"&&(this.css=zC($C,this.options.injectNonce))}setOptions(e={}){this.options={...this.options,...e},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,n=!0){this.setOptions({editable:e}),n&&this.emit("update",{editor:this,transaction:this.state.tr,appendedTransactions:[]})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get view(){return this.editorView?this.editorView:new Proxy({state:this.editorState,updateState:e=>{this.editorState=e},dispatch:e=>{this.dispatchTransaction(e)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(e,n)=>{if(this.editorView)return this.editorView[n];if(n==="state")return this.editorState;if(n in e)return Reflect.get(e,n);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${n}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(e,n){const r=zy(n)?n(e,[...this.state.plugins]):[...this.state.plugins,e],s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}unregisterPlugin(e){if(this.isDestroyed)return;const n=this.state.plugins;let r=n;if([].concat(e).forEach(o=>{const i=typeof o=="string"?`${o}$`:o.key;r=r.filter(l=>!l.key.startsWith(i))}),n.length===r.length)return;const s=this.state.reconfigure({plugins:r});return this.view.updateState(s),s}createExtensionManager(){var e,n;const s=[...this.options.enableCoreExtensions?[cb,nb.configure({blockSeparator:(n=(e=this.options.coreExtensionOptions)==null?void 0:e.clipboardTextSerializer)==null?void 0:n.blockSeparator}),ib,db,hb,pb,ab,fb,lb].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o==null?void 0:o.type));this.extensionManager=new _a(s,this)}createCommandManager(){this.commandManager=new Ta({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let e;try{e=Eu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(n){if(!(n instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(n.message))throw n;this.emit("contentError",{editor:this,error:n,disableCollaboration:()=>{"collaboration"in this.storage&&typeof this.storage.collaboration=="object"&&this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(r=>r.name!=="collaboration"),this.createExtensionManager()}}),e=Eu(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return e}createView(e){var n;this.editorView=new Cy(e,{...this.options.editorProps,attributes:{role:"textbox",...(n=this.options.editorProps)==null?void 0:n.attributes},dispatchTransaction:this.dispatchTransaction.bind(this),state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const r=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(r),this.prependClass(),this.injectCSS();const s=this.view.dom;s.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;const n=this.capturedTransaction;return this.capturedTransaction=null,n}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(u=>{var d;return(d=this.capturedTransaction)==null?void 0:d.step(u)});return}const{state:n,transactions:r}=this.state.applyTransaction(e),s=!this.state.selection.eq(n.selection),o=r.includes(e),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:e,nextState:n}),!o)return;this.view.updateState(n),this.emit("transaction",{editor:this,transaction:e,appendedTransactions:r.slice(1)}),s&&this.emit("selectionUpdate",{editor:this,transaction:e});const l=r.findLast(u=>u.getMeta("focus")||u.getMeta("blur")),a=l==null?void 0:l.getMeta("focus"),c=l==null?void 0:l.getMeta("blur");a&&this.emit("focus",{editor:this,event:a.event,transaction:l}),c&&this.emit("blur",{editor:this,event:c.event,transaction:l}),!(e.getMeta("preventUpdate")||!r.some(u=>u.docChanged)||i.doc.eq(n.doc))&&this.emit("update",{editor:this,transaction:e,appendedTransactions:r.slice(1)})}getAttributes(e){return Ky(this.state,e)}isActive(e,n){const r=typeof e=="string"?e:null,s=typeof e=="string"?n:e;return bS(this.state,r,s)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Wd(this.state.doc.content,this.schema)}getText(e){const{blockSeparator:n=`
130
+
131
+ `,textSerializers:r={}}=e||{};return hS(this.state.doc,{blockSeparator:n,textSerializers:{...Wy(this.schema),...r}})}get isEmpty(){return Yo(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var e,n;return(n=(e=this.editorView)==null?void 0:e.isDestroyed)!=null?n:!0}$node(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelector(e,n))||null}$nodes(e,n){var r;return((r=this.$doc)==null?void 0:r.querySelectorAll(e,n))||null}$pos(e){const n=this.state.doc.resolve(e);return new HC(n,this)}get $doc(){return this.$pos(0)}};function Kr(t){return new Xo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=ke(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:o}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=n.from+l.indexOf(i),u=c+i.length;if(Jd(n.from,n.to,e.doc).filter(f=>f.mark.type.excluded.find(g=>g===t.type&&g!==f.mark.type)).filter(f=>f.to>c).length)return null;u<n.to&&o.delete(u,n.to),c>n.from&&o.delete(n.from+a,c);const h=n.from+a+i.length;o.addMark(n.from+a,h,t.type.create(s||{})),o.removeStoredMark(t.type)}},undoable:t.undoable})}function mb(t){return new Xo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=ke(t.getAttributes,void 0,r)||{},{tr:o}=e,i=n.from;let l=n.to;const a=t.type.create(s);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];o.insertText(d,i+r[0].length-1),o.replaceWith(u,l,a)}else if(r[0]){const c=t.type.isInline?i:i-1;o.insert(c,t.type.create(s)).delete(o.mapping.map(i),o.mapping.map(l))}o.scrollIntoView()},undoable:t.undoable})}function Tu(t){return new Xo({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),o=ke(t.getAttributes,void 0,r)||{};if(!s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,o)},undoable:t.undoable})}function ze(t){return new Xo({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,o=n.from;const i=n.to;if(r[1]){const l=r[0].lastIndexOf(r[1]);s+=r[0].slice(l+r[1].length),o+=l;const a=o-i;a>0&&(s=r[0].slice(l-a,l)+s,o=i)}e.tr.insertText(s,o,i)},undoable:t.undoable})}function Ms(t){return new Xo({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const o=ke(t.getAttributes,void 0,r)||{},i=e.tr.delete(n.from,n.to),a=i.doc.resolve(n.from).blockRange(),c=a&&Ed(a,t.type,o);if(!c)return null;if(i.wrap(a,c),t.keepMarks&&t.editor){const{selection:d,storedMarks:h}=e,{splittableMarks:f}=t.editor.extensionManager,p=h||d.$to.parentOffset&&d.$from.marks();if(p){const g=p.filter(y=>f.includes(y.type.name));i.ensureMarks(g)}}if(t.keepAttributes){const d=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(d,o).run()}const u=i.doc.resolve(n.from-1).nodeBefore;u&&u.type===t.type&&kr(i.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,u))&&i.join(n.from-1)},undoable:t.undoable})}function UC(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof K){const o=r.index();return r.parent.canReplaceWith(o,o+1,e)}let s=r.depth;for(;s>=0;){const o=r.index(s);if(r.node(s).contentMatchAt(o).matchType(e))return!0;s-=1}return!1}function VC(t){return t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function WC(t,e,n={}){const{state:r}=e,{doc:s,tr:o}=r,i=t;s.descendants((l,a)=>{const c=o.mapping.map(a),u=o.mapping.map(a)+l.nodeSize;let d=null;if(l.marks.forEach(f=>{if(f!==i)return!1;d=f}),!d)return;let h=!1;if(Object.keys(n).forEach(f=>{n[f]!==d.attrs[f]&&(h=!0)}),h){const f=t.type.create({...t.attrs,...n});o.removeMark(c,u,t.type),o.addMark(c,u,f)}}),o.docChanged&&e.view.dispatch(o)}var Ie=class gb extends Yd{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new gb(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},qC=class{constructor(t,e,n){this.isDragging=!1,this.component=t,this.editor=e.editor,this.options={stopEvent:null,ignoreMutation:null,...n},this.extension=e.extension,this.node=e.node,this.decorations=e.decorations,this.innerDecorations=e.innerDecorations,this.view=e.view,this.HTMLAttributes=e.HTMLAttributes,this.getPos=e.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(t){var e,n,r,s,o,i,l;const{view:a}=this.editor,c=t.target,u=c.nodeType===3?(e=c.parentElement)==null?void 0:e.closest("[data-drag-handle]"):c.closest("[data-drag-handle]");if(!this.dom||(n=this.contentDOM)!=null&&n.contains(c)||!u)return;let d=0,h=0;if(this.dom!==u){const x=this.dom.getBoundingClientRect(),E=u.getBoundingClientRect(),S=(s=t.offsetX)!=null?s:(r=t.nativeEvent)==null?void 0:r.offsetX,M=(i=t.offsetY)!=null?i:(o=t.nativeEvent)==null?void 0:o.offsetY;d=E.x-x.x+S,h=E.y-x.y+M}const f=this.dom.cloneNode(!0);try{const x=this.dom.getBoundingClientRect();f.style.width=`${Math.round(x.width)}px`,f.style.height=`${Math.round(x.height)}px`,f.style.boxSizing="border-box",f.style.pointerEvents="none"}catch{}let p=null;try{p=document.createElement("div"),p.style.position="absolute",p.style.top="-9999px",p.style.left="-9999px",p.style.pointerEvents="none",p.appendChild(f),document.body.appendChild(p),(l=t.dataTransfer)==null||l.setDragImage(f,d,h)}finally{p&&setTimeout(()=>{try{p==null||p.remove()}catch{}},0)}const g=this.getPos();if(typeof g!="number")return;const y=K.create(a.state.doc,g),b=a.state.tr.setSelection(y);a.dispatch(b)}stopEvent(t){var e;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:t});const n=t.target;if(!(this.dom.contains(n)&&!((e=this.contentDOM)!=null&&e.contains(n))))return!1;const s=t.type.startsWith("drag"),o=t.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(n.tagName)||n.isContentEditable)&&!o&&!s)return!0;const{isEditable:l}=this.editor,{isDragging:a}=this,c=!!this.node.type.spec.draggable,u=K.isSelectable(this.node),d=t.type==="copy",h=t.type==="paste",f=t.type==="cut",p=t.type==="mousedown";if(!c&&u&&s&&t.target===this.dom&&t.preventDefault(),c&&s&&!a&&t.target===this.dom)return t.preventDefault(),!1;if(c&&l&&!a&&p){const g=n.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(a||o||d||h||f||p&&u)}ignoreMutation(t){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:t}):this.node.isLeaf||this.node.isAtom?!0:t.type==="selection"||this.dom.contains(t.target)&&t.type==="childList"&&(Oa()||sb())&&this.editor.isFocused&&[...Array.from(t.addedNodes),...Array.from(t.removedNodes)].every(n=>n.isContentEditable)?!1:this.contentDOM===t.target&&t.type==="attributes"?!0:!this.contentDOM.contains(t.target)}updateAttributes(t){this.editor.commands.command(({tr:e})=>{const n=this.getPos();return typeof n!="number"?!1:(e.setNodeMarkup(n,void 0,{...this.node.attrs,...t}),!0)})}deleteNode(){const t=this.getPos();if(typeof t!="number")return;const e=t+this.node.nodeSize;this.editor.commands.deleteRange({from:t,to:e})}};function mr(t){return new MS({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const o=ke(t.getAttributes,void 0,r,s);if(o===!1||o===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=n.to;if(l){const u=a.search(/\S/),d=n.from+a.indexOf(l),h=d+l.length;if(Jd(n.from,n.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===t.type&&y!==p.mark.type)).filter(p=>p.to>d).length)return null;h<n.to&&i.delete(h,n.to),d>n.from&&i.delete(n.from+u,d),c=n.from+u+l.length,i.addMark(n.from+u,c,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}var Lc,wp;function KC(){return wp||(wp=1,Lc=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,s,o;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(!t(e[s],n[s]))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;for(s of e.entries())if(!t(s[1],n.get(s[0])))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(s of e.entries())if(!n.has(s[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(n)){if(r=e.length,r!=n.length)return!1;for(s=r;s--!==0;)if(e[s]!==n[s])return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(o=Object.keys(e),r=o.length,r!==Object.keys(n).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(n,o[s]))return!1;for(s=r;s--!==0;){var i=o[s];if(!(i==="_owner"&&e.$$typeof)&&!t(e[i],n[i]))return!1}return!0}return e!==e&&n!==n}),Lc}var GC=KC();const JC=ug(GC);var ji={exports:{}},Ic={};/**
132
+ * @license React
133
+ * use-sync-external-store-shim/with-selector.production.js
134
+ *
135
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
136
+ *
137
+ * This source code is licensed under the MIT license found in the
138
+ * LICENSE file in the root directory of this source tree.
139
+ */var vp;function YC(){if(vp)return Ic;vp=1;var t=C,e=kd();function n(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,o=t.useRef,i=t.useEffect,l=t.useMemo,a=t.useDebugValue;return Ic.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=o(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(w){if(!x){if(x=!0,E=w,w=h(w),f!==void 0&&g.hasValue){var T=g.value;if(f(T,w))return S=T}return S=w}if(T=S,r(E,w))return T;var k=h(w);return f!==void 0&&f(T,k)?(E=w,T):(E=w,S=k)}var x=!1,E,S,M=d===void 0?null:d;return[function(){return b(u())},M===null?void 0:function(){return b(M())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},Ic}var jc={};/**
140
+ * @license React
141
+ * use-sync-external-store-shim/with-selector.development.js
142
+ *
143
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
144
+ *
145
+ * This source code is licensed under the MIT license found in the
146
+ * LICENSE file in the root directory of this source tree.
147
+ */var kp;function XC(){return kp||(kp=1,process.env.NODE_ENV!=="production"&&(function(){function t(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var e=C,n=kd(),r=typeof Object.is=="function"?Object.is:t,s=n.useSyncExternalStore,o=e.useRef,i=e.useEffect,l=e.useMemo,a=e.useDebugValue;jc.useSyncExternalStoreWithSelector=function(c,u,d,h,f){var p=o(null);if(p.current===null){var g={hasValue:!1,value:null};p.current=g}else g=p.current;p=l(function(){function b(w){if(!x){if(x=!0,E=w,w=h(w),f!==void 0&&g.hasValue){var T=g.value;if(f(T,w))return S=T}return S=w}if(T=S,r(E,w))return T;var k=h(w);return f!==void 0&&f(T,k)?(E=w,T):(E=w,S=k)}var x=!1,E,S,M=d===void 0?null:d;return[function(){return b(u())},M===null?void 0:function(){return b(M())}]},[u,d,h,f]);var y=s(c,p[0],p[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),a(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),jc}var Sp;function ZC(){return Sp||(Sp=1,process.env.NODE_ENV==="production"?ji.exports=YC():ji.exports=XC()),ji.exports}var QC=ZC(),eE=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},tE=({contentComponent:t})=>{const e=dg.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return m.jsx(m.Fragment,{children:Object.values(e)})};function nE(){const t=new Set;let e={};return{subscribe(n){return t.add(n),()=>{t.delete(n)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(n,r){e={...e,[n]:vd.createPortal(r.reactElement,r.element,n)},t.forEach(s=>s())},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach(s=>s())}}}var rE=class extends C.Component{constructor(t){var e;super(t),this.editorContentRef=C.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=nE(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe(()=>{this.setState(n=>n.hasContentComponentInitialized?n:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){var t;const e=this.props.editor;if(!e||(this.initialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),e.contentComponent=null,!((t=e.options.element)!=null&&t.firstChild)))return;const n=document.createElement("div");n.append(...e.options.element.childNodes),e.setOptions({element:n})}render(){const{editor:t,innerRef:e,...n}=this.props;return m.jsxs(m.Fragment,{children:[m.jsx("div",{ref:eE(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&m.jsx(tE,{contentComponent:t.contentComponent})]})}},sE=C.forwardRef((t,e)=>{const n=C.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return C.createElement(rE,{key:n,innerRef:e,...t})}),yb=C.memo(sE),oE=typeof window<"u"?C.useLayoutEffect:C.useEffect,iE=class{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const e=()=>{this.transactionNumber+=1,this.subscribers.forEach(r=>r())},n=this.editor;return n.on("transaction",e),()=>{n.off("transaction",e)}}}};function lE(t){var e;const[n]=C.useState(()=>new iE(t.editor)),r=QC.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:JC);return oE(()=>n.watch(t.editor),[t.editor,n]),C.useDebugValue(r),r}var Cp=process.env.NODE_ENV!=="production",Nu=typeof window>"u",aE=Nu||!!(typeof window<"u"&&window.next),cE=class bb{constructor(e){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=e,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(e){this.editor=e,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach(n=>n())}getInitialEditor(){if(this.options.current.immediatelyRender===void 0){if(Nu||aE){if(Cp)throw new Error("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches.");return null}return this.createEditor()}if(this.options.current.immediatelyRender&&Nu&&Cp)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onBeforeCreate)==null?void 0:o.call(s,...r)},onBlur:(...r)=>{var s,o;return(o=(s=this.options.current).onBlur)==null?void 0:o.call(s,...r)},onCreate:(...r)=>{var s,o;return(o=(s=this.options.current).onCreate)==null?void 0:o.call(s,...r)},onDestroy:(...r)=>{var s,o;return(o=(s=this.options.current).onDestroy)==null?void 0:o.call(s,...r)},onFocus:(...r)=>{var s,o;return(o=(s=this.options.current).onFocus)==null?void 0:o.call(s,...r)},onSelectionUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onSelectionUpdate)==null?void 0:o.call(s,...r)},onTransaction:(...r)=>{var s,o;return(o=(s=this.options.current).onTransaction)==null?void 0:o.call(s,...r)},onUpdate:(...r)=>{var s,o;return(o=(s=this.options.current).onUpdate)==null?void 0:o.call(s,...r)},onContentError:(...r)=>{var s,o;return(o=(s=this.options.current).onContentError)==null?void 0:o.call(s,...r)},onDrop:(...r)=>{var s,o;return(o=(s=this.options.current).onDrop)==null?void 0:o.call(s,...r)},onPaste:(...r)=>{var s,o;return(o=(s=this.options.current).onPaste)==null?void 0:o.call(s,...r)},onDelete:(...r)=>{var s,o;return(o=(s=this.options.current).onDelete)==null?void 0:o.call(s,...r)}};return new FC(e)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(e){return this.subscriptions.add(e),()=>{this.subscriptions.delete(e)}}static compareOptions(e,n){return Object.keys(e).every(r=>["onCreate","onBeforeCreate","onDestroy","onUpdate","onTransaction","onFocus","onBlur","onSelectionUpdate","onContentError","onDrop","onPaste"].includes(r)?!0:r==="extensions"&&e.extensions&&n.extensions?e.extensions.length!==n.extensions.length?!1:e.extensions.every((s,o)=>{var i;return s===((i=n.extensions)==null?void 0:i[o])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?bb.compareOptions(this.options.current,this.editor.options)||this.editor.setOptions({...this.options.current,editable:this.editor.isEditable}):this.refreshEditorInstance(e),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(e){if(this.editor&&!this.editor.isDestroyed){if(this.previousDeps===null){this.previousDeps=e;return}if(this.previousDeps.length===e.length&&this.previousDeps.every((r,s)=>r===e[s]))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=e}scheduleDestroy(){const e=this.instanceId,n=this.editor;this.scheduledDestructionTimeout=setTimeout(()=>{if(this.isComponentMounted&&this.instanceId===e){n&&n.setOptions(this.options.current);return}n&&!n.isDestroyed&&(n.destroy(),this.instanceId===e&&this.setEditor(null))},1)}};function xb(t={},e=[]){const n=C.useRef(t);n.current=t;const[r]=C.useState(()=>new cE(n)),s=dg.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return C.useDebugValue(s),C.useEffect(r.onRender(e)),lE({editor:s,selector:({transactionNumber:o})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&o===0?0:o+1}),s}var uE=C.createContext({editor:null});uE.Consumer;var wb=C.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),dE=()=>C.useContext(wb),Xd=C.forwardRef((t,e)=>{const{onDragStart:n}=dE(),r=t.as||"div";return m.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});function Ep(t){return!!(typeof t=="function"&&t.prototype&&t.prototype.isReactComponent)}function Mp(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.forward_ref)"||t.$$typeof.description==="react.forward_ref"))}function hE(t){return!!(typeof t=="object"&&t.$$typeof&&(t.$$typeof.toString()==="Symbol(react.memo)"||t.$$typeof.description==="react.memo"))}function fE(t){if(Ep(t)||Mp(t))return!0;if(hE(t)){const e=t.type;if(e)return Ep(e)||Mp(e)}return!1}function pE(){try{if(C.version)return parseInt(C.version.split(".")[0],10)>=19}catch{}return!1}var vb=class{constructor(t,{editor:e,props:n={},as:r="div",className:s=""}){this.ref=null,this.id=Math.floor(Math.random()*4294967295).toString(),this.component=t,this.editor=e,this.props=n,this.element=document.createElement(r),this.element.classList.add("react-renderer"),s&&this.element.classList.add(...s.split(" ")),this.editor.isInitialized?vd.flushSync(()=>{this.render()}):queueMicrotask(()=>{this.render()})}render(){var t;const e=this.component,n=this.props,r=this.editor,s=pE(),o=fE(e),i={...n};i.ref&&!(s||o)&&delete i.ref,!i.ref&&(s||o)&&(i.ref=l=>{this.ref=l}),this.reactElement=m.jsx(e,{...i}),(t=r==null?void 0:r.contentComponent)==null||t.setRenderer(this.id,this)}updateProps(t={}){this.props={...this.props,...t},this.render()}destroy(){var t;const e=this.editor;(t=e==null?void 0:e.contentComponent)==null||t.removeRenderer(this.id);try{this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element)}catch{}}updateAttributes(t){Object.keys(t).forEach(e=>{this.element.setAttribute(e,t[e])})}};C.createContext({markViewContentRef:()=>{}});var mE=class extends qC{constructor(t,e,n){if(super(t,e,n),!this.node.isLeaf){this.options.contentDOMElementTag?this.contentDOMElement=document.createElement(this.options.contentDOMElementTag):this.contentDOMElement=document.createElement(this.node.isInline?"span":"div"),this.contentDOMElement.dataset.nodeViewContentReact="",this.contentDOMElement.dataset.nodeViewWrapper="",this.contentDOMElement.style.whiteSpace="inherit";const r=this.dom.querySelector("[data-node-view-content]");if(!r)return;r.appendChild(this.contentDOMElement)}}mount(){const t={editor:this.editor,node:this.node,decorations:this.decorations,innerDecorations:this.innerDecorations,view:this.view,selected:!1,extension:this.extension,HTMLAttributes:this.HTMLAttributes,getPos:()=>this.getPos(),updateAttributes:(a={})=>this.updateAttributes(a),deleteNode:()=>this.deleteNode(),ref:C.createRef()};if(!this.component.displayName){const a=c=>c.charAt(0).toUpperCase()+c.substring(1);this.component.displayName=a(this.extension.name)}const r={onDragStart:this.onDragStart.bind(this),nodeViewContentRef:a=>{a&&this.contentDOMElement&&a.firstChild!==this.contentDOMElement&&(a.hasAttribute("data-node-view-wrapper")&&a.removeAttribute("data-node-view-wrapper"),a.appendChild(this.contentDOMElement))}},s=this.component,o=C.memo(a=>m.jsx(wb.Provider,{value:r,children:C.createElement(s,a)}));o.displayName="ReactNodeView";let i=this.node.isInline?"span":"div";this.options.as&&(i=this.options.as);const{className:l=""}=this.options;this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.renderer=new vb(o,{editor:this.editor,props:t,as:i,className:`node-${this.node.type.name} ${l}`.trim()}),this.editor.on("selectionUpdate",this.handleSelectionUpdate),this.updateElementAttributes()}get dom(){var t;if(this.renderer.element.firstElementChild&&!((t=this.renderer.element.firstElementChild)!=null&&t.hasAttribute("data-node-view-wrapper")))throw Error("Please use the NodeViewWrapper component for your node view.");return this.renderer.element}get contentDOM(){return this.node.isLeaf?null:this.contentDOMElement}handleSelectionUpdate(){const{from:t,to:e}=this.editor.state.selection,n=this.getPos();if(typeof n=="number")if(t<=n&&e>=n+this.node.nodeSize){if(this.renderer.props.selected)return;this.selectNode()}else{if(!this.renderer.props.selected)return;this.deselectNode()}}update(t,e,n){const r=s=>{this.renderer.updateProps(s),typeof this.options.attrs=="function"&&this.updateElementAttributes()};if(t.type!==this.node.type)return!1;if(typeof this.options.update=="function"){const s=this.node,o=this.decorations,i=this.innerDecorations;return this.node=t,this.decorations=e,this.innerDecorations=n,this.options.update({oldNode:s,oldDecorations:o,newNode:t,newDecorations:e,oldInnerDecorations:i,innerDecorations:n,updateProps:()=>r({node:t,decorations:e,innerDecorations:n})})}return t===this.node&&this.decorations===e&&this.innerDecorations===n||(this.node=t,this.decorations=e,this.innerDecorations=n,r({node:t,decorations:e,innerDecorations:n})),!0}selectNode(){this.renderer.updateProps({selected:!0}),this.renderer.element.classList.add("ProseMirror-selectednode")}deselectNode(){this.renderer.updateProps({selected:!1}),this.renderer.element.classList.remove("ProseMirror-selectednode")}destroy(){this.renderer.destroy(),this.editor.off("selectionUpdate",this.handleSelectionUpdate),this.contentDOMElement=null}updateElementAttributes(){if(this.options.attrs){let t={};if(typeof this.options.attrs=="function"){const e=this.editor.extensionManager.attributes,n=_o(this.node,e);t=this.options.attrs({node:this.node,HTMLAttributes:n})}else t=this.options.attrs;this.renderer.updateAttributes(t)}}};function Zd(t,e){return n=>n.editor.contentComponent?new mE(t,n,e):{}}var Ml=(t,e)=>{if(t==="slot")return 0;if(t instanceof Function)return t(e);const{children:n,...r}=e??{};if(t==="svg")throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");return[t,r,n]},gE=/^\s*>\s$/,kb=Ie.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ml("blockquote",{...xe(this.options.HTMLAttributes,t),children:Ml("slot",{})})},addCommands(){return{setBlockquote:()=>({commands:t})=>t.wrapIn(this.name),toggleBlockquote:()=>({commands:t})=>t.toggleWrap(this.name),unsetBlockquote:()=>({commands:t})=>t.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Ms({find:gE,type:this.type})]}}),yE=kb,bE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,xE=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,wE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,vE=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,kE=ln.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:t=>t.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:t=>t.type.name===this.name},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}]},renderHTML({HTMLAttributes:t}){return Ml("strong",{...xe(this.options.HTMLAttributes,t),children:Ml("slot",{})})},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Kr({find:bE,type:this.type}),Kr({find:wE,type:this.type})]},addPasteRules(){return[mr({find:xE,type:this.type}),mr({find:vE,type:this.type})]}}),SE=/(^|[^`])`([^`]+)`(?!`)/,CE=/(^|[^`])`([^`]+)`(?!`)/g,EE=ln.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setCode:()=>({commands:t})=>t.setMark(this.name),toggleCode:()=>({commands:t})=>t.toggleMark(this.name),unsetCode:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Kr({find:SE,type:this.type})]},addPasteRules(){return[mr({find:CE,type:this.type})]}}),ME=/^```([a-z]+)?[\s\n]$/,AE=/^~~~([a-z]+)?[\s\n]$/,Sb=Ie.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:t=>{var e;const{languageClassPrefix:n}=this.options,o=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(i=>i.startsWith(n)).map(i=>i.replace(n,""))[0];return o||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",xe(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},addCommands(){return{setCodeBlock:t=>({commands:e})=>e.setNode(this.name,t),toggleCodeBlock:t=>({commands:e})=>e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:t,$anchor:e}=this.editor.state.selection,n=e.pos===1;return!t||e.parent.type.name!==this.name?!1:n||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:s}=n;if(!s||r.parent.type!==this.type)return!1;const o=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
148
+
149
+ `);return!o||!i?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:s,empty:o}=n;if(!o||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const l=s.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:c})=>(c.setSelection(Q.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[Tu({find:ME,type:this.type,getAttributes:t=>({language:t[1]})}),Tu({find:AE,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new me({key:new ye("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),s=r?JSON.parse(r):void 0,o=s==null?void 0:s.mode;if(!n||!o)return!1;const{tr:i,schema:l}=t.state,a=l.text(n.replace(/\r\n?/g,`
150
+ `));return i.replaceSelectionWith(this.type.create({language:o},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(Y.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),t.dispatch(i),!0}}})]}}),TE=Sb,NE=Ie.create({name:"doc",topNode:!0,content:"block+"}),RE=Ie.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",xe(this.options.HTMLAttributes,t)]},renderText(){return`
151
+ `},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:o}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=o||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){const d=a.filter(h=>l.includes(h.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Cb=Ie.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,xe(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>Tu({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),_E=Cb,OE=Ie.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",xe(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!UC(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Yy(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:o,dispatch:i})=>{var l;if(i){const{$to:a}=o.selection,c=a.end();if(a.nodeAfter)a.nodeAfter.isTextblock?o.setSelection(Y.create(o.doc,a.pos+1)):a.nodeAfter.isBlock?o.setSelection(K.create(o.doc,a.pos)):o.setSelection(Y.create(o.doc,a.pos));else{const u=(l=a.parent.type.contentMatch.defaultType)==null?void 0:l.create();u&&(o.insert(c,u),o.setSelection(Y.create(o.doc,c+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[mb({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),DE=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,LE=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,IE=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,jE=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,PE=ln.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:t=>t.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Kr({find:DE,type:this.type}),Kr({find:IE,type:this.type})]},addPasteRules(){return[mr({find:LE,type:this.type}),mr({find:jE,type:this.type})]}});const BE="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",HE="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ru="numeric",_u="ascii",Ou="alpha",uo="asciinumeric",so="alphanumeric",Du="domain",Eb="emoji",$E="scheme",zE="slashscheme",Pc="whitespace";function FE(t,e){return t in e||(e[t]=[]),e[t]}function Ir(t,e,n){e[Ru]&&(e[uo]=!0,e[so]=!0),e[_u]&&(e[uo]=!0,e[Ou]=!0),e[uo]&&(e[so]=!0),e[Ou]&&(e[so]=!0),e[so]&&(e[Du]=!0),e[Eb]&&(e[Du]=!0);for(const r in e){const s=FE(r,n);s.indexOf(t)<0&&s.push(t)}}function UE(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function At(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}At.groups={};At.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let r=0;r<e.jr.length;r++){const s=e.jr[r][0],o=e.jr[r][1];if(o&&s.test(t))return o}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let s=0;s<t.length;s++)this.tt(t[s],e,n,r)},tr(t,e,n,r){r=r||At.groups;let s;return e&&e.j?s=e:(s=new At(e),n&&r&&Ir(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const o=t.length;if(!o)return s;for(let i=0;i<o-1;i++)s=s.tt(t[i]);return s.tt(t[o-1],e,n,r)},tt(t,e,n,r){r=r||At.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const o=e;let i,l=s.go(t);if(l?(i=new At,Object.assign(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new At,o){if(r)if(i.t&&typeof i.t=="string"){const a=Object.assign(UE(i.t,r),n);Ir(o,a,r)}else n&&Ir(o,n,r);i.t=o}return s.j[t]=i,i}};const ae=(t,e,n,r,s)=>t.ta(e,n,r,s),je=(t,e,n,r,s)=>t.tr(e,n,r,s),Ap=(t,e,n,r,s)=>t.ts(e,n,r,s),D=(t,e,n,r,s)=>t.tt(e,n,r,s),_n="WORD",Lu="UWORD",Mb="ASCIINUMERICAL",Ab="ALPHANUMERICAL",Oo="LOCALHOST",Iu="TLD",ju="UTLD",rl="SCHEME",hs="SLASH_SCHEME",Qd="NUM",Pu="WS",eh="NL",ho="OPENBRACE",fo="CLOSEBRACE",Al="OPENBRACKET",Tl="CLOSEBRACKET",Nl="OPENPAREN",Rl="CLOSEPAREN",_l="OPENANGLEBRACKET",Ol="CLOSEANGLEBRACKET",Dl="FULLWIDTHLEFTPAREN",Ll="FULLWIDTHRIGHTPAREN",Il="LEFTCORNERBRACKET",jl="RIGHTCORNERBRACKET",Pl="LEFTWHITECORNERBRACKET",Bl="RIGHTWHITECORNERBRACKET",Hl="FULLWIDTHLESSTHAN",$l="FULLWIDTHGREATERTHAN",zl="AMPERSAND",Fl="APOSTROPHE",Ul="ASTERISK",Qn="AT",Vl="BACKSLASH",Wl="BACKTICK",ql="CARET",nr="COLON",th="COMMA",Kl="DOLLAR",mn="DOT",Gl="EQUALS",nh="EXCLAMATION",zt="HYPHEN",po="PERCENT",Jl="PIPE",Yl="PLUS",Xl="POUND",mo="QUERY",rh="QUOTE",Tb="FULLWIDTHMIDDLEDOT",sh="SEMI",gn="SLASH",go="TILDE",Zl="UNDERSCORE",Nb="EMOJI",Ql="SYM";var Rb=Object.freeze({__proto__:null,ALPHANUMERICAL:Ab,AMPERSAND:zl,APOSTROPHE:Fl,ASCIINUMERICAL:Mb,ASTERISK:Ul,AT:Qn,BACKSLASH:Vl,BACKTICK:Wl,CARET:ql,CLOSEANGLEBRACKET:Ol,CLOSEBRACE:fo,CLOSEBRACKET:Tl,CLOSEPAREN:Rl,COLON:nr,COMMA:th,DOLLAR:Kl,DOT:mn,EMOJI:Nb,EQUALS:Gl,EXCLAMATION:nh,FULLWIDTHGREATERTHAN:$l,FULLWIDTHLEFTPAREN:Dl,FULLWIDTHLESSTHAN:Hl,FULLWIDTHMIDDLEDOT:Tb,FULLWIDTHRIGHTPAREN:Ll,HYPHEN:zt,LEFTCORNERBRACKET:Il,LEFTWHITECORNERBRACKET:Pl,LOCALHOST:Oo,NL:eh,NUM:Qd,OPENANGLEBRACKET:_l,OPENBRACE:ho,OPENBRACKET:Al,OPENPAREN:Nl,PERCENT:po,PIPE:Jl,PLUS:Yl,POUND:Xl,QUERY:mo,QUOTE:rh,RIGHTCORNERBRACKET:jl,RIGHTWHITECORNERBRACKET:Bl,SCHEME:rl,SEMI:sh,SLASH:gn,SLASH_SCHEME:hs,SYM:Ql,TILDE:go,TLD:Iu,UNDERSCORE:Zl,UTLD:ju,UWORD:Lu,WORD:_n,WS:Pu});const Tn=/[a-z]/,Zs=new RegExp("\\p{L}","u"),Bc=new RegExp("\\p{Emoji}","u"),Nn=/\d/,Hc=/\s/,Tp="\r",$c=`
152
+ `,VE="️",WE="‍",zc="";let Pi=null,Bi=null;function qE(t=[]){const e={};At.groups=e;const n=new At;Pi==null&&(Pi=Np(BE)),Bi==null&&(Bi=Np(HE)),D(n,"'",Fl),D(n,"{",ho),D(n,"}",fo),D(n,"[",Al),D(n,"]",Tl),D(n,"(",Nl),D(n,")",Rl),D(n,"<",_l),D(n,">",Ol),D(n,"(",Dl),D(n,")",Ll),D(n,"「",Il),D(n,"」",jl),D(n,"『",Pl),D(n,"』",Bl),D(n,"<",Hl),D(n,">",$l),D(n,"&",zl),D(n,"*",Ul),D(n,"@",Qn),D(n,"`",Wl),D(n,"^",ql),D(n,":",nr),D(n,",",th),D(n,"$",Kl),D(n,".",mn),D(n,"=",Gl),D(n,"!",nh),D(n,"-",zt),D(n,"%",po),D(n,"|",Jl),D(n,"+",Yl),D(n,"#",Xl),D(n,"?",mo),D(n,'"',rh),D(n,"/",gn),D(n,";",sh),D(n,"~",go),D(n,"_",Zl),D(n,"\\",Vl),D(n,"・",Tb);const r=je(n,Nn,Qd,{[Ru]:!0});je(r,Nn,r);const s=je(r,Tn,Mb,{[uo]:!0}),o=je(r,Zs,Ab,{[so]:!0}),i=je(n,Tn,_n,{[_u]:!0});je(i,Nn,s),je(i,Tn,i),je(s,Nn,s),je(s,Tn,s);const l=je(n,Zs,Lu,{[Ou]:!0});je(l,Tn),je(l,Nn,o),je(l,Zs,l),je(o,Nn,o),je(o,Tn),je(o,Zs,o);const a=D(n,$c,eh,{[Pc]:!0}),c=D(n,Tp,Pu,{[Pc]:!0}),u=je(n,Hc,Pu,{[Pc]:!0});D(n,zc,u),D(c,$c,a),D(c,zc,u),je(c,Hc,u),D(u,Tp),D(u,$c),je(u,Hc,u),D(u,zc,u);const d=je(n,Bc,Nb,{[Eb]:!0});D(d,"#"),je(d,Bc,d),D(d,VE,d);const h=D(d,WE);D(h,"#"),je(h,Bc,d);const f=[[Tn,i],[Nn,s]],p=[[Tn,null],[Zs,l],[Nn,o]];for(let g=0;g<Pi.length;g++)Gn(n,Pi[g],Iu,_n,f);for(let g=0;g<Bi.length;g++)Gn(n,Bi[g],ju,Lu,p);Ir(Iu,{tld:!0,ascii:!0},e),Ir(ju,{utld:!0,alpha:!0},e),Gn(n,"file",rl,_n,f),Gn(n,"mailto",rl,_n,f),Gn(n,"http",hs,_n,f),Gn(n,"https",hs,_n,f),Gn(n,"ftp",hs,_n,f),Gn(n,"ftps",hs,_n,f),Ir(rl,{scheme:!0,ascii:!0},e),Ir(hs,{slashscheme:!0,ascii:!0},e),t=t.sort((g,y)=>g[0]>y[0]?1:-1);for(let g=0;g<t.length;g++){const y=t[g][0],x=t[g][1]?{[$E]:!0}:{[zE]:!0};y.indexOf("-")>=0?x[Du]=!0:Tn.test(y)?Nn.test(y)?x[uo]=!0:x[_u]=!0:x[Ru]=!0,Ap(n,y,y,x)}return Ap(n,"localhost",Oo,{ascii:!0}),n.jd=new At(Ql),{start:n,tokens:Object.assign({groups:e},Rb)}}function _b(t,e){const n=KE(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,s=[];let o=0,i=0;for(;i<r;){let l=t,a=null,c=0,u=null,d=-1,h=-1;for(;i<r&&(a=l.go(n[i]));)l=a,l.accepts()?(d=0,h=0,u=l):d>=0&&(d+=n[i].length,h++),c+=n[i].length,o+=n[i].length,i++;o-=d,i-=h,c-=d,s.push({t:u.t,v:e.slice(o-c,o),s:o-c,e:o})}return s}function KE(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),o,i=s<55296||s>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(i),r+=i.length}return e}function Gn(t,e,n,r,s){let o;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];t.j[a]?o=t.j[a]:(o=new At(r),o.jr=s.slice(),t.j[a]=o),t=o}return o=new At(n),o.jr=s.slice(),t.j[e[i-1]]=o,o}function Np(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let o=0;for(;s.indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let i=parseInt(t.substring(r,r+o),10);i>0;i--)n.pop();r+=o}else n.push(t[r]),r++}return e}const Do={defaultProtocol:"http",events:null,format:Rp,formatHref:Rp,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oh(t,e=null){let n=Object.assign({},Do);t&&(n=Object.assign(n,t instanceof oh?t.o:t));const r=n.ignoreTags,s=[];for(let o=0;o<r.length;o++)s.push(r[o].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}oh.prototype={o:Do,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let s=this.o[t];return s&&(typeof s=="object"?(s=n.t in s?s[n.t]:Do[t],typeof s=="function"&&r&&(s=s(e,n))):typeof s=="function"&&r&&(s=s(e,n.t,n)),s)},getObj(t,e,n){let r=this.o[t];return typeof r=="function"&&e!=null&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}};function Rp(t){return t}function Ob(t,e){this.t="token",this.v=t,this.tk=e}Ob.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t=Do.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),s=t.get("tagName",n,e),o=this.toFormattedString(t),i={},l=t.get("className",n,e),a=t.get("target",n,e),c=t.get("rel",n,e),u=t.getObj("attributes",n,e),d=t.getObj("events",n,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&Object.assign(i,u),{tagName:s,attributes:i,content:o,eventListeners:d}}};function Da(t,e){class n extends Ob{constructor(s,o){super(s,o),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const _p=Da("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Op=Da("text"),GE=Da("nl"),Hi=Da("url",{isLink:!0,toHref(t=Do.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Oo&&t[1].t===nr}}),$t=t=>new At(t);function JE({groups:t}){const e=t.domain.concat([zl,Ul,Qn,Vl,Wl,ql,Kl,Gl,zt,Qd,po,Jl,Yl,Xl,gn,Ql,go,Zl]),n=[Fl,nr,th,mn,nh,po,mo,rh,sh,_l,Ol,ho,fo,Tl,Al,Nl,Rl,Dl,Ll,Il,jl,Pl,Bl,Hl,$l],r=[zl,Fl,Ul,Vl,Wl,ql,Kl,Gl,zt,ho,fo,po,Jl,Yl,Xl,mo,gn,Ql,go,Zl],s=$t(),o=D(s,go);ae(o,r,o),ae(o,t.domain,o);const i=$t(),l=$t(),a=$t();ae(s,t.domain,i),ae(s,t.scheme,l),ae(s,t.slashscheme,a),ae(i,r,o),ae(i,t.domain,i);const c=D(i,Qn);D(o,Qn,c),D(l,Qn,c),D(a,Qn,c);const u=D(o,mn);ae(u,r,o),ae(u,t.domain,o);const d=$t();ae(c,t.domain,d),ae(d,t.domain,d);const h=D(d,mn);ae(h,t.domain,d);const f=$t(_p);ae(h,t.tld,f),ae(h,t.utld,f),D(c,Oo,f);const p=D(d,zt);D(p,zt,p),ae(p,t.domain,d),ae(f,t.domain,d),D(f,mn,h),D(f,zt,p);const g=D(f,nr);ae(g,t.numeric,_p);const y=D(i,zt),b=D(i,mn);D(y,zt,y),ae(y,t.domain,i),ae(b,r,o),ae(b,t.domain,i);const x=$t(Hi);ae(b,t.tld,x),ae(b,t.utld,x),ae(x,t.domain,i),ae(x,r,o),D(x,mn,b),D(x,zt,y),D(x,Qn,c);const E=D(x,nr),S=$t(Hi);ae(E,t.numeric,S);const M=$t(Hi),w=$t();ae(M,e,M),ae(M,n,w),ae(w,e,M),ae(w,n,w),D(x,gn,M),D(S,gn,M);const T=D(l,nr),k=D(a,nr),N=D(k,gn),R=D(N,gn);ae(l,t.domain,i),D(l,mn,b),D(l,zt,y),ae(a,t.domain,i),D(a,mn,b),D(a,zt,y),ae(T,t.domain,M),D(T,gn,M),D(T,mo,M),ae(R,t.domain,M),ae(R,e,M),D(R,gn,M);const B=[[ho,fo],[Al,Tl],[Nl,Rl],[_l,Ol],[Dl,Ll],[Il,jl],[Pl,Bl],[Hl,$l]];for(let P=0;P<B.length;P++){const[L,H]=B[P],se=D(M,L);D(w,L,se),D(se,H,M);const oe=$t(Hi);ae(se,e,oe);const we=$t();ae(se,n),ae(oe,e,oe),ae(oe,n,we),ae(we,e,oe),ae(we,n,we),D(oe,H,M),D(we,H,M)}return D(s,Oo,x),D(s,eh,GE),{start:s,tokens:Rb}}function YE(t,e,n){let r=n.length,s=0,o=[],i=[];for(;s<r;){let l=t,a=null,c=null,u=0,d=null,h=-1;for(;s<r&&!(a=l.go(n[s].t));)i.push(n[s++]);for(;s<r&&(c=a||l.go(n[s].t));)a=null,l=c,l.accepts()?(h=0,d=l):h>=0&&h++,s++,u++;if(h<0)s-=u,s<r&&(i.push(n[s]),s++);else{i.length>0&&(o.push(Fc(Op,e,i)),i=[]),s-=h,u-=h;const f=d.t,p=n.slice(s-u,s);o.push(Fc(f,e,p))}}return i.length>0&&o.push(Fc(Op,e,i)),o}function Fc(t,e,n){const r=n[0].s,s=n[n.length-1].e,o=e.slice(r,s);return new t(o,n)}const XE=typeof console<"u"&&console&&console.warn||(()=>{}),ZE="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Oe={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function QE(){return At.groups={},Oe.scanner=null,Oe.parser=null,Oe.tokenQueue=[],Oe.pluginQueue=[],Oe.customSchemes=[],Oe.initialized=!1,Oe}function Dp(t,e=!1){if(Oe.initialized&&XE(`linkifyjs: already initialized - will not register custom scheme "${t}" ${ZE}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
153
+ 1. Must only contain digits, lowercase ASCII letters or "-"
154
+ 2. Cannot start or end with "-"
155
+ 3. "-" cannot repeat`);Oe.customSchemes.push([t,e])}function eM(){Oe.scanner=qE(Oe.customSchemes);for(let t=0;t<Oe.tokenQueue.length;t++)Oe.tokenQueue[t][1]({scanner:Oe.scanner});Oe.parser=JE(Oe.scanner.tokens);for(let t=0;t<Oe.pluginQueue.length;t++)Oe.pluginQueue[t][1]({scanner:Oe.scanner,parser:Oe.parser});return Oe.initialized=!0,Oe}function ih(t){return Oe.initialized||eM(),YE(Oe.parser.start,t,_b(Oe.scanner.start,t))}ih.scan=_b;function Db(t,e=null,n=null){if(e&&typeof e=="object"){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new oh(n),s=ih(t),o=[];for(let i=0;i<s.length;i++){const l=s[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&o.push(l.toFormattedObject(r))}return o}var lh="[\0-   ᠎ -\u2029  ]",tM=new RegExp(lh),nM=new RegExp(`${lh}$`),rM=new RegExp(lh,"g");function sM(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function oM(t){return new me({key:new ye("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(c=>c.docChanged)&&!n.doc.eq(r.doc),o=e.some(c=>c.getMeta("preventAutolink"));if(!s||o)return;const{tr:i}=r,l=By(n.doc,[...e]);if(Gy(l).forEach(({newRange:c})=>{const u=lS(r.doc,c,f=>f.isTextblock);let d,h;if(u.length>1)d=u[0],h=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ");else if(u.length){const f=r.doc.textBetween(c.from,c.to," "," ");if(!nM.test(f))return;d=u[0],h=r.doc.textBetween(d.pos,c.to,void 0," ")}if(d&&h){const f=h.split(tM).filter(Boolean);if(f.length<=0)return!1;const p=f[f.length-1],g=d.pos+h.lastIndexOf(p);if(!p)return!1;const y=ih(p).map(b=>b.toObject(t.defaultProtocol));if(!sM(y))return!1;y.filter(b=>b.isLink).map(b=>({...b,from:g+b.start+1,to:g+b.end+1})).filter(b=>r.schema.marks.code?!r.doc.rangeHasMark(b.from,b.to,r.schema.marks.code):!0).filter(b=>t.validate(b.value)).filter(b=>t.shouldAutoLink(b.value)).forEach(b=>{Jd(b.from,b.to,r.doc).some(x=>x.mark.type===t.type)||i.addMark(b.from,b.to,t.type.create({href:b.href}))})}}),!!i.steps.length)return i}})}function iM(t){return new me({key:new ye("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,o;if(r.button!==0||!e.editable)return!1;let i=null;if(r.target instanceof HTMLAnchorElement)i=r.target;else{let u=r.target;const d=[];for(;u.nodeName!=="DIV";)d.push(u),u=u.parentNode;i=d.find(h=>h.nodeName==="A")}if(!i)return!1;const l=Ky(e.state,t.type.name),a=(s=i==null?void 0:i.href)!=null?s:l.href,c=(o=i==null?void 0:i.target)!=null?o:l.target;return t.enableClickSelection&&t.editor.commands.extendMarkRange(t.type.name),i&&a?(window.open(a,c),!0):!1}}})}function lM(t){return new me({key:new ye("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:s}=e,{selection:o}=s,{empty:i}=o;if(i)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Db(l,{defaultProtocol:t.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:t.editor.commands.setMark(t.type,{href:a.href})}}})}function Nr(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const s=typeof r=="string"?r:r.scheme;s&&n.push(s)}),!t||t.replace(rM,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var Lb=ln.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(t=>{if(typeof t=="string"){Dp(t);return}Dp(t.scheme,t.optionalSlashes)})},onDestroy(){QE()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!Nr(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>!!t}},addAttributes(){return{href:{default:null,parseHTML(t){return t.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!Nr(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:t}){return this.options.isAllowedUri(t.href,{defaultValidate:e=>!!Nr(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",xe(this.options.HTMLAttributes,t),0]:["a",xe(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!Nr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,t).setMeta("preventAutolink",!0).run():!1},toggleLink:t=>({chain:e})=>{const{href:n}=t||{};return n&&!this.options.isAllowedUri(n,{defaultValidate:r=>!!Nr(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()},unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[mr({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=Db(t).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:i=>!!Nr(i,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.start}))}return e},type:this.type,getAttributes:t=>{var e;return{href:(e=t.data)==null?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(oM({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!Nr(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&t.push(iM({type:this.type,editor:this.editor,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(lM({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),aM=Lb,cM=Object.defineProperty,uM=(t,e)=>{for(var n in e)cM(t,n,{get:e[n],enumerable:!0})},dM="listItem",Lp="textStyle",Ip=/^\s*([-+*])\s$/,ah=Ie.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:t}){return["ul",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(dM,this.editor.getAttributes(Lp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Ms({find:Ip,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ms({find:Ip,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Lp),editor:this.editor})),[t]}}),Ib=Ie.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",xe(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),hM={};uM(hM,{findListItemPos:()=>Zo,getNextListDepth:()=>ch,handleBackspace:()=>Bu,handleDelete:()=>Hu,hasListBefore:()=>jb,hasListItemAfter:()=>fM,hasListItemBefore:()=>Pb,listItemHasSubList:()=>Bb,nextListIsDeeper:()=>Hb,nextListIsHigher:()=>$b});var Zo=(t,e)=>{const{$from:n}=e.selection,r=Je(t,e.schema);let s=null,o=n.depth,i=n.pos,l=null;for(;o>0&&l===null;)s=n.node(o),s.type===r?l=o:(o-=1,i-=1);return l===null?null:{$pos:e.doc.resolve(i),depth:l}},ch=(t,e)=>{const n=Zo(t,e);if(!n)return!1;const[,r]=gS(e,t,n.$pos.pos+4);return r},jb=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),o=t.doc.resolve(s).node();return!(!o||!n.includes(o.type.name))},Pb=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-2);return!(s.index()===0||((n=s.nodeBefore)==null?void 0:n.type.name)!==t)},Bb=(t,e,n)=>{if(!n)return!1;const r=Je(t,e.schema);let s=!1;return n.descendants(o=>{o.type===r&&(s=!0)}),s},Bu=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!pr(t.state,e)&&jb(t.state,e,n)){const{$anchor:l}=t.state.selection,a=t.state.doc.resolve(l.before()-1),c=[];a.node().descendants((h,f)=>{h.type.name===e&&c.push({node:h,pos:f})});const u=c.at(-1);if(!u)return!1;const d=t.state.doc.resolve(a.start()+u.pos+1);return t.chain().cut({from:l.start()-1,to:l.end()+1},d.end()).joinForward().run()}if(!pr(t.state,e)||!wS(t.state))return!1;const r=Zo(e,t.state);if(!r)return!1;const o=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),i=Bb(e,t.state,o);return Pb(e,t.state)&&!i?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Hb=(t,e)=>{const n=ch(t,e),r=Zo(t,e);return!r||!n?!1:n>r.depth},$b=(t,e)=>{const n=ch(t,e),r=Zo(t,e);return!r||!n?!1:n<r.depth},Hu=(t,e)=>{if(!pr(t.state,e)||!xS(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Hb(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():$b(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},fM=(t,e)=>{var n;const{$anchor:r}=e.selection,s=e.doc.resolve(r.pos-r.parentOffset-2);return!(s.index()===s.parent.childCount-1||((n=s.nodeAfter)==null?void 0:n.type.name)!==t)},zb=fe.create({name:"listKeymap",addOptions(){return{listTypes:[{itemName:"listItem",wrapperNames:["bulletList","orderedList"]},{itemName:"taskItem",wrapperNames:["taskList"]}]}},addKeyboardShortcuts(){return{Delete:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Hu(t,n)&&(e=!0)}),e},"Mod-Delete":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n})=>{t.state.schema.nodes[n]!==void 0&&Hu(t,n)&&(e=!0)}),e},Backspace:({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Bu(t,n,r)&&(e=!0)}),e},"Mod-Backspace":({editor:t})=>{let e=!1;return this.options.listTypes.forEach(({itemName:n,wrapperNames:r})=>{t.state.schema.nodes[n]!==void 0&&Bu(t,n,r)&&(e=!0)}),e}}}}),pM="listItem",jp="textStyle",Pp=/^(\d+)\.\s$/,uh=Ie.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:null,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",xe(this.options.HTMLAttributes,n),0]:["ol",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(pM,this.editor.getAttributes(jp)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Ms({find:Pp,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Ms({find:Pp,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(jp)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),mM=/^\s*(\[([( |x])?\])\s$/,Fb=Ie.create({name:"taskItem",addOptions(){return{nested:!1,HTMLAttributes:{},taskListTypeName:"taskList",a11y:void 0}},content(){return this.options.nested?"paragraph block*":"paragraph+"},defining:!0,addAttributes(){return{checked:{default:!1,keepOnSplit:!1,parseHTML:t=>{const e=t.getAttribute("data-checked");return e===""||e==="true"},renderHTML:t=>({"data-checked":t.checked})}}},parseHTML(){return[{tag:`li[data-type="${this.name}"]`,priority:51}]},renderHTML({node:t,HTMLAttributes:e}){return["li",xe(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},addKeyboardShortcuts(){const t={Enter:()=>this.editor.commands.splitListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)};return this.options.nested?{...t,Tab:()=>this.editor.commands.sinkListItem(this.name)}:t},addNodeView(){return({node:t,HTMLAttributes:e,getPos:n,editor:r})=>{const s=document.createElement("li"),o=document.createElement("label"),i=document.createElement("span"),l=document.createElement("input"),a=document.createElement("div"),c=u=>{var d,h;l.ariaLabel=((h=(d=this.options.a11y)==null?void 0:d.checkboxLabel)==null?void 0:h.call(d,u,l.checked))||`Task item checkbox for ${u.textContent||"empty task item"}`};return c(t),o.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",u=>u.preventDefault()),l.addEventListener("change",u=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:d}=u.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:h})=>{const f=n();if(typeof f!="number")return!1;const p=h.doc.nodeAt(f);return h.setNodeMarkup(f,void 0,{...p==null?void 0:p.attrs,checked:d}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,d)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([u,d])=>{s.setAttribute(u,d)}),s.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,o.append(l,i),s.append(o,a),Object.entries(e).forEach(([u,d])=>{s.setAttribute(u,d)}),{dom:s,contentDOM:a,update:u=>u.type!==this.type?!1:(s.dataset.checked=u.attrs.checked,l.checked=u.attrs.checked,c(u),!0)}}},addInputRules(){return[Ms({find:mM,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),Ub=Ie.create({name:"taskList",addOptions(){return{itemTypeName:"taskItem",HTMLAttributes:{}}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:`ul[data-type="${this.name}"]`,priority:51}]},renderHTML({HTMLAttributes:t}){return["ul",xe(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});fe.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(ah.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Ib.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(zb.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(uh.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Fb.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(Ub.configure(this.options.taskList)),t}});var Vb=Ie.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),gM=Vb,yM=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,bM=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,xM=ln.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Kr({find:yM,type:this.type})]},addPasteRules(){return[mr({find:bM,type:this.type})]}}),wM=Ie.create({name:"text",group:"inline"}),Wb=ln.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["u",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setUnderline:()=>({commands:t})=>t.setMark(this.name),toggleUnderline:()=>({commands:t})=>t.toggleMark(this.name),unsetUnderline:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),vM=Wb;function kM(t={}){return new me({view(e){return new SM(e,t)}})}class SM{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=n.width)!==null&&r!==void 0?r:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(s=>{let o=i=>{this[s](i)};return e.dom.addEventListener(s,o),{name:s,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.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),n=!e.parent.inlineContent,r,s=this.editorView.dom,o=s.getBoundingClientRect(),i=o.width/s.offsetWidth,l=o.height/s.offsetHeight;if(n){let d=e.nodeBefore,h=e.nodeAfter;if(d||h){let f=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(f){let p=f.getBoundingClientRect(),g=d?p.bottom:p.top;d&&h&&(g=(g+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;r={left:p.left,right:p.right,top:g-y,bottom:g+y}}}}if(!r){let d=this.editorView.coordsAtPos(this.cursorPos),h=this.width/2*i;r={left:d.left-h,right:d.left+h,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),h=d.width/a.offsetWidth,f=d.height/a.offsetHeight;c=d.left-a.scrollLeft*h,u=d.top-a.scrollTop*f}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),s=r&&r.type.spec.disableDropCursor,o=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!o){let i=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Bg(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Be extends Q{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Be.valid(r)?new Be(r):Q.near(r)}content(){return j.empty}eq(e){return e instanceof Be&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new Be(e.resolve(n.pos))}getBookmark(){return new dh(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!CM(e)||!EM(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let s=n.contentMatchAt(e.index()).defaultType;return s&&s.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Be.valid(e))return e;let s=e.pos,o=null;for(let i=e.depth;;i--){let l=e.node(i);if(n>0?e.indexAfter(i)<l.childCount:e.index(i)>0){o=l.child(n>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;s+=n;let a=e.doc.resolve(s);if(Be.valid(a))return a}for(;;){let i=n>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!K.isSelectable(o)){e=e.doc.resolve(s+o.nodeSize*n),r=!1;continue e}break}o=i,s+=n;let l=e.doc.resolve(s);if(Be.valid(l))return l}return null}}}Be.prototype.visible=!1;Be.findFrom=Be.findGapCursorFrom;Q.jsonID("gapcursor",Be);class dh{constructor(e){this.pos=e}map(e){return new dh(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Be.valid(n)?new Be(n):Q.near(n)}}function CM(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n-1);;s=s.lastChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function EM(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let s=r.child(n);;s=s.firstChild){if(s.childCount==0&&!s.inlineContent||s.isAtom||s.type.spec.isolating)return!0;if(s.inlineContent)return!1}}return!0}function MM(){return new me({props:{decorations:RM,createSelectionBetween(t,e,n){return e.pos==n.pos&&Be.valid(n)?new Be(n):null},handleClick:TM,handleKeyDown:AM,handleDOMEvents:{beforeinput:NM}}})}const AM=Bd({ArrowLeft:$i("horiz",-1),ArrowRight:$i("horiz",1),ArrowUp:$i("vert",-1),ArrowDown:$i("vert",1)});function $i(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,o){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof Y){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=Be.findGapCursorFrom(l,e,a);return c?(s&&s(r.tr.setSelection(new Be(c))),!0):!1}}function TM(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Be.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&K.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Be(r))),!0)}function NM(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Be))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let s=O.empty;for(let i=r.length-1;i>=0;i--)s=O.from(r[i].createAndFill(null,s));let o=t.state.tr.replace(n.pos,n.pos,new j(s,0,0));return o.setSelection(Y.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function RM(t){if(!(t.selection instanceof Be))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",be.create(t.doc,[De.widget(t.selection.head,e,{key:"gapcursor"})])}var ea=200,rt=function(){};rt.prototype.append=function(e){return e.length?(e=rt.from(e),!this.length&&e||e.length<ea&&this.leafAppend(e)||this.length<ea&&e.leafPrepend(this)||this.appendInner(e)):this};rt.prototype.prepend=function(e){return e.length?rt.from(e).append(this):this};rt.prototype.appendInner=function(e){return new _M(this,e)};rt.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?rt.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};rt.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};rt.prototype.forEach=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length),n<=r?this.forEachInner(e,n,r,0):this.forEachInvertedInner(e,n,r,0)};rt.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(o,i){return s.push(e(o,i))},n,r),s};rt.from=function(e){return e instanceof rt?e:e&&e.length?new qb(e):rt.empty};var qb=(function(t){function e(r){t.call(this),this.values=r}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(s,o){return s==0&&o==this.length?this:new e(this.values.slice(s,o))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,o,i,l){for(var a=o;a<i;a++)if(s(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(s,o,i,l){for(var a=o-1;a>=i;a--)if(s(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=ea)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=ea)return new e(s.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(rt);rt.empty=new qb([]);var _M=(function(t){function e(n,r){t.call(this),this.left=n,this.right=r,this.length=n.length+r.length,this.depth=Math.max(n.depth,r.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,s,o,i){var l=this.left.length;if(s<l&&this.left.forEachInner(r,s,Math.min(o,l),i)===!1||o>l&&this.right.forEachInner(r,Math.max(s-l,0),Math.min(this.length,o)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,o,i){var l=this.left.length;if(s>l&&this.right.forEachInvertedInner(r,s-l,Math.max(o,l)-l,i+l)===!1||o<l&&this.left.forEachInvertedInner(r,Math.min(s,l),o,i)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var o=this.left.length;return s<=o?this.left.slice(r,s):r>=o?this.right.slice(r-o,s-o):this.left.slice(r,o).append(this.right.slice(0,s-o))},e.prototype.leafAppend=function(r){var s=this.right.leafAppend(r);if(s)return new e(this.left,s)},e.prototype.leafPrepend=function(r){var s=this.left.leafPrepend(r);if(s)return new e(s,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e})(rt);const OM=500;class Yt{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let s,o;n&&(s=this.remapping(r,this.items.length),o=s.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((d,h)=>{if(!d.step){s||(s=this.remapping(r,h+1),o=s.maps.length),o--,u.push(d);return}if(s){u.push(new Jn(d.map));let f=d.step.map(s.slice(o)),p;f&&i.maybeStep(f).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new Jn(p,void 0,void 0,c.length+u.length))),o--,p&&s.appendMap(p,o)}else i.maybeStep(d.step);if(d.selection)return l=s?d.selection.map(s.slice(o)):d.selection,a=new Yt(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,n,r,s){let o=[],i=this.eventCount,l=this.items,a=!s&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),h=new Jn(e.mapping.maps[u],d,n),f;(f=a&&a.merge(h))&&(h=f,u?o.pop():l=l.slice(0,l.length-1)),o.push(h),n&&(i++,n=void 0),s||(a=h)}let c=i-r.depth;return c>LM&&(l=DM(l,c),i-=c),new Yt(l.append(o),i)}remapping(e,n){let r=new Co;return this.items.forEach((s,o)=>{let i=s.mirrorOffset!=null&&o-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,i)},e,n),r}addMaps(e){return this.eventCount==0?this:new Yt(this.items.append(e.map(n=>new Jn(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),o=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(h=>{h.selection&&l--},s);let a=n;this.items.forEach(h=>{let f=o.getMirror(--a);if(f==null)return;i=Math.min(i,f);let p=o.maps[f];if(h.step){let g=e.steps[f].invert(e.docs[f]),y=h.selection&&h.selection.map(o.slice(a+1,f));y&&l++,r.push(new Jn(p,g,y))}else r.push(new Jn(p))},s);let c=[];for(let h=n;h<i;h++)c.push(new Jn(o.maps[h]));let u=this.items.slice(0,s).append(c).append(r),d=new Yt(u,l);return d.emptyItemCount()>OM&&(d=d.compress(this.items.length-r.length)),d}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),r=n.maps.length,s=[],o=0;return this.items.forEach((i,l)=>{if(l>=e)s.push(i),i.selection&&o++;else if(i.step){let a=i.step.map(n.slice(r)),c=a&&a.getMap();if(r--,c&&n.appendMap(c,r),a){let u=i.selection&&i.selection.map(n.slice(r));u&&o++;let d=new Jn(c.invert(),a,u),h,f=s.length-1;(h=s.length&&s[f].merge(d))?s[f]=h:s.push(d)}}else i.map&&r--},this.items.length,0),new Yt(rt.from(s.reverse()),o)}}Yt.empty=new Yt(rt.empty,0);function DM(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}let Jn=class Kb{constructor(e,n,r,s){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=s}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Kb(n.getMap().invert(),n,this.selection)}}};class er{constructor(e,n,r,s,o){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=o}}const LM=20;function IM(t,e,n,r){let s=n.getMeta($r),o;if(s)return s.historyState;n.getMeta(BM)&&(t=new er(t.done,t.undone,null,0,-1));let i=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(i&&i.getMeta($r))return i.getMeta($r).redo?new er(t.done.addTransform(n,void 0,r,sl(e)),t.undone,Bp(n.mapping.maps),t.prevTime,t.prevComposition):new er(t.done,t.undone.addTransform(n,void 0,r,sl(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),a=t.prevTime==0||!i&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!jM(n,t.prevRanges)),c=i?Uc(t.prevRanges,n.mapping):Bp(n.mapping.maps);return new er(t.done.addTransform(n,a?e.selection.getBookmark():void 0,r,sl(e)),Yt.empty,c,n.time,l??t.prevComposition)}else return(o=n.getMeta("rebased"))?new er(t.done.rebased(n,o),t.undone.rebased(n,o),Uc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new er(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Uc(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function jM(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let o=0;o<e.length;o+=2)r<=e[o+1]&&s>=e[o]&&(n=!0)}),n}function Bp(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,o,i)=>e.push(o,i));return e}function Uc(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),o=e.map(t[r+1],-1);s<=o&&n.push(s,o)}return n}function PM(t,e,n){let r=sl(e),s=$r.get(e).spec.config,o=(n?t.undone:t.done).popEvent(e,r);if(!o)return null;let i=o.selection.resolve(o.transform.doc),l=(n?t.done:t.undone).addTransform(o.transform,e.selection.getBookmark(),s,r),a=new er(n?l:o.remaining,n?o.remaining:l,null,0,-1);return o.transform.setSelection(i).setMeta($r,{redo:n,historyState:a})}let Vc=!1,Hp=null;function sl(t){let e=t.plugins;if(Hp!=e){Vc=!1,Hp=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){Vc=!0;break}}return Vc}const $r=new ye("history"),BM=new ye("closeHistory");function HM(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new me({key:$r,state:{init(){return new er(Yt.empty,Yt.empty,null,0,-1)},apply(e,n,r){return IM(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?Jb:r=="historyRedo"?Yb:null;return s?(n.preventDefault(),s(e.state,e.dispatch)):!1}}}})}function Gb(t,e){return(n,r)=>{let s=$r.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let o=PM(s,n,t);o&&r(e?o.scrollIntoView():o)}return!0}}const Jb=Gb(!1,!0),Yb=Gb(!0,!0);var $M=fe.create({name:"characterCount",addOptions(){return{limit:null,mode:"textSize",textCounter:t=>t.length,wordCounter:t=>t.split(" ").filter(e=>e!=="").length}},addStorage(){return{characters:()=>0,words:()=>0}},onBeforeCreate(){this.storage.characters=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc;if(((t==null?void 0:t.mode)||this.options.mode)==="textSize"){const r=e.textBetween(0,e.content.size,void 0," ");return this.options.textCounter(r)}return e.nodeSize},this.storage.words=t=>{const e=(t==null?void 0:t.node)||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new me({key:new ye("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>s){const i=o-s,l=0,a=i;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const c=r.tr.deleteRange(l,a);return t=!0,c}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const s=this.storage.characters({node:n.doc}),o=this.storage.characters({node:e.doc});if(o<=r||s>r&&o>r&&o<=s)return!0;if(s>r&&o>r&&o>s||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,a=o-r,c=l-a,u=l;return e.deleteRange(c,u),!(this.storage.characters({node:e.doc})>r)}})]}}),zM=fe.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[kM(this.options)]}});fe.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new me({key:new ye("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,o=[];if(!n||!r)return be.create(t,[]);let i=0;this.options.mode==="deepest"&&t.descendants((a,c)=>{if(a.isText)return;if(!(s>=c&&s<=c+a.nodeSize-1))return!1;i+=1});let l=0;return t.descendants((a,c)=>{if(a.isText||!(s>=c&&s<=c+a.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&i-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";o.push(De.node(c,c+a.nodeSize,{class:this.options.className}))}),be.create(t,o)}}})]}});var Xb=fe.create({name:"gapCursor",addProseMirrorPlugins(){return[MM()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=ke(J(t,"allowGapCursor",n)))!=null?e:null}}}),FM=fe.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new me({key:new ye("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,s=[];if(!n)return null;const o=this.editor.isEmpty;return t.descendants((i,l)=>{const a=r>=l&&r<=l+i.nodeSize,c=!i.isLeaf&&Yo(i);if((a||!this.options.showOnlyCurrent)&&c){const u=[this.options.emptyNodeClass];o&&u.push(this.options.emptyEditorClass);const d=De.node(l,l+i.nodeSize,{class:u.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:i,pos:l,hasAnchor:a}):this.options.placeholder});s.push(d)}return this.options.includeChildren}),be.create(t,s)}}})]}});fe.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new me({key:new ye("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Yy(n.selection)||t.view.dragging?null:be.create(n.doc,[De.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function $p({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var UM=fe.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ye(this.name),e=Object.entries(this.editor.schema.nodes).map(([,n])=>n).filter(n=>(this.options.notAfter||[]).concat(this.options.node).includes(n.name));return[new me({key:t,appendTransaction:(n,r,s)=>{const{doc:o,tr:i,schema:l}=s,a=t.getState(s),c=o.content.size,u=l.nodes[this.options.node];if(a)return i.insert(c,u.create())},state:{init:(n,r)=>{const s=r.tr.doc.lastChild;return!$p({node:s,types:e})},apply:(n,r)=>{if(!n.docChanged)return r;const s=n.doc.lastChild;return!$p({node:s,types:e})}}})]}}),Zb=fe.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Jb(t,e),redo:()=>({state:t,dispatch:e})=>Yb(t,e)}},addProseMirrorPlugins(){return[HM(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),VM=fe.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(kE.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(kb.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(ah.configure(this.options.bulletList)),this.options.code!==!1&&s.push(EE.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Sb.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(NE.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(zM.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(Xb.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(RE.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(Cb.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(Zb.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(OE.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(PE.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Ib.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(zb.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(Lb.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(uh.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(Vb.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(xM.configure(this.options.strike)),this.options.text!==!1&&s.push(wM.configure(this.options.text)),this.options.underline!==!1&&s.push(Wb.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(UM.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),WM=VM,Wc,zp;function qM(){if(zp)return Wc;zp=1;function t(v){return v instanceof Map?v.clear=v.delete=v.set=function(){throw new Error("map is read-only")}:v instanceof Set&&(v.add=v.clear=v.delete=function(){throw new Error("set is read-only")}),Object.freeze(v),Object.getOwnPropertyNames(v).forEach(_=>{const $=v[_],re=typeof $;(re==="object"||re==="function")&&!Object.isFrozen($)&&t($)}),v}class e{constructor(_){_.data===void 0&&(_.data={}),this.data=_.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(v){return v.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(v,..._){const $=Object.create(null);for(const re in v)$[re]=v[re];return _.forEach(function(re){for(const Fe in re)$[Fe]=re[Fe]}),$}const s="</span>",o=v=>!!v.scope,i=(v,{prefix:_})=>{if(v.startsWith("language:"))return v.replace("language:","language-");if(v.includes(".")){const $=v.split(".");return[`${_}${$.shift()}`,...$.map((re,Fe)=>`${re}${"_".repeat(Fe+1)}`)].join(" ")}return`${_}${v}`};class l{constructor(_,$){this.buffer="",this.classPrefix=$.classPrefix,_.walk(this)}addText(_){this.buffer+=n(_)}openNode(_){if(!o(_))return;const $=i(_.scope,{prefix:this.classPrefix});this.span($)}closeNode(_){o(_)&&(this.buffer+=s)}value(){return this.buffer}span(_){this.buffer+=`<span class="${_}">`}}const a=(v={})=>{const _={children:[]};return Object.assign(_,v),_};class c{constructor(){this.rootNode=a(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(_){this.top.children.push(_)}openNode(_){const $=a({scope:_});this.add($),this.stack.push($)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(_){return this.constructor._walk(_,this.rootNode)}static _walk(_,$){return typeof $=="string"?_.addText($):$.children&&(_.openNode($),$.children.forEach(re=>this._walk(_,re)),_.closeNode($)),_}static _collapse(_){typeof _!="string"&&_.children&&(_.children.every($=>typeof $=="string")?_.children=[_.children.join("")]:_.children.forEach($=>{c._collapse($)}))}}class u extends c{constructor(_){super(),this.options=_}addText(_){_!==""&&this.add(_)}startScope(_){this.openNode(_)}endScope(){this.closeNode()}__addSublanguage(_,$){const re=_.root;$&&(re.scope=`language:${$}`),this.add(re)}toHTML(){return new l(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function d(v){return v?typeof v=="string"?v:v.source:null}function h(v){return g("(?=",v,")")}function f(v){return g("(?:",v,")*")}function p(v){return g("(?:",v,")?")}function g(...v){return v.map($=>d($)).join("")}function y(v){const _=v[v.length-1];return typeof _=="object"&&_.constructor===Object?(v.splice(v.length-1,1),_):{}}function b(...v){return"("+(y(v).capture?"":"?:")+v.map(re=>d(re)).join("|")+")"}function x(v){return new RegExp(v.toString()+"|").exec("").length-1}function E(v,_){const $=v&&v.exec(_);return $&&$.index===0}const S=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(v,{joinWith:_}){let $=0;return v.map(re=>{$+=1;const Fe=$;let Ue=d(re),q="";for(;Ue.length>0;){const U=S.exec(Ue);if(!U){q+=Ue;break}q+=Ue.substring(0,U.index),Ue=Ue.substring(U.index+U[0].length),U[0][0]==="\\"&&U[1]?q+="\\"+String(Number(U[1])+Fe):(q+=U[0],U[0]==="("&&$++)}return q}).map(re=>`(${re})`).join(_)}const w=/\b\B/,T="[a-zA-Z]\\w*",k="[a-zA-Z_]\\w*",N="\\b\\d+(\\.\\d+)?",R="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",B="\\b(0b[01]+)",P="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",L=(v={})=>{const _=/^#![ ]*\//;return v.binary&&(v.begin=g(_,/.*\b/,v.binary,/\b.*/)),r({scope:"meta",begin:_,end:/$/,relevance:0,"on:begin":($,re)=>{$.index!==0&&re.ignoreMatch()}},v)},H={begin:"\\\\[\\s\\S]",relevance:0},se={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[H]},oe={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[H]},we={begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},F=function(v,_,$={}){const re=r({scope:"comment",begin:v,end:_,contains:[]},$);re.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const Fe=b("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return re.contains.push({begin:g(/[ ]+/,"(",Fe,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),re},le=F("//","$"),Se=F("/\\*","\\*/"),Te=F("#","$"),Mt={scope:"number",begin:N,relevance:0},dt={scope:"number",begin:R,relevance:0},Cn={scope:"number",begin:B,relevance:0},Cr={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[H,{begin:/\[/,end:/\]/,relevance:0,contains:[H]}]},pi={scope:"title",begin:T,relevance:0},mi={scope:"title",begin:k,relevance:0},gi={begin:"\\.\\s*"+k,relevance:0};var Er=Object.freeze({__proto__:null,APOS_STRING_MODE:se,BACKSLASH_ESCAPE:H,BINARY_NUMBER_MODE:Cn,BINARY_NUMBER_RE:B,COMMENT:F,C_BLOCK_COMMENT_MODE:Se,C_LINE_COMMENT_MODE:le,C_NUMBER_MODE:dt,C_NUMBER_RE:R,END_SAME_AS_BEGIN:function(v){return Object.assign(v,{"on:begin":(_,$)=>{$.data._beginMatch=_[1]},"on:end":(_,$)=>{$.data._beginMatch!==_[1]&&$.ignoreMatch()}})},HASH_COMMENT_MODE:Te,IDENT_RE:T,MATCH_NOTHING_RE:w,METHOD_GUARD:gi,NUMBER_MODE:Mt,NUMBER_RE:N,PHRASAL_WORDS_MODE:we,QUOTE_STRING_MODE:oe,REGEXP_MODE:Cr,RE_STARTERS_RE:P,SHEBANG:L,TITLE_MODE:pi,UNDERSCORE_IDENT_RE:k,UNDERSCORE_TITLE_MODE:mi});function yi(v,_){v.input[v.index-1]==="."&&_.ignoreMatch()}function Vs(v,_){v.className!==void 0&&(v.scope=v.className,delete v.className)}function bi(v,_){_&&v.beginKeywords&&(v.begin="\\b("+v.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",v.__beforeBegin=yi,v.keywords=v.keywords||v.beginKeywords,delete v.beginKeywords,v.relevance===void 0&&(v.relevance=0))}function Ws(v,_){Array.isArray(v.illegal)&&(v.illegal=b(...v.illegal))}function qs(v,_){if(v.match){if(v.begin||v.end)throw new Error("begin & end are not supported with match");v.begin=v.match,delete v.match}}function ic(v,_){v.relevance===void 0&&(v.relevance=1)}const xi=(v,_)=>{if(!v.beforeMatch)return;if(v.starts)throw new Error("beforeMatch cannot be used with starts");const $=Object.assign({},v);Object.keys(v).forEach(re=>{delete v[re]}),v.keywords=$.keywords,v.begin=g($.beforeMatch,h($.begin)),v.starts={relevance:0,contains:[Object.assign($,{endsParent:!0})]},v.relevance=0,delete $.beforeMatch},wi=["of","and","for","in","not","or","if","then","parent","list","value"],vi="keyword";function Ks(v,_,$=vi){const re=Object.create(null);return typeof v=="string"?Fe($,v.split(" ")):Array.isArray(v)?Fe($,v):Object.keys(v).forEach(function(Ue){Object.assign(re,Ks(v[Ue],_,Ue))}),re;function Fe(Ue,q){_&&(q=q.map(U=>U.toLowerCase())),q.forEach(function(U){const ee=U.split("|");re[ee[0]]=[Ue,A(ee[0],ee[1])]})}}function A(v,_){return _?Number(_):W(v)?0:1}function W(v){return wi.includes(v.toLowerCase())}const V={},ue=v=>{console.error(v)},Xe=(v,..._)=>{console.log(`WARN: ${v}`,..._)},ve=(v,_)=>{V[`${v}/${_}`]||(console.log(`Deprecated as of ${v}. ${_}`),V[`${v}/${_}`]=!0)},te=new Error;function Ht(v,_,{key:$}){let re=0;const Fe=v[$],Ue={},q={};for(let U=1;U<=_.length;U++)q[U+re]=Fe[U],Ue[U+re]=!0,re+=x(_[U-1]);v[$]=q,v[$]._emit=Ue,v[$]._multi=!0}function Wn(v){if(Array.isArray(v.begin)){if(v.skip||v.excludeBegin||v.returnBegin)throw ue("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),te;if(typeof v.beginScope!="object"||v.beginScope===null)throw ue("beginScope must be object"),te;Ht(v,v.begin,{key:"beginScope"}),v.begin=M(v.begin,{joinWith:""})}}function ot(v){if(Array.isArray(v.end)){if(v.skip||v.excludeEnd||v.returnEnd)throw ue("skip, excludeEnd, returnEnd not compatible with endScope: {}"),te;if(typeof v.endScope!="object"||v.endScope===null)throw ue("endScope must be object"),te;Ht(v,v.end,{key:"endScope"}),v.end=M(v.end,{joinWith:""})}}function En(v){v.scope&&typeof v.scope=="object"&&v.scope!==null&&(v.beginScope=v.scope,delete v.scope)}function Mr(v){En(v),typeof v.beginScope=="string"&&(v.beginScope={_wrap:v.beginScope}),typeof v.endScope=="string"&&(v.endScope={_wrap:v.endScope}),Wn(v),ot(v)}function un(v){function _(q,U){return new RegExp(d(q),"m"+(v.case_insensitive?"i":"")+(v.unicodeRegex?"u":"")+(U?"g":""))}class ${constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(U,ee){ee.position=this.position++,this.matchIndexes[this.matchAt]=ee,this.regexes.push([ee,U]),this.matchAt+=x(U)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const U=this.regexes.map(ee=>ee[1]);this.matcherRe=_(M(U,{joinWith:"|"}),!0),this.lastIndex=0}exec(U){this.matcherRe.lastIndex=this.lastIndex;const ee=this.matcherRe.exec(U);if(!ee)return null;const Qe=ee.findIndex((Gs,ac)=>ac>0&&Gs!==void 0),qe=this.matchIndexes[Qe];return ee.splice(0,Qe),Object.assign(ee,qe)}}class re{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(U){if(this.multiRegexes[U])return this.multiRegexes[U];const ee=new $;return this.rules.slice(U).forEach(([Qe,qe])=>ee.addRule(Qe,qe)),ee.compile(),this.multiRegexes[U]=ee,ee}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(U,ee){this.rules.push([U,ee]),ee.type==="begin"&&this.count++}exec(U){const ee=this.getMatcher(this.regexIndex);ee.lastIndex=this.lastIndex;let Qe=ee.exec(U);if(this.resumingScanAtSamePosition()&&!(Qe&&Qe.index===this.lastIndex)){const qe=this.getMatcher(0);qe.lastIndex=this.lastIndex+1,Qe=qe.exec(U)}return Qe&&(this.regexIndex+=Qe.position+1,this.regexIndex===this.count&&this.considerAll()),Qe}}function Fe(q){const U=new re;return q.contains.forEach(ee=>U.addRule(ee.begin,{rule:ee,type:"begin"})),q.terminatorEnd&&U.addRule(q.terminatorEnd,{type:"end"}),q.illegal&&U.addRule(q.illegal,{type:"illegal"}),U}function Ue(q,U){const ee=q;if(q.isCompiled)return ee;[Vs,qs,Mr,xi].forEach(qe=>qe(q,U)),v.compilerExtensions.forEach(qe=>qe(q,U)),q.__beforeBegin=null,[bi,Ws,ic].forEach(qe=>qe(q,U)),q.isCompiled=!0;let Qe=null;return typeof q.keywords=="object"&&q.keywords.$pattern&&(q.keywords=Object.assign({},q.keywords),Qe=q.keywords.$pattern,delete q.keywords.$pattern),Qe=Qe||/\w+/,q.keywords&&(q.keywords=Ks(q.keywords,v.case_insensitive)),ee.keywordPatternRe=_(Qe,!0),U&&(q.begin||(q.begin=/\B|\b/),ee.beginRe=_(ee.begin),!q.end&&!q.endsWithParent&&(q.end=/\B|\b/),q.end&&(ee.endRe=_(ee.end)),ee.terminatorEnd=d(ee.end)||"",q.endsWithParent&&U.terminatorEnd&&(ee.terminatorEnd+=(q.end?"|":"")+U.terminatorEnd)),q.illegal&&(ee.illegalRe=_(q.illegal)),q.contains||(q.contains=[]),q.contains=[].concat(...q.contains.map(function(qe){return Kt(qe==="self"?q:qe)})),q.contains.forEach(function(qe){Ue(qe,ee)}),q.starts&&Ue(q.starts,U),ee.matcher=Fe(ee),ee}if(v.compilerExtensions||(v.compilerExtensions=[]),v.contains&&v.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return v.classNameAliases=r(v.classNameAliases||{}),Ue(v)}function Ar(v){return v?v.endsWithParent||Ar(v.starts):!1}function Kt(v){return v.variants&&!v.cachedVariants&&(v.cachedVariants=v.variants.map(function(_){return r(v,{variants:null},_)})),v.cachedVariants?v.cachedVariants:Ar(v)?r(v,{starts:v.starts?r(v.starts):null}):Object.isFrozen(v)?r(v):v}var Tw="11.11.1";class Nw extends Error{constructor(_,$){super(_),this.name="HTMLInjectionError",this.html=$}}const lc=n,Yh=r,Xh=Symbol("nomatch"),Rw=7,Zh=function(v){const _=Object.create(null),$=Object.create(null),re=[];let Fe=!0;const Ue="Could not find the language '{}', did you forget to load/include a language module?",q={disableAutodetect:!0,name:"Plain text",contains:[]};let U={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:u};function ee(I){return U.noHighlightRe.test(I)}function Qe(I){let Z=I.className+" ";Z+=I.parentNode?I.parentNode.className:"";const pe=U.languageDetectRe.exec(Z);if(pe){const Ne=qn(pe[1]);return Ne||(Xe(Ue.replace("{}",pe[1])),Xe("Falling back to no-highlight mode for this block.",I)),Ne?pe[1]:"no-highlight"}return Z.split(/\s+/).find(Ne=>ee(Ne)||qn(Ne))}function qe(I,Z,pe){let Ne="",Ze="";typeof Z=="object"?(Ne=I,pe=Z.ignoreIllegals,Ze=Z.language):(ve("10.7.0","highlight(lang, code, ...args) has been deprecated."),ve("10.7.0",`Please use highlight(code, options) instead.
156
+ https://github.com/highlightjs/highlight.js/issues/2277`),Ze=I,Ne=Z),pe===void 0&&(pe=!0);const Gt={code:Ne,language:Ze};Si("before:highlight",Gt);const Kn=Gt.result?Gt.result:Gs(Gt.language,Gt.code,pe);return Kn.code=Gt.code,Si("after:highlight",Kn),Kn}function Gs(I,Z,pe,Ne){const Ze=Object.create(null);function Gt(z,G){return z.keywords[G]}function Kn(){if(!ie.keywords){it.addText(Re);return}let z=0;ie.keywordPatternRe.lastIndex=0;let G=ie.keywordPatternRe.exec(Re),de="";for(;G;){de+=Re.substring(z,G.index);const Ce=hn.case_insensitive?G[0].toLowerCase():G[0],ht=Gt(ie,Ce);if(ht){const[Mn,Kw]=ht;if(it.addText(de),de="",Ze[Ce]=(Ze[Ce]||0)+1,Ze[Ce]<=Rw&&(Mi+=Kw),Mn.startsWith("_"))de+=G[0];else{const Gw=hn.classNameAliases[Mn]||Mn;dn(G[0],Gw)}}else de+=G[0];z=ie.keywordPatternRe.lastIndex,G=ie.keywordPatternRe.exec(Re)}de+=Re.substring(z),it.addText(de)}function Ci(){if(Re==="")return;let z=null;if(typeof ie.subLanguage=="string"){if(!_[ie.subLanguage]){it.addText(Re);return}z=Gs(ie.subLanguage,Re,!0,lf[ie.subLanguage]),lf[ie.subLanguage]=z._top}else z=cc(Re,ie.subLanguage.length?ie.subLanguage:null);ie.relevance>0&&(Mi+=z.relevance),it.__addSublanguage(z._emitter,z.language)}function Dt(){ie.subLanguage!=null?Ci():Kn(),Re=""}function dn(z,G){z!==""&&(it.startScope(G),it.addText(z),it.endScope())}function nf(z,G){let de=1;const Ce=G.length-1;for(;de<=Ce;){if(!z._emit[de]){de++;continue}const ht=hn.classNameAliases[z[de]]||z[de],Mn=G[de];ht?dn(Mn,ht):(Re=Mn,Kn(),Re=""),de++}}function rf(z,G){return z.scope&&typeof z.scope=="string"&&it.openNode(hn.classNameAliases[z.scope]||z.scope),z.beginScope&&(z.beginScope._wrap?(dn(Re,hn.classNameAliases[z.beginScope._wrap]||z.beginScope._wrap),Re=""):z.beginScope._multi&&(nf(z.beginScope,G),Re="")),ie=Object.create(z,{parent:{value:ie}}),ie}function sf(z,G,de){let Ce=E(z.endRe,de);if(Ce){if(z["on:end"]){const ht=new e(z);z["on:end"](G,ht),ht.isMatchIgnored&&(Ce=!1)}if(Ce){for(;z.endsParent&&z.parent;)z=z.parent;return z}}if(z.endsWithParent)return sf(z.parent,G,de)}function Fw(z){return ie.matcher.regexIndex===0?(Re+=z[0],1):(fc=!0,0)}function Uw(z){const G=z[0],de=z.rule,Ce=new e(de),ht=[de.__beforeBegin,de["on:begin"]];for(const Mn of ht)if(Mn&&(Mn(z,Ce),Ce.isMatchIgnored))return Fw(G);return de.skip?Re+=G:(de.excludeBegin&&(Re+=G),Dt(),!de.returnBegin&&!de.excludeBegin&&(Re=G)),rf(de,z),de.returnBegin?0:G.length}function Vw(z){const G=z[0],de=Z.substring(z.index),Ce=sf(ie,z,de);if(!Ce)return Xh;const ht=ie;ie.endScope&&ie.endScope._wrap?(Dt(),dn(G,ie.endScope._wrap)):ie.endScope&&ie.endScope._multi?(Dt(),nf(ie.endScope,z)):ht.skip?Re+=G:(ht.returnEnd||ht.excludeEnd||(Re+=G),Dt(),ht.excludeEnd&&(Re=G));do ie.scope&&it.closeNode(),!ie.skip&&!ie.subLanguage&&(Mi+=ie.relevance),ie=ie.parent;while(ie!==Ce.parent);return Ce.starts&&rf(Ce.starts,z),ht.returnEnd?0:G.length}function Ww(){const z=[];for(let G=ie;G!==hn;G=G.parent)G.scope&&z.unshift(G.scope);z.forEach(G=>it.openNode(G))}let Ei={};function of(z,G){const de=G&&G[0];if(Re+=z,de==null)return Dt(),0;if(Ei.type==="begin"&&G.type==="end"&&Ei.index===G.index&&de===""){if(Re+=Z.slice(G.index,G.index+1),!Fe){const Ce=new Error(`0 width match regex (${I})`);throw Ce.languageName=I,Ce.badRule=Ei.rule,Ce}return 1}if(Ei=G,G.type==="begin")return Uw(G);if(G.type==="illegal"&&!pe){const Ce=new Error('Illegal lexeme "'+de+'" for mode "'+(ie.scope||"<unnamed>")+'"');throw Ce.mode=ie,Ce}else if(G.type==="end"){const Ce=Vw(G);if(Ce!==Xh)return Ce}if(G.type==="illegal"&&de==="")return Re+=`
157
+ `,1;if(hc>1e5&&hc>G.index*3)throw new Error("potential infinite loop, way more iterations than matches");return Re+=de,de.length}const hn=qn(I);if(!hn)throw ue(Ue.replace("{}",I)),new Error('Unknown language: "'+I+'"');const qw=un(hn);let dc="",ie=Ne||qw;const lf={},it=new U.__emitter(U);Ww();let Re="",Mi=0,Tr=0,hc=0,fc=!1;try{if(hn.__emitTokens)hn.__emitTokens(Z,it);else{for(ie.matcher.considerAll();;){hc++,fc?fc=!1:ie.matcher.considerAll(),ie.matcher.lastIndex=Tr;const z=ie.matcher.exec(Z);if(!z)break;const G=Z.substring(Tr,z.index),de=of(G,z);Tr=z.index+de}of(Z.substring(Tr))}return it.finalize(),dc=it.toHTML(),{language:I,value:dc,relevance:Mi,illegal:!1,_emitter:it,_top:ie}}catch(z){if(z.message&&z.message.includes("Illegal"))return{language:I,value:lc(Z),illegal:!0,relevance:0,_illegalBy:{message:z.message,index:Tr,context:Z.slice(Tr-100,Tr+100),mode:z.mode,resultSoFar:dc},_emitter:it};if(Fe)return{language:I,value:lc(Z),illegal:!1,relevance:0,errorRaised:z,_emitter:it,_top:ie};throw z}}function ac(I){const Z={value:lc(I),illegal:!1,relevance:0,_top:q,_emitter:new U.__emitter(U)};return Z._emitter.addText(I),Z}function cc(I,Z){Z=Z||U.languages||Object.keys(_);const pe=ac(I),Ne=Z.filter(qn).filter(tf).map(Dt=>Gs(Dt,I,!1));Ne.unshift(pe);const Ze=Ne.sort((Dt,dn)=>{if(Dt.relevance!==dn.relevance)return dn.relevance-Dt.relevance;if(Dt.language&&dn.language){if(qn(Dt.language).supersetOf===dn.language)return 1;if(qn(dn.language).supersetOf===Dt.language)return-1}return 0}),[Gt,Kn]=Ze,Ci=Gt;return Ci.secondBest=Kn,Ci}function _w(I,Z,pe){const Ne=Z&&$[Z]||pe;I.classList.add("hljs"),I.classList.add(`language-${Ne}`)}function uc(I){let Z=null;const pe=Qe(I);if(ee(pe))return;if(Si("before:highlightElement",{el:I,language:pe}),I.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",I);return}if(I.children.length>0&&(U.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(I)),U.throwUnescapedHTML))throw new Nw("One of your code blocks includes unescaped HTML.",I.innerHTML);Z=I;const Ne=Z.textContent,Ze=pe?qe(Ne,{language:pe,ignoreIllegals:!0}):cc(Ne);I.innerHTML=Ze.value,I.dataset.highlighted="yes",_w(I,pe,Ze.language),I.result={language:Ze.language,re:Ze.relevance,relevance:Ze.relevance},Ze.secondBest&&(I.secondBest={language:Ze.secondBest.language,relevance:Ze.secondBest.relevance}),Si("after:highlightElement",{el:I,result:Ze,text:Ne})}function Ow(I){U=Yh(U,I)}const Dw=()=>{ki(),ve("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Lw(){ki(),ve("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Qh=!1;function ki(){function I(){ki()}if(document.readyState==="loading"){Qh||window.addEventListener("DOMContentLoaded",I,!1),Qh=!0;return}document.querySelectorAll(U.cssSelector).forEach(uc)}function Iw(I,Z){let pe=null;try{pe=Z(v)}catch(Ne){if(ue("Language definition for '{}' could not be registered.".replace("{}",I)),Fe)ue(Ne);else throw Ne;pe=q}pe.name||(pe.name=I),_[I]=pe,pe.rawDefinition=Z.bind(null,v),pe.aliases&&ef(pe.aliases,{languageName:I})}function jw(I){delete _[I];for(const Z of Object.keys($))$[Z]===I&&delete $[Z]}function Pw(){return Object.keys(_)}function qn(I){return I=(I||"").toLowerCase(),_[I]||_[$[I]]}function ef(I,{languageName:Z}){typeof I=="string"&&(I=[I]),I.forEach(pe=>{$[pe.toLowerCase()]=Z})}function tf(I){const Z=qn(I);return Z&&!Z.disableAutodetect}function Bw(I){I["before:highlightBlock"]&&!I["before:highlightElement"]&&(I["before:highlightElement"]=Z=>{I["before:highlightBlock"](Object.assign({block:Z.el},Z))}),I["after:highlightBlock"]&&!I["after:highlightElement"]&&(I["after:highlightElement"]=Z=>{I["after:highlightBlock"](Object.assign({block:Z.el},Z))})}function Hw(I){Bw(I),re.push(I)}function $w(I){const Z=re.indexOf(I);Z!==-1&&re.splice(Z,1)}function Si(I,Z){const pe=I;re.forEach(function(Ne){Ne[pe]&&Ne[pe](Z)})}function zw(I){return ve("10.7.0","highlightBlock will be removed entirely in v12.0"),ve("10.7.0","Please use highlightElement now."),uc(I)}Object.assign(v,{highlight:qe,highlightAuto:cc,highlightAll:ki,highlightElement:uc,highlightBlock:zw,configure:Ow,initHighlighting:Dw,initHighlightingOnLoad:Lw,registerLanguage:Iw,unregisterLanguage:jw,listLanguages:Pw,getLanguage:qn,registerAliases:ef,autoDetection:tf,inherit:Yh,addPlugin:Hw,removePlugin:$w}),v.debugMode=function(){Fe=!1},v.safeMode=function(){Fe=!0},v.versionString=Tw,v.regex={concat:g,lookahead:h,either:b,optional:p,anyNumberOfTimes:f};for(const I in Er)typeof Er[I]=="object"&&t(Er[I]);return Object.assign(v,Er),v},is=Zh({});return is.newInstance=()=>Zh({}),Wc=is,is.HighlightJS=is,is.default=is,Wc}var KM=qM();const Qb=ug(KM);function e0(t,e=[]){return t.map(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?e0(n.children,r):{text:n.value,classes:r}}).flat()}function Fp(t){return t.value||t.children||[]}function GM(t){return!!Qb.getLanguage(t)}function Up({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return Mu(t,o=>o.type.name===e).forEach(o=>{var i;let l=o.pos+1;const a=o.node.attrs.language||r,c=n.listLanguages(),u=a&&(c.includes(a)||GM(a)||(i=n.registered)!=null&&i.call(n,a))?Fp(n.highlight(a,o.node.textContent)):Fp(n.highlightAuto(o.node.textContent));e0(u).forEach(d=>{const h=l+d.text.length;if(d.classes.length){const f=De.inline(l,h,{class:d.classes.join(" ")});s.push(f)}l=h})}),be.create(t,s)}function JM(t){return typeof t=="function"}function YM({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>JM(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new me({key:new ye("lowlight"),state:{init:(s,{doc:o})=>Up({doc:o,name:t,lowlight:e,defaultLanguage:n}),apply:(s,o,i,l)=>{const a=i.selection.$head.parent.type.name,c=l.selection.$head.parent.type.name,u=Mu(i.doc,h=>h.type.name===t),d=Mu(l.doc,h=>h.type.name===t);return s.docChanged&&([a,c].includes(t)||d.length!==u.length||s.steps.some(h=>h.from!==void 0&&h.to!==void 0&&u.some(f=>f.pos>=h.from&&f.pos+f.node.nodeSize<=h.to)))?Up({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):o.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var XM=TE.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],YM({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),t0=XM,ZM=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,QM=Ie.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:t}){return["img",xe(this.options.HTMLAttributes,t)]},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[mb({find:ZM,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),n0=QM;const qc=(t,e,n)=>Math.max(e,Math.min(n,t));function eA(t){const e=ne.useRef(null),[n,r]=ne.useState(!1),[s,o]=ne.useState(null),i=t.node.attrs,l=ne.useMemo(()=>{const h=i.width;return typeof h=="string"&&h.trim().endsWith("%")?qc(parseFloat(h)||100,1,100):100},[i.width]),a=s??l,c=h=>f=>{var M,w,T,k;f.preventDefault(),f.stopPropagation();const p=f.clientX,g=a,y=((M=e.current)==null?void 0:M.closest(".ProseMirror"))||void 0,b=(y==null?void 0:y.getBoundingClientRect().width)||((T=(w=e.current)==null?void 0:w.parentElement)==null?void 0:T.getBoundingClientRect().width)||((k=e.current)==null?void 0:k.getBoundingClientRect().width)||window.innerWidth;let x=g;const E=N=>{const B=(N.clientX-p)/b*100,P=h==="east"?g+B:g-B,L=qc(P,1,100);x=L,o(L)},S=()=>{r(!1),window.removeEventListener("pointermove",E),window.removeEventListener("pointerup",S);const N=qc(x,1,100);t.updateAttributes({width:`${N.toFixed(2)}%`}),o(null)};r(!0),window.addEventListener("pointermove",E),window.addEventListener("pointerup",S,{once:!0})},u=(()=>{const h={width:`${a}%`,maxWidth:"100%",display:"block"};return i.height?(typeof i.height=="number"||typeof i.height=="string")&&(h.height=i.height):h.height="auto",i.align==="left"&&(h.marginLeft=0,h.marginRight="auto"),i.align==="right"&&(h.marginLeft="auto",h.marginRight=0),i.align==="center"&&(h.margin="0 auto"),h})(),d=t.selected||n;return m.jsxs(Xd,{ref:e,className:"tiptap-image-wrapper relative block","data-dragging":n?"true":"false",contentEditable:!1,style:u,onClick:h=>h.stopPropagation(),children:[m.jsx("img",{src:i.src,alt:i.alt||"",style:{display:"block",width:"100%",height:"100%",objectFit:"cover",objectPosition:`${i.focalX??50}% ${i.focalY??50}%`,borderRadius:6},draggable:!1,onClick:h=>{if(i.focusMode){const f=h.target.getBoundingClientRect(),p=Math.round((h.clientX-f.left)/f.width*100),g=Math.round((h.clientY-f.top)/f.height*100);t.updateAttributes({focalX:p,focalY:g,focusMode:!1})}}}),d&&m.jsxs(m.Fragment,{children:[m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("west"),className:"absolute left-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"}),m.jsx("div",{role:"slider","aria-label":"Resize image","aria-valuemin":1,"aria-valuemax":100,"aria-valuenow":a,onPointerDown:c("east"),className:"absolute right-0 top-1/2 -translate-y-1/2 h-16 w-2 rounded-sm bg-primary cursor-ew-resize shadow border border-primary/40"})]}),d&&m.jsx("div",{className:"pointer-events-none absolute inset-0 rounded-md ring-2 ring-primary/60"}),n&&m.jsxs("div",{className:"pointer-events-none absolute -top-6 right-0 text-xs bg-primary text-primary-foreground px-2 py-0.5 rounded",children:[Number(a.toFixed(1)),"%"]})]})}const tA=n0.extend({name:"image",addAttributes(){var t;return{...((t=this.parent)==null?void 0:t.call(this))||{},width:{default:null,parseHTML:e=>e.getAttribute("width")||e.style.width||null,renderHTML:e=>{const n={};return typeof e.width=="number"?n.width=e.width:typeof e.width=="string"&&e.width.trim().length>0&&(n.style=`width: ${e.width};`),n}},height:{default:null,parseHTML:e=>e.getAttribute("height")||e.style.height||null,renderHTML:e=>{const n={};if(typeof e.height=="number")n.height=e.height;else if(typeof e.height=="string"&&e.height.trim().length>0){const r=`height: ${e.height};`;n.style=n.style?`${n.style} ${r}`:r}return n}},blurDataURL:{default:null,parseHTML:e=>e.getAttribute("data-blur")||null,renderHTML:e=>e.blurDataURL?{"data-blur":e.blurDataURL}:{}},lockAspect:{default:!0,parseHTML:e=>e.getAttribute("data-lock-aspect")!=="false",renderHTML:e=>({"data-lock-aspect":String(e.lockAspect)})},align:{default:null,parseHTML:e=>e.getAttribute("data-align"),renderHTML:e=>e.align?{"data-align":e.align}:{}},caption:{default:null,parseHTML:e=>e.getAttribute("data-caption"),renderHTML:e=>e.caption?{"data-caption":e.caption}:{}},focalX:{default:null,parseHTML:e=>e.getAttribute("data-focal-x"),renderHTML:e=>e.focalX!=null?{"data-focal-x":String(e.focalX)}:{}},focalY:{default:null,parseHTML:e=>e.getAttribute("data-focal-y"),renderHTML:e=>e.focalY!=null?{"data-focal-y":String(e.focalY)}:{}},focusMode:{default:!1,parseHTML:e=>e.getAttribute("data-focus-mode")==="true",renderHTML:e=>e.focusMode?{"data-focus-mode":"true"}:{}}}},addKeyboardShortcuts(){const e=n=>()=>{const s=(this.editor.getAttributes("image")||{}).width;let o=100;typeof s=="string"&&s.endsWith("%")&&(o=parseFloat(s)||100);const i=Math.max(1,Math.min(100,o+n));return this.editor.chain().focus().updateAttributes("image",{width:`${i}%`}).run()};return{"Alt-=":e(5),"Alt-+":e(5),"Alt--":e(-5),"Alt-_":e(-5)}},addNodeView(){return Zd(eA)}});var r0=Ub,s0=Fb,$u,zu;if(typeof WeakMap<"u"){let t=new WeakMap;$u=e=>t.get(e),zu=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;$u=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},zu=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var He=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e<this.map.length;e++){const n=this.map[e];if(n!=t)continue;const r=e%this.width,s=e/this.width|0;let o=r+1,i=s+1;for(let l=1;o<this.width&&this.map[e+l]==n;l++)o++;for(let l=1;i<this.height&&this.map[e+this.width*l]==n;l++)i++;return{left:r,top:s,right:o,bottom:i}}throw new RangeError(`No cell with offset ${t} found`)}colCount(t){for(let e=0;e<this.map.length;e++)if(this.map[e]==t)return e%this.width;throw new RangeError(`No cell with offset ${t} found`)}nextCell(t,e,n){const{left:r,right:s,top:o,bottom:i}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[o*this.width+(n<0?r-1:s)]:(n<0?o==0:i==this.height)?null:this.map[r+this.width*(n<0?o-1:i)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:o}=this.findCell(t),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(n,i),top:Math.min(s,a),right:Math.max(r,l),bottom:Math.max(o,c)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const o=r*this.width+s,i=this.map[o];n[i]||(n[i]=!0,!(s==t.left&&s&&this.map[o-1]==i||r==t.top&&r&&this.map[o-this.width]==i)&&e.push(i))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const o=s+n.child(r).nodeSize;if(r==t){let i=e+t*this.width;const l=(t+1)*this.width;for(;i<l&&this.map[i]<s;)i++;return i==l?o-1:this.map[i]}s=o}}static get(t){return $u(t)||zu(t,nA(t))}};function nA(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=rA(t),n=t.childCount,r=[];let s=0,o=null;const i=[];for(let c=0,u=e*n;c<u;c++)r[c]=0;for(let c=0,u=0;c<n;c++){const d=t.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==d.childCount)break;const g=d.child(p),{colspan:y,rowspan:b,colwidth:x}=g.attrs;for(let E=0;E<b;E++){if(E+c>=n){(o||(o=[])).push({type:"overlong_rowspan",pos:u,n:b-E});break}const S=s+E*e;for(let M=0;M<y;M++){r[S+M]==0?r[S+M]=u:(o||(o=[])).push({type:"collision",row:c,pos:u,n:y-M});const w=x&&x[M];if(w){const T=(S+M)%e*2,k=i[T];k==null||k!=w&&i[T+1]==1?(i[T]=w,i[T+1]=1):k==w&&i[T+1]++}}}s+=y,u+=g.nodeSize}const h=(c+1)*e;let f=0;for(;s<h;)r[s++]==0&&f++;f&&(o||(o=[])).push({type:"missing",row:c,n:f}),u++}(e===0||n===0)&&(o||(o=[])).push({type:"zero_sized"});const l=new He(e,n,r,o);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<n&&(a=!0);return a&&sA(l,i,t),l}function rA(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let o=0;if(n)for(let i=0;i<r;i++){const l=t.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(o+=c.attrs.colspan)}}for(let i=0;i<s.childCount;i++){const l=s.child(i);o+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function sA(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const o=t.map[s];if(r[o])continue;r[o]=!0;const i=n.nodeAt(o);if(!i)throw new RangeError(`No cell with offset ${o} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(s+c)%t.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=oA(a)))[c]=d)}l&&t.problems.unshift({type:"colwidth mismatch",pos:o,colwidth:l})}}function oA(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function xt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],s=r.spec.tableRole;s&&(e[s]=r)}}return e}var rr=new ye("selectingCells");function js(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function iA(t){for(let e=t.depth;e>0;e--){const n=t.node(e).type.spec.tableRole;if(n==="cell"||n==="header_cell")return t.node(e)}return null}function an(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function La(t){const e=t.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const n=js(e.$head)||lA(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function lA(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Fu(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function aA(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function hh(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function o0(t,e,n){const r=t.node(-1),s=He.get(r),o=t.start(-1),i=s.nextCell(t.pos-o,e,n);return i==null?null:t.node(0).resolve(o+i)}function Gr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function i0(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<n;s++)r.colwidth.splice(e,0,0)}return r}function cA(t,e,n){const r=xt(e.type.schema).header_cell;for(let s=0;s<t.height;s++)if(e.nodeAt(t.map[n+s*t.width]).type!=r)return!1;return!0}var _e=class On extends Q{constructor(e,n=e){const r=e.node(-1),s=He.get(r),o=e.start(-1),i=s.rectBetween(e.pos-o,n.pos-o),l=e.node(0),a=s.cellsInRect(i).filter(u=>u!=n.pos-o);a.unshift(n.pos-o);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const h=o+u+1;return new Ad(l.resolve(h),l.resolve(h+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),s=e.resolve(n.map(this.$headCell.pos));if(Fu(r)&&Fu(s)&&hh(r,s)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?On.rowSelection(r,s):o&&this.isColSelection()?On.colSelection(r,s):new On(r,s)}return Y.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=He.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},i=[];for(let a=s.top;a<s.bottom;a++){const c=[];for(let u=a*n.width+s.left,d=s.left;d<s.right;d++,u++){const h=n.map[u];if(o[h])continue;o[h]=!0;const f=n.findCell(h);let p=e.nodeAt(h);if(!p)throw RangeError(`No cell with offset ${h} found`);const g=s.left-f.left,y=f.right-s.right;if(g>0||y>0){let b=p.attrs;if(g>0&&(b=Gr(b,0,g)),y>0&&(b=Gr(b,b.colspan-y,y)),f.left<s.left){if(p=p.type.createAndFill(b),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(b)}`)}else p=p.type.create(b,p.content)}if(f.top<s.top||f.bottom>s.bottom){const b={...p.attrs,rowspan:Math.min(f.bottom,s.bottom)-Math.max(f.top,s.top)};f.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}i.push(e.child(a).copy(O.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new j(O.from(l),1,1)}replace(e,n=j.empty){const r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){const{$from:l,$to:a}=s[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?j.empty:n)}const o=Q.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);o&&e.setSelection(o)}replaceWith(e,n){this.replace(e,new j(O.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=He.get(n),s=this.$anchorCell.start(-1),o=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let i=0;i<o.length;i++)e(n.nodeAt(o[i]),s+o[i])}isColSelection(){const e=this.$anchorCell.index(-1),n=this.$headCell.index(-1);if(Math.min(e,n)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),s=He.get(r),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(n.pos-o),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(o+s.map[i.left])),l.bottom<s.height&&(n=a.resolve(o+s.map[s.width*(s.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(o+s.map[l.left])),i.bottom<s.height&&(e=a.resolve(o+s.map[s.width*(s.height-1)+i.right-1]))),new On(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=He.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),o=n.colCount(this.$headCell.pos-r);if(Math.min(s,o)>0)return!1;const i=s+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==n.width}eq(e){return e instanceof On&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=He.get(r),o=e.start(-1),i=s.findCell(e.pos-o),l=s.findCell(n.pos-o),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(o+s.map[i.top*s.width])),l.right<s.width&&(n=a.resolve(o+s.map[s.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(o+s.map[l.top*s.width])),i.right<s.width&&(e=a.resolve(o+s.map[s.width*(i.top+1)-1]))),new On(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new On(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new On(e.resolve(n),e.resolve(r))}getBookmark(){return new uA(this.$anchorCell.pos,this.$headCell.pos)}};_e.prototype.visible=!1;Q.jsonID("cell",_e);var uA=class l0{constructor(e,n){this.anchor=e,this.head=n}map(e){return new l0(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return n.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&n.index()<n.parent.childCount&&r.index()<r.parent.childCount&&hh(n,r)?new _e(n,r):Q.near(r,1)}};function dA(t){if(!(t.selection instanceof _e))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(De.node(r,r+n.nodeSize,{class:"selectedCell"}))}),be.create(t.doc,e)}function hA({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,s=t.depth;for(;s>=0&&!(t.after(s+1)<t.end(s));s--,n++);for(let o=e.depth;o>=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function fA({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const o=t.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let s=e.depth;s>0;s--){const o=e.node(s);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function pA(t,e,n){const r=(e||t).selection,s=(e||t).doc;let o,i;if(r instanceof K&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")o=_e.create(s,r.from);else if(i=="row"){const l=s.resolve(r.from+1);o=_e.rowSelection(l,l)}else if(!n){const l=He.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];o=_e.create(s,a+1,c)}}else r instanceof Y&&hA(r)?o=Y.create(s,r.from):r instanceof Y&&fA(r)&&(o=Y.create(s,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var mA=new ye("fix-tables");function a0(t,e,n,r){const s=t.childCount,o=e.childCount;e:for(let i=0,l=0;i<o;i++){const a=e.child(i);for(let c=l,u=Math.min(s,i+3);c<u;c++)if(t.child(c)==a){l=c+1,n+=a.nodeSize;continue e}r(a,n),l<s&&t.child(l).sameMarkup(a)?a0(t.child(l),a,n+1,r):a.nodesBetween(0,a.content.size,r,n+1),n+=a.nodeSize}}function c0(t,e){let n;const r=(s,o)=>{s.type.spec.tableRole=="table"&&(n=gA(t,s,o,n))};return e?e.doc!=t.doc&&a0(e.doc,t.doc,0,r):t.doc.descendants(r),n}function gA(t,e,n,r){const s=He.get(e);if(!s.problems)return r;r||(r=t.tr);const o=[];for(let a=0;a<s.height;a++)o.push(0);for(let a=0;a<s.problems.length;a++){const c=s.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let h=0;h<d.rowspan;h++)o[c.row+h]+=c.n;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,Gr(d,d.colspan-c.n,c.n))}else if(c.type=="missing")o[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(n+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(n);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<o.length;a++)o[a]&&(i==null&&(i=a),l=a);for(let a=0,c=n+1;a<s.height;a++){const u=e.child(a),d=c+u.nodeSize,h=o[a];if(h>0){let f="cell";u.firstChild&&(f=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<h;y++){const b=xt(t.schema)[f].createAndFill();b&&p.push(b)}const g=(a==0||i==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(g),p)}c=d}return r.setMeta(mA,{fixTables:!0})}function kn(t){const e=t.selection,n=La(t),r=n.node(-1),s=n.start(-1),o=He.get(r);return{...e instanceof _e?o.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o.findCell(n.pos-s),tableStart:s,map:o,table:r}}function u0(t,{map:e,tableStart:n,table:r},s){let o=s>0?-1:0;cA(e,r,s+o)&&(o=s==0||s==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+s;if(s>0&&s<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);t.setNodeMarkup(t.mapping.map(n+a),null,i0(c.attrs,s-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=o==null?xt(r.type.schema).cell:r.nodeAt(e.map[l+o]).type,c=e.positionAt(i,s,r);t.insert(t.mapping.map(n+c),a.createAndFill())}}return t}function yA(t,e){if(!an(t))return!1;if(e){const n=kn(t);e(u0(t.tr,n,n.left))}return!0}function bA(t,e){if(!an(t))return!1;if(e){const n=kn(t);e(u0(t.tr,n,n.right))}return!0}function xA(t,{map:e,table:n,tableStart:r},s){const o=t.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+s,a=e.map[l],c=n.nodeAt(a),u=c.attrs;if(s>0&&e.map[l-1]==a||s<e.width-1&&e.map[l+1]==a)t.setNodeMarkup(t.mapping.slice(o).map(r+a),null,Gr(u,s-e.colCount(a)));else{const d=t.mapping.slice(o).map(r+a);t.delete(d,d+c.nodeSize)}i+=u.rowspan}}function wA(t,e){if(!an(t))return!1;if(e){const n=kn(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;xA(r,n,s),s!=n.left;s--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=He.get(o)}e(r)}return!0}function vA(t,e,n){var r;const s=xt(e.type.schema).header_cell;for(let o=0;o<t.width;o++)if(((r=e.nodeAt(t.map[o+n*t.width]))==null?void 0:r.type)!=s)return!1;return!0}function d0(t,{map:e,tableStart:n,table:r},s){var o;let i=n;for(let c=0;c<s;c++)i+=r.child(c).nodeSize;const l=[];let a=s>0?-1:0;vA(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let c=0,u=e.width*s;c<e.width;c++,u++)if(s>0&&s<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],h=r.nodeAt(d).attrs;t.setNodeMarkup(n+d,null,{...h,rowspan:h.rowspan+1}),c+=h.colspan-1}else{const d=a==null?xt(r.type.schema).cell:(o=r.nodeAt(e.map[u+a*e.width]))==null?void 0:o.type,h=d==null?void 0:d.createAndFill();h&&l.push(h)}return t.insert(i,xt(r.type.schema).row.create(null,l)),t}function kA(t,e){if(!an(t))return!1;if(e){const n=kn(t);e(d0(t.tr,n,n.top))}return!0}function SA(t,e){if(!an(t))return!1;if(e){const n=kn(t);e(d0(t.tr,n,n.bottom))}return!0}function CA(t,{map:e,table:n,tableStart:r},s){let o=0;for(let c=0;c<s;c++)o+=n.child(c).nodeSize;const i=o+n.child(s).nodeSize,l=t.mapping.maps.length;t.delete(o+r,i+r);const a=new Set;for(let c=0,u=s*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),s>0&&d==e.map[u-e.width]){const h=n.nodeAt(d).attrs;t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h,rowspan:h.rowspan-1}),c+=h.colspan-1}else if(s<e.height&&d==e.map[u+e.width]){const h=n.nodeAt(d),f=h.attrs,p=h.type.create({...f,rowspan:h.attrs.rowspan-1},h.content),g=e.positionAt(s+1,c,n);t.insert(t.mapping.slice(l).map(r+g),p),c+=f.colspan-1}}}}function EA(t,e){if(!an(t))return!1;if(e){const n=kn(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;CA(r,n,s),s!=n.top;s--){const o=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!o)throw RangeError("No table found");n.table=o,n.map=He.get(n.table)}e(r)}return!0}function Vp(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function MA({width:t,height:e,map:n},r){let s=r.top*t+r.left,o=s,i=(r.bottom-1)*t+r.left,l=s+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&n[o]==n[o-1]||r.right<t&&n[l]==n[l+1])return!0;o+=t,l+=t}for(let a=r.left;a<r.right;a++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[i]==n[i+t])return!0;s++,i++}return!1}function Wp(t,e){const n=t.selection;if(!(n instanceof _e)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=kn(t),{map:s}=r;if(MA(s,r))return!1;if(e){const o=t.tr,i={};let l=O.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const h=s.map[u*s.width+d],f=r.table.nodeAt(h);if(!(i[h]||!f))if(i[h]=!0,a==null)a=h,c=f;else{Vp(f)||(l=l.append(f.content));const p=o.mapping.map(h+r.tableStart);o.delete(p,p+f.nodeSize)}}if(a==null||c==null)return!0;if(o.setNodeMarkup(a+r.tableStart,null,{...i0(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,d=Vp(c)?a+1:u;o.replaceWith(d+r.tableStart,u+r.tableStart,l)}o.setSelection(new _e(o.doc.resolve(a+r.tableStart))),e(o)}return!0}function qp(t,e){const n=xt(t.schema);return AA(({node:r})=>n[r.type.spec.tableRole])(t,e)}function AA(t){return(e,n)=>{var r;const s=e.selection;let o,i;if(s instanceof _e){if(s.$anchorCell.pos!=s.$headCell.pos)return!1;o=s.$anchorCell.nodeAfter,i=s.$anchorCell.pos}else{if(o=iA(s.$from),!o)return!1;i=(r=js(s.$from))==null?void 0:r.pos}if(o==null||i==null||o.attrs.colspan==1&&o.attrs.rowspan==1)return!1;if(n){let l=o.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=kn(e),d=e.tr;for(let f=0;f<u.right-u.left;f++)a.push(c?{...l,colwidth:c&&c[f]?[c[f]]:null}:l);let h;for(let f=u.top;f<u.bottom;f++){let p=u.map.positionAt(f,u.left,u.table);f==u.top&&(p+=o.nodeSize);for(let g=u.left,y=0;g<u.right;g++,y++)g==u.left&&f==u.top||d.insert(h=d.mapping.map(p+u.tableStart,1),t({node:o,row:f,col:g}).createAndFill(a[y]))}d.setNodeMarkup(i,t({node:o,row:u.top,col:u.left}),a[0]),s instanceof _e&&d.setSelection(new _e(d.doc.resolve(s.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function TA(t,e){return function(n,r){if(!an(n))return!1;const s=La(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const o=n.tr;n.selection instanceof _e?n.selection.forEachCell((i,l)=>{i.attrs[t]!==e&&o.setNodeMarkup(l,null,{...i.attrs,[t]:e})}):o.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(o)}return!0}}function NA(t){return function(e,n){if(!an(e))return!1;if(n){const r=xt(e.schema),s=kn(e),o=e.tr,i=s.map.cellsInRect(t=="column"?{left:s.left,top:0,right:s.right,bottom:s.map.height}:t=="row"?{left:0,top:s.top,right:s.map.width,bottom:s.bottom}:s),l=i.map(a=>s.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&o.setNodeMarkup(s.tableStart+i[a],r.cell,l[a].attrs);if(o.steps.length==0)for(let a=0;a<i.length;a++)o.setNodeMarkup(s.tableStart+i[a],r.header_cell,l[a].attrs);n(o)}return!0}}function Kp(t,e,n){const r=e.map.cellsInRect({left:0,top:0,right:t=="row"?e.map.width:1,bottom:t=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const o=e.table.nodeAt(r[s]);if(o&&o.type!==n.header_cell)return!1}return!0}function Lo(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?NA(t):function(n,r){if(!an(n))return!1;if(r){const s=xt(n.schema),o=kn(n),i=n.tr,l=Kp("row",o,s),a=Kp("column",o,s),u=(t==="column"?l:t==="row"?a:!1)?1:0,d=t=="column"?{left:0,top:u,right:1,bottom:o.map.height}:t=="row"?{left:u,top:0,right:o.map.width,bottom:1}:o,h=t=="column"?a?s.cell:s.header_cell:t=="row"?l?s.cell:s.header_cell:s.cell;o.map.cellsInRect(d).forEach(f=>{const p=f+o.tableStart,g=i.doc.nodeAt(p);g&&i.setNodeMarkup(p,h,g.attrs)}),r(i)}return!0}}Lo("row",{useDeprecatedLogic:!0});Lo("column",{useDeprecatedLogic:!0});var RA=Lo("cell",{useDeprecatedLogic:!0});function _A(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,s=t.before();r>=0;r--){const o=t.node(-1).child(r),i=o.lastChild;if(i)return s-1-i.nodeSize;s-=o.nodeSize}}else{if(t.index()<t.parent.childCount-1)return t.pos+t.nodeAfter.nodeSize;const n=t.node(-1);for(let r=t.indexAfter(-1),s=t.after();r<n.childCount;r++){const o=n.child(r);if(o.childCount)return s+1;s+=o.nodeSize}}return null}function Gp(t){return function(e,n){if(!an(e))return!1;const r=_A(La(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(Y.between(s,aA(s))).scrollIntoView())}return!0}}function OA(t,e){const n=t.selection.$anchor;for(let r=n.depth;r>0;r--)if(n.node(r).type.spec.tableRole=="table")return e&&e(t.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function zi(t,e){const n=t.selection;if(!(n instanceof _e))return!1;if(e){const r=t.tr,s=xt(t.schema).cell.createAndFill().content;n.forEachCell((o,i)=>{o.content.eq(s)||r.replace(r.mapping.map(i+1),r.mapping.map(i+o.nodeSize-1),new j(s,0,0))}),r.docChanged&&e(r)}return!0}function DA(t){if(!t.size)return null;let{content:e,openStart:n,openEnd:r}=t;for(;e.childCount==1&&(n>0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const s=e.child(0),o=s.type.spec.tableRole,i=s.type.schema,l=[];if(o=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,n-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Uu(xt(i).row,new j(c,u,d)).content),l.push(c)}else if(o=="cell"||o=="header_cell")l.push(n||r?Uu(xt(i).row,new j(e,n,r)).content:e);else return null;return LA(i,l)}function LA(t,e){const n=[];for(let s=0;s<e.length;s++){const o=e[s];for(let i=o.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=o.child(i).attrs;for(let c=s;c<s+l;c++)n[c]=(n[c]||0)+a}}let r=0;for(let s=0;s<n.length;s++)r=Math.max(r,n[s]);for(let s=0;s<n.length;s++)if(s>=e.length&&e.push(O.empty),n[s]<r){const o=xt(t).cell.createAndFill(),i=[];for(let l=n[s];l<r;l++)i.push(o);e[s]=e[s].append(O.from(i))}return{height:e.length,width:r,rows:e}}function Uu(t,e){const n=t.createAndFill();return new Md(n).replace(0,n.content.size,e).doc}function IA({width:t,height:e,rows:n},r,s){if(t!=r){const o=[],i=[];for(let l=0;l<n.length;l++){const a=n[l],c=[];for(let u=o[l]||0,d=0;u<r;d++){let h=a.child(d%a.childCount);u+h.attrs.colspan>r&&(h=h.type.createChecked(Gr(h.attrs,h.attrs.colspan,u+h.attrs.colspan-r),h.content)),c.push(h),u+=h.attrs.colspan;for(let f=1;f<h.attrs.rowspan;f++)o[l+f]=(o[l+f]||0)+h.attrs.colspan}i.push(O.from(c))}n=i,t=r}if(e!=s){const o=[];for(let i=0,l=0;i<s;i++,l++){const a=[],c=n[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>s&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,s-d.attrs.rowspan)},d.content)),a.push(d)}o.push(O.from(a))}n=o,e=s}return{width:t,height:e,rows:n}}function jA(t,e,n,r,s,o,i){const l=t.doc.type.schema,a=xt(l);let c,u;if(s>e.width)for(let d=0,h=0;d<e.height;d++){const f=n.child(d);h+=f.nodeSize;const p=[];let g;f.lastChild==null||f.lastChild.type==a.cell?g=c||(c=a.cell.createAndFill()):g=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);t.insert(t.mapping.slice(i).map(h-1+r),p)}if(o>e.height){const d=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){const y=p>=e.width?!1:n.nodeAt(e.map[g+p]).type==a.header_cell;d.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const h=a.row.create(null,O.from(d)),f=[];for(let p=e.height;p<o;p++)f.push(h);t.insert(t.mapping.slice(i).map(r+n.nodeSize-2),f)}return!!(c||u)}function Jp(t,e,n,r,s,o,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=s;c<o;c++){const u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const h=n.nodeAt(d),{top:f,left:p}=e.findCell(d);t.setNodeMarkup(t.mapping.slice(l).map(d+r),null,{...h.attrs,rowspan:i-f}),t.insert(t.mapping.slice(l).map(e.positionAt(i,p,n)),h.type.createAndFill({...h.attrs,rowspan:f+h.attrs.rowspan-i})),c+=h.attrs.colspan-1}}return a}function Yp(t,e,n,r,s,o,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=s;c<o;c++){const u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;const h=n.nodeAt(d),f=e.colCount(d),p=t.mapping.slice(l).map(d+r);t.setNodeMarkup(p,null,Gr(h.attrs,i-f,h.attrs.colspan-(i-f))),t.insert(p+h.nodeSize,h.type.createAndFill(Gr(h.attrs,0,i-f))),c+=h.attrs.rowspan-1}}return a}function Xp(t,e,n,r,s){let o=n?t.doc.nodeAt(n-1):t.doc;if(!o)throw new Error("No table found");let i=He.get(o);const{top:l,left:a}=r,c=a+s.width,u=l+s.height,d=t.tr;let h=0;function f(){if(o=n?d.doc.nodeAt(n-1):d.doc,!o)throw new Error("No table found");i=He.get(o),h=d.mapping.maps.length}jA(d,i,o,n,c,u,h)&&f(),Jp(d,i,o,n,a,c,l,h)&&f(),Jp(d,i,o,n,a,c,u,h)&&f(),Yp(d,i,o,n,l,u,a,h)&&f(),Yp(d,i,o,n,l,u,c,h)&&f();for(let p=l;p<u;p++){const g=i.positionAt(p,a,o),y=i.positionAt(p,c,o);d.replace(d.mapping.slice(h).map(g+n),d.mapping.slice(h).map(y+n),new j(s.rows[p-l],0,0))}f(),d.setSelection(new _e(d.doc.resolve(n+i.positionAt(l,a,o)),d.doc.resolve(n+i.positionAt(u-1,c-1,o)))),e(d)}var PA=Bd({ArrowLeft:Fi("horiz",-1),ArrowRight:Fi("horiz",1),ArrowUp:Fi("vert",-1),ArrowDown:Fi("vert",1),"Shift-ArrowLeft":Ui("horiz",-1),"Shift-ArrowRight":Ui("horiz",1),"Shift-ArrowUp":Ui("vert",-1),"Shift-ArrowDown":Ui("vert",1),Backspace:zi,"Mod-Backspace":zi,Delete:zi,"Mod-Delete":zi});function ol(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Fi(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;if(o instanceof _e)return ol(n,r,Q.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const i=h0(s,t,e);if(i==null)return!1;if(t=="horiz")return ol(n,r,Q.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(i),a=o0(l,t,e);let c;return a?c=Q.near(a,1):e<0?c=Q.near(n.doc.resolve(l.before(-1)),-1):c=Q.near(n.doc.resolve(l.after(-1)),1),ol(n,r,c)}}}function Ui(t,e){return(n,r,s)=>{if(!s)return!1;const o=n.selection;let i;if(o instanceof _e)i=o;else{const a=h0(s,t,e);if(a==null)return!1;i=new _e(n.doc.resolve(a))}const l=o0(i.$headCell,t,e);return l?ol(n,r,new _e(i.$anchorCell,l)):!1}}function BA(t,e){const n=t.state.doc,r=js(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new _e(r))),!0):!1}function HA(t,e,n){if(!an(t.state))return!1;let r=DA(n);const s=t.state.selection;if(s instanceof _e){r||(r={width:1,height:1,rows:[O.from(Uu(xt(t.state.schema).cell,n))]});const o=s.$anchorCell.node(-1),i=s.$anchorCell.start(-1),l=He.get(o).rectBetween(s.$anchorCell.pos-i,s.$headCell.pos-i);return r=IA(r,l.right-l.left,l.bottom-l.top),Xp(t.state,t.dispatch,i,l,r),!0}else if(r){const o=La(t.state),i=o.start(-1);return Xp(t.state,t.dispatch,i,He.get(o.node(-1)).findCell(o.pos-i),r),!0}else return!1}function $A(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Zp(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof _e)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=js(t.state.selection.$anchor))!=null&&((n=Kc(t,e))==null?void 0:n.pos)!=s.pos)o(s,e),e.preventDefault();else if(!r)return;function o(a,c){let u=Kc(t,c);const d=rr.getState(t.state)==null;if(!u||!hh(a,u))if(d)u=a;else return;const h=new _e(a,u);if(d||!t.state.selection.eq(h)){const f=t.state.tr.setSelection(h);d&&f.setMeta(rr,a.pos),t.dispatch(f)}}function i(){t.root.removeEventListener("mouseup",i),t.root.removeEventListener("dragstart",i),t.root.removeEventListener("mousemove",l),rr.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(rr,-1))}function l(a){const c=a,u=rr.getState(t.state);let d;if(u!=null)d=t.state.doc.resolve(u);else if(Zp(t,c.target)!=r&&(d=Kc(t,e),!d))return i();d&&o(d,c)}t.root.addEventListener("mouseup",i),t.root.addEventListener("dragstart",i),t.root.addEventListener("mousemove",l)}function h0(t,e,n){if(!(t.state.selection instanceof Y))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const o=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(s),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Zp(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Kc(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?js(t.state.doc.resolve(n.pos)):null}var zA=class{constructor(e,n){this.node=e,this.defaultCellMinWidth=n,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${n}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Vu(e,this.colgroup,this.table,n),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Vu(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Vu(t,e,n,r,s,o){var i;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u){for(let d=0,h=0;d<u.childCount;d++){const{colspan:f,colwidth:p}=u.child(d).attrs;for(let g=0;g<f;g++,h++){const y=s==h?o:p&&p[g],b=y?y+"px":"";if(l+=y||r,y||(a=!1),c)c.style.width!=b&&(c.style.width=b),c=c.nextSibling;else{const x=document.createElement("col");x.style.width=b,e.appendChild(x)}}}for(;c;){const d=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=d}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Pt=new ye("tableColumnResizing");function FA({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=zA,lastColumnResizable:s=!0}={}){const o=new me({key:Pt,state:{init(i,l){var a,c;const u=(c=(a=o.spec)==null?void 0:a.props)==null?void 0:c.nodeViews,d=xt(l.schema).table.name;return r&&u&&(u[d]=(h,f)=>new r(h,n,f)),new UA(-1,!1)},apply(i,l){return l.apply(i)}},props:{attributes:i=>{const l=Pt.getState(i);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(i,l)=>{VA(i,l,t,s)},mouseleave:i=>{WA(i)},mousedown:(i,l)=>{qA(i,l,e,n)}},decorations:i=>{const l=Pt.getState(i);if(l&&l.activeHandle>-1)return XA(i,l.activeHandle)},nodeViews:{}}});return o}var UA=class il{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Pt);if(r&&r.setHandle!=null)return new il(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new il(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return Fu(e.doc.resolve(s))||(s=-1),new il(s,n.dragging)}return n}};function VA(t,e,n,r){if(!t.editable)return;const s=Pt.getState(t.state);if(s&&!s.dragging){const o=GA(e.target);let i=-1;if(o){const{left:l,right:a}=o.getBoundingClientRect();e.clientX-l<=n?i=Qp(t,e,"left",n):a-e.clientX<=n&&(i=Qp(t,e,"right",n))}if(i!=s.activeHandle){if(!r&&i!==-1){const l=t.state.doc.resolve(i),a=l.node(-1),c=He.get(a),u=l.start(-1);if(c.colCount(l.pos-u)+l.nodeAfter.attrs.colspan-1==c.width-1)return}f0(t,i)}}}function WA(t){if(!t.editable)return;const e=Pt.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&f0(t,-1)}function qA(t,e,n,r){var s;if(!t.editable)return!1;const o=(s=t.dom.ownerDocument.defaultView)!=null?s:window,i=Pt.getState(t.state);if(!i||i.activeHandle==-1||i.dragging)return!1;const l=t.state.doc.nodeAt(i.activeHandle),a=KA(t,i.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Pt,{setDragging:{startX:e.clientX,startWidth:a}}));function c(d){o.removeEventListener("mouseup",c),o.removeEventListener("mousemove",u);const h=Pt.getState(t.state);h!=null&&h.dragging&&(JA(t,h.activeHandle,em(h.dragging,d,n)),t.dispatch(t.state.tr.setMeta(Pt,{setDragging:null})))}function u(d){if(!d.which)return c(d);const h=Pt.getState(t.state);if(h&&h.dragging){const f=em(h.dragging,d,n);tm(t,h.activeHandle,f,r)}}return tm(t,i.activeHandle,a,r),o.addEventListener("mouseup",c),o.addEventListener("mousemove",u),e.preventDefault(),!0}function KA(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let c=0;c<n;c++)r[c]&&(l-=r[c],a--);return l/a}function GA(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Qp(t,e,n,r){const s=n=="right"?-r:r,o=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!o)return-1;const{pos:i}=o,l=js(t.state.doc.resolve(i));if(!l)return-1;if(n=="right")return l.pos;const a=He.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function em(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function f0(t,e){t.dispatch(t.state.tr.setMeta(Pt,{setHandle:e}))}function JA(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),o=He.get(s),i=r.start(-1),l=o.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,a=t.state.tr;for(let c=0;c<o.height;c++){const u=c*o.width+l;if(c&&o.map[u]==o.map[u-o.width])continue;const d=o.map[u],h=s.nodeAt(d).attrs,f=h.colspan==1?0:l-o.colCount(d);if(h.colwidth&&h.colwidth[f]==n)continue;const p=h.colwidth?h.colwidth.slice():YA(h.colspan);p[f]=n,a.setNodeMarkup(i+d,null,{...h,colwidth:p})}a.docChanged&&t.dispatch(a)}function tm(t,e,n,r){const s=t.state.doc.resolve(e),o=s.node(-1),i=s.start(-1),l=He.get(o).colCount(s.pos-i)+s.nodeAfter.attrs.colspan-1;let a=t.domAtPos(s.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&Vu(o,a.firstChild,a,r,l,n)}function YA(t){return Array(t).fill(0)}function XA(t,e){var n;const r=[],s=t.doc.resolve(e),o=s.node(-1);if(!o)return be.empty;const i=He.get(o),l=s.start(-1),a=i.colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;for(let c=0;c<i.height;c++){const u=a+c*i.width;if((a==i.width-1||i.map[u]!=i.map[u+1])&&(c==0||i.map[u]!=i.map[u-i.width])){const d=i.map[u],h=l+d+o.nodeAt(d).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",(n=Pt.getState(t))!=null&&n.dragging&&r.push(De.node(l+d,l+d+o.nodeAt(d).nodeSize,{class:"column-resize-dragging"})),r.push(De.widget(h,f))}}return be.create(t.doc,r)}function ZA({allowTableNodeSelection:t=!1}={}){return new me({key:rr,state:{init(){return null},apply(e,n){const r=e.getMeta(rr);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:o}=e.mapping.mapResult(n);return s?null:o}},props:{decorations:dA,handleDOMEvents:{mousedown:$A},createSelectionBetween(e){return rr.getState(e.state)!=null?e.state.selection:null},handleTripleClick:BA,handleKeyDown:PA,handlePaste:HA},appendTransaction(e,n,r){return pA(r,c0(r,n),t)}})}var p0=Ie.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",xe(this.options.HTMLAttributes,t),0]}}),m0=Ie.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{const e=t.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",xe(this.options.HTMLAttributes,t),0]}}),g0=Ie.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",xe(this.options.HTMLAttributes,t),0]}});function Wu(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function nm(t,e,n,r,s,o){var i;let l=0,a=!0,c=e.firstChild;const u=t.firstChild;if(u!==null)for(let d=0,h=0;d<u.childCount;d+=1){const{colspan:f,colwidth:p}=u.child(d).attrs;for(let g=0;g<f;g+=1,h+=1){const y=s===h?o:p&&p[g],b=y?`${y}px`:"";if(l+=y||r,y||(a=!1),c){if(c.style.width!==b){const[x,E]=Wu(r,y);c.style.setProperty(x,E)}c=c.nextSibling}else{const x=document.createElement("col"),[E,S]=Wu(r,y);x.style.setProperty(E,S),e.appendChild(x)}}}for(;c;){const d=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=d}a?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var QA=class{constructor(t,e){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),nm(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!==this.node.type?!1:(this.node=t,nm(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type==="attributes"&&(t.target===this.table||this.colgroup.contains(t.target))}};function eT(t,e,n,r){let s=0,o=!0;const i=[],l=t.firstChild;if(!l)return{};for(let d=0,h=0;d<l.childCount;d+=1){const{colspan:f,colwidth:p}=l.child(d).attrs;for(let g=0;g<f;g+=1,h+=1){const y=n===h?r:p&&p[g];s+=y||e,y||(o=!1);const[b,x]=Wu(e,y);i.push(["col",{style:`${b}: ${x}`}])}}const a=o?`${s}px`:"",c=o?"":`${s}px`;return{colgroup:["colgroup",{},...i],tableWidth:a,tableMinWidth:c}}function rm(t,e){return t.createAndFill()}function tT(t){if(t.cached.tableNodeTypes)return t.cached.tableNodeTypes;const e={};return Object.keys(t.nodes).forEach(n=>{const r=t.nodes[n];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),t.cached.tableNodeTypes=e,e}function nT(t,e,n,r,s){const o=tT(t),i=[],l=[];for(let c=0;c<n;c+=1){const u=rm(o.cell);if(u&&l.push(u),r){const d=rm(o.header_cell);d&&i.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(o.row.createChecked(null,r&&c===0?i:l));return o.table.createChecked(null,a)}function rT(t){return t instanceof _e}var Vi=({editor:t})=>{const{selection:e}=t.state;if(!rT(e))return!1;let n=0;const r=$y(e.ranges[0].$from,o=>o.type.name==="table");return r==null||r.node.descendants(o=>{if(o.type.name==="table")return!1;["tableCell","tableHeader"].includes(o.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},y0=Ie.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:QA,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:t,HTMLAttributes:e}){const{colgroup:n,tableWidth:r,tableMinWidth:s}=eT(t,this.options.cellMinWidth);return["table",xe(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${s}`}),n,["tbody",0]]},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:o})=>{const i=nT(o.schema,t,e,n);if(s){const l=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(Y.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>yA(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>bA(t,e),deleteColumn:()=>({state:t,dispatch:e})=>wA(t,e),addRowBefore:()=>({state:t,dispatch:e})=>kA(t,e),addRowAfter:()=>({state:t,dispatch:e})=>SA(t,e),deleteRow:()=>({state:t,dispatch:e})=>EA(t,e),deleteTable:()=>({state:t,dispatch:e})=>OA(t,e),mergeCells:()=>({state:t,dispatch:e})=>Wp(t,e),splitCell:()=>({state:t,dispatch:e})=>qp(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Lo("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Lo("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>RA(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Wp(t,e)?!0:qp(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>TA(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>Gp(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>Gp(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&c0(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=_e.create(e.doc,t.anchorCell,t.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:Vi,"Mod-Backspace":Vi,Delete:Vi,"Mod-Delete":Vi}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[FA({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ZA({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:ke(J(t,"tableRole",e))}}});fe.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(y0.configure(this.options.table)),this.options.tableCell!==!1&&t.push(p0.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(m0.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(g0.configure(this.options.tableRow)),t}});var sT=g0,oT=m0,iT=p0,lT=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,aT=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,cT=ln.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:t=>t.getAttribute("data-color")||t.style.backgroundColor,renderHTML:t=>t.color?{"data-color":t.color,style:`background-color: ${t.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:t}){return["mark",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setHighlight:t=>({commands:e})=>e.setMark(this.name,t),toggleHighlight:t=>({commands:e})=>e.toggleMark(this.name,t),unsetHighlight:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Kr({find:lT,type:this.type})]},addPasteRules(){return[mr({find:aT,type:this.type})]}}),uT=cT,dT=ln.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(t){return t!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sub",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSubscript:()=>({commands:t})=>t.setMark(this.name),toggleSubscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSubscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hT=dT,fT=ln.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(t){return t!=="super"?!1:null}}]},renderHTML({HTMLAttributes:t}){return["sup",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{setSuperscript:()=>({commands:t})=>t.setMark(this.name),toggleSuperscript:()=>({commands:t})=>t.toggleMark(this.name),unsetSuperscript:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),pT=fT,mT=fe.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:t=>{const e=t.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:t=>t.textAlign?{style:`text-align: ${t.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:t=>({commands:e})=>this.options.alignments.includes(t)?this.options.types.map(n=>e.updateAttributes(n,{textAlign:t})).every(n=>n):!1,unsetTextAlign:()=>({commands:t})=>this.options.types.map(e=>t.resetAttributes(e,"textAlign")).every(e=>e),toggleTextAlign:t=>({editor:e,commands:n})=>this.options.alignments.includes(t)?e.isActive({textAlign:t})?n.unsetTextAlign():n.setTextAlign(t):!1}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),gT=mT,yT=t=>{if(!t.children.length)return;const e=t.querySelectorAll("span");e&&e.forEach(n=>{var r,s;const o=n.getAttribute("style"),i=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${i};${o}`)})},bT=ln.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&yT(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",xe(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleTextStyle:t=>({commands:e})=>e.toggleMark(this.name,t),removeEmptyTextStyle:()=>({tr:t})=>{const{selection:e}=t;return t.doc.nodesBetween(e.from,e.to,(n,r)=>{if(n.isTextblock)return!0;n.marks.filter(s=>s.type===this.type).some(s=>Object.values(s.attrs).some(o=>!!o))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),xT=fe.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;return(e=t.style.backgroundColor)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.backgroundColor?{style:`background-color: ${t.backgroundColor}`}:{}}}}]},addCommands(){return{setBackgroundColor:t=>({chain:e})=>e().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),wT=fe.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;return(e=t.style.color)==null?void 0:e.replace(/['"]+/g,"")},renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}}}}]},addCommands(){return{setColor:t=>({chain:e})=>e().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),vT=fe.create({name:"fontFamily",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontFamily:{default:null,parseHTML:t=>t.style.fontFamily,renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}}}}]},addCommands(){return{setFontFamily:t=>({chain:e})=>e().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run()}}}),kT=fe.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize,renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),ST=fe.create({name:"lineHeight",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{lineHeight:{default:null,parseHTML:t=>t.style.lineHeight,renderHTML:t=>t.lineHeight?{style:`line-height: ${t.lineHeight}`}:{}}}}]},addCommands(){return{setLineHeight:t=>({chain:e})=>e().setMark("textStyle",{lineHeight:t}).run(),unsetLineHeight:()=>({chain:t})=>t().setMark("textStyle",{lineHeight:null}).removeEmptyTextStyle().run()}}}),CT=fe.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(xT.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(wT.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(vT.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(kT.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(ST.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(bT.configure(this.options.textStyle)),t}}),ET=$M,MT=t=>ze({find:/--$/,replace:t??"—"}),AT=t=>ze({find:/\.\.\.$/,replace:t??"…"}),TT=t=>ze({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),NT=t=>ze({find:/"$/,replace:t??"”"}),RT=t=>ze({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),_T=t=>ze({find:/'$/,replace:t??"’"}),OT=t=>ze({find:/<-$/,replace:t??"←"}),DT=t=>ze({find:/->$/,replace:t??"→"}),LT=t=>ze({find:/\(c\)$/,replace:t??"©"}),IT=t=>ze({find:/\(tm\)$/,replace:t??"™"}),jT=t=>ze({find:/\(sm\)$/,replace:t??"℠"}),PT=t=>ze({find:/\(r\)$/,replace:t??"®"}),BT=t=>ze({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),HT=t=>ze({find:/\+\/-$/,replace:t??"±"}),$T=t=>ze({find:/!=$/,replace:t??"≠"}),zT=t=>ze({find:/<<$/,replace:t??"«"}),FT=t=>ze({find:/>>$/,replace:t??"»"}),UT=t=>ze({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),VT=t=>ze({find:/\^2$/,replace:t??"²"}),WT=t=>ze({find:/\^3$/,replace:t??"³"}),qT=t=>ze({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),KT=t=>ze({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),GT=fe.create({name:"typography",addOptions(){return{closeDoubleQuote:"”",closeSingleQuote:"’",copyright:"©",ellipsis:"…",emDash:"—",laquo:"«",leftArrow:"←",multiplication:"×",notEqual:"≠",oneHalf:"½",oneQuarter:"¼",openDoubleQuote:"“",openSingleQuote:"‘",plusMinus:"±",raquo:"»",registeredTrademark:"®",rightArrow:"→",servicemark:"℠",superscriptThree:"³",superscriptTwo:"²",threeQuarters:"¾",trademark:"™"}},addInputRules(){const t=[];return this.options.emDash!==!1&&t.push(MT(this.options.emDash)),this.options.ellipsis!==!1&&t.push(AT(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(TT(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(NT(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(RT(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(_T(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(OT(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(DT(this.options.rightArrow)),this.options.copyright!==!1&&t.push(LT(this.options.copyright)),this.options.trademark!==!1&&t.push(IT(this.options.trademark)),this.options.servicemark!==!1&&t.push(jT(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(PT(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(BT(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(HT(this.options.plusMinus)),this.options.notEqual!==!1&&t.push($T(this.options.notEqual)),this.options.laquo!==!1&&t.push(zT(this.options.laquo)),this.options.raquo!==!1&&t.push(FT(this.options.raquo)),this.options.multiplication!==!1&&t.push(UT(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(VT(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(WT(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(qT(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(KT(this.options.threeQuarters)),t}}),JT=GT,YT=Xb,XT=Zb;const As=Math.min,It=Math.max,ta=Math.round,Wi=Math.floor,yn=t=>({x:t,y:t}),ZT={left:"right",right:"left",bottom:"top",top:"bottom"},QT={start:"end",end:"start"};function sm(t,e,n){return It(t,As(e,n))}function Qo(t,e){return typeof t=="function"?t(e):t}function gr(t){return t.split("-")[0]}function ei(t){return t.split("-")[1]}function b0(t){return t==="x"?"y":"x"}function x0(t){return t==="y"?"height":"width"}const eN=new Set(["top","bottom"]);function jn(t){return eN.has(gr(t))?"y":"x"}function w0(t){return b0(jn(t))}function tN(t,e,n){n===void 0&&(n=!1);const r=ei(t),s=w0(t),o=x0(s);let i=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[o]>e.floating[o]&&(i=na(i)),[i,na(i)]}function nN(t){const e=na(t);return[qu(t),e,qu(e)]}function qu(t){return t.replace(/start|end/g,e=>QT[e])}const om=["left","right"],im=["right","left"],rN=["top","bottom"],sN=["bottom","top"];function oN(t,e,n){switch(t){case"top":case"bottom":return n?e?im:om:e?om:im;case"left":case"right":return e?rN:sN;default:return[]}}function iN(t,e,n,r){const s=ei(t);let o=oN(gr(t),n==="start",r);return s&&(o=o.map(i=>i+"-"+s),e&&(o=o.concat(o.map(qu)))),o}function na(t){return t.replace(/left|right|bottom|top/g,e=>ZT[e])}function lN(t){return{top:0,right:0,bottom:0,left:0,...t}}function aN(t){return typeof t!="number"?lN(t):{top:t,right:t,bottom:t,left:t}}function ra(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function lm(t,e,n){let{reference:r,floating:s}=t;const o=jn(e),i=w0(e),l=x0(i),a=gr(e),c=o==="y",u=r.x+r.width/2-s.width/2,d=r.y+r.height/2-s.height/2,h=r[l]/2-s[l]/2;let f;switch(a){case"top":f={x:u,y:r.y-s.height};break;case"bottom":f={x:u,y:r.y+r.height};break;case"right":f={x:r.x+r.width,y:d};break;case"left":f={x:r.x-s.width,y:d};break;default:f={x:r.x,y:r.y}}switch(ei(e)){case"start":f[i]-=h*(n&&c?-1:1);break;case"end":f[i]+=h*(n&&c?-1:1);break}return f}const cN=async(t,e,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:i}=n,l=o.filter(Boolean),a=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:t,floating:e,strategy:s}),{x:u,y:d}=lm(c,r,a),h=r,f={},p=0;for(let g=0;g<l.length;g++){const{name:y,fn:b}=l[g],{x,y:E,data:S,reset:M}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:s,middlewareData:f,rects:c,platform:i,elements:{reference:t,floating:e}});u=x??u,d=E??d,f={...f,[y]:{...f[y],...S}},M&&p<=50&&(p++,typeof M=="object"&&(M.placement&&(h=M.placement),M.rects&&(c=M.rects===!0?await i.getElementRects({reference:t,floating:e,strategy:s}):M.rects),{x:u,y:d}=lm(c,h,a)),g=-1)}return{x:u,y:d,placement:h,strategy:s,middlewareData:f}};async function fh(t,e){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:i,elements:l,strategy:a}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:f=0}=Qo(e,t),p=aN(f),y=l[h?d==="floating"?"reference":"floating":d],b=ra(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(y)))==null||n?y:y.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:c,rootBoundary:u,strategy:a})),x=d==="floating"?{x:r,y:s,width:i.floating.width,height:i.floating.height}:i.reference,E=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),S=await(o.isElement==null?void 0:o.isElement(E))?await(o.getScale==null?void 0:o.getScale(E))||{x:1,y:1}:{x:1,y:1},M=ra(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:E,strategy:a}):x);return{top:(b.top-M.top+p.top)/S.y,bottom:(M.bottom-b.bottom+p.bottom)/S.y,left:(b.left-M.left+p.left)/S.x,right:(M.right-b.right+p.right)/S.x}}const uN=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:s,middlewareData:o,rects:i,initialPlacement:l,platform:a,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:f="bestFit",fallbackAxisSideDirection:p="none",flipAlignment:g=!0,...y}=Qo(t,e);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const b=gr(s),x=jn(l),E=gr(l)===l,S=await(a.isRTL==null?void 0:a.isRTL(c.floating)),M=h||(E||!g?[na(l)]:nN(l)),w=p!=="none";!h&&w&&M.push(...iN(l,g,p,S));const T=[l,...M],k=await fh(e,y),N=[];let R=((r=o.flip)==null?void 0:r.overflows)||[];if(u&&N.push(k[b]),d){const H=tN(s,i,S);N.push(k[H[0]],k[H[1]])}if(R=[...R,{placement:s,overflows:N}],!N.every(H=>H<=0)){var B,P;const H=(((B=o.flip)==null?void 0:B.index)||0)+1,se=T[H];if(se&&(!(d==="alignment"?x!==jn(se):!1)||R.every(F=>jn(F.placement)===x?F.overflows[0]>0:!0)))return{data:{index:H,overflows:R},reset:{placement:se}};let oe=(P=R.filter(we=>we.overflows[0]<=0).sort((we,F)=>we.overflows[1]-F.overflows[1])[0])==null?void 0:P.placement;if(!oe)switch(f){case"bestFit":{var L;const we=(L=R.filter(F=>{if(w){const le=jn(F.placement);return le===x||le==="y"}return!0}).map(F=>[F.placement,F.overflows.filter(le=>le>0).reduce((le,Se)=>le+Se,0)]).sort((F,le)=>F[1]-le[1])[0])==null?void 0:L[0];we&&(oe=we);break}case"initialPlacement":oe=l;break}if(s!==oe)return{reset:{placement:oe}}}return{}}}},dN=new Set(["left","top"]);async function hN(t,e){const{placement:n,platform:r,elements:s}=t,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),i=gr(n),l=ei(n),a=jn(n)==="y",c=dN.has(i)?-1:1,u=o&&a?-1:1,d=Qo(e,t);let{mainAxis:h,crossAxis:f,alignmentAxis:p}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof p=="number"&&(f=l==="end"?p*-1:p),a?{x:f*u,y:h*c}:{x:h*c,y:f*u}}const fN=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:s,y:o,placement:i,middlewareData:l}=e,a=await hN(e,t);return i===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+a.x,y:o+a.y,data:{...a,placement:i}}}}},pN=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:s}=e,{mainAxis:o=!0,crossAxis:i=!1,limiter:l={fn:y=>{let{x:b,y:x}=y;return{x:b,y:x}}},...a}=Qo(t,e),c={x:n,y:r},u=await fh(e,a),d=jn(gr(s)),h=b0(d);let f=c[h],p=c[d];if(o){const y=h==="y"?"top":"left",b=h==="y"?"bottom":"right",x=f+u[y],E=f-u[b];f=sm(x,f,E)}if(i){const y=d==="y"?"top":"left",b=d==="y"?"bottom":"right",x=p+u[y],E=p-u[b];p=sm(x,p,E)}const g=l.fn({...e,[h]:f,[d]:p});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[h]:o,[d]:i}}}}}},mN=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:s,rects:o,platform:i,elements:l}=e,{apply:a=()=>{},...c}=Qo(t,e),u=await fh(e,c),d=gr(s),h=ei(s),f=jn(s)==="y",{width:p,height:g}=o.floating;let y,b;d==="top"||d==="bottom"?(y=d,b=h===(await(i.isRTL==null?void 0:i.isRTL(l.floating))?"start":"end")?"left":"right"):(b=d,y=h==="end"?"top":"bottom");const x=g-u.top-u.bottom,E=p-u.left-u.right,S=As(g-u[y],x),M=As(p-u[b],E),w=!e.middlewareData.shift;let T=S,k=M;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(k=E),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(T=x),w&&!h){const R=It(u.left,0),B=It(u.right,0),P=It(u.top,0),L=It(u.bottom,0);f?k=p-2*(R!==0||B!==0?R+B:It(u.left,u.right)):T=g-2*(P!==0||L!==0?P+L:It(u.top,u.bottom))}await a({...e,availableWidth:k,availableHeight:T});const N=await i.getDimensions(l.floating);return p!==N.width||g!==N.height?{reset:{rects:!0}}:{}}}};function Ia(){return typeof window<"u"}function Ps(t){return v0(t)?(t.nodeName||"").toLowerCase():"#document"}function Bt(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Sn(t){var e;return(e=(v0(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function v0(t){return Ia()?t instanceof Node||t instanceof Bt(t).Node:!1}function gt(t){return Ia()?t instanceof Element||t instanceof Bt(t).Element:!1}function vn(t){return Ia()?t instanceof HTMLElement||t instanceof Bt(t).HTMLElement:!1}function am(t){return!Ia()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Bt(t).ShadowRoot}const gN=new Set(["inline","contents"]);function ti(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=rn(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!gN.has(s)}const yN=new Set(["table","td","th"]);function bN(t){return yN.has(Ps(t))}const xN=[":popover-open",":modal"];function ja(t){return xN.some(e=>{try{return t.matches(e)}catch{return!1}})}const wN=["transform","translate","scale","rotate","perspective"],vN=["transform","translate","scale","rotate","perspective","filter"],kN=["paint","layout","strict","content"];function ph(t){const e=mh(),n=gt(t)?rn(t):t;return wN.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||vN.some(r=>(n.willChange||"").includes(r))||kN.some(r=>(n.contain||"").includes(r))}function SN(t){let e=yr(t);for(;vn(e)&&!Ts(e);){if(ph(e))return e;if(ja(e))return null;e=yr(e)}return null}function mh(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const CN=new Set(["html","body","#document"]);function Ts(t){return CN.has(Ps(t))}function rn(t){return Bt(t).getComputedStyle(t)}function Pa(t){return gt(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function yr(t){if(Ps(t)==="html")return t;const e=t.assignedSlot||t.parentNode||am(t)&&t.host||Sn(t);return am(e)?e.host:e}function k0(t){const e=yr(t);return Ts(e)?t.ownerDocument?t.ownerDocument.body:t.body:vn(e)&&ti(e)?e:k0(e)}function Io(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=k0(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),i=Bt(s);if(o){const l=Ku(i);return e.concat(i,i.visualViewport||[],ti(s)?s:[],l&&n?Io(l):[])}return e.concat(s,Io(s,[],n))}function Ku(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function S0(t){const e=rn(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=vn(t),o=s?t.offsetWidth:n,i=s?t.offsetHeight:r,l=ta(n)!==o||ta(r)!==i;return l&&(n=o,r=i),{width:n,height:r,$:l}}function gh(t){return gt(t)?t:t.contextElement}function ys(t){const e=gh(t);if(!vn(e))return yn(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=S0(e);let i=(o?ta(n.width):n.width)/r,l=(o?ta(n.height):n.height)/s;return(!i||!Number.isFinite(i))&&(i=1),(!l||!Number.isFinite(l))&&(l=1),{x:i,y:l}}const EN=yn(0);function C0(t){const e=Bt(t);return!mh()||!e.visualViewport?EN:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function MN(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Bt(t)?!1:e}function Jr(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=gh(t);let i=yn(1);e&&(r?gt(r)&&(i=ys(r)):i=ys(t));const l=MN(o,n,r)?C0(o):yn(0);let a=(s.left+l.x)/i.x,c=(s.top+l.y)/i.y,u=s.width/i.x,d=s.height/i.y;if(o){const h=Bt(o),f=r&&gt(r)?Bt(r):r;let p=h,g=Ku(p);for(;g&&r&&f!==p;){const y=ys(g),b=g.getBoundingClientRect(),x=rn(g),E=b.left+(g.clientLeft+parseFloat(x.paddingLeft))*y.x,S=b.top+(g.clientTop+parseFloat(x.paddingTop))*y.y;a*=y.x,c*=y.y,u*=y.x,d*=y.y,a+=E,c+=S,p=Bt(g),g=Ku(p)}}return ra({width:u,height:d,x:a,y:c})}function yh(t,e){const n=Pa(t).scrollLeft;return e?e.left+n:Jr(Sn(t)).left+n}function E0(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=r.left+e.scrollLeft-(n?0:yh(t,r)),o=r.top+e.scrollTop;return{x:s,y:o}}function AN(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",i=Sn(r),l=e?ja(e.floating):!1;if(r===i||l&&o)return n;let a={scrollLeft:0,scrollTop:0},c=yn(1);const u=yn(0),d=vn(r);if((d||!d&&!o)&&((Ps(r)!=="body"||ti(i))&&(a=Pa(r)),vn(r))){const f=Jr(r);c=ys(r),u.x=f.x+r.clientLeft,u.y=f.y+r.clientTop}const h=i&&!d&&!o?E0(i,a,!0):yn(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-a.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-a.scrollTop*c.y+u.y+h.y}}function TN(t){return Array.from(t.getClientRects())}function NN(t){const e=Sn(t),n=Pa(t),r=t.ownerDocument.body,s=It(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=It(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let i=-n.scrollLeft+yh(t);const l=-n.scrollTop;return rn(r).direction==="rtl"&&(i+=It(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:i,y:l}}function RN(t,e){const n=Bt(t),r=Sn(t),s=n.visualViewport;let o=r.clientWidth,i=r.clientHeight,l=0,a=0;if(s){o=s.width,i=s.height;const c=mh();(!c||c&&e==="fixed")&&(l=s.offsetLeft,a=s.offsetTop)}return{width:o,height:i,x:l,y:a}}const _N=new Set(["absolute","fixed"]);function ON(t,e){const n=Jr(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=vn(t)?ys(t):yn(1),i=t.clientWidth*o.x,l=t.clientHeight*o.y,a=s*o.x,c=r*o.y;return{width:i,height:l,x:a,y:c}}function cm(t,e,n){let r;if(e==="viewport")r=RN(t,n);else if(e==="document")r=NN(Sn(t));else if(gt(e))r=ON(e,n);else{const s=C0(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ra(r)}function M0(t,e){const n=yr(t);return n===e||!gt(n)||Ts(n)?!1:rn(n).position==="fixed"||M0(n,e)}function DN(t,e){const n=e.get(t);if(n)return n;let r=Io(t,[],!1).filter(l=>gt(l)&&Ps(l)!=="body"),s=null;const o=rn(t).position==="fixed";let i=o?yr(t):t;for(;gt(i)&&!Ts(i);){const l=rn(i),a=ph(i);!a&&l.position==="fixed"&&(s=null),(o?!a&&!s:!a&&l.position==="static"&&!!s&&_N.has(s.position)||ti(i)&&!a&&M0(t,i))?r=r.filter(u=>u!==i):s=l,i=yr(i)}return e.set(t,r),r}function LN(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const i=[...n==="clippingAncestors"?ja(e)?[]:DN(e,this._c):[].concat(n),r],l=i[0],a=i.reduce((c,u)=>{const d=cm(e,u,s);return c.top=It(d.top,c.top),c.right=As(d.right,c.right),c.bottom=As(d.bottom,c.bottom),c.left=It(d.left,c.left),c},cm(e,l,s));return{width:a.right-a.left,height:a.bottom-a.top,x:a.left,y:a.top}}function IN(t){const{width:e,height:n}=S0(t);return{width:e,height:n}}function jN(t,e,n){const r=vn(e),s=Sn(e),o=n==="fixed",i=Jr(t,!0,o,e);let l={scrollLeft:0,scrollTop:0};const a=yn(0);function c(){a.x=yh(s)}if(r||!r&&!o)if((Ps(e)!=="body"||ti(s))&&(l=Pa(e)),r){const f=Jr(e,!0,o,e);a.x=f.x+e.clientLeft,a.y=f.y+e.clientTop}else s&&c();o&&!r&&s&&c();const u=s&&!r&&!o?E0(s,l):yn(0),d=i.left+l.scrollLeft-a.x-u.x,h=i.top+l.scrollTop-a.y-u.y;return{x:d,y:h,width:i.width,height:i.height}}function Gc(t){return rn(t).position==="static"}function um(t,e){if(!vn(t)||rn(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Sn(t)===n&&(n=n.ownerDocument.body),n}function A0(t,e){const n=Bt(t);if(ja(t))return n;if(!vn(t)){let s=yr(t);for(;s&&!Ts(s);){if(gt(s)&&!Gc(s))return s;s=yr(s)}return n}let r=um(t,e);for(;r&&bN(r)&&Gc(r);)r=um(r,e);return r&&Ts(r)&&Gc(r)&&!ph(r)?n:r||SN(t)||n}const PN=async function(t){const e=this.getOffsetParent||A0,n=this.getDimensions,r=await n(t.floating);return{reference:jN(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function BN(t){return rn(t).direction==="rtl"}const HN={convertOffsetParentRelativeRectToViewportRelativeRect:AN,getDocumentElement:Sn,getClippingRect:LN,getOffsetParent:A0,getElementRects:PN,getClientRects:TN,getDimensions:IN,getScale:ys,isElement:gt,isRTL:BN};function T0(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function $N(t,e){let n=null,r;const s=Sn(t);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function i(l,a){l===void 0&&(l=!1),a===void 0&&(a=1),o();const c=t.getBoundingClientRect(),{left:u,top:d,width:h,height:f}=c;if(l||e(),!h||!f)return;const p=Wi(d),g=Wi(s.clientWidth-(u+h)),y=Wi(s.clientHeight-(d+f)),b=Wi(u),E={rootMargin:-p+"px "+-g+"px "+-y+"px "+-b+"px",threshold:It(0,As(1,a))||1};let S=!0;function M(w){const T=w[0].intersectionRatio;if(T!==a){if(!S)return i();T?i(!1,T):r=setTimeout(()=>{i(!1,1e-7)},1e3)}T===1&&!T0(c,t.getBoundingClientRect())&&i(),S=!1}try{n=new IntersectionObserver(M,{...E,root:s.ownerDocument})}catch{n=new IntersectionObserver(M,E)}n.observe(t)}return i(!0),o}function Bs(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:a=!1}=r,c=gh(t),u=s||o?[...c?Io(c):[],...Io(e)]:[];u.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const d=c&&l?$N(c,n):null;let h=-1,f=null;i&&(f=new ResizeObserver(b=>{let[x]=b;x&&x.target===c&&f&&(f.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var E;(E=f)==null||E.observe(e)})),n()}),c&&!a&&f.observe(c),f.observe(e));let p,g=a?Jr(t):null;a&&y();function y(){const b=Jr(t);g&&!T0(g,b)&&n(),g=b,p=requestAnimationFrame(y)}return n(),()=>{var b;u.forEach(x=>{s&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),d==null||d(),(b=f)==null||b.disconnect(),f=null,a&&cancelAnimationFrame(p)}}const N0=fN,R0=pN,_0=uN,O0=mN,bh=(t,e,n)=>{const r=new Map,s={platform:HN,...n},o={...s.platform,_c:r};return cN(t,e,{...s,platform:o})},en=()=>new Map,Gu=t=>{const e=en();return t.forEach((n,r)=>{e.set(r,n)}),e},Un=(t,e,n)=>{let r=t.get(e);return r===void 0&&t.set(e,r=n()),r},zN=(t,e)=>{const n=[];for(const[r,s]of t)n.push(e(s,r));return n},FN=(t,e)=>{for(const[n,r]of t)if(e(r,n))return!0;return!1},Yr=()=>new Set,Jc=t=>t[t.length-1],UN=(t,e)=>{for(let n=0;n<e.length;n++)t.push(e[n])},Xr=Array.from,VN=(t,e)=>{for(let n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},Ju=Array.isArray;class D0{constructor(){this._observers=en()}on(e,n){return Un(this._observers,e,Yr).add(n),n}once(e,n){const r=(...s)=>{this.off(e,r),n(...s)};this.on(e,r)}off(e,n){const r=this._observers.get(e);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(e))}emit(e,n){return Xr((this._observers.get(e)||en()).values()).forEach(r=>r(...n))}destroy(){this._observers=en()}}const zn=Math.floor,ll=Math.abs,Ns=(t,e)=>t<e?t:e,br=(t,e)=>t>e?t:e,L0=t=>t!==0?t<0:1/t<0,dm=1,hm=2,Yc=4,Xc=8,jo=32,Hn=64,kt=128,WN=1<<29,Ba=31,Yu=63,zr=127,qN=2147483647,I0=Number.MAX_SAFE_INTEGER,KN=Number.isInteger||(t=>typeof t=="number"&&isFinite(t)&&zn(t)===t),GN=String.fromCharCode,JN=t=>t.toLowerCase(),YN=/^\s*/g,XN=t=>t.replace(YN,""),ZN=/([A-Z])/g,fm=(t,e)=>XN(t.replace(ZN,n=>`${e}${JN(n)}`)),QN=t=>{const e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=e.codePointAt(s);return r},Po=typeof TextEncoder<"u"?new TextEncoder:null,eR=t=>Po.encode(t),tR=Po?eR:QN;let yo=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});yo&&yo.decode(new Uint8Array).length===1&&(yo=null);class ni{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const ri=()=>new ni,nR=t=>{const e=ri();return t(e),Qt(e)},rR=t=>{let e=t.cpos;for(let n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},Qt=t=>{const e=new Uint8Array(rR(t));let n=0;for(let r=0;r<t.bufs.length;r++){const s=t.bufs[r];e.set(s,n),n+=s.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},sR=(t,e)=>{const n=t.cbuf.length;n-t.cpos<e&&(t.bufs.push(new Uint8Array(t.cbuf.buffer,0,t.cpos)),t.cbuf=new Uint8Array(br(n,e)*2),t.cpos=0)},et=(t,e)=>{const n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(n*2),t.cpos=0),t.cbuf[t.cpos++]=e},Xu=et,ge=(t,e)=>{for(;e>zr;)et(t,kt|zr&e),e=zn(e/128);et(t,zr&e)},xh=(t,e)=>{const n=L0(e);for(n&&(e=-e),et(t,(e>Yu?kt:0)|(n?Hn:0)|Yu&e),e=zn(e/64);e>0;)et(t,(e>zr?kt:0)|zr&e),e=zn(e/128)},Zu=new Uint8Array(3e4),oR=Zu.length/3,iR=(t,e)=>{if(e.length<oR){const n=Po.encodeInto(e,Zu).written||0;ge(t,n);for(let r=0;r<n;r++)et(t,Zu[r])}else Lt(t,tR(e))},lR=(t,e)=>{const n=unescape(encodeURIComponent(e)),r=n.length;ge(t,r);for(let s=0;s<r;s++)et(t,n.codePointAt(s))},bs=Po&&Po.encodeInto?iR:lR,Ha=(t,e)=>{const n=t.cbuf.length,r=t.cpos,s=Ns(n-r,e.length),o=e.length-s;t.cbuf.set(e.subarray(0,s),r),t.cpos+=s,o>0&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(br(n*2,o)),t.cbuf.set(e.subarray(s)),t.cpos=o)},Lt=(t,e)=>{ge(t,e.byteLength),Ha(t,e)},wh=(t,e)=>{sR(t,e);const n=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,n},aR=(t,e)=>wh(t,4).setFloat32(0,e,!1),cR=(t,e)=>wh(t,8).setFloat64(0,e,!1),uR=(t,e)=>wh(t,8).setBigInt64(0,e,!1),pm=new DataView(new ArrayBuffer(4)),dR=t=>(pm.setFloat32(0,t),pm.getFloat32(0)===t),Rs=(t,e)=>{switch(typeof e){case"string":et(t,119),bs(t,e);break;case"number":KN(e)&&ll(e)<=qN?(et(t,125),xh(t,e)):dR(e)?(et(t,124),aR(t,e)):(et(t,123),cR(t,e));break;case"bigint":et(t,122),uR(t,e);break;case"object":if(e===null)et(t,126);else if(Ju(e)){et(t,117),ge(t,e.length);for(let n=0;n<e.length;n++)Rs(t,e[n])}else if(e instanceof Uint8Array)et(t,116),Lt(t,e);else{et(t,118);const n=Object.keys(e);ge(t,n.length);for(let r=0;r<n.length;r++){const s=n[r];bs(t,s),Rs(t,e[s])}}break;case"boolean":et(t,e?120:121);break;default:et(t,127)}};class mm extends ni{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ge(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const gm=t=>{t.count>0&&(xh(t.encoder,t.count===1?t.s:-t.s),t.count>1&&ge(t.encoder,t.count-2))};class al{constructor(){this.encoder=new ni,this.s=0,this.count=0}write(e){this.s===e?this.count++:(gm(this),this.count=1,this.s=e)}toUint8Array(){return gm(this),Qt(this.encoder)}}const ym=t=>{if(t.count>0){const e=t.diff*2+(t.count===1?0:1);xh(t.encoder,e),t.count>1&&ge(t.encoder,t.count-2)}};class Zc{constructor(){this.encoder=new ni,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(ym(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return ym(this),Qt(this.encoder)}}class hR{constructor(){this.sarr=[],this.s="",this.lensE=new al}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new ni;return this.sarr.push(this.s),this.s="",bs(e,this.sarr.join("")),Ha(e,this.lensE.toUint8Array()),Qt(e)}}const xr=t=>new Error(t),tn=()=>{throw xr("Method unimplemented")},Ot=()=>{throw xr("Unexpected case")},j0=xr("Unexpected end of array"),P0=xr("Integer out of Range");class $a{constructor(e){this.arr=e,this.pos=0}}const vh=t=>new $a(t),fR=t=>t.pos!==t.arr.length,pR=(t,e)=>{const n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e);return t.pos+=e,n},Ft=t=>pR(t,Le(t)),Bo=t=>t.arr[t.pos++],Le=t=>{let e=0,n=1;const r=t.arr.length;for(;t.pos<r;){const s=t.arr[t.pos++];if(e=e+(s&zr)*n,n*=128,s<kt)return e;if(e>I0)throw P0}throw j0},kh=t=>{let e=t.arr[t.pos++],n=e&Yu,r=64;const s=(e&Hn)>0?-1:1;if((e&kt)===0)return s*n;const o=t.arr.length;for(;t.pos<o;){if(e=t.arr[t.pos++],n=n+(e&zr)*r,r*=128,e<kt)return s*n;if(n>I0)throw P0}throw j0},mR=t=>{let e=Le(t);if(e===0)return"";{let n=String.fromCodePoint(Bo(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(Bo(t));else for(;e>0;){const r=e<1e4?e:1e4,s=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(n))}},gR=t=>yo.decode(Ft(t)),Qu=yo?gR:mR,Sh=(t,e)=>{const n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},yR=t=>Sh(t,4).getFloat32(0,!1),bR=t=>Sh(t,8).getFloat64(0,!1),xR=t=>Sh(t,8).getBigInt64(0,!1),wR=[t=>{},t=>null,kh,yR,bR,xR,t=>!1,t=>!0,Qu,t=>{const e=Le(t),n={};for(let r=0;r<e;r++){const s=Qu(t);n[s]=sa(t)}return n},t=>{const e=Le(t),n=[];for(let r=0;r<e;r++)n.push(sa(t));return n},Ft],sa=t=>wR[127-Bo(t)](t);class bm extends $a{constructor(e,n){super(e),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),fR(this)?this.count=Le(this)+1:this.count=-1),this.count--,this.s}}class cl extends $a{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=kh(this);const e=L0(this.s);this.count=1,e&&(this.s=-this.s,this.count=Le(this)+2)}return this.count--,this.s}}class Qc extends $a{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=kh(this),n=e&1;this.diff=zn(e/2),this.count=1,n&&(this.count=Le(this)+2)}return this.s+=this.diff,this.count--,this.s}}class vR{constructor(e){this.decoder=new cl(e),this.str=Qu(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),n=this.str.slice(this.spos,e);return this.spos=e,n}}const kR=crypto.getRandomValues.bind(crypto),SR=Math.random,B0=()=>kR(new Uint32Array(1))[0],CR=t=>t[zn(SR()*t.length)],ER="10000000-1000-4000-8000"+-1e11,MR=()=>ER.replace(/[018]/g,t=>(t^B0()&15>>t/4).toString(16)),AR=Date.now,xm=t=>new Promise(t);Promise.all.bind(Promise);const wm=t=>t===void 0?null:t;class TR{constructor(){this.map=new Map}setItem(e,n){this.map.set(e,n)}getItem(e){return this.map.get(e)}}let H0=new TR,NR=!0;try{typeof localStorage<"u"&&localStorage&&(H0=localStorage,NR=!1)}catch{}const RR=H0,_R=Object.assign,$0=Object.keys,OR=(t,e)=>{for(const n in t)e(t[n],n)},vm=t=>$0(t).length,DR=t=>{for(const e in t)return!1;return!0},z0=(t,e)=>{for(const n in t)if(!e(t[n],n))return!1;return!0},LR=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),IR=(t,e)=>t===e||vm(t)===vm(e)&&z0(t,(n,r)=>(n!==void 0||LR(e,r))&&e[r]===n),jR=Object.freeze,F0=t=>{for(const e in t){const n=t[e];(typeof n=="object"||typeof n=="function")&&F0(t[e])}return jR(t)},Ch=(t,e,n=0)=>{try{for(;n<t.length;n++)t[n](...e)}finally{n<t.length&&Ch(t,e,n+1)}},PR=(t,e)=>e.includes(t),_s=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",U0=typeof window<"u"&&typeof document<"u"&&!_s;let fn;const BR=()=>{if(fn===void 0)if(_s){fn=en();const t=process.argv;let e=null;for(let n=0;n<t.length;n++){const r=t[n];r[0]==="-"?(e!==null&&fn.set(e,""),e=r):e!==null&&(fn.set(e,r),e=null)}e!==null&&fn.set(e,"")}else typeof location=="object"?(fn=en(),(location.search||"?").slice(1).split("&").forEach(t=>{if(t.length!==0){const[e,n]=t.split("=");fn.set(`--${fm(e,"-")}`,n),fn.set(`-${fm(e,"-")}`,n)}})):fn=en();return fn},ed=t=>BR().has(t),oa=t=>wm(_s?process.env[t.toUpperCase().replaceAll("-","_")]:RR.getItem(t)),V0=t=>ed("--"+t)||oa(t)!==null;V0("production");const HR=_s&&PR(process.env.FORCE_COLOR,["true","1","2"]),$R=HR||!ed("--no-colors")&&!V0("no-color")&&(!_s||process.stdout.isTTY)&&(!_s||ed("--color")||oa("COLORTERM")!==null||(oa("TERM")||"").includes("color")),zR=t=>{let e="";for(let n=0;n<t.byteLength;n++)e+=GN(t[n]);return btoa(e)},FR=t=>Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64"),UR=U0?zR:FR,VR=t=>nR(e=>Rs(e,t));class WR{constructor(e,n){this.left=e,this.right=n}}const Rn=(t,e)=>new WR(t,e),qR=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const KR=t=>zN(t,(e,n)=>`${n}:${e};`).join(""),GR=t=>class{constructor(n){this._=n}destroy(){t(this._)}},JR=GR(clearTimeout),W0=(t,e)=>new JR(setTimeout(e,t)),Vn=Symbol,q0=Vn(),K0=Vn(),YR=Vn(),XR=Vn(),ZR=Vn(),G0=Vn(),QR=Vn(),Eh=Vn(),e_=Vn(),t_=t=>{var s;t.length===1&&((s=t[0])==null?void 0:s.constructor)===Function&&(t=t[0]());const e=[],n=[];let r=0;for(;r<t.length;r++){const o=t[r];if(o===void 0)break;if(o.constructor===String||o.constructor===Number)e.push(o);else if(o.constructor===Object)break}for(r>0&&n.push(e.join(""));r<t.length;r++){const o=t[r];o instanceof Symbol||n.push(o)}return n},n_={[q0]:Rn("font-weight","bold"),[K0]:Rn("font-weight","normal"),[YR]:Rn("color","blue"),[ZR]:Rn("color","green"),[XR]:Rn("color","grey"),[G0]:Rn("color","red"),[QR]:Rn("color","purple"),[Eh]:Rn("color","orange"),[e_]:Rn("color","black")},r_=t=>{var i;t.length===1&&((i=t[0])==null?void 0:i.constructor)===Function&&(t=t[0]());const e=[],n=[],r=en();let s=[],o=0;for(;o<t.length;o++){const l=t[o],a=n_[l];if(a!==void 0)r.set(a.left,a.right);else{if(l===void 0)break;if(l.constructor===String||l.constructor===Number){const c=KR(r);o>0||c.length>0?(e.push("%c"+l),n.push(c)):e.push(l)}else break}}for(o>0&&(s=n,s.unshift(e.join("")));o<t.length;o++){const l=t[o];l instanceof Symbol||s.push(l)}return s},J0=$R?r_:t_,s_=(...t)=>{console.log(...J0(t)),X0.forEach(e=>e.print(t))},Y0=(...t)=>{console.warn(...J0(t)),t.unshift(Eh),X0.forEach(e=>e.print(t))},X0=Yr(),Z0=t=>({[Symbol.iterator](){return this},next:t}),o_=(t,e)=>Z0(()=>{let n;do n=t.next();while(!n.done&&!e(n.value));return n}),eu=(t,e)=>Z0(()=>{const{done:n,value:r}=t.next();return{done:n,value:n?void 0:e(r)}});class Mh{constructor(e,n){this.clock=e,this.len=n}}class Hs{constructor(){this.clients=new Map}}const wr=(t,e,n)=>e.clients.forEach((r,s)=>{const o=t.doc.store.clients.get(s);if(o!=null){const i=o[o.length-1],l=i.id.clock+i.length;for(let a=0,c=r[a];a<r.length&&c.clock<l;c=r[++a])ix(t,o,c.clock,c.len,n)}}),i_=(t,e)=>{let n=0,r=t.length-1;for(;n<=r;){const s=zn((n+r)/2),o=t[s],i=o.clock;if(i<=e){if(e<i+o.len)return s;n=s+1}else r=s-1}return null},$s=(t,e)=>{const n=t.clients.get(e.client);return n!==void 0&&i_(n,e.clock)!==null},Ah=t=>{t.clients.forEach(e=>{e.sort((s,o)=>s.clock-o.clock);let n,r;for(n=1,r=1;n<e.length;n++){const s=e[r-1],o=e[n];s.clock+s.len>=o.clock?s.len=br(s.len,o.clock+o.len-s.clock):(r<n&&(e[r]=o),r++)}e.length=r})},td=t=>{const e=new Hs;for(let n=0;n<t.length;n++)t[n].clients.forEach((r,s)=>{if(!e.clients.has(s)){const o=r.slice();for(let i=n+1;i<t.length;i++)UN(o,t[i].clients.get(s)||[]);e.clients.set(s,o)}});return Ah(e),e},Ho=(t,e,n,r)=>{Un(t.clients,e,()=>[]).push(new Mh(n,r))},Q0=()=>new Hs,l_=t=>{const e=Q0();return t.clients.forEach((n,r)=>{const s=[];for(let o=0;o<n.length;o++){const i=n[o];if(i.deleted){const l=i.id.clock;let a=i.length;if(o+1<n.length)for(let c=n[o+1];o+1<n.length&&c.deleted;c=n[++o+1])a+=c.length;s.push(new Mh(l,a))}}s.length>0&&e.clients.set(r,s)}),e},Th=(t,e)=>{ge(t.restEncoder,e.clients.size),Xr(e.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{t.resetDsCurVal(),ge(t.restEncoder,n);const s=r.length;ge(t.restEncoder,s);for(let o=0;o<s;o++){const i=r[o];t.writeDsClock(i.clock),t.writeDsLen(i.len)}})},a_=t=>{const e=new Hs,n=Le(t.restDecoder);for(let r=0;r<n;r++){t.resetDsCurVal();const s=Le(t.restDecoder),o=Le(t.restDecoder);if(o>0){const i=Un(e.clients,s,()=>[]);for(let l=0;l<o;l++)i.push(new Mh(t.readDsClock(),t.readDsLen()))}}return e},km=(t,e,n)=>{const r=new Hs,s=Le(t.restDecoder);for(let o=0;o<s;o++){t.resetDsCurVal();const i=Le(t.restDecoder),l=Le(t.restDecoder),a=n.clients.get(i)||[],c=We(n,i);for(let u=0;u<l;u++){const d=t.readDsClock(),h=d+t.readDsLen();if(d<c){c<h&&Ho(r,i,c,h-c);let f=sn(a,d),p=a[f];for(!p.deleted&&p.id.clock<d&&(a.splice(f+1,0,ha(e,p,d-p.id.clock)),f++);f<a.length&&(p=a[f++],p.id.clock<h);)p.deleted||(h<p.id.clock+p.length&&a.splice(f,0,ha(e,p,h-p.id.clock)),p.delete(e))}else Ho(r,i,d,h-d)}}if(r.clients.size>0){const o=new za;return ge(o.restEncoder,0),Th(o,r),o.toUint8Array()}return null},ex=B0;class ns extends D0{constructor({guid:e=MR(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:o=null,autoLoad:i=!1,shouldLoad:l=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ex(),this.guid=e,this.collectionid=n,this.share=new Map,this.store=new sx,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=l,this.autoLoad=i,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=xm(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const a=()=>xm(c=>{const u=d=>{(d===void 0||d===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=a()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=a()}load(){const e=this._item;e!==null&&!this.shouldLoad&&Me(e.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Xr(this.subdocs).map(e=>e.guid))}transact(e,n=null){return Me(this,e,n)}get(e,n=st){const r=Un(this.share,e,()=>{const o=new n;return o._integrate(this,null),o}),s=r.constructor;if(n!==st&&s!==n)if(s===st){const o=new n;o._map=r._map,r._map.forEach(i=>{for(;i!==null;i=i.left)i.parent=o}),o._start=r._start;for(let i=o._start;i!==null;i=i.right)i.parent=o;return o._length=r._length,this.share.set(e,o),o._integrate(this,null),o}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,vs)}getText(e=""){return this.get(e,vr)}getMap(e=""){return this.get(e,Os)}getXmlElement(e=""){return this.get(e,yt)}getXmlFragment(e=""){return this.get(e,Zr)}toJSON(){const e={};return this.share.forEach((n,r)=>{e[r]=n.toJSON()}),e}destroy(){this.isDestroyed=!0,Xr(this.subdocs).forEach(n=>n.destroy());const e=this._item;if(e!==null){this._item=null;const n=e.content;n.doc=new ns({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=e,Me(e.parent.doc,r=>{const s=n.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class c_{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Le(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Le(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class ia extends c_{constructor(e){super(e),this.keys=[],Le(e),this.keyClockDecoder=new Qc(Ft(e)),this.clientDecoder=new cl(Ft(e)),this.leftClockDecoder=new Qc(Ft(e)),this.rightClockDecoder=new Qc(Ft(e)),this.infoDecoder=new bm(Ft(e),Bo),this.stringDecoder=new vR(Ft(e)),this.parentInfoDecoder=new bm(Ft(e),Bo),this.typeRefDecoder=new cl(Ft(e)),this.lenDecoder=new cl(Ft(e))}readLeftID(){return new xs(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new xs(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return sa(this.restDecoder)}readBuf(){return Ft(this.restDecoder)}readJSON(){return sa(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const n=this.stringDecoder.read();return this.keys.push(n),n}}}class u_{constructor(){this.restEncoder=ri()}toUint8Array(){return Qt(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ge(this.restEncoder,e)}writeDsLen(e){ge(this.restEncoder,e)}}class d_ extends u_{writeLeftID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeRightID(e){ge(this.restEncoder,e.client),ge(this.restEncoder,e.clock)}writeClient(e){ge(this.restEncoder,e)}writeInfo(e){Xu(this.restEncoder,e)}writeString(e){bs(this.restEncoder,e)}writeParentInfo(e){ge(this.restEncoder,e?1:0)}writeTypeRef(e){ge(this.restEncoder,e)}writeLen(e){ge(this.restEncoder,e)}writeAny(e){Rs(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){bs(this.restEncoder,JSON.stringify(e))}writeKey(e){bs(this.restEncoder,e)}}class h_{constructor(){this.restEncoder=ri(),this.dsCurrVal=0}toUint8Array(){return Qt(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const n=e-this.dsCurrVal;this.dsCurrVal=e,ge(this.restEncoder,n)}writeDsLen(e){e===0&&Ot(),ge(this.restEncoder,e-1),this.dsCurrVal+=e}}class za extends h_{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Zc,this.clientEncoder=new al,this.leftClockEncoder=new Zc,this.rightClockEncoder=new Zc,this.infoEncoder=new mm(Xu),this.stringEncoder=new hR,this.parentInfoEncoder=new mm(Xu),this.typeRefEncoder=new al,this.lenEncoder=new al}toUint8Array(){const e=ri();return ge(e,0),Lt(e,this.keyClockEncoder.toUint8Array()),Lt(e,this.clientEncoder.toUint8Array()),Lt(e,this.leftClockEncoder.toUint8Array()),Lt(e,this.rightClockEncoder.toUint8Array()),Lt(e,Qt(this.infoEncoder)),Lt(e,this.stringEncoder.toUint8Array()),Lt(e,Qt(this.parentInfoEncoder)),Lt(e,this.typeRefEncoder.toUint8Array()),Lt(e,this.lenEncoder.toUint8Array()),Ha(e,Qt(this.restEncoder)),Qt(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Rs(this.restEncoder,e)}writeBuf(e){Lt(this.restEncoder,e)}writeJSON(e){Rs(this.restEncoder,e)}writeKey(e){const n=this.keyMap.get(e);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(n)}}const f_=(t,e,n,r)=>{r=br(r,e[0].id.clock);const s=sn(e,r);ge(t.restEncoder,e.length-s),t.writeClient(n),ge(t.restEncoder,r);const o=e[s];o.write(t,r-o.id.clock);for(let i=s+1;i<e.length;i++)e[i].write(t,0)},tx=(t,e,n)=>{const r=new Map;n.forEach((s,o)=>{We(e,o)>s&&r.set(o,s)}),Fa(e).forEach((s,o)=>{n.has(o)||r.set(o,0)}),ge(t.restEncoder,r.size),Xr(r.entries()).sort((s,o)=>o[0]-s[0]).forEach(([s,o])=>{f_(t,e.clients.get(s),s,o)})},p_=(t,e)=>{const n=en(),r=Le(t.restDecoder);for(let s=0;s<r;s++){const o=Le(t.restDecoder),i=new Array(o),l=t.readClient();let a=Le(t.restDecoder);n.set(l,{i:0,refs:i});for(let c=0;c<o;c++){const u=t.readInfo();switch(Ba&u){case 0:{const d=t.readLen();i[c]=new Wt(he(l,a),d),a+=d;break}case 10:{const d=Le(t.restDecoder);i[c]=new Xt(he(l,a),d),a+=d;break}default:{const d=(u&(Hn|kt))===0,h=new Ee(he(l,a),null,(u&kt)===kt?t.readLeftID():null,null,(u&Hn)===Hn?t.readRightID():null,d?t.readParentInfo()?e.get(t.readString()):t.readLeftID():null,d&&(u&jo)===jo?t.readString():null,Tx(t,u));i[c]=h,a+=h.length}}}}return n},m_=(t,e,n)=>{const r=[];let s=Xr(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;const o=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f};let i=o();if(i===null)return null;const l=new sx,a=new Map,c=(f,p)=>{const g=a.get(f);(g==null||g>p)&&a.set(f,p)};let u=i.refs[i.i++];const d=new Map,h=()=>{for(const f of r){const p=f.id.client,g=n.get(p);g?(g.i--,l.clients.set(p,g.refs.slice(g.i)),n.delete(p),g.i=0,g.refs=[]):l.clients.set(p,[f]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==Xt){const p=Un(d,u.id.client,()=>We(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),h();else{const g=u.getMissing(t,e);if(g!==null){r.push(u);const y=n.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,We(e,g)),h();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(t,p),d.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(i!==null&&i.i<i.refs.length)u=i.refs[i.i++];else{if(i=o(),i===null)break;u=i.refs[i.i++]}}if(l.clients.size>0){const f=new za;return tx(f,l,new Map),ge(f.restEncoder,0),{missing:a,update:f.toUint8Array()}}return null},g_=(t,e)=>tx(t,e.doc.store,e.beforeState),y_=(t,e,n,r=new ia(t))=>Me(e,s=>{s.local=!1;let o=!1;const i=s.doc,l=i.store,a=p_(r,i),c=m_(s,l,a),u=l.pendingStructs;if(u){for(const[h,f]of u.missing)if(f<We(l,h)){o=!0;break}if(c){for(const[h,f]of c.missing){const p=u.missing.get(h);(p==null||p>f)&&u.missing.set(h,f)}u.update=_m([u.update,c.update])}}else l.pendingStructs=c;const d=km(r,s,l);if(l.pendingDs){const h=new ia(vh(l.pendingDs));Le(h.restDecoder);const f=km(h,s,l);d&&f?l.pendingDs=_m([d,f]):l.pendingDs=d||f}else l.pendingDs=d;if(o){const h=l.pendingStructs.update;l.pendingStructs=null,nd(s.doc,h)}},n,!1),nd=(t,e,n,r=ia)=>{const s=vh(e);y_(s,t,n,new r(s))};class b_{constructor(){this.l=[]}}const Sm=()=>new b_,Cm=(t,e)=>t.l.push(e),Em=(t,e)=>{const n=t.l,r=n.length;t.l=n.filter(s=>e!==s),r===t.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},nx=(t,e,n)=>Ch(t.l,[e,n]);class xs{constructor(e,n){this.client=e,this.clock=n}}const qi=(t,e)=>t===e||t!==null&&e!==null&&t.client===e.client&&t.clock===e.clock,he=(t,e)=>new xs(t,e),$o=t=>{for(const[e,n]of t.doc.share.entries())if(n===t)return e;throw Ot()},zo=(t,e)=>{for(;e!==null;){if(e.parent===t)return!0;e=e.parent._item}return!1};class la{constructor(e,n,r,s=0){this.type=e,this.tname=n,this.item=r,this.assoc=s}}class x_{constructor(e,n,r=0){this.type=e,this.index=n,this.assoc=r}}const w_=(t,e,n=0)=>new x_(t,e,n),Ki=(t,e,n)=>{let r=null,s=null;return t._item===null?s=$o(t):r=he(t._item.id.client,t._item.id.clock),new la(r,s,e,n)},tu=(t,e,n=0)=>{let r=t._start;if(n<0){if(e===0)return Ki(t,null,n);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Ki(t,he(r.id.client,r.id.clock+e),n);e-=r.length}if(r.right===null&&n<0)return Ki(t,r.lastId,n);r=r.right}return Ki(t,null,n)},v_=(t,e)=>{const n=ws(t,e),r=e.clock-n.id.clock;return{item:n,diff:r}},k_=(t,e,n=!0)=>{const r=e.store,s=t.item,o=t.type,i=t.tname,l=t.assoc;let a=null,c=0;if(s!==null){if(We(r,s.client)<=s.clock)return null;const u=n?id(r,s):v_(r,s),d=u.item;if(!(d instanceof Ee))return null;if(a=d.parent,a._item===null||!a._item.deleted){c=d.deleted||!d.countable?0:u.diff+(l>=0?0:1);let h=d.left;for(;h!==null;)!h.deleted&&h.countable&&(c+=h.length),h=h.left}}else{if(i!==null)a=e.get(i);else if(o!==null){if(We(r,o.client)<=o.clock)return null;const{item:u}=n?id(r,o):{item:ws(r,o)};if(u instanceof Ee&&u.content instanceof cn)a=u.content.type;else return null}else throw Ot();l>=0?c=a._length:c=0}return w_(a,c,t.assoc)};class Nh{constructor(e,n){this.ds=e,this.sv=n}}const rx=(t,e)=>new Nh(t,e),nu=t=>rx(l_(t.store),Fa(t.store)),_r=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&(e.sv.get(t.id.client)||0)>t.id.clock&&!$s(e.ds,t.id),rd=(t,e)=>{const n=Un(t.meta,rd,Yr),r=t.doc.store;n.has(e)||(e.sv.forEach((s,o)=>{s<We(r,o)&&Tt(t,he(o,s))}),wr(t,e.ds,s=>{}),n.add(e))};class sx{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Fa=t=>{const e=new Map;return t.clients.forEach((n,r)=>{const s=n[n.length-1];e.set(r,s.id.clock+s.length)}),e},We=(t,e)=>{const n=t.clients.get(e);if(n===void 0)return 0;const r=n[n.length-1];return r.id.clock+r.length},ox=(t,e)=>{let n=t.clients.get(e.id.client);if(n===void 0)n=[],t.clients.set(e.id.client,n);else{const r=n[n.length-1];if(r.id.clock+r.length!==e.id.clock)throw Ot()}n.push(e)},sn=(t,e)=>{let n=0,r=t.length-1,s=t[r],o=s.id.clock;if(o===e)return r;let i=zn(e/(o+s.length-1)*r);for(;n<=r;){if(s=t[i],o=s.id.clock,o<=e){if(e<o+s.length)return i;n=i+1}else r=i-1;i=zn((n+r)/2)}throw Ot()},S_=(t,e)=>{const n=t.clients.get(e.client);return n[sn(n,e.clock)]},ws=S_,sd=(t,e,n)=>{const r=sn(e,n),s=e[r];return s.id.clock<n&&s instanceof Ee?(e.splice(r+1,0,ha(t,s,n-s.id.clock)),r+1):r},Tt=(t,e)=>{const n=t.doc.store.clients.get(e.client);return n[sd(t,n,e.clock)]},Mm=(t,e,n)=>{const r=e.clients.get(n.client),s=sn(r,n.clock),o=r[s];return n.clock!==o.id.clock+o.length-1&&o.constructor!==Wt&&r.splice(s+1,0,ha(t,o,n.clock-o.id.clock+1)),o},C_=(t,e,n)=>{const r=t.clients.get(e.id.client);r[sn(r,e.id.clock)]=n},ix=(t,e,n,r,s)=>{if(r===0)return;const o=n+r;let i=sd(t,e,n),l;do l=e[i++],o<l.id.clock+l.length&&sd(t,e,o),s(l);while(i<e.length&&e[i].id.clock<o)};class E_{constructor(e,n,r){this.doc=e,this.deleteSet=new Hs,this.beforeState=Fa(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const Am=(t,e)=>e.deleteSet.clients.size===0&&!FN(e.afterState,(n,r)=>e.beforeState.get(r)!==n)?!1:(Ah(e.deleteSet),g_(t,e),Th(t,e.deleteSet),!0),Tm=(t,e,n)=>{const r=e._item;(r===null||r.id.clock<(t.beforeState.get(r.id.client)||0)&&!r.deleted)&&Un(t.changed,e,Yr).add(n)},ul=(t,e)=>{let n=t[e],r=t[e-1],s=e;for(;s>0;n=r,r=t[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof Ee&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}const o=e-s;return o&&t.splice(e+1-o,o),o},M_=(t,e,n)=>{for(const[r,s]of t.clients.entries()){const o=e.clients.get(r);for(let i=s.length-1;i>=0;i--){const l=s[i],a=l.clock+l.len;for(let c=sn(o,l.clock),u=o[c];c<o.length&&u.id.clock<a;u=o[++c]){const d=o[c];if(l.clock+l.len<=d.id.clock)break;d instanceof Ee&&d.deleted&&!d.keep&&n(d)&&d.gc(e,!1)}}}},A_=(t,e)=>{t.clients.forEach((n,r)=>{const s=e.clients.get(r);for(let o=n.length-1;o>=0;o--){const i=n[o],l=Ns(s.length-1,1+sn(s,i.clock+i.len-1));for(let a=l,c=s[a];a>0&&c.id.clock>=i.clock;c=s[a])a-=1+ul(s,a)}})},lx=(t,e)=>{if(e<t.length){const n=t[e],r=n.doc,s=r.store,o=n.deleteSet,i=n._mergeStructs;try{Ah(o),n.afterState=Fa(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const l=[];n.changed.forEach((a,c)=>l.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(n,a)})),l.push(()=>{n.changedParentTypes.forEach((a,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(a=a.filter(u=>u.target._item===null||!u.target._item.deleted),a.forEach(u=>{u.currentTarget=c,u._path=null}),a.sort((u,d)=>u.path.length-d.path.length),nx(c._dEH,a,n))})}),l.push(()=>r.emit("afterTransaction",[n,r])),Ch(l,[]),n._needFormattingCleanup&&K_(n)}finally{r.gc&&M_(o,s,r.gcFilter),A_(o,s),n.afterState.forEach((u,d)=>{const h=n.beforeState.get(d)||0;if(h!==u){const f=s.clients.get(d),p=br(sn(f,h),1);for(let g=f.length-1;g>=p;)g-=1+ul(f,g)}});for(let u=i.length-1;u>=0;u--){const{client:d,clock:h}=i[u].id,f=s.clients.get(d),p=sn(f,h);p+1<f.length&&ul(f,p+1)>1||p>0&&ul(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(s_(Eh,q0,"[yjs] ",K0,G0,"Changed the client-id because another client seems to be using it."),r.clientID=ex()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const u=new d_;Am(u,n)&&r.emit("update",[u.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const u=new za;Am(u,n)&&r.emit("updateV2",[u.toUint8Array(),n.origin,r,n])}const{subdocsAdded:l,subdocsLoaded:a,subdocsRemoved:c}=n;(l.size>0||c.size>0||a.size>0)&&(l.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:a,added:l,removed:c},r,n]),c.forEach(u=>u.destroy())),t.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,t])):lx(t,e+1)}}},Me=(t,e,n=null,r=!0)=>{const s=t._transactionCleanups;let o=!1,i=null;t._transaction===null&&(o=!0,t._transaction=new E_(t,n,r),s.push(t._transaction),s.length===1&&t.emit("beforeAllTransactions",[t]),t.emit("beforeTransaction",[t._transaction,t]));try{i=e(t._transaction)}finally{if(o){const l=t._transaction===s[0];t._transaction=null,l&&lx(s,0)}}return i};class T_{constructor(e,n){this.insertions=n,this.deletions=e,this.meta=new Map}}const Nm=(t,e,n)=>{wr(t,n.deletions,r=>{r instanceof Ee&&e.scope.some(s=>s===t.doc||zo(s,r))&&Lh(r,!1)})},Rm=(t,e,n)=>{let r=null;const s=t.doc,o=t.scope;Me(s,l=>{for(;e.length>0&&t.currStackItem===null;){const a=s.store,c=e.pop(),u=new Set,d=[];let h=!1;wr(l,c.insertions,f=>{if(f instanceof Ee){if(f.redone!==null){let{item:p,diff:g}=id(a,f.id);g>0&&(p=Tt(l,he(p.id.client,p.id.clock+g))),f=p}!f.deleted&&o.some(p=>p===l.doc||zo(p,f))&&d.push(f)}}),wr(l,c.deletions,f=>{f instanceof Ee&&o.some(p=>p===l.doc||zo(p,f))&&!$s(c.insertions,f.id)&&u.add(f)}),u.forEach(f=>{h=Ax(l,f,u,c.insertions,t.ignoreRemoteMapChanges,t)!==null||h});for(let f=d.length-1;f>=0;f--){const p=d[f];t.deleteFilter(p)&&(p.delete(l),h=!0)}t.currStackItem=h?c:null}l.changed.forEach((a,c)=>{a.has(null)&&c._searchMarker&&(c._searchMarker.length=0)}),r=l},t);const i=t.currStackItem;if(i!=null){const l=r.changedParentTypes;t.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:l,origin:t},t]),t.currStackItem=null}return i};class ax extends D0{constructor(e,{captureTimeout:n=500,captureTransaction:r=a=>!0,deleteFilter:s=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:i=!1,doc:l=Ju(e)?e[0].doc:e instanceof ns?e:e.doc}={}){super(),this.scope=[],this.doc=l,this.addToScope(e),this.deleteFilter=s,o.add(this),this.trackedOrigins=o,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=i,this.captureTimeout=n,this.afterTransactionHandler=a=>{if(!this.captureTransaction(a)||!this.scope.some(y=>a.changedParentTypes.has(y)||y===this.doc)||!this.trackedOrigins.has(a.origin)&&(!a.origin||!this.trackedOrigins.has(a.origin.constructor)))return;const c=this.undoing,u=this.redoing,d=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const h=new Hs;a.afterState.forEach((y,b)=>{const x=a.beforeState.get(b)||0,E=y-x;E>0&&Ho(h,b,x,E)});const f=AR();let p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&d.length>0&&!c&&!u){const y=d[d.length-1];y.deletions=td([y.deletions,a.deleteSet]),y.insertions=td([y.insertions,h])}else d.push(new T_(a.deleteSet,h)),p=!0;!c&&!u&&(this.lastChange=f),wr(a,a.deleteSet,y=>{y instanceof Ee&&this.scope.some(b=>b===a.doc||zo(b,y))&&Lh(y,!0)});const g=[{stackItem:d[d.length-1],origin:a.origin,type:c?"redo":"undo",changedParentTypes:a.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){const n=new Set(this.scope);e=Ju(e)?e:[e],e.forEach(r=>{n.has(r)||(n.add(r),(r instanceof st?r.doc!==this.doc:r!==this.doc)&&Y0("[yjs#509] Not same Y.Doc"),this.scope.push(r))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,n=!0){(e&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>Nm(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>Nm(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=Rm(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=Rm(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*N_(t){const e=Le(t.restDecoder);for(let n=0;n<e;n++){const r=Le(t.restDecoder),s=t.readClient();let o=Le(t.restDecoder);for(let i=0;i<r;i++){const l=t.readInfo();if(l===10){const a=Le(t.restDecoder);yield new Xt(he(s,o),a),o+=a}else if((Ba&l)!==0){const a=(l&(Hn|kt))===0,c=new Ee(he(s,o),null,(l&kt)===kt?t.readLeftID():null,null,(l&Hn)===Hn?t.readRightID():null,a?t.readParentInfo()?t.readString():t.readLeftID():null,a&&(l&jo)===jo?t.readString():null,Tx(t,l));yield c,o+=c.length}else{const a=t.readLen();yield new Wt(he(s,o),a),o+=a}}}}class R_{constructor(e,n){this.gen=N_(e),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===Xt);return this.curr}}class __{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const O_=(t,e)=>{if(t.constructor===Wt){const{client:n,clock:r}=t.id;return new Wt(he(n,r+e),t.length-e)}else if(t.constructor===Xt){const{client:n,clock:r}=t.id;return new Xt(he(n,r+e),t.length-e)}else{const n=t,{client:r,clock:s}=n.id;return new Ee(he(r,s+e),null,he(r,s+e-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(e))}},_m=(t,e=ia,n=za)=>{if(t.length===1)return t[0];const r=t.map(u=>new e(vh(u)));let s=r.map(u=>new R_(u,!0)),o=null;const i=new n,l=new __(i);for(;s=s.filter(h=>h.curr!==null),s.sort((h,f)=>{if(h.curr.id.client===f.curr.id.client){const p=h.curr.id.clock-f.curr.id.clock;return p===0?h.curr.constructor===f.curr.constructor?0:h.curr.constructor===Xt?1:-1:p}else return f.curr.id.client-h.curr.id.client}),s.length!==0;){const u=s[0],d=u.curr.id.client;if(o!==null){let h=u.curr,f=!1;for(;h!==null&&h.id.clock+h.length<=o.struct.id.clock+o.struct.length&&h.id.client>=o.struct.id.client;)h=u.next(),f=!0;if(h===null||h.id.client!==d||f&&h.id.clock>o.struct.id.clock+o.struct.length)continue;if(d!==o.struct.id.client)Qs(l,o.struct,o.offset),o={struct:h,offset:0},u.next();else if(o.struct.id.clock+o.struct.length<h.id.clock)if(o.struct.constructor===Xt)o.struct.length=h.id.clock+h.length-o.struct.id.clock;else{Qs(l,o.struct,o.offset);const p=h.id.clock-o.struct.id.clock-o.struct.length;o={struct:new Xt(he(d,o.struct.id.clock+o.struct.length),p),offset:0}}else{const p=o.struct.id.clock+o.struct.length-h.id.clock;p>0&&(o.struct.constructor===Xt?o.struct.length-=p:h=O_(h,p)),o.struct.mergeWith(h)||(Qs(l,o.struct,o.offset),o={struct:h,offset:0},u.next())}}else o={struct:u.curr,offset:0},u.next();for(let h=u.curr;h!==null&&h.id.client===d&&h.id.clock===o.struct.id.clock+o.struct.length&&h.constructor!==Xt;h=u.next())Qs(l,o.struct,o.offset),o={struct:h,offset:0}}o!==null&&(Qs(l,o.struct,o.offset),o=null),D_(l);const a=r.map(u=>a_(u)),c=td(a);return Th(i,c),i.toUint8Array()},cx=t=>{t.written>0&&(t.clientStructs.push({written:t.written,restEncoder:Qt(t.encoder.restEncoder)}),t.encoder.restEncoder=ri(),t.written=0)},Qs=(t,e,n)=>{t.written>0&&t.currClient!==e.id.client&&cx(t),t.written===0&&(t.currClient=e.id.client,t.encoder.writeClient(e.id.client),ge(t.encoder.restEncoder,e.id.clock+n)),e.write(t.encoder,n),t.written++},D_=t=>{cx(t);const e=t.encoder.restEncoder;ge(e,t.clientStructs.length);for(let n=0;n<t.clientStructs.length;n++){const r=t.clientStructs[n];ge(e,r.written),Ha(e,r.restEncoder)}},Om="You must not compute changes after the event-handler fired.";class Ua{constructor(e,n){this.target=e,this.currentTarget=e,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=L_(this.currentTarget,this.target))}deletes(e){return $s(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw xr(Om);const e=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){const o=n._map.get(s);let i,l;if(this.adds(o)){let a=o.left;for(;a!==null&&this.adds(a);)a=a.left;if(this.deletes(o))if(a!==null&&this.deletes(a))i="delete",l=Jc(a.content.getContent());else return;else a!==null&&this.deletes(a)?(i="update",l=Jc(a.content.getContent())):(i="add",l=void 0)}else if(this.deletes(o))i="delete",l=Jc(o.content.getContent());else return;e.set(s,{action:i,oldValue:l})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw xr(Om);const n=this.target,r=Yr(),s=Yr(),o=[];if(e={added:r,deleted:s,delta:o,keys:this.keys},this.transaction.changed.get(n).has(null)){let l=null;const a=()=>{l&&o.push(l)};for(let c=n._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((l===null||l.delete===void 0)&&(a(),l={delete:0}),l.delete+=c.length,s.add(c)):this.adds(c)?((l===null||l.insert===void 0)&&(a(),l={insert:[]}),l.insert=l.insert.concat(c.content.getContent()),r.add(c)):((l===null||l.retain===void 0)&&(a(),l={retain:0}),l.retain+=c.length);l!==null&&l.retain===void 0&&a()}this._changes=e}return e}}const L_=(t,e)=>{const n=[];for(;e._item!==null&&e!==t;){if(e._item.parentSub!==null)n.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)!s.deleted&&s.countable&&(r+=s.length),s=s.right;n.unshift(r)}e=e._item.parent}return n},bt=()=>{Y0("Invalid access: Add Yjs type to a document before reading data.")},ux=80;let Rh=0;class I_{constructor(e,n){e.marker=!0,this.p=e,this.index=n,this.timestamp=Rh++}}const j_=t=>{t.timestamp=Rh++},dx=(t,e,n)=>{t.p.marker=!1,t.p=e,e.marker=!0,t.index=n,t.timestamp=Rh++},P_=(t,e,n)=>{if(t.length>=ux){const r=t.reduce((s,o)=>s.timestamp<o.timestamp?s:o);return dx(r,e,n),r}else{const r=new I_(e,n);return t.push(r),r}},Va=(t,e)=>{if(t._start===null||e===0||t._searchMarker===null)return null;const n=t._searchMarker.length===0?null:t._searchMarker.reduce((o,i)=>ll(e-o.index)<ll(e-i.index)?o:i);let r=t._start,s=0;for(n!==null&&(r=n.p,s=n.index,j_(n));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&ll(n.index-s)<r.parent.length/ux?(dx(n,r,s),n):P_(t._searchMarker,r,s)},Fo=(t,e,n)=>{for(let r=t.length-1;r>=0;r--){const s=t[r];if(n>0){let o=s.p;for(o.marker=!1;o&&(o.deleted||!o.countable);)o=o.left,o&&!o.deleted&&o.countable&&(s.index-=o.length);if(o===null||o.marker===!0){t.splice(r,1);continue}s.p=o,o.marker=!0}(e<s.index||n>0&&e===s.index)&&(s.index=br(e,s.index+n))}},Wa=(t,e,n)=>{const r=t,s=e.changedParentTypes;for(;Un(s,t,()=>[]).push(n),t._item!==null;)t=t._item.parent;nx(r._eH,n,e)};class st{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Sm(),this._dEH=Sm(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,n){this.doc=e,this._item=n}_copy(){throw tn()}clone(){throw tn()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,n){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){Cm(this._eH,e)}observeDeep(e){Cm(this._dEH,e)}unobserve(e){Em(this._eH,e)}unobserveDeep(e){Em(this._dEH,e)}toJSON(){}}const hx=(t,e,n)=>{t.doc??bt(),e<0&&(e=t._length+e),n<0&&(n=t._length+n);let r=n-e;const s=[];let o=t._start;for(;o!==null&&r>0;){if(o.countable&&!o.deleted){const i=o.content.getContent();if(i.length<=e)e-=i.length;else{for(let l=e;l<i.length&&r>0;l++)s.push(i[l]),r--;e=0}}o=o.right}return s},fx=t=>{t.doc??bt();const e=[];let n=t._start;for(;n!==null;){if(n.countable&&!n.deleted){const r=n.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}n=n.right}return e},px=(t,e)=>{const n=[];let r=t._start;for(;r!==null;){if(r.countable&&_r(r,e)){const s=r.content.getContent();for(let o=0;o<s.length;o++)n.push(s[o])}r=r.right}return n},Uo=(t,e)=>{let n=0,r=t._start;for(t.doc??bt();r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let o=0;o<s.length;o++)e(s[o],n++,t)}r=r.right}},mx=(t,e)=>{const n=[];return Uo(t,(r,s)=>{n.push(e(r,s,t))}),n},B_=t=>{let e=t._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};n=e.content.getContent(),r=0,e=e.right}const s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},gx=(t,e)=>{t.doc??bt();const n=Va(t,e);let r=t._start;for(n!==null&&(r=n.p,e-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},aa=(t,e,n,r)=>{let s=n;const o=t.doc,i=o.clientID,l=o.store,a=n===null?e._start:n.right;let c=[];const u=()=>{c.length>0&&(s=new Ee(he(i,We(l,i)),s,s&&s.lastId,a,a&&a.id,e,null,new Qr(c)),s.integrate(t,0),c=[])};r.forEach(d=>{if(d===null)c.push(d);else switch(d.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(d);break;default:switch(u(),d.constructor){case Uint8Array:case ArrayBuffer:s=new Ee(he(i,We(l,i)),s,s&&s.lastId,a,a&&a.id,e,null,new si(new Uint8Array(d))),s.integrate(t,0);break;case ns:s=new Ee(he(i,We(l,i)),s,s&&s.lastId,a,a&&a.id,e,null,new oi(d)),s.integrate(t,0);break;default:if(d instanceof st)s=new Ee(he(i,We(l,i)),s,s&&s.lastId,a,a&&a.id,e,null,new cn(d)),s.integrate(t,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},yx=()=>xr("Length exceeded!"),bx=(t,e,n,r)=>{if(n>e._length)throw yx();if(n===0)return e._searchMarker&&Fo(e._searchMarker,n,r.length),aa(t,e,null,r);const s=n,o=Va(e,n);let i=e._start;for(o!==null&&(i=o.p,n-=o.index,n===0&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));i!==null;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&Tt(t,he(i.id.client,i.id.clock+n));break}n-=i.length}return e._searchMarker&&Fo(e._searchMarker,s,r.length),aa(t,e,i,r)},H_=(t,e,n)=>{let s=(e._searchMarker||[]).reduce((o,i)=>i.index>o.index?i:o,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return aa(t,e,s,n)},xx=(t,e,n,r)=>{if(r===0)return;const s=n,o=r,i=Va(e,n);let l=e._start;for(i!==null&&(l=i.p,n-=i.index);l!==null&&n>0;l=l.right)!l.deleted&&l.countable&&(n<l.length&&Tt(t,he(l.id.client,l.id.clock+n)),n-=l.length);for(;r>0&&l!==null;)l.deleted||(r<l.length&&Tt(t,he(l.id.client,l.id.clock+r)),l.delete(t),r-=l.length),l=l.right;if(r>0)throw yx();e._searchMarker&&Fo(e._searchMarker,s,-o+r)},ca=(t,e,n)=>{const r=e._map.get(n);r!==void 0&&r.delete(t)},_h=(t,e,n,r)=>{const s=e._map.get(n)||null,o=t.doc,i=o.clientID;let l;if(r==null)l=new Qr([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:case Date:case BigInt:l=new Qr([r]);break;case Uint8Array:l=new si(r);break;case ns:l=new oi(r);break;default:if(r instanceof st)l=new cn(r);else throw new Error("Unexpected content type")}new Ee(he(i,We(o.store,i)),s,s&&s.lastId,null,null,e,n,l).integrate(t,0)},Oh=(t,e)=>{t.doc??bt();const n=t._map.get(e);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},wx=t=>{const e={};return t.doc??bt(),t._map.forEach((n,r)=>{n.deleted||(e[r]=n.content.getContent()[n.length-1])}),e},vx=(t,e)=>{t.doc??bt();const n=t._map.get(e);return n!==void 0&&!n.deleted},$_=(t,e)=>{const n={};return t._map.forEach((r,s)=>{let o=r;for(;o!==null&&(!e.sv.has(o.id.client)||o.id.clock>=(e.sv.get(o.id.client)||0));)o=o.left;o!==null&&_r(o,e)&&(n[s]=o.content.getContent()[o.length-1])}),n},Gi=t=>(t.doc??bt(),o_(t._map.entries(),e=>!e[1].deleted));class z_ extends Ua{}class vs extends st{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const n=new vs;return n.push(e),n}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new vs}clone(){const e=new vs;return e.insert(0,this.toArray().map(n=>n instanceof st?n.clone():n)),e}get length(){return this.doc??bt(),this._length}_callObserver(e,n){super._callObserver(e,n),Wa(this,e,new z_(this,e))}insert(e,n){this.doc!==null?Me(this.doc,r=>{bx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}push(e){this.doc!==null?Me(this.doc,n=>{H_(n,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,n=1){this.doc!==null?Me(this.doc,r=>{xx(r,this,e,n)}):this._prelimContent.splice(e,n)}get(e){return gx(this,e)}toArray(){return fx(this)}slice(e=0,n=this.length){return hx(this,e,n)}toJSON(){return this.map(e=>e instanceof st?e.toJSON():e)}map(e){return mx(this,e)}forEach(e){Uo(this,e)}[Symbol.iterator](){return B_(this)}_write(e){e.writeTypeRef(hO)}}const F_=t=>new vs;class U_ extends Ua{constructor(e,n,r){super(e,n),this.keysChanged=r}}class Os extends st{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,n){super._integrate(e,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new Os}clone(){const e=new Os;return this.forEach((n,r)=>{e.set(r,n instanceof st?n.clone():n)}),e}_callObserver(e,n){Wa(this,e,new U_(this,e,n))}toJSON(){this.doc??bt();const e={};return this._map.forEach((n,r)=>{if(!n.deleted){const s=n.content.getContent()[n.length-1];e[r]=s instanceof st?s.toJSON():s}}),e}get size(){return[...Gi(this)].length}keys(){return eu(Gi(this),e=>e[0])}values(){return eu(Gi(this),e=>e[1].content.getContent()[e[1].length-1])}entries(){return eu(Gi(this),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this.doc??bt(),this._map.forEach((n,r)=>{n.deleted||e(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?Me(this.doc,n=>{ca(n,this,e)}):this._prelimContent.delete(e)}set(e,n){return this.doc!==null?Me(this.doc,r=>{_h(r,this,e,n)}):this._prelimContent.set(e,n),n}get(e){return Oh(this,e)}has(e){return vx(this,e)}clear(){this.doc!==null?Me(this.doc,e=>{this.forEach(function(n,r,s){ca(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(fO)}}const V_=t=>new Os,lr=(t,e)=>t===e||typeof t=="object"&&typeof e=="object"&&t&&e&&IR(t,e);class od{constructor(e,n,r,s){this.left=e,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&Ot(),this.right.content.constructor){case Ye:this.right.deleted||zs(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const Dm=(t,e,n)=>{for(;e.right!==null&&n>0;){switch(e.right.content.constructor){case Ye:e.right.deleted||zs(e.currentAttributes,e.right.content);break;default:e.right.deleted||(n<e.right.length&&Tt(t,he(e.right.id.client,e.right.id.clock+n)),e.index+=e.right.length,n-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},Ji=(t,e,n,r)=>{const s=new Map,o=r?Va(e,n):null;if(o){const i=new od(o.p.left,o.p,o.index,s);return Dm(t,i,n-o.index)}else{const i=new od(null,e._start,0,s);return Dm(t,i,n)}},kx=(t,e,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===Ye&&lr(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const s=t.doc,o=s.clientID;r.forEach((i,l)=>{const a=n.left,c=n.right,u=new Ee(he(o,We(s.store,o)),a,a&&a.lastId,c,c&&c.id,e,null,new Ye(l,i));u.integrate(t,0),n.right=u,n.forward()})},zs=(t,e)=>{const{key:n,value:r}=e;r===null?t.delete(n):t.set(n,r)},Sx=(t,e)=>{for(;t.right!==null;){if(!(t.right.deleted||t.right.content.constructor===Ye&&lr(e[t.right.content.key]??null,t.right.content.value)))break;t.forward()}},Cx=(t,e,n,r)=>{const s=t.doc,o=s.clientID,i=new Map;for(const l in r){const a=r[l],c=n.currentAttributes.get(l)??null;if(!lr(c,a)){i.set(l,c);const{left:u,right:d}=n;n.right=new Ee(he(o,We(s.store,o)),u,u&&u.lastId,d,d&&d.id,e,null,new Ye(l,a)),n.right.integrate(t,0),n.forward()}}return i},ru=(t,e,n,r,s)=>{n.currentAttributes.forEach((h,f)=>{s[f]===void 0&&(s[f]=null)});const o=t.doc,i=o.clientID;Sx(n,s);const l=Cx(t,e,n,s),a=r.constructor===String?new on(r):r instanceof st?new cn(r):new rs(r);let{left:c,right:u,index:d}=n;e._searchMarker&&Fo(e._searchMarker,n.index,a.getLength()),u=new Ee(he(i,We(o.store,i)),c,c&&c.lastId,u,u&&u.id,e,null,a),u.integrate(t,0),n.right=u,n.index=d,n.forward(),kx(t,e,n,l)},Lm=(t,e,n,r,s)=>{const o=t.doc,i=o.clientID;Sx(n,s);const l=Cx(t,e,n,s);e:for(;n.right!==null&&(r>0||l.size>0&&(n.right.deleted||n.right.content.constructor===Ye));){if(!n.right.deleted)switch(n.right.content.constructor){case Ye:{const{key:a,value:c}=n.right.content,u=s[a];if(u!==void 0){if(lr(u,c))l.delete(a);else{if(r===0)break e;l.set(a,c)}n.right.delete(t)}else n.currentAttributes.set(a,c);break}default:r<n.right.length&&Tt(t,he(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let a="";for(;r>0;r--)a+=`
158
+ `;n.right=new Ee(he(i,We(o.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,e,null,new on(a)),n.right.integrate(t,0),n.forward()}kx(t,e,n,l)},Ex=(t,e,n,r,s)=>{let o=e;const i=en();for(;o&&(!o.countable||o.deleted);){if(!o.deleted&&o.content.constructor===Ye){const c=o.content;i.set(c.key,c)}o=o.right}let l=0,a=!1;for(;e!==o;){if(n===e&&(a=!0),!e.deleted){const c=e.content;switch(c.constructor){case Ye:{const{key:u,value:d}=c,h=r.get(u)??null;(i.get(u)!==c||h===d)&&(e.delete(t),l++,!a&&(s.get(u)??null)===d&&h!==d&&(h===null?s.delete(u):s.set(u,h))),!a&&!e.deleted&&zs(s,c);break}}}e=e.right}return l},W_=(t,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const n=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Ye){const r=e.content.key;n.has(r)?e.delete(t):n.add(r)}e=e.left}},q_=t=>{let e=0;return Me(t.doc,n=>{let r=t._start,s=t._start,o=en();const i=Gu(o);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Ye:zs(i,s.content);break;default:e+=Ex(n,r,s,o,i),o=Gu(i),r=s;break}s=s.right}}),e},K_=t=>{const e=new Set,n=t.doc;for(const[r,s]of t.afterState.entries()){const o=t.beforeState.get(r)||0;s!==o&&ix(t,n.store.clients.get(r),o,s,i=>{!i.deleted&&i.content.constructor===Ye&&i.constructor!==Wt&&e.add(i.parent)})}Me(n,r=>{wr(t,t.deleteSet,s=>{if(s instanceof Wt||!s.parent._hasFormatting||e.has(s.parent))return;const o=s.parent;s.content.constructor===Ye?e.add(o):W_(r,s)});for(const s of e)q_(s)})},Im=(t,e,n)=>{const r=n,s=Gu(e.currentAttributes),o=e.right;for(;n>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case cn:case rs:case on:n<e.right.length&&Tt(t,he(e.right.id.client,e.right.id.clock+n)),n-=e.right.length,e.right.delete(t);break}e.forward()}o&&Ex(t,o,e.right,s,e.currentAttributes);const i=(e.left||e.right).parent;return i._searchMarker&&Fo(i._searchMarker,e.index,-r+n),e};class G_ extends Ua{constructor(e,n,r){super(e,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,n=[];Me(e,r=>{const s=new Map,o=new Map;let i=this.target._start,l=null;const a={};let c="",u=0,d=0;const h=()=>{if(l!==null){let f=null;switch(l){case"delete":d>0&&(f={delete:d}),d=0;break;case"insert":(typeof c=="object"||c.length>0)&&(f={insert:c},s.size>0&&(f.attributes={},s.forEach((p,g)=>{p!==null&&(f.attributes[g]=p)}))),c="";break;case"retain":u>0&&(f={retain:u},DR(a)||(f.attributes=_R({},a))),u=0;break}f&&n.push(f),l=null}};for(;i!==null;){switch(i.content.constructor){case cn:case rs:this.adds(i)?this.deletes(i)||(h(),l="insert",c=i.content.getContent()[0],h()):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),d+=1):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=1);break;case on:this.adds(i)?this.deletes(i)||(l!=="insert"&&(h(),l="insert"),c+=i.content.str):this.deletes(i)?(l!=="delete"&&(h(),l="delete"),d+=i.length):i.deleted||(l!=="retain"&&(h(),l="retain"),u+=i.length);break;case Ye:{const{key:f,value:p}=i.content;if(this.adds(i)){if(!this.deletes(i)){const g=s.get(f)??null;lr(g,p)?p!==null&&i.delete(r):(l==="retain"&&h(),lr(p,o.get(f)??null)?delete a[f]:a[f]=p)}}else if(this.deletes(i)){o.set(f,p);const g=s.get(f)??null;lr(g,p)||(l==="retain"&&h(),a[f]=g)}else if(!i.deleted){o.set(f,p);const g=a[f];g!==void 0&&(lr(g,p)?g!==null&&i.delete(r):(l==="retain"&&h(),p===null?delete a[f]:a[f]=p))}i.deleted||(l==="insert"&&h(),zs(s,i.content));break}}i=i.right}for(h();n.length>0;){const f=n[n.length-1];if(f.retain!==void 0&&f.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}}class vr extends st{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??bt(),this._length}_integrate(e,n){super._integrate(e,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new vr}clone(){const e=new vr;return e.applyDelta(this.toDelta()),e}_callObserver(e,n){super._callObserver(e,n);const r=new G_(this,e,n);Wa(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??bt();let e="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===on&&(e+=n.content.str),n=n.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:n=!0}={}){this.doc!==null?Me(this.doc,r=>{const s=new od(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const i=e[o];if(i.insert!==void 0){const l=!n&&typeof i.insert=="string"&&o===e.length-1&&s.right===null&&i.insert.slice(-1)===`
159
+ `?i.insert.slice(0,-1):i.insert;(typeof l!="string"||l.length>0)&&ru(r,this,s,l,i.attributes||{})}else i.retain!==void 0?Lm(r,this,s,i.retain,i.attributes||{}):i.delete!==void 0&&Im(r,s,i.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,n,r){this.doc??bt();const s=[],o=new Map,i=this.doc;let l="",a=this._start;function c(){if(l.length>0){const d={};let h=!1;o.forEach((p,g)=>{h=!0,d[g]=p});const f={insert:l};h&&(f.attributes=d),s.push(f),l=""}}const u=()=>{for(;a!==null;){if(_r(a,e)||n!==void 0&&_r(a,n))switch(a.content.constructor){case on:{const d=o.get("ychange");e!==void 0&&!_r(a,e)?(d===void 0||d.user!==a.id.client||d.type!=="removed")&&(c(),o.set("ychange",r?r("removed",a.id):{type:"removed"})):n!==void 0&&!_r(a,n)?(d===void 0||d.user!==a.id.client||d.type!=="added")&&(c(),o.set("ychange",r?r("added",a.id):{type:"added"})):d!==void 0&&(c(),o.delete("ychange")),l+=a.content.str;break}case cn:case rs:{c();const d={insert:a.content.getContent()[0]};if(o.size>0){const h={};d.attributes=h,o.forEach((f,p)=>{h[p]=f})}s.push(d);break}case Ye:_r(a,e)&&(c(),zs(o,a.content));break}a=a.right}c()};return e||n?Me(i,d=>{e&&rd(d,e),n&&rd(d,n),u()},"cleanup"):u(),s}insert(e,n,r){if(n.length<=0)return;const s=this.doc;s!==null?Me(s,o=>{const i=Ji(o,this,e,!r);r||(r={},i.currentAttributes.forEach((l,a)=>{r[a]=l})),ru(o,this,i,n,r)}):this._pending.push(()=>this.insert(e,n,r))}insertEmbed(e,n,r){const s=this.doc;s!==null?Me(s,o=>{const i=Ji(o,this,e,!r);ru(o,this,i,n,r||{})}):this._pending.push(()=>this.insertEmbed(e,n,r||{}))}delete(e,n){if(n===0)return;const r=this.doc;r!==null?Me(r,s=>{Im(s,Ji(s,this,e,!0),n)}):this._pending.push(()=>this.delete(e,n))}format(e,n,r){if(n===0)return;const s=this.doc;s!==null?Me(s,o=>{const i=Ji(o,this,e,!1);i.right!==null&&Lm(o,this,i,n,r)}):this._pending.push(()=>this.format(e,n,r))}removeAttribute(e){this.doc!==null?Me(this.doc,n=>{ca(n,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,n){this.doc!==null?Me(this.doc,r=>{_h(r,this,e,n)}):this._pending.push(()=>this.setAttribute(e,n))}getAttribute(e){return Oh(this,e)}getAttributes(){return wx(this)}_write(e){e.writeTypeRef(pO)}}const J_=t=>new vr;class su{constructor(e,n=()=>!0){this._filter=n,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??bt()}[Symbol.iterator](){return this}next(){let e=this._currentNode,n=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(n)))do if(n=e.content.type,!e.deleted&&(n.constructor===yt||n.constructor===Zr)&&n._start!==null)e=n._start;else for(;e!==null;){const r=e.next;if(r!==null){e=r;break}else e.parent===this._root?e=null:e=e.parent._item}while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class Zr extends st{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,n){super._integrate(e,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new Zr}clone(){const e=new Zr;return e.insert(0,this.toArray().map(n=>n instanceof st?n.clone():n)),e}get length(){return this.doc??bt(),this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new su(this,e)}querySelector(e){e=e.toUpperCase();const r=new su(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Xr(new su(this,n=>n.nodeName&&n.nodeName.toUpperCase()===e))}_callObserver(e,n){Wa(this,e,new Z_(this,n,e))}toString(){return mx(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,n={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Uo(this,o=>{s.insertBefore(o.toDOM(e,n,r),null)}),s}insert(e,n){this.doc!==null?Me(this.doc,r=>{bx(r,this,e,n)}):this._prelimContent.splice(e,0,...n)}insertAfter(e,n){if(this.doc!==null)Me(this.doc,r=>{const s=e&&e instanceof st?e._item:e;aa(r,this,s,n)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(o=>o===e)+1;if(s===0&&e!==null)throw xr("Reference item not found");r.splice(s,0,...n)}}delete(e,n=1){this.doc!==null?Me(this.doc,r=>{xx(r,this,e,n)}):this._prelimContent.splice(e,n)}toArray(){return fx(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return gx(this,e)}slice(e=0,n=this.length){return hx(this,e,n)}forEach(e){Uo(this,e)}_write(e){e.writeTypeRef(gO)}}const Y_=t=>new Zr;class yt extends Zr{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,n){super._integrate(e,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new yt(this.nodeName)}clone(){const e=new yt(this.nodeName),n=this.getAttributes();return OR(n,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof st?r.clone():r)),e}toString(){const e=this.getAttributes(),n=[],r=[];for(const l in e)r.push(l);r.sort();const s=r.length;for(let l=0;l<s;l++){const a=r[l];n.push(a+'="'+e[a]+'"')}const o=this.nodeName.toLocaleLowerCase(),i=n.length>0?" "+n.join(" "):"";return`<${o}${i}>${super.toString()}</${o}>`}removeAttribute(e){this.doc!==null?Me(this.doc,n=>{ca(n,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,n){this.doc!==null?Me(this.doc,r=>{_h(r,this,e,n)}):this._prelimAttrs.set(e,n)}getAttribute(e){return Oh(this,e)}hasAttribute(e){return vx(this,e)}getAttributes(e){return e?$_(this,e):wx(this)}toDOM(e=document,n={},r){const s=e.createElement(this.nodeName),o=this.getAttributes();for(const i in o){const l=o[i];typeof l=="string"&&s.setAttribute(i,l)}return Uo(this,i=>{s.appendChild(i.toDOM(e,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(mO),e.writeKey(this.nodeName)}}const X_=t=>new yt(t.readKey());class Z_ extends Ua{constructor(e,n,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class ua extends Os{constructor(e){super(),this.hookName=e}_copy(){return new ua(this.hookName)}clone(){const e=new ua(this.hookName);return this.forEach((n,r)=>{e.set(r,n)}),e}toDOM(e=document,n={},r){const s=n[this.hookName];let o;return s!==void 0?o=s.createDom(this):o=document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(o,this),o}_write(e){e.writeTypeRef(yO),e.writeKey(this.hookName)}}const Q_=t=>new ua(t.readKey());class _t extends vr{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new _t}clone(){const e=new _t;return e.applyDelta(this.toDelta()),e}toDOM(e=document,n,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const n=[];for(const s in e.attributes){const o=[];for(const i in e.attributes[s])o.push({key:i,value:e.attributes[s][i]});o.sort((i,l)=>i.key<l.key?-1:1),n.push({nodeName:s,attrs:o})}n.sort((s,o)=>s.nodeName<o.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){const o=n[s];r+=`<${o.nodeName}`;for(let i=0;i<o.attrs.length;i++){const l=o.attrs[i];r+=` ${l.key}="${l.value}"`}r+=">"}r+=e.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(bO)}}const eO=t=>new _t;class Dh{constructor(e,n){this.id=e,this.length=n}get deleted(){throw tn()}mergeWith(e){return!1}write(e,n,r){throw tn()}integrate(e,n){throw tn()}}const tO=0;class Wt extends Dh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){n>0&&(this.id.clock+=n,this.length-=n),ox(e.doc.store,this)}write(e,n){e.writeInfo(tO),e.writeLen(this.length-n)}getMissing(e,n){return null}}class si{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new si(this.content)}splice(e){throw tn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeBuf(this.content)}getRef(){return 3}}const nO=t=>new si(t.readBuf());class Vo{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Vo(this.len)}splice(e){const n=new Vo(this.len-e);return this.len=e,n}mergeWith(e){return this.len+=e.len,!0}integrate(e,n){Ho(e.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(e){}gc(e){}write(e,n){e.writeLen(this.len-n)}getRef(){return 1}}const rO=t=>new Vo(t.readLen()),Mx=(t,e)=>new ns({guid:t,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class oi{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const n={};this.opts=n,e.gc||(n.gc=!1),e.autoLoad&&(n.autoLoad=!0),e.meta!==null&&(n.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new oi(Mx(this.doc.guid,this.opts))}splice(e){throw tn()}mergeWith(e){return!1}integrate(e,n){this.doc._item=n,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,n){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const sO=t=>new oi(Mx(t.readString(),t.readAny()));class rs{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new rs(this.embed)}splice(e){throw tn()}mergeWith(e){return!1}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeJSON(this.embed)}getRef(){return 5}}const oO=t=>new rs(t.readJSON());class Ye{constructor(e,n){this.key=e,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Ye(this.key,this.value)}splice(e){throw tn()}mergeWith(e){return!1}integrate(e,n){const r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,n){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const iO=t=>new Ye(t.readKey(),t.readJSON());class da{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new da(this.arr)}splice(e){const n=new da(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const o=this.arr[s];e.writeString(o===void 0?"undefined":JSON.stringify(o))}}getRef(){return 2}}const lO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++){const s=t.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new da(n)},aO=oa("node_env")==="development";class Qr{constructor(e){this.arr=e,aO&&F0(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new Qr(this.arr)}splice(e){const n=new Qr(this.arr.slice(e));return this.arr=this.arr.slice(0,e),n}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){const r=this.arr.length;e.writeLen(r-n);for(let s=n;s<r;s++){const o=this.arr[s];e.writeAny(o)}}getRef(){return 8}}const cO=t=>{const e=t.readLen(),n=[];for(let r=0;r<e;r++)n.push(t.readAny());return new Qr(n)};class on{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new on(this.str)}splice(e){const n=new on(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",n.str="�"+n.str.slice(1)),n}mergeWith(e){return this.str+=e.str,!0}integrate(e,n){}delete(e){}gc(e){}write(e,n){e.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}}const uO=t=>new on(t.readString()),dO=[F_,V_,J_,X_,Y_,Q_,eO],hO=0,fO=1,pO=2,mO=3,gO=4,yO=5,bO=6;class cn{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new cn(this.type._copy())}splice(e){throw tn()}mergeWith(e){return!1}integrate(e,n){this.type._integrate(e.doc,n)}delete(e){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(e.beforeState.get(n.id.client)||0)&&e._mergeStructs.push(n):n.delete(e),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let n=this.type._start;for(;n!==null;)n.gc(e,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,n){this.type._write(e)}getRef(){return 7}}const xO=t=>new cn(dO[t.readTypeRef()](t)),id=(t,e)=>{let n=e,r=0,s;do r>0&&(n=he(n.client,n.clock+r)),s=ws(t,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof Ee);return{item:s,diff:r}},Lh=(t,e)=>{for(;t!==null&&t.keep!==e;)t.keep=e,t=t.parent._item},ha=(t,e,n)=>{const{client:r,clock:s}=e.id,o=new Ee(he(r,s+n),e,he(r,s+n-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(n));return e.deleted&&o.markDeleted(),e.keep&&(o.keep=!0),e.redone!==null&&(o.redone=he(e.redone.client,e.redone.clock+n)),e.right=o,o.right!==null&&(o.right.left=o),t._mergeStructs.push(o),o.parentSub!==null&&o.right===null&&o.parent._map.set(o.parentSub,o),e.length=n,o},jm=(t,e)=>VN(t,n=>$s(n.deletions,e)),Ax=(t,e,n,r,s,o)=>{const i=t.doc,l=i.store,a=i.clientID,c=e.redone;if(c!==null)return Tt(t,c);let u=e.parent._item,d=null,h;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!n.has(u)||Ax(t,u,n,r,s,o)===null))return null;for(;u.redone!==null;)u=Tt(t,u.redone)}const f=u===null?e.parent:u.content.type;if(e.parentSub===null){for(d=e.left,h=e;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Tt(t,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.left}for(;h!==null;){let b=h;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:Tt(t,b.redone);if(b!==null&&b.parent._item===u){h=b;break}h=h.right}}else if(h=null,e.right&&!s){for(d=e;d!==null&&d.right!==null&&(d.right.redone||$s(r,d.right.id)||jm(o.undoStack,d.right.id)||jm(o.redoStack,d.right.id));)for(d=d.right;d.redone;)d=Tt(t,d.redone);if(d&&d.right!==null)return null}else d=f._map.get(e.parentSub)||null;const p=We(l,a),g=he(a,p),y=new Ee(g,d,d&&d.lastId,h,h&&h.id,f,e.parentSub,e.content.copy());return e.redone=g,Lh(y,!0),y.integrate(t,0),y};class Ee extends Dh{constructor(e,n,r,s,o,i,l,a){super(e,a.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=o,this.parent=i,this.parentSub=l,this.redone=null,this.content=a,this.info=this.content.isCountable()?hm:0}set marker(e){(this.info&Xc)>0!==e&&(this.info^=Xc)}get marker(){return(this.info&Xc)>0}get keep(){return(this.info&dm)>0}set keep(e){this.keep!==e&&(this.info^=dm)}get countable(){return(this.info&hm)>0}get deleted(){return(this.info&Yc)>0}set deleted(e){this.deleted!==e&&(this.info^=Yc)}markDeleted(){this.info|=Yc}getMissing(e,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=We(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=We(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===xs&&this.id.client!==this.parent.client&&this.parent.clock>=We(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=Mm(e,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=Tt(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===Wt||this.right&&this.right.constructor===Wt)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===Ee?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===Ee&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===xs){const r=ws(n,this.parent);r.constructor===Wt?this.parent=null:this.parent=r.content.type}return null}integrate(e,n){if(n>0&&(this.id.clock+=n,this.left=Mm(e,e.doc.store,he(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const o=new Set,i=new Set;for(;s!==null&&s!==this.right;){if(i.add(s),o.add(s),qi(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,o.clear();else if(qi(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&i.has(ws(e.doc.store,s.origin)))o.has(ws(e.doc.store,s.origin))||(r=s,o.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),ox(e.doc.store,this),this.content.integrate(e,this),Tm(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new Wt(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:he(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&qi(e.origin,this.lastId)&&this.right===e&&qi(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Ho(e.deleteSet,this.id.client,this.id.clock,this.length),Tm(e,n,this.parentSub),this.content.delete(e)}}gc(e,n){if(!this.deleted)throw Ot();this.content.gc(e),n?C_(e,this,new Wt(this.id,this.length)):this.content=new Vo(this.length)}write(e,n){const r=n>0?he(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,o=this.parentSub,i=this.content.getRef()&Ba|(r===null?0:kt)|(s===null?0:Hn)|(o===null?0:jo);if(e.writeInfo(i),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const l=this.parent;if(l._item!==void 0){const a=l._item;if(a===null){const c=$o(l);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(a.id)}else l.constructor===String?(e.writeParentInfo(!0),e.writeString(l)):l.constructor===xs?(e.writeParentInfo(!1),e.writeLeftID(l)):Ot();o!==null&&e.writeString(o)}this.content.write(e,n)}}const Tx=(t,e)=>wO[e&Ba](t),wO=[()=>{Ot()},rO,lO,nO,uO,oO,iO,xO,cO,sO,()=>{Ot()}],vO=10;class Xt extends Dh{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,n){Ot()}write(e,n){e.writeInfo(vO),ge(e.restEncoder,this.length-n)}getMissing(e,n){return null}}const Nx=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},Rx="__ $YJS$ __";Nx[Rx]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Nx[Rx]=!0;const kO=()=>{let t=!0;return(e,n)=>{if(t){t=!1;try{e()}finally{t=!0}}else n!==void 0&&n()}},SO=/[\uD800-\uDBFF]/,CO=/[\uDC00-\uDFFF]/,EO=(t,e)=>{let n=0,r=0;for(;n<t.length&&n<e.length&&t[n]===e[n];)n++;for(n>0&&SO.test(t[n-1])&&n--;r+n<t.length&&r+n<e.length&&t[t.length-r-1]===e[e.length-r-1];)r++;return r>0&&CO.test(t[t.length-r])&&r--,{index:n,remove:t.length-n-r,insert:e.slice(n,e.length-r)}},MO=EO,bn=(t,e)=>t>>>e|t<<32-e,AO=t=>bn(t,2)^bn(t,13)^bn(t,22),TO=t=>bn(t,6)^bn(t,11)^bn(t,25),NO=t=>bn(t,7)^bn(t,18)^t>>>3,RO=t=>bn(t,17)^bn(t,19)^t>>>10,_O=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),OO=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]);class DO{constructor(){const e=new ArrayBuffer(320);this._H=new Uint32Array(e,0,8),this._H.set(OO),this._W=new Uint32Array(e,64,64)}_updateHash(){const e=this._H,n=this._W;for(let d=16;d<64;d++)n[d]=RO(n[d-2])+n[d-7]+NO(n[d-15])+n[d-16];let r=e[0],s=e[1],o=e[2],i=e[3],l=e[4],a=e[5],c=e[6],u=e[7];for(let d=0,h,f;d<64;d++)h=u+TO(l)+(l&a^~l&c)+_O[d]+n[d]>>>0,f=AO(r)+(r&s^r&o^s&o)>>>0,u=c,c=a,a=l,l=i+h>>>0,i=o,o=s,s=r,r=h+f>>>0;e[0]+=r,e[1]+=s,e[2]+=o,e[3]+=i,e[4]+=l,e[5]+=a,e[6]+=c,e[7]+=u}digest(e){let n=0;for(;n+56<=e.length;){let i=0;for(;i<16&&n+3<e.length;i++)this._W[i]=e[n++]<<24|e[n++]<<16|e[n++]<<8|e[n++];if(n%64!==0){for(this._W.fill(0,i,16);n<e.length;)this._W[i]|=e[n]<<(3-n%4)*8,n++;this._W[i]|=kt<<(3-n%4)*8}this._updateHash()}const r=n%64!==0;this._W.fill(0,0,16);let s=0;for(;n<e.length;s++)for(let i=3;i>=0&&n<e.length;i--)this._W[s]|=e[n++]<<i*8;r||(this._W[s-(n%4===0?0:1)]|=kt<<(3-n%4)*8),this._W[14]=e.byteLength/WN,this._W[15]=e.byteLength*8,this._updateHash();const o=new Uint8Array(32);for(let i=0;i<this._H.length;i++)for(let l=0;l<4;l++)o[i*4+l]=this._H[i]>>>(3-l)*8;return o}}const LO=t=>new DO().digest(t),Pe=new ye("y-sync"),$n=new ye("y-undo");new ye("yjs-cursor");const IO=t=>{for(let n=6;n<t.length;n++)t[n%6]=t[n%6]^t[n];return t.slice(0,6)},jO=t=>UR(IO(LO(VR(t)))),fa=(t,e)=>e===void 0?!t.deleted:e.sv.has(t.id.client)&&e.sv.get(t.id.client)>t.id.clock&&!$s(e.ds,t.id),PO=[{light:"#ecd44433",dark:"#ecd444"}],BO=(t,e,n)=>{if(!t.has(n)){if(t.size<e.length){const r=Yr();t.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}t.set(n,CR(e))}return t.get(n)},HO=(t,{colors:e=PO,colorMapping:n=new Map,permanentUserData:r=null,onFirstRender:s=()=>{},mapping:o}={})=>{let i=!1;const l=new zO(t,o),a=new me({props:{editable:c=>{const u=Pe.getState(c);return u.snapshot==null&&u.prevSnapshot==null}},key:Pe,state:{init:(c,u)=>({type:t,doc:t.doc,binding:l,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:n,permanentUserData:r}),apply:(c,u)=>{const d=c.getMeta(Pe);if(d!==void 0){u=Object.assign({},u);for(const h in d)u[h]=d[h]}return u.addToHistory=c.getMeta("addToHistory")!==!1,u.isChangeOrigin=d!==void 0&&!!d.isChangeOrigin,u.isUndoRedoOperation=d!==void 0&&!!d.isChangeOrigin&&!!d.isUndoRedoOperation,l.prosemirrorView!==null&&d!==void 0&&(d.snapshot!=null||d.prevSnapshot!=null)&&W0(0,()=>{l.prosemirrorView!=null&&(d.restore==null?l._renderSnapshot(d.snapshot,d.prevSnapshot,u):(l._renderSnapshot(d.snapshot,d.snapshot,u),delete u.restore,delete u.snapshot,delete u.prevSnapshot,l.mux(()=>{l._prosemirrorChanged(l.prosemirrorView.state.doc)})))}),u}},view:c=>(l.initView(c),o==null&&l._forceRerender(),s(),{update:()=>{const u=a.getState(c.state);if(u.snapshot==null&&u.prevSnapshot==null&&(i||c.state.doc.content.findDiffStart(c.state.doc.type.createAndFill().content)!==null)){if(i=!0,u.addToHistory===!1&&!u.isChangeOrigin){const d=$n.getState(c.state),h=d&&d.undoManager;h&&h.stopCapturing()}l.mux(()=>{u.doc.transact(d=>{d.meta.set("addToHistory",u.addToHistory),l._prosemirrorChanged(c.state.doc)},Pe)})}},destroy:()=>{l.destroy()}})});return a},$O=(t,e,n)=>{if(e!==null&&e.anchor!==null&&e.head!==null)if(e.type==="all")t.setSelection(new Nt(t.doc));else if(e.type==="node"){const r=hl(n.doc,n.type,e.anchor,n.mapping);t.setSelection(K.create(t.doc,r))}else{const r=hl(n.doc,n.type,e.anchor,n.mapping),s=hl(n.doc,n.type,e.head,n.mapping);r!==null&&s!==null&&t.setSelection(Y.between(t.doc.resolve(r),t.doc.resolve(s)))}},ld=(t,e)=>({type:e.selection.jsonID,anchor:dd(e.selection.anchor,t.type,t.mapping),head:dd(e.selection.head,t.type,t.mapping)});class zO{constructor(e,n=new Map){this.type=e,this.prosemirrorView=null,this.mux=kO(),this.mapping=n,this.isOMark=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&this.prosemirrorView!=null&&(this.beforeTransactionSelection=ld(this,this.prosemirrorView.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(U0&&this._domSelectionInView===null&&(W0(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection();if(e==null||e.anchorNode==null)return!1;const n=this.prosemirrorView._root.createRange();n.setStart(e.anchorNode,e.anchorOffset),n.setEnd(e.focusNode,e.focusOffset),n.getClientRects().length===0&&n.startContainer&&n.collapsed&&n.selectNodeContents(n.startContainer);const s=n.getBoundingClientRect(),o=qR.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||o.clientWidth||0)&&s.top<=(window.innerHeight||o.clientHeight||0)}renderSnapshot(e,n){n||(n=rx(Q0(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(Pe,{snapshot:e,prevSnapshot:n}))}unrenderSnapshot(){this.mapping.clear(),this.mux(()=>{const e=this.type.toArray().map(r=>dl(r,this.prosemirrorView.state.schema,this)).filter(r=>r!==null),n=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(O.from(e),0,0));n.setMeta(Pe,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(n)})}_forceRerender(){this.mapping.clear(),this.mux(()=>{const e=this.beforeTransactionSelection!==null?null:this.prosemirrorView.state.selection,n=this.type.toArray().map(s=>dl(s,this.prosemirrorView.state.schema,this)).filter(s=>s!==null),r=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(O.from(n),0,0));if(e){const s=Ns(br(e.anchor,0),r.doc.content.size),o=Ns(br(e.head,0),r.doc.content.size);r.setSelection(Y.create(r.doc,s,o))}this.prosemirrorView.dispatch(r.setMeta(Pe,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,n,r){let s=this.doc,o=this.type;if(e||(e=nu(this.doc)),e instanceof Uint8Array||n instanceof Uint8Array)if((!(e instanceof Uint8Array)||!(n instanceof Uint8Array))&&Ot(),s=new ns({gc:!1}),nd(s,n),n=nu(s),nd(s,e),e=nu(s),o._item===null){const i=Array.from(this.doc.share.keys()).find(l=>this.doc.share.get(l)===this.type);o=s.getXmlFragment(i)}else{const i=s.store.clients.get(o._item.id.client)??[],l=sn(i,o._item.id.clock);o=i[l].content.type}this.mapping.clear(),this.mux(()=>{s.transact(i=>{const l=r.permanentUserData;l&&l.dss.forEach(d=>{wr(i,d,h=>{})});const a=(d,h)=>{const f=d==="added"?l.getUserByClientId(h.client):l.getUserByDeletedId(h);return{user:f,type:d,color:BO(r.colorMapping,r.colors,f)}},c=px(o,new Nh(n.ds,e.sv)).map(d=>!d._item.deleted||fa(d._item,e)||fa(d._item,n)?dl(d,this.prosemirrorView.state.schema,{mapping:new Map,isOMark:new Map},e,n,a):null).filter(d=>d!==null),u=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(O.from(c),0,0));this.prosemirrorView.dispatch(u.setMeta(Pe,{isChangeOrigin:!0}))},Pe)})}_typeChanged(e,n){if(this.prosemirrorView==null)return;const r=Pe.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(l,a)=>this.mapping.delete(a);wr(n,n.deleteSet,l=>{if(l.constructor===Ee){const a=l.content.type;a&&this.mapping.delete(a)}}),n.changed.forEach(s),n.changedParentTypes.forEach(s);const o=this.type.toArray().map(l=>_x(l,this.prosemirrorView.state.schema,this)).filter(l=>l!==null);let i=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new j(O.from(o),0,0));$O(i,this.beforeTransactionSelection,this),i=i.setMeta(Pe,{isChangeOrigin:!0,isUndoRedoOperation:n.origin instanceof ax}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&i.scrollIntoView(),this.prosemirrorView.dispatch(i)})}_prosemirrorChanged(e){this.doc.transact(()=>{cd(this.doc,this.type,e,this),this.beforeTransactionSelection=ld(this,this.prosemirrorView.state)},Pe)}initView(e){this.prosemirrorView!=null&&this.destroy(),this.prosemirrorView=e,this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),this.type.observeDeep(this._observeFunction)}destroy(){this.prosemirrorView!=null&&(this.prosemirrorView=null,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions))}}const _x=(t,e,n,r,s,o)=>{const i=n.mapping.get(t);if(i===void 0){if(t instanceof yt)return dl(t,e,n,r,s,o);throw tn()}return i},dl=(t,e,n,r,s,o)=>{const i=[],l=a=>{var c,u;if(a instanceof yt){const d=_x(a,e,n,r,s,o);d!==null&&i.push(d)}else{const d=(u=(c=a._item.right)==null?void 0:c.content)==null?void 0:u.type;d instanceof vr&&!d._item.deleted&&d._item.id.client===d.doc.clientID&&(a.applyDelta([{retain:a.length},...d.toDelta()]),d.doc.transact(f=>{d._item.delete(f)}));const h=FO(a,e,n,r,s,o);h!==null&&h.forEach(f=>{f!==null&&i.push(f)})}};r===void 0||s===void 0?t.toArray().forEach(l):px(t,new Nh(s.ds,r.sv)).forEach(l);try{const a=t.getAttributes(r);r!==void 0&&(fa(t._item,r)?fa(t._item,s)||(a.ychange=o?o("added",t._item.id):{type:"added"}):a.ychange=o?o("removed",t._item.id):{type:"removed"});const c=e.node(t.nodeName,a,i);return n.mapping.set(t,c),c}catch{return t.doc.transact(c=>{t._item.delete(c)},Pe),n.mapping.delete(t),null}},FO=(t,e,n,r,s,o)=>{const i=[],l=t.toDelta(r,s,o);try{for(let a=0;a<l.length;a++){const c=l[a];i.push(e.text(c.insert,GO(c.attributes,e)))}}catch{return t.doc.transact(c=>{t._item.delete(c)},Pe),null}return i},UO=(t,e)=>{const n=new _t,r=t.map(s=>({insert:s.text,attributes:Dx(s.marks,e)}));return n.applyDelta(r),e.mapping.set(n,t),n},VO=(t,e)=>{const n=new yt(t.type.name);for(const r in t.attrs){const s=t.attrs[r];s!==null&&r!=="ychange"&&n.setAttribute(r,s)}return n.insert(0,qa(t).map(r=>ad(r,e))),e.mapping.set(n,t),n},ad=(t,e)=>t instanceof Array?UO(t,e):VO(t,e),Pm=t=>typeof t=="object"&&t!==null,Ih=(t,e)=>{const n=Object.keys(t).filter(s=>t[s]!==null);let r=n.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<n.length&&r;s++){const o=n[s],i=t[o],l=e[o];r=o==="ychange"||i===l||Pm(i)&&Pm(l)&&Ih(i,l)}return r},qa=t=>{const e=t.content.content,n=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const o=[];for(let i=e[r];r<e.length&&i.isText;i=e[++r])o.push(i);r--,n.push(o)}else n.push(s)}return n},Ox=(t,e)=>{const n=t.toDelta();return n.length===e.length&&n.every((r,s)=>r.insert===e[s].text&&$0(r.attributes||{}).length===e[s].marks.length&&z0(r.attributes,(o,i)=>{var c;const l=jh(i),a=e[s].marks;return Ih(o,(c=a.find(u=>u.type.name===l))==null?void 0:c.attrs)}))},Wo=(t,e)=>{if(t instanceof yt&&!(e instanceof Array)&&ud(t,e)){const n=qa(e);return t._length===n.length&&Ih(t.getAttributes(),e.attrs)&&t.toArray().every((r,s)=>Wo(r,n[s]))}return t instanceof _t&&e instanceof Array&&Ox(t,e)},pa=(t,e)=>t===e||t instanceof Array&&e instanceof Array&&t.length===e.length&&t.every((n,r)=>e[r]===n),Bm=(t,e,n)=>{const r=t.toArray(),s=qa(e),o=s.length,i=r.length,l=Ns(i,o);let a=0,c=0,u=!1;for(;a<l;a++){const d=r[a],h=s[a];if(pa(n.mapping.get(d),h))u=!0;else if(!Wo(d,h))break}for(;a+c<l;c++){const d=r[i-c-1],h=s[o-c-1];if(pa(n.mapping.get(d),h))u=!0;else if(!Wo(d,h))break}return{equalityFactor:a+c,foundMappedChild:u}},WO=t=>{let e="",n=t._start;const r={};for(;n!==null;)n.deleted||(n.countable&&n.content instanceof on?e+=n.content.str:n.content instanceof Ye&&(r[n.content.key]=null)),n=n.right;return{str:e,nAttrs:r}},qO=(t,e,n)=>{n.mapping.set(t,e);const{nAttrs:r,str:s}=WO(t),o=e.map(c=>({insert:c.text,attributes:Object.assign({},r,Dx(c.marks,n))})),{insert:i,remove:l,index:a}=MO(s,o.map(c=>c.insert).join(""));t.delete(a,l),t.insert(a,i),t.applyDelta(o.map(c=>({retain:c.insert.length,attributes:c.attributes})))},KO=/(.*)(--[a-zA-Z0-9+/=]{8})$/,jh=t=>{var e;return((e=KO.exec(t))==null?void 0:e[1])??t},GO=(t,e)=>{const n=[];for(const r in t)n.push(e.mark(jh(r),t[r]));return n},Dx=(t,e)=>{const n={};return t.forEach(r=>{if(r.type.name!=="ychange"){const s=Un(e.isOMark,r.type,()=>!r.type.excludes(r.type));n[s?`${r.type.name}--${jO(r.toJSON())}`:r.type.name]=r.attrs}}),n},cd=(t,e,n,r)=>{if(e instanceof yt&&e.nodeName!==n.type.name)throw new Error("node name mismatch!");if(r.mapping.set(e,n),e instanceof yt){const d=e.getAttributes(),h=n.attrs;for(const f in h)h[f]!==null?d[f]!==h[f]&&f!=="ychange"&&e.setAttribute(f,h[f]):e.removeAttribute(f);for(const f in d)h[f]===void 0&&e.removeAttribute(f)}const s=qa(n),o=s.length,i=e.toArray(),l=i.length,a=Ns(o,l);let c=0,u=0;for(;c<a;c++){const d=i[c],h=s[c];if(!pa(r.mapping.get(d),h))if(Wo(d,h))r.mapping.set(d,h);else break}for(;u+c+1<a;u++){const d=i[l-u-1],h=s[o-u-1];if(!pa(r.mapping.get(d),h))if(Wo(d,h))r.mapping.set(d,h);else break}t.transact(()=>{for(;l-c-u>0&&o-c-u>0;){const h=i[c],f=s[c],p=i[l-u-1],g=s[o-u-1];if(h instanceof _t&&f instanceof Array)Ox(h,f)||qO(h,f,r),c+=1;else{let y=h instanceof yt&&ud(h,f),b=p instanceof yt&&ud(p,g);if(y&&b){const x=Bm(h,f,r),E=Bm(p,g,r);x.foundMappedChild&&!E.foundMappedChild?b=!1:!x.foundMappedChild&&E.foundMappedChild||x.equalityFactor<E.equalityFactor?y=!1:b=!1}y?(cd(t,h,f,r),c+=1):b?(cd(t,p,g,r),u+=1):(r.mapping.delete(e.get(c)),e.delete(c,1),e.insert(c,[ad(f,r)]),c+=1)}}const d=l-c-u;if(l===1&&o===0&&i[0]instanceof _t?(r.mapping.delete(i[0]),i[0].delete(0,i[0].length)):d>0&&(e.slice(c,c+d).forEach(h=>r.mapping.delete(h)),e.delete(c,d)),c+u<o){const h=[];for(let f=c;f<o-u;f++)h.push(ad(s[f],r));e.insert(c,h)}},Pe)},ud=(t,e)=>!(e instanceof Array)&&t.nodeName===e.type.name,dd=(t,e,n)=>{if(t===0)return tu(e,0,-1);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof _t){if(r._length>=t)return tu(r,t,-1);if(t-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,t--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(n.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&t<s)r=r._first.content.type,t--;else{if(t===1&&r._length===0&&s>1)return new la(r._item===null?null:r._item.id,r._item===null?$o(r):null,null);if(t-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(t===0)return r=r._item===null?r:r._item.parent,new la(r._item===null?null:r._item.id,r._item===null?$o(r):null,null);do r=r._item.parent,t--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw Ot();if(t===0&&r.constructor!==_t&&r!==e)return JO(r._item.parent,r._item)}return tu(e,e._length,-1)},JO=(t,e)=>{let n=null,r=null;return t._item===null?r=$o(t):n=he(t._item.id.client,t._item.id.clock),new la(n,r,e.id)},hl=(t,e,n,r)=>{const s=k_(n,t);if(s===null||s.type!==e&&!zo(e,s.type._item))return null;let o=s.type,i=0;if(o.constructor===_t)i=s.index;else if(o._item===null||!o._item.deleted){let l=o._first,a=0;for(;a<o._length&&a<s.index&&l!==null;){if(!l.deleted){const c=l.content.type;a++,c instanceof _t?i+=c._length:i+=r.get(c).nodeSize}l=l.right}i+=1}for(;o!==e&&o._item!==null;){const l=o._item.parent;if(l._item===null||!l._item.deleted){i+=1;let a=l._first;for(;a!==null;){const c=a.content.type;if(c===o)break;a.deleted||(c instanceof _t?i+=c._length:i+=r.get(c).nodeSize),a=a.right}}o=l}return i-1};function YO(t){const e=t.toArray(),n=r=>{let s;if(r instanceof _t)s=r.toDelta().map(i=>{const l={type:"text",text:i.insert};return i.attributes&&(l.marks=Object.keys(i.attributes).map(a=>{const c=i.attributes[a],d={type:jh(a)};return Object.keys(c)&&(d.attrs=c),d})),l});else if(r instanceof yt){s={type:r.nodeName};const o=r.getAttributes();Object.keys(o).length&&(s.attrs=o);const i=r.toArray();i.length&&(s.content=i.map(n).flat())}else Ot();return s};return{type:"doc",content:e.map(n)}}const XO=t=>{const e=$n.getState(t).undoManager;if(e!=null)return e.undo(),!0},ZO=t=>{const e=$n.getState(t).undoManager;if(e!=null)return e.redo(),!0},QO=new Set(["paragraph"]),eD=(t,e)=>!(t instanceof Ee)||!(t.content instanceof cn)||!(t.content.type instanceof vr||t.content.type instanceof yt&&e.has(t.content.type.nodeName))||t.content.type._length===0,tD=({protectedNodes:t=QO,trackedOrigins:e=[],undoManager:n=null}={})=>new me({key:$n,state:{init:(r,s)=>{const o=Pe.getState(s),i=n||new ax(o.type,{trackedOrigins:new Set([Pe].concat(e)),deleteFilter:l=>eD(l,t),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:i,prevSel:null,hasUndoOps:i.undoStack.length>0,hasRedoOps:i.redoStack.length>0}},apply:(r,s,o,i)=>{const l=Pe.getState(i).binding,a=s.undoManager,c=a.undoStack.length>0,u=a.redoStack.length>0;return l?{undoManager:a,prevSel:ld(l,o),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:a.undoStack.length>0,hasRedoOps:a.redoStack.length>0}):s}},view:r=>{const s=Pe.getState(r.state),o=$n.getState(r.state).undoManager;return o.on("stack-item-added",({stackItem:i})=>{const l=s.binding;l&&i.meta.set(l,$n.getState(r.state).prevSel)}),o.on("stack-item-popped",({stackItem:i})=>{const l=s.binding;l&&(l.beforeTransactionSelection=i.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{o.destroy()}}}});fe.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null,provider:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(t=>t.name==="undoRedo")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-undo-redo".')},addCommands(){return{undo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),$n.getState(e).undoManager.undoStack.length===0?!1:n?XO(e):!0),redo:()=>({tr:t,state:e,dispatch:n})=>(t.setMeta("preventDispatch",!0),$n.getState(e).undoManager.redoStack.length===0?!1:n?ZO(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var t;const e=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),n=tD(this.options.yUndoOptions),r=n.spec.view;n.spec.view=i=>{const{undoManager:l}=$n.getState(i.state);l.restore&&(l.restore(),l.restore=()=>{});const a=r?r(i):void 0;return{destroy:()=>{const c=l.trackedOrigins.has(l),u=l._observers;l.restore=()=>{c&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=u},a!=null&&a.destroy&&a.destroy()}}};const s={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},o=HO(e,s);return this.editor.options.enableContentCheck&&((t=e.doc)==null||t.on("beforeTransaction",()=>{try{const i=YO(e);if(i.content.length===0)return;this.editor.schema.nodeFromJSON(i).check()}catch(i){return this.editor.emit("contentError",{error:i,editor:this.editor,disableCollaboration:()=>{var l;(l=e.doc)==null||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[o,n,this.editor.options.enableContentCheck&&new me({key:new ye("filterInvalidContent"),filterTransaction:()=>{var i;return this.storage.isDisabled!==!1&&((i=e.doc)==null||i.destroy()),!0}})].filter(Boolean)}});function nD(t){return!!t.getMeta(Pe)}function Hm(t){if(!t.length)return be.empty;const e=[],n=t[0].$from.node(0);return t.forEach(r=>{const s=r.$from.pos,o=r.$from.nodeAfter;o&&e.push(De.node(s,s+o.nodeSize,{class:"ProseMirror-selectednoderange"}))}),be.create(n,e)}function Ka(t,e,n){const r=[],s=t.node(0);typeof n=="number"&&n>=0||(t.sameParent(e)?n=Math.max(0,t.sharedDepth(e.pos)-1):n=t.sharedDepth(e.pos));const o=new ko(t,e,n),i=o.depth===0?0:s.resolve(o.start).posAtIndex(0);return o.parent.forEach((l,a)=>{const c=i+a,u=c+l.nodeSize;if(c<o.start||c>=o.end)return;const d=new Ad(s.resolve(c),s.resolve(u));r.push(d)}),r}var rD=class Lx{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Lx(e.map(this.anchor),e.map(this.head))}resolve(e){const n=e.resolve(this.anchor),r=e.resolve(this.head);return new ar(n,r)}},ar=class Xn extends Q{constructor(e,n,r,s=1){const{doc:o}=e,i=e===n,l=e.pos===o.content.size&&n.pos===o.content.size,a=i&&!l?o.resolve(n.pos+(s>0?1:-1)):n,c=i&&l?o.resolve(e.pos-(s>0?1:-1)):e,u=Ka(c.min(a),c.max(a),r),d=a.pos>=e.pos?u[0].$from:u[u.length-1].$to,h=a.pos>=e.pos?u[u.length-1].$to:u[0].$from;super(d,h,u),this.depth=r}get $to(){return this.ranges[this.ranges.length-1].$to}eq(e){return e instanceof Xn&&e.$from.pos===this.$from.pos&&e.$to.pos===this.$to.pos}map(e,n){const r=e.resolve(n.map(this.anchor)),s=e.resolve(n.map(this.head));return new Xn(r,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:e}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),o=s[0].$from,i=s[s.length-1].$to;return new Xn(o,i,this.depth)}const n=this.ranges[0],r=e.resolve(Math.max(0,n.$from.pos-1));return new Xn(this.$anchor,r,this.depth)}extendForwards(){const{doc:e}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),o=s[0].$from,i=s[s.length-1].$to;return new Xn(i,o,this.depth)}const n=this.ranges[this.ranges.length-1],r=e.resolve(Math.min(e.content.size,n.$to.pos+1));return new Xn(this.$anchor,r,this.depth)}static fromJSON(e,n){return new Xn(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r,s,o=1){return new this(e.resolve(n),e.resolve(r),s,o)}getBookmark(){return new rD(this.anchor,this.head)}};ar.prototype.visible=!1;function Yi(t){return t instanceof ar}var sD=fe.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:o,tr:i}=r,{anchor:l,head:a}=o;if(!Yi(o)){const u=ar.create(s,l,a,e,-1);return i.setSelection(u),n.dispatch(i),!0}const c=o.extendBackwards();return i.setSelection(c),n.dispatch(i),!0},"Shift-ArrowDown":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,selection:o,tr:i}=r,{anchor:l,head:a}=o;if(!Yi(o)){const u=ar.create(s,l,a,e);return i.setSelection(u),n.dispatch(i),!0}const c=o.extendForwards();return i.setSelection(c),n.dispatch(i),!0},"Mod-a":({editor:t})=>{const{depth:e}=this.options,{view:n,state:r}=t,{doc:s,tr:o}=r,i=ar.create(s,0,s.content.size,e);return o.setSelection(i),n.dispatch(o),!0}}},onSelectionUpdate(){const{selection:t}=this.editor.state;Yi(t)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let t=!1,e=!1;return[new me({key:new ye("nodeRange"),props:{attributes:()=>t?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(n,r)=>{const{key:s}=this.options,o=/Mac/.test(navigator.platform),i=!!r.shiftKey,l=!!r.ctrlKey,a=!!r.altKey,c=!!r.metaKey,u=o?c:l;return(s==null||s==="Shift"&&i||s==="Control"&&l||s==="Alt"&&a||s==="Meta"&&c||s==="Mod"&&u)&&(e=!0),e&&document.addEventListener("mouseup",()=>{e=!1;const{state:d}=n,{doc:h,selection:f,tr:p}=d,{$anchor:g,$head:y}=f;if(g.sameParent(y))return;const b=ar.create(h,g.pos,y.pos,this.options.depth);p.setSelection(b),n.dispatch(p)},{once:!0}),!1}},decorations:n=>{const{selection:r}=n,s=Yi(r);if(t=!1,!e)return s?(t=!0,Hm(r.ranges)):null;const{$from:o,$to:i}=r;if(!s&&o.sameParent(i))return null;const l=Ka(o,i,this.options.depth);return l.length?(t=!0,Hm(l)):null}}})]}}),oD=sD;function iD(t){let e="";const n=getComputedStyle(t);for(let r=0;r<n.length;r+=1)e+=`${n[r]}:${n.getPropertyValue(n[r])};`;return e}function lD(t){const e=t.cloneNode(!0),n=[t,...Array.from(t.getElementsByTagName("*"))],r=[e,...Array.from(e.getElementsByTagName("*"))];return n.forEach((s,o)=>{r[o].style.cssText=iD(s)}),e}var Ix=t=>{const{x:e,y:n,direction:r,editor:s}=t;let o=null,i=null,l=null,a=e;for(;i===null&&a<window.innerWidth&&a>0;){const c=document.elementsFromPoint(a,n),u=c.findIndex(h=>h.classList.contains("ProseMirror")),d=c.slice(0,u);if(d.length>0){const h=d[0];if(o=h,l=s.view.posAtDOM(h,0),l>=0){i=s.state.doc.nodeAt(Math.max(l-1,0)),i!=null&&i.isText&&(i=s.state.doc.nodeAt(Math.max(l-1,0))),i||(i=s.state.doc.nodeAt(Math.max(l,0)));break}}r==="left"?a-=1:a+=1}return{resultElement:o,resultNode:i,pos:l??null}};function Xi(t,e){return window.getComputedStyle(t)[e]}function aD(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function cD(t,e,n){const r=parseInt(Xi(t.dom,"paddingLeft"),10),s=parseInt(Xi(t.dom,"paddingRight"),10),o=parseInt(Xi(t.dom,"borderLeftWidth"),10),i=parseInt(Xi(t.dom,"borderLeftWidth"),10),l=t.dom.getBoundingClientRect();return{left:aD(e,l.left+r+o,l.right-s-i),top:n}}function jx(t){var e;(e=t.parentNode)==null||e.removeChild(t)}function uD(t,e){const{doc:n}=e.view.state,r=Ix({editor:e,x:t.clientX,y:t.clientY,direction:"right"});if(!r.resultNode||r.pos===null)return[];const s=t.clientX,o=cD(e.view,s,t.clientY),i=e.view.posAtCoords(o);if(!i)return[];const{pos:l}=i;if(!n.resolve(l).parent)return[];const c=n.resolve(r.pos),u=n.resolve(r.pos+1);return Ka(c,u,0)}function dD(t,e){const{view:n}=e;if(!t.dataTransfer)return;const{empty:r,$from:s,$to:o}=n.state.selection,i=uD(t,e),l=Ka(s,o,0),a=l.some(y=>i.find(b=>b.$from===y.$from&&b.$to===y.$to)),c=r||!a?i:l;if(!c.length)return;const{tr:u}=n.state,d=document.createElement("div"),h=c[0].$from.pos,f=c[c.length-1].$to.pos,p=ar.create(n.state.doc,h,f),g=p.content();c.forEach(y=>{const b=n.nodeDOM(y.$from.pos),x=lD(b);d.append(x)}),d.style.position="absolute",d.style.top="-10000px",document.body.append(d),t.dataTransfer.clearData(),t.dataTransfer.setDragImage(d,0,0),n.dragging={slice:g,move:!0},u.setSelection(p),n.dispatch(u),document.addEventListener("drop",()=>jx(d),{once:!0})}var $m=(t,e)=>{const n=t.resolve(e),{depth:r}=n;return r===0?e:n.pos-n.parentOffset-1},zm=(t,e)=>{const n=t.nodeAt(e),r=t.resolve(e);let{depth:s}=r,o=n;for(;s>0;){const i=r.node(s);s-=1,s===0&&(o=i)}return o},ou=(t,e)=>{const n=Pe.getState(t);return n?dd(e,n.type,n.binding.mapping):null},hD=(t,e)=>{const n=Pe.getState(t);return n?hl(n.doc,n.type,e,n.binding.mapping)||0:-1},Fm=(t,e)=>{let n=e;for(;n!=null&&n.parentNode&&n.parentNode!==t.dom;)n=n.parentNode;return n},fD=new ye("dragHandle"),pD=({pluginKey:t=fD,element:e,editor:n,computePositionConfig:r,onNodeChange:s,onElementDragStart:o,onElementDragEnd:i})=>{const l=document.createElement("div");let a=!1,c=null,u=-1,d;function h(){e&&(e.style.visibility="hidden",e.style.pointerEvents="none")}function f(){if(e){if(!n.isEditable){h();return}e.style.visibility="",e.style.pointerEvents="auto"}}function p(b){bh({getBoundingClientRect:()=>b.getBoundingClientRect()},e,r).then(E=>{Object.assign(e.style,{position:E.strategy,left:`${E.x}px`,top:`${E.y}px`})})}function g(b){o==null||o(b),dD(b,n),setTimeout(()=>{e&&(e.style.pointerEvents="none")},0)}function y(b){i==null||i(b),h(),e&&(e.style.pointerEvents="auto")}return e.addEventListener("dragstart",g),e.addEventListener("dragend",y),l.appendChild(e),{unbind(){e.removeEventListener("dragstart",g),e.removeEventListener("dragend",y)},plugin:new me({key:typeof t=="string"?new ye(t):t,state:{init(){return{locked:!1}},apply(b,x,E,S){const M=b.getMeta("lockDragHandle"),w=b.getMeta("hideDragHandle");if(M!==void 0&&(a=M),w)return h(),a=!1,c=null,u=-1,s==null||s({editor:n,node:null,pos:-1}),x;if(b.docChanged&&u!==-1&&e)if(nD(b)){const T=hD(S,d);T!==u&&(u=T)}else{const T=b.mapping.map(u);T!==u&&(u=T,d=ou(S,u))}return x}},view:b=>{var x;return e.draggable=!0,e.style.pointerEvents="auto",(x=n.view.dom.parentElement)==null||x.appendChild(l),l.style.pointerEvents="none",l.style.position="absolute",l.style.top="0",l.style.left="0",{update(E,S){if(!e)return;if(!n.isEditable){h();return}if(a?e.draggable=!1:e.draggable=!0,b.state.doc.eq(S.doc)||u===-1)return;let M=b.nodeDOM(u);if(M=Fm(b,M),M===b.dom||(M==null?void 0:M.nodeType)!==1)return;const w=b.posAtDOM(M,0),T=zm(n.state.doc,w),k=$m(n.state.doc,w);c=T,u=k,d=ou(b.state,u),s==null||s({editor:n,node:c,pos:u}),p(M)},destroy(){e&&jx(l)}}},props:{handleDOMEvents:{keydown(b){return!e||a||b.hasFocus()&&(h(),c=null,u=-1,s==null||s({editor:n,node:null,pos:-1})),!1},mouseleave(b,x){return a||x.target&&!l.contains(x.relatedTarget)&&(h(),c=null,u=-1,s==null||s({editor:n,node:null,pos:-1})),!1},mousemove(b,x){if(!e||a)return!1;const E=Ix({x:x.clientX,y:x.clientY,direction:"right",editor:n});if(!E.resultElement)return!1;let S=E.resultElement;if(S=Fm(b,S),S===b.dom||(S==null?void 0:S.nodeType)!==1)return!1;const M=b.posAtDOM(S,0),w=zm(n.state.doc,M);if(w!==c){const T=$m(n.state.doc,M);c=w,u=T,d=ou(b.state,u),s==null||s({editor:n,node:c,pos:u}),p(S),f()}return!1}}}})}},mD={placement:"left-start",strategy:"absolute"},gD=fe.create({name:"dragHandle",addOptions(){return{render(){const t=document.createElement("div");return t.classList.add("drag-handle"),t},computePositionConfig:{},locked:!1,onNodeChange:()=>null}},addCommands(){return{lockDragHandle:()=>({editor:t})=>(this.options.locked=!0,t.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:t})=>(this.options.locked=!1,t.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:t})=>(this.options.locked=!this.options.locked,t.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const t=this.options.render();return[pD({computePositionConfig:{...mD,...this.options.computePositionConfig},element:t,editor:this.editor,onNodeChange:this.options.onNodeChange}).plugin]}}),yD=gD;function bD(t){const e=t.regex,n={},r={begin:/\$\{/,end:/\}/,contains:["self",{begin:/:-/,contains:[n]}]};Object.assign(n,{className:"variable",variants:[{begin:e.concat(/\$[\w\d#@][\w\d_]*/,"(?![\\w\\d])(?![$])")},r]});const s={className:"subst",begin:/\$\(/,end:/\)/,contains:[t.BACKSLASH_ESCAPE]},o=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),i={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},l={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(l);const a={match:/\\"/},c={className:"string",begin:/'/,end:/'/},u={match:/\\'/},d={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},h=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],f=t.SHEBANG({binary:`(${h.join("|")})`,relevance:10}),p={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},g=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],y=["true","false"],b={match:/(\/[a-z._-]+)+/},x=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],E=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],S=["autoload","bg","bindkey","bye","cap","chdir","clone","comparguments","compcall","compctl","compdescribe","compfiles","compgroups","compquote","comptags","comptry","compvalues","dirs","disable","disown","echotc","echoti","emulate","fc","fg","float","functions","getcap","getln","history","integer","jobs","kill","limit","log","noglob","popd","print","pushd","pushln","rehash","sched","setcap","setopt","stat","suspend","ttyctl","unfunction","unhash","unlimit","unsetopt","vared","wait","whence","where","which","zcompile","zformat","zftp","zle","zmodload","zparseopts","zprof","zpty","zregexparse","zsocket","zstyle","ztcp"],M=["chcon","chgrp","chown","chmod","cp","dd","df","dir","dircolors","ln","ls","mkdir","mkfifo","mknod","mktemp","mv","realpath","rm","rmdir","shred","sync","touch","truncate","vdir","b2sum","base32","base64","cat","cksum","comm","csplit","cut","expand","fmt","fold","head","join","md5sum","nl","numfmt","od","paste","ptx","pr","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shuf","sort","split","sum","tac","tail","tr","tsort","unexpand","uniq","wc","arch","basename","chroot","date","dirname","du","echo","env","expr","factor","groups","hostid","id","link","logname","nice","nohup","nproc","pathchk","pinky","printenv","printf","pwd","readlink","runcon","seq","sleep","stat","stdbuf","stty","tee","test","timeout","tty","uname","unlink","uptime","users","who","whoami","yes"];return{name:"Bash",aliases:["sh","zsh"],keywords:{$pattern:/\b[a-z][a-z0-9._-]+\b/,keyword:g,literal:y,built_in:[...x,...E,"set","shopt",...S,...M]},contains:[f,t.SHEBANG(),p,d,o,i,b,l,a,c,u,n]}}const xD=t=>({IMPORTANT:{scope:"meta",begin:"!important"},BLOCK_COMMENT:t.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",contains:[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{scope:"number",begin:t.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}}),wD=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video"],vD=["defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],kD=[...wD,...vD],SD=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),CD=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),ED=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),MD=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse();function AD(t){const e=t.regex,n=xD(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",o=/@-?\w[\w]*(-\w+)*/,i="[a-zA-Z-][a-zA-Z0-9_-]*",l=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE];return{name:"CSS",case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},classNameAliases:{keyframePosition:"selector-tag"},contains:[n.BLOCK_COMMENT,r,n.CSS_NUMBER_MODE,{className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{className:"selector-class",begin:"\\."+i,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+CD.join("|")+")"},{begin:":(:)?("+ED.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+MD.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...l,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...l,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:o},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:SD.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...l,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+kD.join("|")+")\\b"}]}}const Um="[A-Za-z$_][0-9A-Za-z$_]*",TD=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],ND=["true","false","null","undefined","NaN","Infinity"],Px=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Bx=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Hx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],RD=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],_D=[].concat(Hx,Px,Bx);function OD(t){const e=t.regex,n=(F,{after:le})=>{const Se="</"+F[0].slice(1);return F.input.indexOf(Se,le)!==-1},r=Um,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,le)=>{const Se=F[0].length+F.index,Te=F.input[Se];if(Te==="<"||Te===","){le.ignoreMatch();return}Te===">"&&(n(F,{after:Se})||le.ignoreMatch());let Mt;const dt=F.input.substring(Se);if(Mt=dt.match(/^\s*=/)){le.ignoreMatch();return}if((Mt=dt.match(/^\s+extends\s+/))&&Mt.index===0){le.ignoreMatch();return}}},l={$pattern:Um,keyword:TD,literal:ND,built_in:_D,"variable.language":RD},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},E=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},d];h.contains=E.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(E)});const S=[].concat(x,h.contains),M=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),w={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},T={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Px,...Bx]}},N={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},R={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function P(F){return e.concat("(?!",F.join("|"),")")}const L={match:e.concat(/\b/,P([...Hx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},H={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},se={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},oe="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",we={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(oe)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),N,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,x,{match:/\$\d+/},d,k,{scope:"attr",match:r+e.lookahead(":"),relevance:0},we,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:oe,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},R,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},H,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},L,B,T,se,{match:/\$[(.]/}]}}function DD(t){const e={className:"attr",begin:/"(\\.|[^\\"\r\n])*"(?=\s*:)/,relevance:1.01},n={match:/[{}[\],:]/,className:"punctuation",relevance:0},r=["true","false","null"],s={scope:"literal",beginKeywords:r.join(" ")};return{name:"JSON",aliases:["jsonc"],keywords:{literal:r},contains:[e,n,t.QUOTE_STRING_MODE,s,t.C_NUMBER_MODE,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE],illegal:"\\S"}}function LD(t){const e=t.regex,n=new RegExp("[\\p{XID_Start}_]\\p{XID_Continue}*","u"),r=["and","as","assert","async","await","break","case","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","match","nonlocal|10","not","or","pass","raise","return","try","while","with","yield"],l={$pattern:/[A-Za-z]\w+|__\w+__/,keyword:r,built_in:["__import__","abs","all","any","ascii","bin","bool","breakpoint","bytearray","bytes","callable","chr","classmethod","compile","complex","delattr","dict","dir","divmod","enumerate","eval","exec","filter","float","format","frozenset","getattr","globals","hasattr","hash","help","hex","id","input","int","isinstance","issubclass","iter","len","list","locals","map","max","memoryview","min","next","object","oct","open","ord","pow","print","property","range","repr","reversed","round","set","setattr","slice","sorted","staticmethod","str","sum","super","tuple","type","vars","zip"],literal:["__debug__","Ellipsis","False","None","NotImplemented","True"],type:["Any","Callable","Coroutine","Dict","List","Literal","Generic","Optional","Sequence","Set","Tuple","Type","Union"]},a={className:"meta",begin:/^(>>>|\.\.\.) /},c={className:"subst",begin:/\{/,end:/\}/,keywords:l,illegal:/#/},u={begin:/\{\{/,relevance:0},d={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,a,u,c]},{begin:/([uU]|[rR])'/,end:/'/,relevance:10},{begin:/([uU]|[rR])"/,end:/"/,relevance:10},{begin:/([bB]|[bB][rR]|[rR][bB])'/,end:/'/},{begin:/([bB]|[bB][rR]|[rR][bB])"/,end:/"/},{begin:/([fF][rR]|[rR][fF]|[fF])'/,end:/'/,contains:[t.BACKSLASH_ESCAPE,u,c]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,u,c]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},h="[0-9](_?[0-9])*",f=`(\\b(${h}))?\\.(${h})|\\b(${h})\\.`,p=`\\b|${r.join("|")}`,g={className:"number",relevance:0,variants:[{begin:`(\\b(${h})|(${f}))[eE][+-]?(${h})[jJ]?(?=${p})`},{begin:`(${f})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${p})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${p})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${p})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${p})`},{begin:`\\b(${h})[jJ](?=${p})`}]},y={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:l,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},b={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:["self",a,g,d,t.HASH_COMMENT_MODE]}]};return c.contains=[d,g,a],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:l,illegal:/(<\/|\?)|=>/,contains:[a,g,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},d,y,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[b]},{variants:[{match:[/\bclass/,/\s+/,n,/\s*/,/\(\s*/,n,/\s*\)/]},{match:[/\bclass/,/\s+/,n]}],scope:{1:"keyword",3:"title.class",6:"title.class.inherited"}},{className:"meta",begin:/^[\t ]*@/,end:/(?=#)|$/,contains:[g,b,d]}]}}function ID(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},o=["true","false","unknown"],i=["double precision","large object","with timezone","without timezone"],l=["bigint","binary","blob","boolean","char","character","clob","date","dec","decfloat","decimal","float","int","integer","interval","nchar","nclob","national","numeric","real","row","smallint","time","timestamp","varchar","varying","varbinary"],a=["add","asc","collation","desc","final","first","last","view"],c=["abs","acos","all","allocate","alter","and","any","are","array","array_agg","array_max_cardinality","as","asensitive","asin","asymmetric","at","atan","atomic","authorization","avg","begin","begin_frame","begin_partition","between","bigint","binary","blob","boolean","both","by","call","called","cardinality","cascaded","case","cast","ceil","ceiling","char","char_length","character","character_length","check","classifier","clob","close","coalesce","collate","collect","column","commit","condition","connect","constraint","contains","convert","copy","corr","corresponding","cos","cosh","count","covar_pop","covar_samp","create","cross","cube","cume_dist","current","current_catalog","current_date","current_default_transform_group","current_path","current_role","current_row","current_schema","current_time","current_timestamp","current_path","current_role","current_transform_group_for_type","current_user","cursor","cycle","date","day","deallocate","dec","decimal","decfloat","declare","default","define","delete","dense_rank","deref","describe","deterministic","disconnect","distinct","double","drop","dynamic","each","element","else","empty","end","end_frame","end_partition","end-exec","equals","escape","every","except","exec","execute","exists","exp","external","extract","false","fetch","filter","first_value","float","floor","for","foreign","frame_row","free","from","full","function","fusion","get","global","grant","group","grouping","groups","having","hold","hour","identity","in","indicator","initial","inner","inout","insensitive","insert","int","integer","intersect","intersection","interval","into","is","join","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","language","large","last_value","lateral","lead","leading","left","like","like_regex","listagg","ln","local","localtime","localtimestamp","log","log10","lower","match","match_number","match_recognize","matches","max","member","merge","method","min","minute","mod","modifies","module","month","multiset","national","natural","nchar","nclob","new","no","none","normalize","not","nth_value","ntile","null","nullif","numeric","octet_length","occurrences_regex","of","offset","old","omit","on","one","only","open","or","order","out","outer","over","overlaps","overlay","parameter","partition","pattern","per","percent","percent_rank","percentile_cont","percentile_disc","period","portion","position","position_regex","power","precedes","precision","prepare","primary","procedure","ptf","range","rank","reads","real","recursive","ref","references","referencing","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","release","result","return","returns","revoke","right","rollback","rollup","row","row_number","rows","running","savepoint","scope","scroll","search","second","seek","select","sensitive","session_user","set","show","similar","sin","sinh","skip","smallint","some","specific","specifictype","sql","sqlexception","sqlstate","sqlwarning","sqrt","start","static","stddev_pop","stddev_samp","submultiset","subset","substring","substring_regex","succeeds","sum","symmetric","system","system_time","system_user","table","tablesample","tan","tanh","then","time","timestamp","timezone_hour","timezone_minute","to","trailing","translate","translate_regex","translation","treat","trigger","trim","trim_array","true","truncate","uescape","union","unique","unknown","unnest","update","upper","user","using","value","values","value_of","var_pop","var_samp","varbinary","varchar","varying","versioning","when","whenever","where","width_bucket","window","with","within","without","year"],u=["abs","acos","array_agg","asin","atan","avg","cast","ceil","ceiling","coalesce","corr","cos","cosh","count","covar_pop","covar_samp","cume_dist","dense_rank","deref","element","exp","extract","first_value","floor","json_array","json_arrayagg","json_exists","json_object","json_objectagg","json_query","json_table","json_table_primitive","json_value","lag","last_value","lead","listagg","ln","log","log10","lower","max","min","mod","nth_value","ntile","nullif","percent_rank","percentile_cont","percentile_disc","position","position_regex","power","rank","regr_avgx","regr_avgy","regr_count","regr_intercept","regr_r2","regr_slope","regr_sxx","regr_sxy","regr_syy","row_number","sin","sinh","sqrt","stddev_pop","stddev_samp","substring","substring_regex","sum","tan","tanh","translate","translate_regex","treat","trim","trim_array","unnest","upper","value_of","var_pop","var_samp","width_bucket"],d=["current_catalog","current_date","current_default_transform_group","current_path","current_role","current_schema","current_transform_group_for_type","current_user","session_user","system_time","system_user","current_time","localtime","current_timestamp","localtimestamp"],h=["create table","insert into","primary key","foreign key","not null","alter table","add constraint","grouping sets","on overflow","character set","respect nulls","ignore nulls","nulls first","nulls last","depth first","breadth first"],f=u,p=[...c,...a].filter(M=>!u.includes(M)),g={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},y={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},b={match:e.concat(/\b/,e.either(...f),/\s*\(/),relevance:0,keywords:{built_in:f}};function x(M){return e.concat(/\b/,e.either(...M.map(w=>w.replace(/\s+/,"\\s+"))),/\b/)}const E={scope:"keyword",match:x(h),relevance:0};function S(M,{exceptions:w,when:T}={}){const k=T;return w=w||[],M.map(N=>N.match(/\|\d+$/)||w.includes(N)?N:k(N)?`${N}|0`:N)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:S(p,{when:M=>M.length<3}),literal:o,type:l,built_in:d},contains:[{scope:"type",match:x(i)},E,b,g,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,y]}}const ma="[A-Za-z$_][0-9A-Za-z$_]*",$x=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends","using"],zx=["true","false","null","undefined","NaN","Infinity"],Fx=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],Ux=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],Vx=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],Wx=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],qx=[].concat(Vx,Fx,Ux);function jD(t){const e=t.regex,n=(F,{after:le})=>{const Se="</"+F[0].slice(1);return F.input.indexOf(Se,le)!==-1},r=ma,s={begin:"<>",end:"</>"},o=/<[A-Za-z0-9\\._:-]+\s*\/>/,i={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(F,le)=>{const Se=F[0].length+F.index,Te=F.input[Se];if(Te==="<"||Te===","){le.ignoreMatch();return}Te===">"&&(n(F,{after:Se})||le.ignoreMatch());let Mt;const dt=F.input.substring(Se);if(Mt=dt.match(/^\s*=/)){le.ignoreMatch();return}if((Mt=dt.match(/^\s+extends\s+/))&&Mt.index===0){le.ignoreMatch();return}}},l={$pattern:ma,keyword:$x,literal:zx,built_in:qx,"variable.language":Wx},a="[0-9](_?[0-9])*",c=`\\.(${a})`,u="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",d={className:"number",variants:[{begin:`(\\b(${u})((${c})|\\.)?|(${c}))[eE][+-]?(${a})\\b`},{begin:`\\b(${u})\\b((${c})\\b|\\.)?|(${c})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},h={className:"subst",begin:"\\$\\{",end:"\\}",keywords:l,contains:[]},f={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"xml"}},p={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"css"}},g={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,h],subLanguage:"graphql"}},y={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,h]},x={className:"comment",variants:[t.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:r+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),t.C_BLOCK_COMMENT_MODE,t.C_LINE_COMMENT_MODE]},E=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,{match:/\$\d+/},d];h.contains=E.concat({begin:/\{/,end:/\}/,keywords:l,contains:["self"].concat(E)});const S=[].concat(x,h.contains),M=S.concat([{begin:/(\s*)\(/,end:/\)/,keywords:l,contains:["self"].concat(S)}]),w={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M},T={variants:[{match:[/class/,/\s+/,r,/\s+/,/extends/,/\s+/,e.concat(r,"(",e.concat(/\./,r),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,r],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:e.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...Fx,...Ux]}},N={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},R={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},B={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function P(F){return e.concat("(?!",F.join("|"),")")}const L={match:e.concat(/\b/,P([...Vx,"super","import"].map(F=>`${F}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},H={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},se={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},oe="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",we={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(oe)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:l,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),N,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,f,p,g,y,x,{match:/\$\d+/},d,k,{scope:"attr",match:r+e.lookahead(":"),relevance:0},we,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[x,t.REGEXP_MODE,{className:"function",begin:oe,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:t.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:o},{begin:i.begin,"on:begin":i.isTrulyOpeningTag,end:i.end}],subLanguage:"xml",contains:[{begin:i.begin,end:i.end,skip:!0,contains:["self"]}]}]},R,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},H,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},L,B,T,se,{match:/\$[(.]/}]}}function PD(t){const e=t.regex,n=jD(t),r=ma,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],o={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},i={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},l={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},a=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],c={$pattern:ma,keyword:$x.concat(a),literal:zx,built_in:qx.concat(s),"variable.language":Wx},u={className:"meta",begin:"@"+r},d=(g,y,b)=>{const x=g.contains.findIndex(E=>E.label===y);if(x===-1)throw new Error("can not find mode to replace");g.contains.splice(x,1,b)};Object.assign(n.keywords,c),n.exports.PARAMS_CONTAINS.push(u);const h=n.contains.find(g=>g.scope==="attr"),f=Object.assign({},h,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,h,f]),n.contains=n.contains.concat([u,o,i,f]),d(n,"shebang",t.SHEBANG()),d(n,"use_strict",l);const p=n.contains.find(g=>g.label==="func.def");return p.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function BD(t){const e=t.regex,n=e.concat(/[\p{L}_]/u,e.optional(/[\p{L}0-9_.-]*:/u),/[\p{L}0-9_.-]*/u),r=/[\p{L}0-9._:-]+/u,s={className:"symbol",begin:/&[a-z]+;|&#[0-9]+;|&#x[a-f0-9]+;/},o={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},i=t.inherit(o,{begin:/\(/,end:/\)/}),l=t.inherit(t.APOS_STRING_MODE,{className:"string"}),a=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),c={endsWithParent:!0,illegal:/</,relevance:0,contains:[{className:"attr",begin:r,relevance:0},{begin:/=\s*/,relevance:0,contains:[{className:"string",endsParent:!0,variants:[{begin:/"/,end:/"/,contains:[s]},{begin:/'/,end:/'/,contains:[s]},{begin:/[^\s"'=<>`]+/}]}]}]};return{name:"HTML, XML",aliases:["html","xhtml","rss","atom","xjb","xsd","xsl","plist","wsf","svg"],case_insensitive:!0,unicodeRegex:!0,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,relevance:10,contains:[o,a,l,i,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[o,i,a,l]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[a]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[c],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[c],starts:{end:/<\/script>/,returnEnd:!0,subLanguage:["javascript","handlebars","xml"]}},{className:"tag",begin:/<>|<\/>/},{className:"tag",begin:e.concat(/</,e.lookahead(e.concat(n,e.either(/\/>/,/>/,/\s/)))),end:/\/?>/,contains:[{className:"name",begin:n,relevance:0,starts:c}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}const Vm={},HD="hljs-";function $D(t){const e=Qb.newInstance();return t&&o(t),{highlight:n,highlightAuto:r,listLanguages:s,register:o,registerAlias:i,registered:l};function n(a,c,u){const d=u||Vm,h=typeof d.prefix=="string"?d.prefix:HD;if(!e.getLanguage(a))throw new Error("Unknown language: `"+a+"` is not registered");e.configure({__emitter:zD,classPrefix:h});const f=e.highlight(c,{ignoreIllegals:!0,language:a});if(f.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:f.errorRaised});const p=f._emitter.root,g=p.data;return g.language=f.language,g.relevance=f.relevance,p}function r(a,c){const d=(c||Vm).subset||s();let h=-1,f=0,p;for(;++h<d.length;){const g=d[h];if(!e.getLanguage(g))continue;const y=n(g,a,c);y.data&&y.data.relevance!==void 0&&y.data.relevance>f&&(f=y.data.relevance,p=y)}return p||{type:"root",children:[],data:{language:void 0,relevance:f}}}function s(){return e.listLanguages()}function o(a,c){if(typeof a=="string")e.registerLanguage(a,c);else{let u;for(u in a)Object.hasOwn(a,u)&&e.registerLanguage(u,a[u])}}function i(a,c){if(typeof a=="string")e.registerAliases(typeof c=="string"?c:[...c],{languageName:a});else{let u;for(u in a)if(Object.hasOwn(a,u)){const d=a[u];e.registerAliases(typeof d=="string"?d:[...d],{languageName:u})}}}function l(a){return!!e.getLanguage(a)}}class zD{constructor(e){this.options=e,this.root={type:"root",children:[],data:{language:void 0,relevance:0}},this.stack=[this.root]}addText(e){if(e==="")return;const n=this.stack[this.stack.length-1],r=n.children[n.children.length-1];r&&r.type==="text"?r.value+=e:n.children.push({type:"text",value:e})}startScope(e){this.openNode(String(e))}endScope(){this.closeNode()}__addSublanguage(e,n){const r=this.stack[this.stack.length-1],s=e.root.children;n?r.children.push({type:"element",tagName:"span",properties:{className:[n]},children:s}):r.children.push(...s)}openNode(e){const n=this,r=e.split(".").map(function(i,l){return l?i+"_".repeat(l):n.options.classPrefix+i}),s=this.stack[this.stack.length-1],o={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(o),this.stack.push(o)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Kx=fe.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:[]}},addProseMirrorPlugins(){const t=new ye("trailingNode");return[new me({key:t,appendTransaction:(e,n,r)=>{if(!e.some(h=>h.docChanged))return null;const{doc:o,schema:i}=r,l=o.lastChild,a=this.options.node,c=i.nodes[a];if(!c||(l==null?void 0:l.type.name)===a||l&&this.options.notAfter.includes(l.type.name))return null;const u=o.content.size;return r.tr.insert(u,c.create())}})]}});var FD=FM;const UD=t=>{const{editor:e,pos:n}=t,r=e.state.doc.resolve(Math.max(n,0));return r.depth>0?r.node(r.depth-1):null},VD=t=>{const e='Press "/" to insert or start typing...',{node:n}=t,r=n.type.name,s=UD(t);if(r==="heading"){const o=n.attrs.level??1;switch(o){case 1:return"Add a title...";case 2:return"Add a section heading...";case 3:return"Add a subheading...";default:return`Heading ${o}`}}if(r==="taskItem")return"Add a task...";if(r==="listItem"){const o=s==null?void 0:s.type.name;return o==="bulletList"?"Add a bullet...":o==="orderedList"?"Add a numbered item...":"Add a list item..."}if(r==="codeBlock"){const o=n.attrs.language;return o?`Write ${o} code...`:"Write some code..."}if(r==="paragraph"){const o=s==null?void 0:s.type.name;if(!o||o==="doc")return e}return r==="doc"?e:""},Gx=FD.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",includeChildren:!0,showOnlyCurrent:!0,showOnlyWhenEditable:!0,placeholder:n=>VD(n)}},addProseMirrorPlugins(){const t=new Set(["table","tableCell","tableHeader","tableRow"]),e=n=>{const r=this.editor.state.doc.resolve(n);for(let s=r.depth;s>=0;s-=1){const o=r.node(s);if(t.has(o.type.name))return!0}return!1};return[new me({key:new ye("placeholder"),props:{decorations:({doc:n,selection:r})=>{if(!(this.editor.isEditable||!this.options.showOnlyWhenEditable))return null;const{anchor:o}=r,i=[],l=this.editor.isEmpty;return n.descendants((a,c)=>{if(e(c))return this.options.includeChildren;const u=o>=c&&o<=c+a.nodeSize,d=!a.isLeaf&&Yo(a);if((u||!this.options.showOnlyCurrent)&&d){const h=[this.options.emptyNodeClass];l&&h.push(this.options.emptyEditorClass);const f=typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:a,pos:c,hasAnchor:u}):this.options.placeholder,p=De.node(c,c+a.nodeSize,{class:h.join(" "),"data-placeholder":f});i.push(p)}return this.options.includeChildren}),i.length?be.create(n,i):null}}})]}}),WD=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{type:o,title:i,message:l,align:a,size:c,textAlign:u}=t.attrs,d={info:"bg-blue-50 text-blue-900 border-2 border-blue-200 dark:bg-blue-900/20 dark:text-blue-100 dark:border-blue-800",warning:"bg-yellow-50 text-yellow-900 border-2 border-yellow-200 dark:bg-yellow-900/20 dark:text-yellow-100 dark:border-yellow-800",error:"bg-red-50 text-red-900 border-2 border-red-200 dark:bg-red-900/20 dark:text-red-100 dark:border-red-800",success:"bg-green-50 text-green-900 border-2 border-green-200 dark:bg-green-900/20 dark:text-green-100 dark:border-green-800"},h={small:"text-sm p-2",medium:"text-base p-3",large:"text-lg p-4"},f={left:"text-left",center:"text-center",right:"text-right"},p={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Xd,{children:[m.jsx("div",{className:`${f[a]||"text-left"} cursor-grab`,onClick:()=>s(!0),"data-drag-handle":!0,children:m.jsxs("div",{className:`inline-block rounded-lg border p-2 m-1 ${d[o]||d.info} ${h[c]||h["fit-content"]} ${p[u]||p.left}`,children:[m.jsx("strong",{className:"font-bold block",children:i}),m.jsx("span",{children:l})]})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:g=>g.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit Alert"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"title",className:"block text-sm font-medium text-gray-700 mb-1",children:"Title"}),m.jsx("input",{type:"text",id:"title",defaultValue:i,onBlur:g=>e({title:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"message",className:"block text-sm font-medium text-gray-700 mb-1",children:"Message"}),m.jsx("textarea",{id:"message",defaultValue:l,onBlur:g=>e({message:g.target.value}),rows:3,className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"type",className:"block text-sm font-medium text-gray-700 mb-1",children:"Type"}),m.jsxs("select",{id:"type",defaultValue:o,onChange:g=>e({type:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"info",children:"Info"}),m.jsx("option",{value:"warning",children:"Warning"}),m.jsx("option",{value:"error",children:"Error"}),m.jsx("option",{value:"success",children:"Success"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"align",className:"block text-sm font-medium text-gray-700 mb-1",children:"Alignment"}),m.jsxs("select",{id:"align",defaultValue:a,onChange:g=>e({align:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:c,onChange:g=>e({size:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"small",children:"Small"}),m.jsx("option",{value:"medium",children:"Medium"}),m.jsx("option",{value:"large",children:"Large"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:u,onChange:g=>e({textAlign:g.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Jx=Ie.create({name:"alertWidget",group:"block",atom:!0,draggable:!0,defining:!0,addAttributes(){return{type:{default:"info",parseHTML:t=>t.getAttribute("data-type"),renderHTML:t=>({"data-type":t.type})},title:{default:"Alert",parseHTML:t=>t.getAttribute("data-title"),renderHTML:t=>({"data-title":t.title})},message:{default:"This is an alert message.",parseHTML:t=>t.getAttribute("data-message"),renderHTML:t=>({"data-message":t.message})},align:{default:"center",parseHTML:t=>t.getAttribute("data-align"),renderHTML:t=>({"data-align":t.align})},size:{default:"medium",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-alert-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",xe(t,{"data-alert-widget":""})]},addNodeView(){return Zd(WD)},addCommands(){return{setAlertWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}}),qD=({node:t,updateAttributes:e,editor:n})=>{const[r,s]=C.useState(!1),{text:o,url:i,style:l,size:a,textAlign:c}=t.attrs,u={primary:"bg-primary text-primary-foreground hover:bg-primary/90",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80"},d={"fit-content":"w-auto","full-width":"w-full"},h={left:"text-left",center:"text-center",right:"text-right"};return m.jsxs(Xd,{children:[m.jsx("div",{className:`p-2 ${h[c]||h.left} cursor-grab`,"data-drag-handle":!0,onClick:()=>s(!0),children:m.jsx("div",{role:"button",tabIndex:0,className:`inline-block px-4 py-2 rounded-md ${u[l]} ${d[a]||d["fit-content"]}`,onKeyDown:f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),s(!0))},children:o})}),r&&m.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center",onClick:()=>s(!1),children:m.jsxs("div",{className:"bg-white p-6 rounded-lg shadow-xl w-full max-w-md",onClick:f=>f.stopPropagation(),children:[m.jsx("h3",{className:"text-xl font-semibold mb-4 text-gray-800",children:"Edit CTA Button"}),m.jsxs("div",{className:"space-y-4",children:[m.jsxs("div",{children:[m.jsx("label",{htmlFor:"text",className:"block text-sm font-medium text-gray-700 mb-1",children:"Button Text"}),m.jsx("input",{type:"text",id:"text",defaultValue:o,onBlur:f=>e({text:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"url",className:"block text-sm font-medium text-gray-700 mb-1",children:"URL"}),m.jsx("input",{type:"text",id:"url",defaultValue:i,onBlur:f=>e({url:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900"})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"style",className:"block text-sm font-medium text-gray-700 mb-1",children:"Style"}),m.jsxs("select",{id:"style",defaultValue:l,onChange:f=>e({style:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"primary",children:"Primary"}),m.jsx("option",{value:"secondary",children:"Secondary"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"size",className:"block text-sm font-medium text-gray-700 mb-1",children:"Size"}),m.jsxs("select",{id:"size",defaultValue:a,onChange:f=>e({size:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"fit-content",children:"Fit Content"}),m.jsx("option",{value:"full-width",children:"Full Width"})]})]}),m.jsxs("div",{children:[m.jsx("label",{htmlFor:"textAlign",className:"block text-sm font-medium text-gray-700 mb-1",children:"Text Alignment"}),m.jsxs("select",{id:"textAlign",defaultValue:c,onChange:f=>e({textAlign:f.target.value}),className:"mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm text-gray-900",children:[m.jsx("option",{value:"left",children:"Left"}),m.jsx("option",{value:"center",children:"Center"}),m.jsx("option",{value:"right",children:"Right"})]})]})]}),m.jsx("div",{className:"mt-6 flex justify-end",children:m.jsx("button",{onClick:()=>s(!1),className:"px-4 py-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:"Done"})})]})})]})},Yx=Ie.create({name:"ctaWidget",group:"block",draggable:!0,atom:!0,defining:!0,addAttributes(){return{text:{default:"Click Here",parseHTML:t=>t.getAttribute("data-text"),renderHTML:t=>({"data-text":t.text})},url:{default:"#",parseHTML:t=>t.getAttribute("data-url"),renderHTML:t=>({"data-url":t.url})},style:{default:"primary",parseHTML:t=>t.getAttribute("data-style"),renderHTML:t=>({"data-style":t.style})},size:{default:"fit-content",parseHTML:t=>t.getAttribute("data-size"),renderHTML:t=>({"data-size":t.size})},textAlign:{default:"left",parseHTML:t=>t.getAttribute("data-text-align"),renderHTML:t=>({"data-text-align":t.textAlign})}}},parseHTML(){return[{tag:"div[data-cta-widget]",priority:52}]},renderHTML({HTMLAttributes:t}){return["div",xe(t,{"data-cta-widget":""})]},addNodeView(){return Zd(qD)},addCommands(){return{setCtaWidget:(t={})=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}}});function KD(t){var e;const{char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:l}=t,a=r&&!s,c=VC(n),u=new RegExp(`\\s${c}$`),d=i?"^":"",h=s?"":c,f=a?new RegExp(`${d}${c}.*?(?=\\s${h}|$)`,"gm"):new RegExp(`${d}(?:^)?${c}[^\\s${h}]*`,"gm"),p=((e=l.nodeBefore)==null?void 0:e.isText)&&l.nodeBefore.text;if(!p)return null;const g=l.pos-p.length,y=Array.from(p.matchAll(f)).pop();if(!y||y.input===void 0||y.index===void 0)return null;const b=y.input.slice(Math.max(0,y.index-1),y.index),x=new RegExp(`^[${o==null?void 0:o.join("")}\0]?$`).test(b);if(o!==null&&!x)return null;const E=g+y.index;let S=E+y[0].length;return a&&u.test(p.slice(S-1,S+1))&&(y[0]+=" ",S+=1),E<l.pos&&S>=l.pos?{range:{from:E,to:S},query:y[0].slice(n.length),text:y[0]}:null}var GD=new ye("suggestion");function JD({pluginKey:t=GD,editor:e,char:n="@",allowSpaces:r=!1,allowToIncludeChar:s=!1,allowedPrefixes:o=[" "],startOfLine:i=!1,decorationTag:l="span",decorationClass:a="suggestion",decorationContent:c="",decorationEmptyClass:u="is-empty",command:d=()=>null,items:h=()=>[],render:f=()=>({}),allow:p=()=>!0,findSuggestionMatch:g=KD}){let y;const b=f==null?void 0:f(),x=new me({key:t,view(){return{update:async(E,S)=>{var M,w,T,k,N,R,B;const P=(M=this.key)==null?void 0:M.getState(S),L=(w=this.key)==null?void 0:w.getState(E.state),H=P.active&&L.active&&P.range.from!==L.range.from,se=!P.active&&L.active,oe=P.active&&!L.active,we=!se&&!oe&&P.query!==L.query,F=se||H&&we,le=we||H,Se=oe||H&&we;if(!F&&!le&&!Se)return;const Te=Se&&!F?P:L,Mt=E.dom.querySelector(`[data-decoration-id="${Te.decorationId}"]`);y={editor:e,range:Te.range,query:Te.query,text:Te.text,items:[],command:dt=>d({editor:e,range:Te.range,props:dt}),decorationNode:Mt,clientRect:Mt?()=>{var dt;const{decorationId:Cn}=(dt=this.key)==null?void 0:dt.getState(e.state),Cr=E.dom.querySelector(`[data-decoration-id="${Cn}"]`);return(Cr==null?void 0:Cr.getBoundingClientRect())||null}:null},F&&((T=b==null?void 0:b.onBeforeStart)==null||T.call(b,y)),le&&((k=b==null?void 0:b.onBeforeUpdate)==null||k.call(b,y)),(le||F)&&(y.items=await h({editor:e,query:Te.query})),Se&&((N=b==null?void 0:b.onExit)==null||N.call(b,y)),le&&((R=b==null?void 0:b.onUpdate)==null||R.call(b,y)),F&&((B=b==null?void 0:b.onStart)==null||B.call(b,y))},destroy:()=>{var E;y&&((E=b==null?void 0:b.onExit)==null||E.call(b,y))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(E,S,M,w){const{isEditable:T}=e,{composing:k}=e.view,{selection:N}=E,{empty:R,from:B}=N,P={...S};if(P.composing=k,T&&(R||e.view.composing)){(B<S.range.from||B>S.range.to)&&!k&&!S.composing&&(P.active=!1);const L=g({char:n,allowSpaces:r,allowToIncludeChar:s,allowedPrefixes:o,startOfLine:i,$position:N.$from}),H=`id_${Math.floor(Math.random()*4294967295)}`;L&&p({editor:e,state:w,range:L.range,isActive:S.active})?(P.active=!0,P.decorationId=S.decorationId?S.decorationId:H,P.range=L.range,P.query=L.query,P.text=L.text):P.active=!1}else P.active=!1;return P.active||(P.decorationId=null,P.range={from:0,to:0},P.query=null,P.text=null),P}},props:{handleKeyDown(E,S){var M;const{active:w,range:T}=x.getState(E.state);return w&&((M=b==null?void 0:b.onKeyDown)==null?void 0:M.call(b,{view:E,event:S,range:T}))||!1},decorations(E){const{active:S,range:M,decorationId:w,query:T}=x.getState(E);if(!S)return null;const k=!(T!=null&&T.length),N=[a];return k&&N.push(u),be.create(E.doc,[De.inline(M.from,M.to,{nodeName:l,class:N.join(" "),"data-decoration-id":w,"data-decoration-content":c})])}}});return x}/**
160
+ * @license lucide-react v0.534.0 - ISC
161
+ *
162
+ * This source code is licensed under the ISC license.
163
+ * See the LICENSE file in the root directory of this source tree.
164
+ */const YD=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),XD=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Wm=t=>{const e=XD(t);return e.charAt(0).toUpperCase()+e.slice(1)},Xx=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),ZD=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};/**
165
+ * @license lucide-react v0.534.0 - ISC
166
+ *
167
+ * This source code is licensed under the ISC license.
168
+ * See the LICENSE file in the root directory of this source tree.
169
+ */var QD={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
170
+ * @license lucide-react v0.534.0 - ISC
171
+ *
172
+ * This source code is licensed under the ISC license.
173
+ * See the LICENSE file in the root directory of this source tree.
174
+ */const eL=C.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:o,iconNode:i,...l},a)=>C.createElement("svg",{ref:a,...QD,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:Xx("lucide",s),...!o&&!ZD(l)&&{"aria-hidden":"true"},...l},[...i.map(([c,u])=>C.createElement(c,u)),...Array.isArray(o)?o:[o]]));/**
175
+ * @license lucide-react v0.534.0 - ISC
176
+ *
177
+ * This source code is licensed under the ISC license.
178
+ * See the LICENSE file in the root directory of this source tree.
179
+ */const X=(t,e)=>{const n=C.forwardRef(({className:r,...s},o)=>C.createElement(eL,{ref:o,iconNode:e,className:Xx(`lucide-${YD(Wm(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Wm(t),n};/**
180
+ * @license lucide-react v0.534.0 - ISC
181
+ *
182
+ * This source code is licensed under the ISC license.
183
+ * See the LICENSE file in the root directory of this source tree.
184
+ */const tL=[["path",{d:"M17 12H7",key:"16if0g"}],["path",{d:"M19 18H5",key:"18s9l3"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],ii=X("align-center",tL);/**
185
+ * @license lucide-react v0.534.0 - ISC
186
+ *
187
+ * This source code is licensed under the ISC license.
188
+ * See the LICENSE file in the root directory of this source tree.
189
+ */const nL=[["path",{d:"M15 12H3",key:"6jk70r"}],["path",{d:"M17 18H3",key:"1amg6g"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],Ds=X("align-left",nL);/**
190
+ * @license lucide-react v0.534.0 - ISC
191
+ *
192
+ * This source code is licensed under the ISC license.
193
+ * See the LICENSE file in the root directory of this source tree.
194
+ */const rL=[["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 18h18",key:"1h113x"}],["path",{d:"M3 6h18",key:"d0wm0j"}]],Ph=X("align-justify",rL);/**
195
+ * @license lucide-react v0.534.0 - ISC
196
+ *
197
+ * This source code is licensed under the ISC license.
198
+ * See the LICENSE file in the root directory of this source tree.
199
+ */const sL=[["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M21 18H7",key:"1ygte8"}],["path",{d:"M21 6H3",key:"1jwq7v"}]],li=X("align-right",sL);/**
200
+ * @license lucide-react v0.534.0 - ISC
201
+ *
202
+ * This source code is licensed under the ISC license.
203
+ * See the LICENSE file in the root directory of this source tree.
204
+ */const oL=[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]],ga=X("bold",oL);/**
205
+ * @license lucide-react v0.534.0 - ISC
206
+ *
207
+ * This source code is licensed under the ISC license.
208
+ * See the LICENSE file in the root directory of this source tree.
209
+ */const iL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],qm=X("circle-alert",iL);/**
210
+ * @license lucide-react v0.534.0 - ISC
211
+ *
212
+ * This source code is licensed under the ISC license.
213
+ * See the LICENSE file in the root directory of this source tree.
214
+ */const lL=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],aL=X("circle-check-big",lL);/**
215
+ * @license lucide-react v0.534.0 - ISC
216
+ *
217
+ * This source code is licensed under the ISC license.
218
+ * See the LICENSE file in the root directory of this source tree.
219
+ */const cL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],uL=X("circle-plus",cL);/**
220
+ * @license lucide-react v0.534.0 - ISC
221
+ *
222
+ * This source code is licensed under the ISC license.
223
+ * See the LICENSE file in the root directory of this source tree.
224
+ */const dL=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],hL=X("circle-x",dL);/**
225
+ * @license lucide-react v0.534.0 - ISC
226
+ *
227
+ * This source code is licensed under the ISC license.
228
+ * See the LICENSE file in the root directory of this source tree.
229
+ */const fL=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],Fr=X("code-xml",fL);/**
230
+ * @license lucide-react v0.534.0 - ISC
231
+ *
232
+ * This source code is licensed under the ISC license.
233
+ * See the LICENSE file in the root directory of this source tree.
234
+ */const pL=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],Fs=X("code",pL);/**
235
+ * @license lucide-react v0.534.0 - ISC
236
+ *
237
+ * This source code is licensed under the ISC license.
238
+ * See the LICENSE file in the root directory of this source tree.
239
+ */const mL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]],gL=X("columns-2",mL);/**
240
+ * @license lucide-react v0.534.0 - ISC
241
+ *
242
+ * This source code is licensed under the ISC license.
243
+ * See the LICENSE file in the root directory of this source tree.
244
+ */const yL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],bL=X("columns-3",yL);/**
245
+ * @license lucide-react v0.534.0 - ISC
246
+ *
247
+ * This source code is licensed under the ISC license.
248
+ * See the LICENSE file in the root directory of this source tree.
249
+ */const xL=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Zx=X("download",xL);/**
250
+ * @license lucide-react v0.534.0 - ISC
251
+ *
252
+ * This source code is licensed under the ISC license.
253
+ * See the LICENSE file in the root directory of this source tree.
254
+ */const wL=[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]],vL=X("eraser",wL);/**
255
+ * @license lucide-react v0.534.0 - ISC
256
+ *
257
+ * This source code is licensed under the ISC license.
258
+ * See the LICENSE file in the root directory of this source tree.
259
+ */const kL=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],SL=X("eye",kL);/**
260
+ * @license lucide-react v0.534.0 - ISC
261
+ *
262
+ * This source code is licensed under the ISC license.
263
+ * See the LICENSE file in the root directory of this source tree.
264
+ */const CL=[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]],EL=X("file-code-2",CL);/**
265
+ * @license lucide-react v0.534.0 - ISC
266
+ *
267
+ * This source code is licensed under the ISC license.
268
+ * See the LICENSE file in the root directory of this source tree.
269
+ */const ML=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],AL=X("grip-vertical",ML);/**
270
+ * @license lucide-react v0.534.0 - ISC
271
+ *
272
+ * This source code is licensed under the ISC license.
273
+ * See the LICENSE file in the root directory of this source tree.
274
+ */const TL=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],NL=X("hash",TL);/**
275
+ * @license lucide-react v0.534.0 - ISC
276
+ *
277
+ * This source code is licensed under the ISC license.
278
+ * See the LICENSE file in the root directory of this source tree.
279
+ */const RL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"m17 12 3-2v8",key:"1hhhft"}]],Ls=X("heading-1",RL);/**
280
+ * @license lucide-react v0.534.0 - ISC
281
+ *
282
+ * This source code is licensed under the ISC license.
283
+ * See the LICENSE file in the root directory of this source tree.
284
+ */const _L=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1",key:"9jr5yi"}]],ai=X("heading-2",_L);/**
285
+ * @license lucide-react v0.534.0 - ISC
286
+ *
287
+ * This source code is licensed under the ISC license.
288
+ * See the LICENSE file in the root directory of this source tree.
289
+ */const OL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2",key:"68ncm8"}],["path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2",key:"1ejuhz"}]],Ga=X("heading-3",OL);/**
290
+ * @license lucide-react v0.534.0 - ISC
291
+ *
292
+ * This source code is licensed under the ISC license.
293
+ * See the LICENSE file in the root directory of this source tree.
294
+ */const DL=[["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 10v3a1 1 0 0 0 1 1h3",key:"tj5zdr"}],["path",{d:"M21 10v8",key:"1kdml4"}],["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}]],LL=X("heading-4",DL);/**
295
+ * @license lucide-react v0.534.0 - ISC
296
+ *
297
+ * This source code is licensed under the ISC license.
298
+ * See the LICENSE file in the root directory of this source tree.
299
+ */const IL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["path",{d:"M17 13v-3h4",key:"1nvgqp"}],["path",{d:"M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17",key:"2nebdn"}]],jL=X("heading-5",IL);/**
300
+ * @license lucide-react v0.534.0 - ISC
301
+ *
302
+ * This source code is licensed under the ISC license.
303
+ * See the LICENSE file in the root directory of this source tree.
304
+ */const PL=[["path",{d:"M4 12h8",key:"17cfdx"}],["path",{d:"M4 18V6",key:"1rz3zl"}],["path",{d:"M12 18V6",key:"zqpxq5"}],["circle",{cx:"19",cy:"16",r:"2",key:"15mx69"}],["path",{d:"M20 10c-2 2-3 3.5-3 6",key:"f35dl0"}]],BL=X("heading-6",PL);/**
305
+ * @license lucide-react v0.534.0 - ISC
306
+ *
307
+ * This source code is licensed under the ISC license.
308
+ * See the LICENSE file in the root directory of this source tree.
309
+ */const HL=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],es=X("image",HL);/**
310
+ * @license lucide-react v0.534.0 - ISC
311
+ *
312
+ * This source code is licensed under the ISC license.
313
+ * See the LICENSE file in the root directory of this source tree.
314
+ */const $L=[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]],Bh=X("italic",$L);/**
315
+ * @license lucide-react v0.534.0 - ISC
316
+ *
317
+ * This source code is licensed under the ISC license.
318
+ * See the LICENSE file in the root directory of this source tree.
319
+ */const zL=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Ja=X("link-2",zL);/**
320
+ * @license lucide-react v0.534.0 - ISC
321
+ *
322
+ * This source code is licensed under the ISC license.
323
+ * See the LICENSE file in the root directory of this source tree.
324
+ */const FL=[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]],ci=X("list-ordered",FL);/**
325
+ * @license lucide-react v0.534.0 - ISC
326
+ *
327
+ * This source code is licensed under the ISC license.
328
+ * See the LICENSE file in the root directory of this source tree.
329
+ */const UL=[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]],Us=X("list",UL);/**
330
+ * @license lucide-react v0.534.0 - ISC
331
+ *
332
+ * This source code is licensed under the ISC license.
333
+ * See the LICENSE file in the root directory of this source tree.
334
+ */const VL=[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]],Ya=X("megaphone",VL);/**
335
+ * @license lucide-react v0.534.0 - ISC
336
+ *
337
+ * This source code is licensed under the ISC license.
338
+ * See the LICENSE file in the root directory of this source tree.
339
+ */const WL=[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]],qL=X("menu",WL);/**
340
+ * @license lucide-react v0.534.0 - ISC
341
+ *
342
+ * This source code is licensed under the ISC license.
343
+ * See the LICENSE file in the root directory of this source tree.
344
+ */const KL=[["path",{d:"M5 12h14",key:"1ays0h"}]],Xa=X("minus",KL);/**
345
+ * @license lucide-react v0.534.0 - ISC
346
+ *
347
+ * This source code is licensed under the ISC license.
348
+ * See the LICENSE file in the root directory of this source tree.
349
+ */const GL=[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]],Hh=X("palette",GL);/**
350
+ * @license lucide-react v0.534.0 - ISC
351
+ *
352
+ * This source code is licensed under the ISC license.
353
+ * See the LICENSE file in the root directory of this source tree.
354
+ */const JL=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],YL=X("play",JL);/**
355
+ * @license lucide-react v0.534.0 - ISC
356
+ *
357
+ * This source code is licensed under the ISC license.
358
+ * See the LICENSE file in the root directory of this source tree.
359
+ */const XL=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],ZL=X("redo-2",XL);/**
360
+ * @license lucide-react v0.534.0 - ISC
361
+ *
362
+ * This source code is licensed under the ISC license.
363
+ * See the LICENSE file in the root directory of this source tree.
364
+ */const QL=[["path",{d:"M14 4a2 2 0 0 1 2-2",key:"1w2hp7"}],["path",{d:"M16 10a2 2 0 0 1-2-2",key:"shjach"}],["path",{d:"M20 2a2 2 0 0 1 2 2",key:"188mtx"}],["path",{d:"M22 8a2 2 0 0 1-2 2",key:"ddf4tu"}],["path",{d:"m3 7 3 3 3-3",key:"x25e72"}],["path",{d:"M6 10V5a3 3 0 0 1 3-3h1",key:"3y3t5z"}],["rect",{x:"2",y:"14",width:"8",height:"8",rx:"2",key:"4rksxw"}]],eI=X("replace",QL);/**
365
+ * @license lucide-react v0.534.0 - ISC
366
+ *
367
+ * This source code is licensed under the ISC license.
368
+ * See the LICENSE file in the root directory of this source tree.
369
+ */const tI=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],nI=X("rotate-ccw",tI);/**
370
+ * @license lucide-react v0.534.0 - ISC
371
+ *
372
+ * This source code is licensed under the ISC license.
373
+ * See the LICENSE file in the root directory of this source tree.
374
+ */const rI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 12h18",key:"1i2n21"}]],sI=X("rows-2",rI);/**
375
+ * @license lucide-react v0.534.0 - ISC
376
+ *
377
+ * This source code is licensed under the ISC license.
378
+ * See the LICENSE file in the root directory of this source tree.
379
+ */const oI=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]],iI=X("rows-3",oI);/**
380
+ * @license lucide-react v0.534.0 - ISC
381
+ *
382
+ * This source code is licensed under the ISC license.
383
+ * See the LICENSE file in the root directory of this source tree.
384
+ */const lI=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],aI=X("search",lI);/**
385
+ * @license lucide-react v0.534.0 - ISC
386
+ *
387
+ * This source code is licensed under the ISC license.
388
+ * See the LICENSE file in the root directory of this source tree.
389
+ */const cI=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Za=X("square-check-big",cI);/**
390
+ * @license lucide-react v0.534.0 - ISC
391
+ *
392
+ * This source code is licensed under the ISC license.
393
+ * See the LICENSE file in the root directory of this source tree.
394
+ */const uI=[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]],Qx=X("strikethrough",uI);/**
395
+ * @license lucide-react v0.534.0 - ISC
396
+ *
397
+ * This source code is licensed under the ISC license.
398
+ * See the LICENSE file in the root directory of this source tree.
399
+ */const dI=[["path",{d:"m4 5 8 8",key:"1eunvl"}],["path",{d:"m12 5-8 8",key:"1ah0jp"}],["path",{d:"M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07",key:"e8ta8j"}]],ew=X("subscript",dI);/**
400
+ * @license lucide-react v0.534.0 - ISC
401
+ *
402
+ * This source code is licensed under the ISC license.
403
+ * See the LICENSE file in the root directory of this source tree.
404
+ */const hI=[["path",{d:"m4 19 8-8",key:"hr47gm"}],["path",{d:"m12 19-8-8",key:"1dhhmo"}],["path",{d:"M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06",key:"1dfcux"}]],tw=X("superscript",hI);/**
405
+ * @license lucide-react v0.534.0 - ISC
406
+ *
407
+ * This source code is licensed under the ISC license.
408
+ * See the LICENSE file in the root directory of this source tree.
409
+ */const fI=[["path",{d:"M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",key:"gugj83"}]],ui=X("table-2",fI);/**
410
+ * @license lucide-react v0.534.0 - ISC
411
+ *
412
+ * This source code is licensed under the ISC license.
413
+ * See the LICENSE file in the root directory of this source tree.
414
+ */const pI=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],mI=X("terminal",pI);/**
415
+ * @license lucide-react v0.534.0 - ISC
416
+ *
417
+ * This source code is licensed under the ISC license.
418
+ * See the LICENSE file in the root directory of this source tree.
419
+ */const gI=[["path",{d:"M17 6H3",key:"16j9eg"}],["path",{d:"M21 12H8",key:"scolzb"}],["path",{d:"M21 18H8",key:"1wfozv"}],["path",{d:"M3 12v6",key:"fv4c87"}]],di=X("text-quote",gI);/**
420
+ * @license lucide-react v0.534.0 - ISC
421
+ *
422
+ * This source code is licensed under the ISC license.
423
+ * See the LICENSE file in the root directory of this source tree.
424
+ */const yI=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],nw=X("trash-2",yI);/**
425
+ * @license lucide-react v0.534.0 - ISC
426
+ *
427
+ * This source code is licensed under the ISC license.
428
+ * See the LICENSE file in the root directory of this source tree.
429
+ */const bI=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Qa=X("triangle-alert",bI);/**
430
+ * @license lucide-react v0.534.0 - ISC
431
+ *
432
+ * This source code is licensed under the ISC license.
433
+ * See the LICENSE file in the root directory of this source tree.
434
+ */const xI=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],ss=X("type",xI);/**
435
+ * @license lucide-react v0.534.0 - ISC
436
+ *
437
+ * This source code is licensed under the ISC license.
438
+ * See the LICENSE file in the root directory of this source tree.
439
+ */const wI=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4",key:"9kb039"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20",key:"nun2al"}]],$h=X("underline",wI);/**
440
+ * @license lucide-react v0.534.0 - ISC
441
+ *
442
+ * This source code is licensed under the ISC license.
443
+ * See the LICENSE file in the root directory of this source tree.
444
+ */const vI=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],kI=X("undo-2",vI);/**
445
+ * @license lucide-react v0.534.0 - ISC
446
+ *
447
+ * This source code is licensed under the ISC license.
448
+ * See the LICENSE file in the root directory of this source tree.
449
+ */const SI=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],rw=X("video",SI);/**
450
+ * @license lucide-react v0.534.0 - ISC
451
+ *
452
+ * This source code is licensed under the ISC license.
453
+ * See the LICENSE file in the root directory of this source tree.
454
+ */const CI=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],sw=X("x",CI),zh=C.forwardRef(({items:t,command:e},n)=>{const[r,s]=C.useState(-1),o=C.useRef(null),i=a=>{const c=t[a];c&&e(c)};C.useEffect(()=>{if(t.length===0){s(-1);return}s(a=>{if(a===-1)return-1;const c=Math.min(Math.max(a,0),t.length-1);return Number.isFinite(c)?c:-1})},[t]),C.useEffect(()=>{if(!o.current||r===-1)return;const a=o.current.querySelector(`[data-index="${r}"]`);a&&a.scrollIntoView({block:"nearest"})},[r]),C.useImperativeHandle(n,()=>({onKeyDown:({event:a})=>t.length===0?!1:a.key==="ArrowUp"?(a.preventDefault(),s(c=>c===-1?t.length-1:(c-1+t.length)%t.length),!0):a.key==="ArrowDown"?(a.preventDefault(),s(c=>c===-1?0:(c+1)%t.length),!0):a.key==="Enter"?(a.preventDefault(),r!==-1&&i(r),!0):!1}));const l=a=>{a.stopPropagation()};return m.jsx("div",{ref:o,className:"z-50 max-h-72 w-72 overflow-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md",role:"listbox","aria-activedescendant":r!==-1?`cmd-opt-${r}`:void 0,tabIndex:-1,onWheel:l,style:{scrollbarWidth:"thin",scrollbarColor:"rgb(148 163 184) transparent"},children:t.length>0?t.map((a,c)=>{const u=r!==-1&&c===r;return m.jsxs("button",{id:`cmd-opt-${c}`,"data-index":c,role:"option","aria-selected":u,type:"button",onMouseDown:d=>d.preventDefault(),onClick:()=>i(c),className:$e.cn("flex w-full items-center gap-2 rounded-sm p-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",u&&"bg-accent text-accent-foreground"),children:[m.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-md border bg-background",children:a.icon}),m.jsxs("div",{className:"min-w-0",children:[m.jsx("p",{className:"truncate font-medium",children:a.title}),a.description?m.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.description}):null]})]},`${a.title}-${c}`)}):m.jsx("div",{className:"p-2 text-sm text-muted-foreground",children:"No results"})})});zh.displayName="SlashCommandList";const EI=[{title:"Text",description:"Start writing with plain text.",icon:C.createElement(ss,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).clearNodes().run()}},{title:"Heading 1",description:"Large section heading.",icon:C.createElement(Ls,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:1}).run()}},{title:"Heading 2",description:"Medium section heading.",icon:C.createElement(ai,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:2}).run()}},{title:"Heading 3",description:"Small section heading.",icon:C.createElement(Ga,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:3}).run()}},{title:"Heading 4",description:"Extra small section heading.",icon:C.createElement(LL,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:4}).run()}},{title:"Heading 5",description:"Tiny section heading.",icon:C.createElement(jL,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:5}).run()}},{title:"Heading 6",description:"Smallest section heading.",icon:C.createElement(BL,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHeading({level:6}).run()}},{title:"Bullet List",description:"Create a simple bulleted list.",icon:C.createElement(Us,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBulletList().run()}},{title:"Numbered List",description:"Create a list with numbering.",icon:C.createElement(ci,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleOrderedList().run()}},{title:"Task List",description:"Create a list with checkboxes.",icon:C.createElement(Za,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleTaskList().run()}},{title:"Blockquote",description:"Create a quote or citation.",icon:C.createElement(di,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Code Block",description:"Create a code block with syntax highlighting.",icon:C.createElement(Fs,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).toggleCodeBlock().run()}},{title:"Horizontal Rule",description:"Insert a horizontal divider.",icon:C.createElement(Xa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setHorizontalRule().run()}},{title:"Image",description:"Insert an image from URL.",icon:C.createElement(es,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter image URL:");n&&t.chain().focus().deleteRange(e).setImage({src:n}).run()}},{title:"Table",description:"Insert a table with rows and columns.",icon:C.createElement(ui,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).insertTable({rows:3,cols:3,withHeaderRow:!0}).run()}},{title:"Align Left",description:"Align text to the left.",icon:C.createElement(Ds,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("left").run()}},{title:"Align Center",description:"Center align text.",icon:C.createElement(ii,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("center").run()}},{title:"Align Right",description:"Align text to the right.",icon:C.createElement(li,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("right").run()}},{title:"Justify",description:"Justify text alignment.",icon:C.createElement(Ph,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.chain().focus().deleteRange(e).setTextAlign("justify").run()}},{title:"Video",description:"Embed a video from URL.",icon:C.createElement(rw,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{const n=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");n&&t.chain().focus().deleteRange(e).insertContent(`<p><a href="${n}" target="_blank">Video: ${n}</a></p>`).run()}},{title:"Alert",description:"Insert an alert or notice.",icon:C.createElement(Qa,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setAlertWidget()?t.chain().focus().deleteRange(e).setAlertWidget().run():t.chain().focus().deleteRange(e).toggleBlockquote().run()}},{title:"Call to Action",description:"Insert a call to action button.",icon:C.createElement(Ya,{className:"h-5 w-5"}),command:({editor:t,range:e})=>{t.can().setCtaWidget()?t.chain().focus().deleteRange(e).setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().deleteRange(e).insertContent("Call to Action").run()}}],ow=fe.create({name:"slashCommand",addOptions(){return{suggestion:{char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command"}}},addProseMirrorPlugins(){return[JD({char:"/",allowSpaces:!1,allowedPrefixes:[" "],startOfLine:!1,decorationTag:"span",decorationClass:"slash-command",editor:this.editor,items:({query:t})=>EI.filter(n=>n.title.toLowerCase().includes(t.toLowerCase())||n.description.toLowerCase().includes(t.toLowerCase())).slice(0,10),command:({editor:t,range:e,props:n})=>{n.command({editor:t,range:e})},render:()=>{let t=null,e=null,n=null;const r=o=>({getBoundingClientRect:()=>o()||new DOMRect(0,0,0,0)}),s=async o=>{if(!e)return;const i=r(o),{x:l,y:a}=await bh(i,e,{placement:"bottom-start",middleware:[N0(6),_0({fallbackPlacements:["top-start","bottom-start"]}),R0({padding:8}),O0({apply({availableWidth:c,availableHeight:u,elements:d}){Object.assign(d.floating.style,{maxWidth:`${Math.min(288,c-16)}px`,maxHeight:`${Math.min(288,u-16)}px`})}})],strategy:"fixed"});e.style.left=`${Math.round(l)}px`,e.style.top=`${Math.round(a)}px`};return{onStart:o=>{if(!o.clientRect)return;const i=o.clientRect;t=new vb(zh,{props:o,editor:o.editor}),e=document.createElement("div"),e.style.position="fixed",e.style.zIndex="10000",e.style.top="0",e.style.left="0",e.style.pointerEvents="none",e.appendChild(t.element),t.element.style.pointerEvents="auto",t.element.addEventListener("wheel",a=>{a.stopPropagation()},{passive:!0}),document.body.appendChild(e);const l=r(i);n=Bs(l,e,()=>s(i)),s(i)},onUpdate:o=>{t==null||t.updateProps(o),o.clientRect&&s(o.clientRect)},onKeyDown:({event:o})=>{var i;return o.key==="Escape"?!0:((i=t==null?void 0:t.ref)==null?void 0:i.onKeyDown({event:o}))??!1},onExit:()=>{n==null||n(),n=null,t==null||t.destroy(),t=null,e==null||e.remove(),e=null}}}})]}});var MI=ah,AI=uh;gM.extend({draggable:!0});_E.extend({draggable:!0});yE.extend({draggable:!0});MI.extend({draggable:!0});AI.extend({draggable:!0});r0.extend({draggable:!0});s0.extend({draggable:!0});t0.extend({draggable:!0});n0.extend({draggable:!0});const iw=fe.create({name:"draggableNodes",addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","bulletList","orderedList","taskList","taskItem","codeBlock","image"],attributes:{draggable:{default:!0,parseHTML:()=>!0,renderHTML:()=>({"data-draggable":"true"})}}}]}}),TI=Ie.create({name:"styleTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{cssContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/css",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},media:{default:null,parseHTML:t=>t.getAttribute("media"),renderHTML:t=>t.media?{media:t.media}:{}}}},parseHTML(){return[{tag:"style",getAttrs:t=>{const e=t,n={cssContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("media");return r!==null&&(n.media=r),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.cssContent,["style",n,e.attrs.cssContent||""]},addNodeView(){return({node:t,editor:e,getPos:n})=>{const r=document.createElement("div");return r.setAttribute("data-style-node-placeholder","true"),r.style.border="1px dashed #999",r.style.padding="8px",r.style.margin="1rem 0",r.style.fontFamily="monospace",r.style.fontSize="0.9em",r.style.color="#555",r.style.cursor="pointer",r.textContent="[Custom CSS Block - Edit in Source View]",r.contentEditable="false",r.title="Click to open Source View",r.addEventListener("click",()=>{try{e==null||e.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:r}}}}),NI=Ie.create({name:"divBlock",group:"block",content:"block*",defining:!0,draggable:!0,addOptions(){return{HTMLAttributes:{}}},addAttributes(){return{class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}}}},parseHTML(){return[{tag:"div",priority:51,getAttrs:t=>{const e=t,n={};for(let r=0;r<e.attributes.length;r++){const s=e.attributes[r];n[s.name]=s.value}return n}}]},renderHTML({node:t}){return["div",xe(this.options.HTMLAttributes,t.attrs),0]}}),RI=fe.create({name:"preserveAllAttributesExtension",addGlobalAttributes(){return[{types:["paragraph","heading","listItem","blockquote","codeBlock","bulletList","orderedList","textStyle"],attributes:{style:{default:null,parseHTML:t=>t.getAttribute("style"),renderHTML:t=>t.style?{style:t.style}:{}},class:{default:null,parseHTML:t=>t.getAttribute("class"),renderHTML:t=>t.class?{class:t.class}:{}},id:{default:null,parseHTML:t=>t.getAttribute("id"),renderHTML:t=>t.id?{id:t.id}:{}},dataAttributes:{default:null,parseHTML:t=>{const e={};for(let n=0;n<t.attributes.length;n++){const r=t.attributes[n];r.name.startsWith("data-")&&(e[r.name]=r.value)}return Object.keys(e).length>0?e:null},renderHTML:t=>t.dataAttributes||{}}}}]}}),_I=Ie.create({name:"scriptTag",group:"block",atom:!0,isolating:!0,defining:!0,draggable:!1,addAttributes(){return{jsContent:{default:"",parseHTML:t=>t.innerHTML},type:{default:"text/javascript",parseHTML:t=>t.getAttribute("type"),renderHTML:t=>t.type?{type:t.type}:{}},src:{default:null,parseHTML:t=>t.getAttribute("src"),renderHTML:t=>t.src?{src:t.src}:{}},async:{default:null,parseHTML:t=>t.getAttribute("async"),renderHTML:t=>t.async!=null?{async:""}:{}},defer:{default:null,parseHTML:t=>t.getAttribute("defer"),renderHTML:t=>t.defer!=null?{defer:""}:{}}}},parseHTML(){return[{tag:"script",getAttrs:t=>{const e=t,n={jsContent:e.innerHTML,type:e.getAttribute("type")},r=e.getAttribute("src");return r!==null&&(n.src=r),e.hasAttribute("async")&&(n.async=""),e.hasAttribute("defer")&&(n.defer=""),n}}]},renderHTML({HTMLAttributes:t,node:e}){const n={...t};return delete n.jsContent,["script",n,e.attrs.src?"":e.attrs.jsContent||""]},addNodeView(){return({editor:t})=>{const e=document.createElement("div");return e.setAttribute("data-script-node-placeholder","true"),e.style.border="1px dashed #999",e.style.padding="8px",e.style.margin="1rem 0",e.style.fontFamily="monospace",e.style.fontSize="0.9em",e.style.color="#555",e.style.cursor="pointer",e.textContent="[Custom JavaScript Block - Edit in Source View]",e.contentEditable="false",e.title="Click to open Source View",e.addEventListener("click",()=>{try{t==null||t.chain().focus()}catch{}try{window.dispatchEvent(new CustomEvent("editor:openSourceView"))}catch{}}),{dom:e}}}});let pn=null,Zi=null;const OI=$D({html:BD,css:AD,js:OD,ts:PD,python:LD,json:DD,bash:bD,sql:ID}),Fh=[WM.configure({codeBlock:!1,link:!1,undoRedo:!1,bulletList:{HTMLAttributes:{class:"list-disc pl-4"},keepMarks:!0,keepAttributes:!1},orderedList:{HTMLAttributes:{class:"list-decimal pl-4"},keepMarks:!0,keepAttributes:!1},dropcursor:{color:"#60A5FA",width:2},gapcursor:!1}),aM.configure({openOnClick:!1,autolink:!0,defaultProtocol:"https",protocols:["http","https","ftp","mailto"],validate:t=>/^https?:\/\//.test(t),HTMLAttributes:{class:"text-primary underline underline-offset-2 hover:text-primary/80 cursor-pointer",rel:"noopener noreferrer",target:"_blank"}}),YT,vM,XT.configure({depth:100,newGroupDelay:500}),t0.configure({lowlight:OI,defaultLanguage:"plaintext",HTMLAttributes:{class:"relative rounded-md bg-muted p-4 font-mono text-sm"}}),NI,TI,_I,RI,tA.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"max-w-full h-auto rounded-md"}}),r0.configure({HTMLAttributes:{class:"list-none pl-0 space-y-1"}}),s0.configure({nested:!0,HTMLAttributes:{class:"flex items-start gap-2 my-1"}}),y0.configure({resizable:!0,cellMinWidth:100,HTMLAttributes:{class:"w-full border-collapse border border-gray-300 dark:border-gray-700 my-4"}}),sT.configure({HTMLAttributes:{class:"border-b border-gray-300 dark:border-gray-700"}}),oT.configure({HTMLAttributes:{class:"bg-gray-100 dark:bg-gray-800 font-bold p-3 text-left border border-gray-300 dark:border-gray-700"}}),iT.configure({HTMLAttributes:{class:"p-3 border border-gray-300 dark:border-gray-700 min-w-[100px]"}}),CT.configure({color:{types:["textStyle"]},fontFamily:{types:["textStyle"]},fontSize:{types:["textStyle"]}}),uT.configure({multicolor:!0,HTMLAttributes:{class:"rounded-sm px-1 py-0.5"}}),hT,pT,gT.configure({types:["heading","paragraph","div"],alignments:["left","center","right","justify"],defaultAlignment:"left"}),JT,Gx,ET.configure({limit:5e4,mode:"textSize"}),Kx,Jx,Yx,ow,iw,oD,yD.configure({render:()=>{const t=document.createElement("div");pn=t,t.classList.add("tiptap-drag-handle"),t.dataset.active="false",t.style.visibility="hidden",t.style.pointerEvents="none";const e=document.createElement("button");Zi=e,e.type="button",e.className="tiptap-drag-handle__button tiptap-drag-handle__plus",e.setAttribute("aria-label","Insert block"),e.setAttribute("aria-expanded","false"),e.draggable=!1,e.textContent="+",e.dataset.tooltip="Insert block";const n=document.createElement("span");n.className="tiptap-drag-handle__button tiptap-drag-handle__grip",n.innerHTML=`
455
+ <svg width="12" height="18" viewBox="0 0 12 18" fill="none" xmlns="http://www.w3.org/2000/svg">
456
+ <circle cx="3" cy="3" r="1.5" fill="currentColor"/>
457
+ <circle cx="9" cy="3" r="1.5" fill="currentColor"/>
458
+ <circle cx="3" cy="9" r="1.5" fill="currentColor"/>
459
+ <circle cx="9" cy="9" r="1.5" fill="currentColor"/>
460
+ <circle cx="3" cy="15" r="1.5" fill="currentColor"/>
461
+ <circle cx="9" cy="15" r="1.5" fill="currentColor"/>
462
+ </svg>
463
+ `,n.setAttribute("aria-hidden","true"),t.dataset.tooltip=`Click for options
464
+ Hold for drag`,t.appendChild(e),t.appendChild(n);const r=()=>t.classList.add("tiptap-drag-handle--hint"),s=()=>t.classList.remove("tiptap-drag-handle--hint");return n.addEventListener("mouseenter",r),n.addEventListener("mouseleave",s),t.addEventListener("mouseleave",s),e.addEventListener("mousedown",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("dragstart",o=>{o.preventDefault(),o.stopPropagation()}),e.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),e.click())}),e.addEventListener("click",o=>{o.preventDefault(),o.stopPropagation(),t.classList.remove("tiptap-drag-handle--hint");const i=new CustomEvent("tiptap-gutter-toggle",{bubbles:!0,detail:{handle:t,button:e}});t.dispatchEvent(i)}),t},onNodeChange:({editor:t,node:e})=>{if(!pn)return;const n=(e==null?void 0:e.type.name)==="doc";!!e&&!n&&t.isFocused&&t.isEditable?(pn.dataset.active="true",pn.style.visibility="",pn.style.pointerEvents="auto"):(pn.dataset.active="false",pn.classList.remove("tiptap-drag-handle--hint"),pn.removeAttribute("data-menu-open"),pn.style.visibility="hidden",pn.style.pointerEvents="none",Zi==null||Zi.setAttribute("aria-expanded","false"))}})];var DI=typeof document<"u",LI=function(){},hd=DI?C.useLayoutEffect:LI;const II={...ne},jI=II.useInsertionEffect,PI=jI||(t=>t());function BI(t){const e=ne.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return PI(()=>{e.current=t}),ne.useCallback(function(){for(var n=arguments.length,r=new Array(n),s=0;s<n;s++)r[s]=arguments[s];return e.current==null?void 0:e.current(...r)},[])}var HI=typeof document<"u",$I=function(){},fl=HI?C.useLayoutEffect:$I;function ya(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,s;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!ya(t[r],e[r]))return!1;return!0}if(s=Object.keys(t),n=s.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&t.$$typeof)&&!ya(t[o],e[o]))return!1}return!0}return t!==t&&e!==e}function lw(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function Km(t,e){const n=lw(t);return Math.round(e*n)/n}function iu(t){const e=ne.useRef(t);return fl(()=>{e.current=t}),e}function zI(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:i}={},transform:l=!0,whileElementsMounted:a,open:c}=t,[u,d]=ne.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,f]=ne.useState(r);ya(h,r)||f(r);const[p,g]=ne.useState(null),[y,b]=ne.useState(null),x=ne.useCallback(F=>{F!==w.current&&(w.current=F,g(F))},[]),E=ne.useCallback(F=>{F!==T.current&&(T.current=F,b(F))},[]),S=o||p,M=i||y,w=ne.useRef(null),T=ne.useRef(null),k=ne.useRef(u),N=a!=null,R=iu(a),B=iu(s),P=iu(c),L=ne.useCallback(()=>{if(!w.current||!T.current)return;const F={placement:e,strategy:n,middleware:h};B.current&&(F.platform=B.current),bh(w.current,T.current,F).then(le=>{const Se={...le,isPositioned:P.current!==!1};H.current&&!ya(k.current,Se)&&(k.current=Se,Yw.flushSync(()=>{d(Se)}))})},[h,e,n,B,P]);fl(()=>{c===!1&&k.current.isPositioned&&(k.current.isPositioned=!1,d(F=>({...F,isPositioned:!1})))},[c]);const H=ne.useRef(!1);fl(()=>(H.current=!0,()=>{H.current=!1}),[]),fl(()=>{if(S&&(w.current=S),M&&(T.current=M),S&&M){if(R.current)return R.current(S,M,L);L()}},[S,M,L,R,N]);const se=ne.useMemo(()=>({reference:w,floating:T,setReference:x,setFloating:E}),[x,E]),oe=ne.useMemo(()=>({reference:S,floating:M}),[S,M]),we=ne.useMemo(()=>{const F={position:n,left:0,top:0};if(!oe.floating)return F;const le=Km(oe.floating,u.x),Se=Km(oe.floating,u.y);return l?{...F,transform:"translate("+le+"px, "+Se+"px)",...lw(oe.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:le,top:Se}},[n,l,oe.floating,u.x,u.y]);return ne.useMemo(()=>({...u,update:L,refs:se,elements:oe,floatingStyles:we}),[u,L,se,oe,we])}const hi=(t,e)=>({...N0(t),options:[t,e]}),ec=(t,e)=>({...R0(t),options:[t,e]}),tc=(t,e)=>({..._0(t),options:[t,e]}),FI=(t,e)=>({...O0(t),options:[t,e]}),UI={...ne};let Gm=!1,VI=0;const Jm=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+VI++;function WI(){const[t,e]=ne.useState(()=>Gm?Jm():void 0);return hd(()=>{t==null&&e(Jm())},[]),ne.useEffect(()=>{Gm=!0},[]),t}const qI=UI.useId,KI=qI||WI;let fd;process.env.NODE_ENV!=="production"&&(fd=new Set);function GI(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];const s="Floating UI: "+n.join(" ");if(!((t=fd)!=null&&t.has(s))){var o;(o=fd)==null||o.add(s),console.error(s)}}function JI(){const t=new Map;return{emit(e,n){var r;(r=t.get(e))==null||r.forEach(s=>s(n))},on(e,n){t.has(e)||t.set(e,new Set),t.get(e).add(n)},off(e,n){var r;(r=t.get(e))==null||r.delete(n)}}}const YI=ne.createContext(null),XI=ne.createContext(null),ZI=()=>{var t;return((t=ne.useContext(YI))==null?void 0:t.id)||null},QI=()=>ne.useContext(XI);function e2(t){const{open:e=!1,onOpenChange:n,elements:r}=t,s=KI(),o=ne.useRef({}),[i]=ne.useState(()=>JI()),l=ZI()!=null;if(process.env.NODE_ENV!=="production"){const f=r.reference;f&&!gt(f)&&GI("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[a,c]=ne.useState(r.reference),u=BI((f,p,g)=>{o.current.openEvent=f?p:void 0,i.emit("openchange",{open:f,event:p,reason:g,nested:l}),n==null||n(f,p,g)}),d=ne.useMemo(()=>({setPositionReference:c}),[]),h=ne.useMemo(()=>({reference:a||r.reference||null,floating:r.floating||null,domReference:r.reference}),[a,r.reference,r.floating]);return ne.useMemo(()=>({dataRef:o,open:e,onOpenChange:u,elements:h,events:i,floatingId:s,refs:d}),[e,u,h,i,s,d])}function fi(t){t===void 0&&(t={});const{nodeId:e}=t,n=e2({...t,elements:{reference:null,floating:null,...t.elements}}),r=t.rootContext||n,s=r.elements,[o,i]=ne.useState(null),[l,a]=ne.useState(null),u=(s==null?void 0:s.domReference)||o,d=ne.useRef(null),h=QI();hd(()=>{u&&(d.current=u)},[u]);const f=zI({...t,elements:{...s,...l&&{reference:l}}}),p=ne.useCallback(E=>{const S=gt(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),getClientRects:()=>E.getClientRects(),contextElement:E}:E;a(S),f.refs.setReference(S)},[f.refs]),g=ne.useCallback(E=>{(gt(E)||E===null)&&(d.current=E,i(E)),(gt(f.refs.reference.current)||f.refs.reference.current===null||E!==null&&!gt(E))&&f.refs.setReference(E)},[f.refs]),y=ne.useMemo(()=>({...f.refs,setReference:g,setPositionReference:p,domReference:d}),[f.refs,g,p]),b=ne.useMemo(()=>({...f.elements,domReference:u}),[f.elements,u]),x=ne.useMemo(()=>({...f,...r,refs:y,elements:b,nodeId:e}),[f,y,b,e,r]);return hd(()=>{r.dataRef.current.floatingContext=x;const E=h==null?void 0:h.nodesRef.current.find(S=>S.id===e);E&&(E.context=x)}),ne.useMemo(()=>({...f,context:x,refs:y,elements:b}),[f,y,b,x])}const t2="_pickerRoot_1wq30_1",n2="_picker_1wq30_1",Ym={pickerRoot:t2,picker:n2};function nc(){return(nc=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function aw(t,e){if(t==null)return{};var n,r,s={},o=Object.keys(t);for(r=0;r<o.length;r++)e.indexOf(n=o[r])>=0||(s[n]=t[n]);return s}function pd(t){var e=C.useRef(t),n=C.useRef(function(r){e.current&&e.current(r)});return e.current=t,n.current}var qo=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t<e?e:t},bo=function(t){return"touches"in t},md=function(t){return t&&t.ownerDocument.defaultView||self},Xm=function(t,e,n){var r=t.getBoundingClientRect(),s=bo(e)?(function(o,i){for(var l=0;l<o.length;l++)if(o[l].identifier===i)return o[l];return o[0]})(e.touches,n):e;return{left:qo((s.pageX-(r.left+md(t).pageXOffset))/r.width),top:qo((s.pageY-(r.top+md(t).pageYOffset))/r.height)}},Zm=function(t){!bo(t)&&t.preventDefault()},cw=C.memo(function(t){var e=t.onMove,n=t.onKey,r=aw(t,["onMove","onKey"]),s=C.useRef(null),o=pd(e),i=pd(n),l=C.useRef(null),a=C.useRef(!1),c=C.useMemo(function(){var f=function(y){Zm(y),(bo(y)?y.touches.length>0:y.buttons>0)&&s.current?o(Xm(s.current,y,l.current)):g(!1)},p=function(){return g(!1)};function g(y){var b=a.current,x=md(s.current),E=y?x.addEventListener:x.removeEventListener;E(b?"touchmove":"mousemove",f),E(b?"touchend":"mouseup",p)}return[function(y){var b=y.nativeEvent,x=s.current;if(x&&(Zm(b),!(function(S,M){return M&&!bo(S)})(b,a.current)&&x)){if(bo(b)){a.current=!0;var E=b.changedTouches||[];E.length&&(l.current=E[0].identifier)}x.focus(),o(Xm(x,b,l.current)),g(!0)}},function(y){var b=y.which||y.keyCode;b<37||b>40||(y.preventDefault(),i({left:b===39?.05:b===37?-.05:0,top:b===40?.05:b===38?-.05:0}))},g]},[i,o]),u=c[0],d=c[1],h=c[2];return C.useEffect(function(){return h},[h]),C.createElement("div",nc({},r,{onTouchStart:u,onMouseDown:u,className:"react-colorful__interactive",ref:s,onKeyDown:d,tabIndex:0,role:"slider"}))}),Uh=function(t){return t.filter(Boolean).join(" ")},uw=function(t){var e=t.color,n=t.left,r=t.top,s=r===void 0?.5:r,o=Uh(["react-colorful__pointer",t.className]);return C.createElement("div",{className:o,style:{top:100*s+"%",left:100*n+"%"}},C.createElement("div",{className:"react-colorful__pointer-fill",style:{backgroundColor:e}}))},ut=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n},r2=function(t){return a2(gd(t))},gd=function(t){return t[0]==="#"&&(t=t.substring(1)),t.length<6?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ut(parseInt(t[3]+t[3],16)/255,2):1}:{r:parseInt(t.substring(0,2),16),g:parseInt(t.substring(2,4),16),b:parseInt(t.substring(4,6),16),a:t.length===8?ut(parseInt(t.substring(6,8),16)/255,2):1}},s2=function(t){return l2(i2(t))},o2=function(t){var e=t.s,n=t.v,r=t.a,s=(200-e)*n/100;return{h:ut(t.h),s:ut(s>0&&s<200?e*n/100/(s<=100?s:200-s)*100:0),l:ut(s/2),a:ut(r,2)}},yd=function(t){var e=o2(t);return"hsl("+e.h+", "+e.s+"%, "+e.l+"%)"},i2=function(t){var e=t.h,n=t.s,r=t.v,s=t.a;e=e/360*6,n/=100,r/=100;var o=Math.floor(e),i=r*(1-n),l=r*(1-(e-o)*n),a=r*(1-(1-e+o)*n),c=o%6;return{r:ut(255*[r,l,i,i,a,r][c]),g:ut(255*[a,r,r,l,i,i][c]),b:ut(255*[i,i,a,r,r,l][c]),a:ut(s,2)}},Qi=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},l2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,o=s<1?Qi(ut(255*s)):"";return"#"+Qi(e)+Qi(n)+Qi(r)+o},a2=function(t){var e=t.r,n=t.g,r=t.b,s=t.a,o=Math.max(e,n,r),i=o-Math.min(e,n,r),l=i?o===e?(n-r)/i:o===n?2+(r-e)/i:4+(e-n)/i:0;return{h:ut(60*(l<0?l+6:l)),s:ut(o?i/o*100:0),v:ut(o/255*100),a:s}},c2=C.memo(function(t){var e=t.hue,n=t.onChange,r=Uh(["react-colorful__hue",t.className]);return C.createElement("div",{className:r},C.createElement(cw,{onMove:function(s){n({h:360*s.left})},onKey:function(s){n({h:qo(e+360*s.left,0,360)})},"aria-label":"Hue","aria-valuenow":ut(e),"aria-valuemax":"360","aria-valuemin":"0"},C.createElement(uw,{className:"react-colorful__hue-pointer",left:e/360,color:yd({h:e,s:100,v:100,a:1})})))}),u2=C.memo(function(t){var e=t.hsva,n=t.onChange,r={backgroundColor:yd({h:e.h,s:100,v:100,a:1})};return C.createElement("div",{className:"react-colorful__saturation",style:r},C.createElement(cw,{onMove:function(s){n({s:100*s.left,v:100-100*s.top})},onKey:function(s){n({s:qo(e.s+100*s.left,0,100),v:qo(e.v-100*s.top,0,100)})},"aria-label":"Color","aria-valuetext":"Saturation "+ut(e.s)+"%, Brightness "+ut(e.v)+"%"},C.createElement(uw,{className:"react-colorful__saturation-pointer",top:1-e.v/100,left:e.s/100,color:yd(e)})))}),dw=function(t,e){if(t===e)return!0;for(var n in t)if(t[n]!==e[n])return!1;return!0},d2=function(t,e){return t.toLowerCase()===e.toLowerCase()||dw(gd(t),gd(e))};function h2(t,e,n){var r=pd(n),s=C.useState(function(){return t.toHsva(e)}),o=s[0],i=s[1],l=C.useRef({color:e,hsva:o});C.useEffect(function(){if(!t.equal(e,l.current.color)){var c=t.toHsva(e);l.current={hsva:c,color:e},i(c)}},[e,t]),C.useEffect(function(){var c;dw(o,l.current.hsva)||t.equal(c=t.fromHsva(o),l.current.color)||(l.current={hsva:o,color:c},r(c))},[o,t,r]);var a=C.useCallback(function(c){i(function(u){return Object.assign({},u,c)})},[]);return[o,a]}var f2=typeof window<"u"?C.useLayoutEffect:C.useEffect,p2=function(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:void 0},Qm=new Map,m2=function(t){f2(function(){var e=t.current?t.current.ownerDocument:document;if(e!==void 0&&!Qm.has(e)){var n=e.createElement("style");n.innerHTML=`.react-colorful{position:relative;display:flex;flex-direction:column;width:200px;height:200px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:default}.react-colorful__saturation{position:relative;flex-grow:1;border-color:transparent;border-bottom:12px solid #000;border-radius:8px 8px 0 0;background-image:linear-gradient(0deg,#000,transparent),linear-gradient(90deg,#fff,hsla(0,0%,100%,0))}.react-colorful__alpha-gradient,.react-colorful__pointer-fill{content:"";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;border-radius:inherit}.react-colorful__alpha-gradient,.react-colorful__saturation{box-shadow:inset 0 0 0 1px rgba(0,0,0,.05)}.react-colorful__alpha,.react-colorful__hue{position:relative;height:24px}.react-colorful__hue{background:linear-gradient(90deg,red 0,#ff0 17%,#0f0 33%,#0ff 50%,#00f 67%,#f0f 83%,red)}.react-colorful__last-control{border-radius:0 0 8px 8px}.react-colorful__interactive{position:absolute;left:0;top:0;right:0;bottom:0;border-radius:inherit;outline:none;touch-action:none}.react-colorful__pointer{position:absolute;z-index:1;box-sizing:border-box;width:28px;height:28px;transform:translate(-50%,-50%);background-color:#fff;border:2px solid #fff;border-radius:50%;box-shadow:0 2px 4px rgba(0,0,0,.2)}.react-colorful__interactive:focus .react-colorful__pointer{transform:translate(-50%,-50%) scale(1.1)}.react-colorful__alpha,.react-colorful__alpha-pointer{background-color:#fff;background-image:url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill-opacity=".05"><path d="M8 0h8v8H8zM0 8h8v8H0z"/></svg>')}.react-colorful__saturation-pointer{z-index:3}.react-colorful__hue-pointer{z-index:2}`,Qm.set(e,n);var r=p2();r&&n.setAttribute("nonce",r),e.head.appendChild(n)}},[])},g2=function(t){var e=t.className,n=t.colorModel,r=t.color,s=r===void 0?n.defaultColor:r,o=t.onChange,i=aw(t,["className","colorModel","color","onChange"]),l=C.useRef(null);m2(l);var a=h2(n,s,o),c=a[0],u=a[1],d=Uh(["react-colorful",e]);return C.createElement("div",nc({},i,{ref:l,className:d}),C.createElement(u2,{hsva:c,onChange:u}),C.createElement(c2,{hue:c.h,onChange:u,className:"react-colorful__last-control"}))},y2={defaultColor:"000",toHsva:r2,fromHsva:function(t){return s2({h:t.h,s:t.s,v:t.v,a:1})},equal:d2},b2=function(t){return C.createElement(g2,nc({},t,{colorModel:y2}))};const eg="#1F2937",tg="#FFF7D1",x2=["#FFF7D1","#FFEAE3","#DCFCE7","#DBEAFE"],w2=[{title:"Brand",colors:[{label:"Primary",value:"hsl(var(--primary))"},{label:"Secondary",value:"hsl(var(--secondary))"},{label:"Accent",value:"hsl(var(--accent))"},{label:"Ring",value:"hsl(var(--ring))"}]},{title:"Neutrals",colors:[{label:"Foreground",value:"hsl(var(--foreground))"},{label:"Muted",value:"hsl(var(--muted-foreground))"},{label:"Background",value:"hsl(var(--background))"},{label:"Card",value:"hsl(var(--card))"}]},{title:"States",colors:[{label:"Warning",value:"hsl(var(--warning))"},{label:"Destructive",value:"hsl(var(--destructive))"},{label:"Success",value:"hsl(var(--chart-2))"},{label:"Info",value:"hsl(var(--chart-5))"}]},{title:"Utility",colors:[{label:"Secondary FG",value:"hsl(var(--secondary-foreground))"},{label:"Accent FG",value:"hsl(var(--accent-foreground))"},{label:"Primary FG",value:"hsl(var(--primary-foreground))"},{label:"Border",value:"hsl(var(--border))"}]}],v2=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,k2=/^#[0-9a-f]{6}$/i,hw=/^rgba?\((\s*\d{1,3}\s*,){2}\s*\d{1,3}\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i,fw=/^hsla?\((\s*\d{1,3}\s*,)(\s*\d{1,3}%\s*,)\s*\d{1,3}%\s*(,\s*(0|1|0?\.\d+)\s*)?\)$/i;function ba(t){const e=t.replace("#","").trim();return e.length===3||e.length===4?`#${e.split("").map(r=>r+r).join("").toUpperCase()}`:e.length===6||e.length===8?`#${e.toUpperCase()}`:t}function pw(t){const e=ba(t).replace("#","");if(e.length!==6&&e.length!==8)return null;const n=parseInt(e.slice(0,2),16),r=parseInt(e.slice(2,4),16),s=parseInt(e.slice(4,6),16),o=e.length===8?parseInt(e.slice(6,8),16)/255:1;return{r:n,g:r,b:s,a:o}}function bd(t,e,n){return`#${[t,e,n].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("").toUpperCase()}`}function xo(t,e=2){const n=10**e;return Math.round(t*n)/n}function wo(t,e,n,r=1){const s=t/255,o=e/255,i=n/255,l=Math.max(s,o,i),a=Math.min(s,o,i);let c=0,u=0;const d=(l+a)/2;if(l!==a){const g=l-a;switch(u=d>.5?g/(2-l-a):g/(l+a),l){case s:c=(o-i)/g+(o<i?6:0);break;case o:c=(i-s)/g+2;break;case i:c=(s-o)/g+4;break}c/=6}const h=Math.round(c*360),f=Math.round(u*100),p=Math.round(d*100);return r!==1?`hsla(${h}, ${f}%, ${p}%, ${xo(r,2)})`:`hsl(${h}, ${f}%, ${p}%)`}function ng(t){if(typeof window>"u"||typeof document>"u")return null;const e=document.createElement("span");if(e.style.color="",e.style.color=t,!e.style.color)return null;e.style.position="absolute",e.style.visibility="hidden",e.style.pointerEvents="none",document.body.appendChild(e);const n=getComputedStyle(e).color;document.body.removeChild(e);const r=n.match(/rgba?\(([^)]+)\)/i);if(!r)return null;const[s,o,i,l]=r[1].split(",").map(a=>a.trim()).map((a,c)=>c===3?parseFloat(a):parseInt(a,10));return[s,o,i].some(a=>Number.isNaN(a))?null:{r:s,g:o,b:i,a:typeof l=="number"&&!Number.isNaN(l)?l:1}}function Ln(t){if(!t)return null;const e=t.trim();if(v2.test(e)){const r=ba(e),s=pw(r);if(!s)return null;const o=`#${r.replace("#","").slice(0,6)}`;return{source:r,hex:o,rgb:s.a===1?`rgb(${s.r}, ${s.g}, ${s.b})`:`rgba(${s.r}, ${s.g}, ${s.b}, ${xo(s.a,2)})`,hsl:wo(s.r,s.g,s.b,s.a),alpha:s.a}}if(hw.test(e)||fw.test(e)){const r=ng(e);return r?{source:e,hex:bd(r.r,r.g,r.b),rgb:r.a===1?`rgb(${r.r}, ${r.g}, ${r.b})`:`rgba(${r.r}, ${r.g}, ${r.b}, ${xo(r.a,2)})`,hsl:wo(r.r,r.g,r.b,r.a),alpha:r.a}:null}const n=ng(e);return n?{source:e,hex:bd(n.r,n.g,n.b),rgb:n.a===1?`rgb(${n.r}, ${n.g}, ${n.b})`:`rgba(${n.r}, ${n.g}, ${n.b}, ${xo(n.a,2)})`,hsl:wo(n.r,n.g,n.b,n.a),alpha:n.a}:null}function mw(t){const e=pw(t);if(e)return{source:ba(t),hex:bd(e.r,e.g,e.b),rgb:e.a===1?`rgb(${e.r}, ${e.g}, ${e.b})`:`rgba(${e.r}, ${e.g}, ${e.b}, ${xo(e.a,2)})`,hsl:wo(e.r,e.g,e.b,e.a),alpha:e.a};const n=ba(t);return{source:n,hex:n.slice(0,7),rgb:"rgb(0, 0, 0)",hsl:wo(0,0,0,1),alpha:1}}const eo=Ln(eg)??mw(eg),rg=Ln(tg)??mw(tg);function gw({editor:t,className:e,initialMode:n="text"}){const r=C.useRef(null),[s,o]=C.useState(n),[i,l]=C.useState(null),[a,c]=C.useState(eo),[u,d]=C.useState(rg);C.useEffect(()=>{o(n)},[n]);const[h,f]=C.useState(eo.hex),[p,g]=C.useState(!1),[y,b]=C.useState(eo.rgb),[x,E]=C.useState(!1),[S,M]=C.useState(eo.hsl),[w,T]=C.useState(!1),k=s==="text"?a:u;C.useEffect(()=>{const L=()=>{if(i)return;const H=t.getAttributes("textStyle").color,se=t.getAttributes("highlight").color,oe=Ln(H)??eo,we=Ln(se)??rg;c(oe),d(we)};return L(),t.on("selectionUpdate",L),t.on("transaction",L),()=>{t.off("selectionUpdate",L),t.off("transaction",L)}},[t,i,s]),C.useEffect(()=>{i!=="hex"&&f(k.hex),i!=="rgb"&&b(k.rgb),i!=="hsl"&&M(k.hsl),i===null&&(g(!1),E(!1),T(!1))},[k,i]);const N=C.useCallback((L,H,se=!0)=>{const oe=t.chain();se&&oe.focus(),L==="text"?(c(H),oe.setColor(H.source).run()):(d(H),oe.setHighlight({color:H.source}).run())},[t,c,d]),R=C.useCallback((L,H)=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{N(L,H,!1)},300)},[N]),B=C.useCallback(L=>{r.current&&clearTimeout(r.current);const H=Ln(L);H&&(N(s,H,!1),g(!1))},[N,s,g]),P=C.useCallback(L=>{r.current&&clearTimeout(r.current);const H=Ln(L);H&&(N(s,H),g(!1))},[N,s,g]);return m.jsxs("div",{className:$e.cn("flex w-full sm:w-auto flex-col gap-3 sm:gap-4",e),children:[m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsxs("div",{className:"inline-flex items-center gap-1 rounded-md bg-muted/60 p-1",children:[m.jsx(ce.Button,{type:"button",variant:s==="text"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>o("text"),children:"Text"}),m.jsx(ce.Button,{type:"button",variant:s==="highlight"?"default":"ghost",size:"sm",className:"h-7 px-3 text-xs",onClick:()=>o("highlight"),children:"Highlight"})]}),m.jsx("div",{className:"flex items-center",children:m.jsx(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 text-xs",onClick:()=>{s==="text"?t.chain().focus().unsetColor().run():t.chain().focus().unsetHighlight().run()},children:"Remove Color"})})]}),m.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:gap-4",children:[m.jsx("div",{className:Ym.pickerRoot,children:m.jsx(b2,{color:k.hex,onChange:B,className:Ym.picker})}),m.jsxs("div",{className:"flex w-full flex-col gap-2 text-[11px] sm:w-[150px]",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HEX"}),m.jsx(ps.Input,{value:h,onFocus:()=>l("hex"),onChange:L=>{const H=L.target.value;if(f(H),k2.test(H)){const se=Ln(H);se&&(R(s,se),g(!1))}else g(!0)},onBlur:()=>{l(null),p&&(f(k.hex),g(!1))},spellCheck:!1,className:$e.cn("h-8 w-full text-xs",p&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"RGB"}),m.jsx(ps.Input,{value:y,onFocus:()=>l("rgb"),onChange:L=>{const H=L.target.value;if(b(H),hw.test(H)){const se=Ln(H);se&&(R(s,se),E(!1))}else E(!0)},onBlur:()=>{l(null),x&&(b(k.rgb),E(!1))},spellCheck:!1,className:$e.cn("h-8 w-full text-xs",x&&"border-destructive focus-visible:ring-destructive")})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"HSL"}),m.jsx(ps.Input,{value:S,onFocus:()=>l("hsl"),onChange:L=>{const H=L.target.value;if(M(H),fw.test(H)){const se=Ln(H);se&&(R(s,se),T(!1))}else T(!0)},onBlur:()=>{l(null),w&&(M(k.hsl),T(!1))},spellCheck:!1,className:$e.cn("h-8 w-full text-xs",w&&"border-destructive focus-visible:ring-destructive")})]})]})]}),m.jsxs("div",{className:"space-y-1.5",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Theme colors"}),m.jsx("div",{className:"space-y-1",children:w2.map(L=>m.jsxs("div",{className:"flex items-center justify-between gap-2",children:[m.jsx("span",{className:"w-16 shrink-0 text-[11px] font-medium text-muted-foreground/80",children:L.title}),m.jsx("div",{className:"flex items-center gap-1.5",children:L.colors.map(H=>m.jsx("button",{type:"button",onClick:()=>P(H.value),className:"h-6 w-6 rounded border border-border bg-background shadow-sm transition hover:border-primary/40 hover:shadow-sm",style:{background:H.value},"aria-label":`${L.title} color ${H.label}`,title:`${L.title} color ${H.label}`},H.label))})]},L.title))})]}),s==="highlight"?m.jsxs("div",{className:"space-y-2",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Highlight presets"}),m.jsx("div",{className:"flex flex-wrap gap-1.5",children:x2.map(L=>m.jsxs("button",{type:"button",onClick:()=>P(L),className:"flex items-center gap-1 rounded-full border bg-background px-2 py-1 text-[11px] shadow-sm transition hover:border-primary/40 hover:shadow-sm",children:[m.jsx("span",{className:"h-3.5 w-3.5 rounded-full border",style:{background:L},"aria-hidden":!0}),L]},L))})]}):null]})}const S2=["px","pt","rem","em","%"];function pl(t){if(!t)return null;const n=String(t).trim().match(/^(-?\d*\.?\d+)(px|pt|rem|em|%)$/i);if(!n)return null;const r=parseFloat(n[1]),s=n[2].toLowerCase();return Number.isFinite(r)?{value:r,unit:s}:null}function xd(t){if(!t)return null;const{value:e,unit:n}=t;return n==="%"?`${Math.max(1,Math.round(e))}%`:n==="px"||n==="pt"?`${Math.max(1,Math.round(e))}${n}`:`${Math.max(.01,Math.round(e*100)/100)}${n}`}function C2(t){const e=pl(t);return e?xd(e):null}function E2(){if(typeof document>"u")return[];const t=[];try{const n=Array.from(document.styleSheets),r=[],s=[];for(const l of n){const a=l.href,c=l.ownerNode;`${a||""} ${(c==null?void 0:c.textContent)||""}`.toLowerCase().includes("globals.css")?r.push(l):s.push(l)}const o=[...r,...s],i=new Set(["h1","h2","h3","h4","h5","h6"]);for(const l of o){let a=null;try{a=l.cssRules}catch{continue}if(a){for(const c of Array.from(a))if(c.style){const d=c.style.fontSize,h=c.selectorText;if(d&&h&&i.has(h)){const f=C2(d)??d.trim();if(f){const p=parseInt(h.replace("h",""),10);t.push({level:p,value:f})}}}}}}catch{}const e=new Map;for(const n of t)e.has(n.level)||e.set(n.level,n.value);return Array.from(e.entries()).map(([n,r])=>({level:n,value:r}))}function M2(t){if(typeof document>"u")return 0;try{const e=document.createElement("span");e.style.position="absolute",e.style.visibility="hidden",e.style.fontSize=t,document.body.appendChild(e);const n=parseFloat(getComputedStyle(e).fontSize);return document.body.removeChild(e),Number.isFinite(n)?n:0}catch{return 0}}function xa(){if(typeof document>"u")return 16;try{const t=parseFloat(getComputedStyle(document.documentElement).fontSize);return Number.isFinite(t)&&t>0?t:16}catch{return 16}}function Vh(t){try{const e=t.state.selection.from,n=t.view.domAtPos(e),r=n&&n.node||t.view.dom,s=r.nodeType===1?r:t.view.dom,o=parseFloat(getComputedStyle(s).fontSize);return Number.isFinite(o)&&o>0?o:xa()}catch{return xa()}}function A2(t,e,n){const r=xa(),s=Vh(n);switch(e){case"px":return t;case"pt":return t*(96/72);case"rem":return t*r;case"em":return t*s;case"%":return t/100*s}}function T2(t,e,n){const r=xa(),s=Vh(n);switch(e){case"px":return t;case"pt":return t*(72/96);case"rem":return t/r;case"em":return t/s;case"%":return t/s*100}}function yw({editor:t,className:e}){const[n,r]=C.useState([]),[s,o]=C.useState(null),[i,l]=C.useState(""),[a,c]=C.useState("px"),[u,d]=C.useState(!1),h=C.useRef(null),f=C.useCallback(()=>{const S=t.getAttributes("textStyle").fontSize,M=pl(S);if(M)l(String(M.value)),c(M.unit),d(!1);else{if(S&&typeof S=="string"){const w=M2(S);if(w>0&&!s){l(String(Math.round(w))),c("px"),d(!1);return}}s||(l(""),c("px"),d(!1))}},[t,s]);C.useEffect(()=>{f();const S=()=>f();return t.on("selectionUpdate",S),t.on("transaction",S),()=>{t.off("selectionUpdate",S),t.off("transaction",S)}},[t,f]),C.useEffect(()=>{r(E2())},[]);const p=C.useCallback((S,M=!0)=>{h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{const w=t.chain();M&&w.focus(),w.setFontSize(S).run()},120)},[t]),g=C.useCallback(S=>{l(S);const M=`${S}${a}`,w=pl(M);if(w){d(!1);const T=xd(w);T&&p(T,!1)}else d(S.trim().length>0)},[a,p]),y=C.useCallback(S=>{const M=a;c(S);let w=0;const T=parseFloat(i);Number.isFinite(T)?w=A2(T,M,t):w=Vh(t);let k=T2(w,S,t),N;S==="px"||S==="pt"||S==="%"?N=String(Math.round(k)):N=String(Math.max(.01,Math.round(k*100)/100)),l(N);const R=xd(pl(`${N}${S}`));R&&p(R)},[a,i,t,p]),b=C.useCallback(()=>{h.current&&clearTimeout(h.current),t.chain().focus().unsetFontSize().run(),d(!1)},[t]),x=C.useMemo(()=>a==="px"||a==="pt"||a==="%"?1:.01,[a]),E=C.useMemo(()=>{switch(a){case"%":return"100";case"px":return"16";case"pt":return"12";case"rem":return"1";case"em":return"1";default:return""}},[a]);return m.jsxs("div",{className:$e.cn("space-y-3",e),onMouseDown:S=>S.stopPropagation(),children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(ss,{className:"h-4 w-4 text-muted-foreground"}),m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Font size"})]}),m.jsxs(ce.Button,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:b,title:"Erase font size","aria-label":"Erase font size",children:[m.jsx(vL,{className:"h-3.5 w-3.5 mr-1"}),"Erase"]})]}),m.jsxs("div",{className:"grid grid-cols-[1fr_auto] gap-2 items-end",children:[m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Value"}),m.jsx(ps.Input,{type:"number",inputMode:"decimal",step:x,placeholder:E,value:i,onFocus:()=>o("value"),onChange:S=>g(S.target.value),onBlur:()=>o(null),className:$e.cn("h-9",u&&"border-destructive focus-visible:ring-destructive"),spellCheck:!1})]}),m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"font-medium text-muted-foreground",children:"Unit"}),m.jsx("div",{className:"flex gap-1",children:m.jsx("select",{value:a,onChange:S=>y(S.target.value),onFocus:()=>o("unit"),onBlur:()=>o(null),className:"h-9 w-[84px] rounded-md border border-input bg-background px-2 text-sm shadow-sm outline-none focus-visible:ring-2 focus-visible:ring-ring",children:S2.map(S=>m.jsx("option",{value:S,children:S},S))})})]})]}),m.jsxs("div",{className:"space-y-2",children:[n.length>0?m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Headings"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:n.map(({level:S,value:M})=>m.jsx("button",{type:"button",onClick:()=>p(M),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply H${S} (${M})`,children:`H${S} (${M})`},`h${S}`))})]}):null,m.jsxs("div",{className:"space-y-1",children:[m.jsx("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:"Keywords"}),m.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:["xx-small","x-small","small","medium","large","x-large"].map(S=>m.jsx("button",{type:"button",onClick:()=>p(S),className:"h-8 w-full rounded-md border bg-background px-2 text-xs font-medium shadow-sm transition hover:border-primary/40 hover:shadow-sm",title:`Apply ${S}`,children:S.replace(/\b\w/g,M=>M.toUpperCase())},S))})]})]})]})}const N2=({editor:t})=>{var s;const[e,n]=C.useState(((s=t.getAttributes("link"))==null?void 0:s.href)??"");C.useEffect(()=>{const o=()=>{var i;n(((i=t.getAttributes("link"))==null?void 0:i.href)??"")};return t.on("selectionUpdate",o),t.on("transaction",o),()=>{t.off("selectionUpdate",o),t.off("transaction",o)}},[t]);const r=()=>{const o=e.trim();o?t.chain().focus().extendMarkRange("link").setLink({href:o}).run():t.chain().focus().extendMarkRange("link").unsetLink().run()};return m.jsxs("div",{className:"p-2 flex items-center gap-2",onMouseDown:o=>o.preventDefault(),children:[m.jsx("input",{type:"url",value:e,onChange:o=>n(o.target.value),placeholder:"Enter URL",className:"bg-background p-1 rounded border border-input text-sm",onKeyDown:o=>o.key==="Enter"&&r()}),m.jsx(ce.Button,{type:"button",size:"sm",onClick:r,children:"Set Link"})]})},R2=({editor:t})=>m.jsx("div",{className:"w-[380px]",children:m.jsx(gw,{editor:t,className:"p-4",initialMode:t.isActive("highlight")?"highlight":"text"})}),Wh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),[o,i]=C.useState(!1),[l,a]=C.useState(!1),{x:c,y:u,refs:d,strategy:h,update:f}=fi({placement:"top",middleware:[hi(6),tc(),ec()],whileElementsMounted:Bs}),p=C.useCallback(()=>{if(!t||!t.isEditable)return!1;const{state:y}=t,{from:b,to:x}=y.selection,E=b!==x,S=y.selection instanceof K,M=t.isActive("codeBlock"),w=y.selection.empty&&(t.isActive("alert-widget")||t.isActive("cta-widget")),T=t.isActive("image");return E&&!S&&!M&&!w&&!T},[t]),g=C.useCallback(()=>{if(!(!t||!p()))try{const{from:y,to:b}=t.state.selection,x=t.view.coordsAtPos(y),E=t.view.coordsAtPos(b),S={getBoundingClientRect:()=>({x:x.left,y:x.top,top:x.top,left:x.left,bottom:E.bottom,right:E.right,width:E.right-x.left,height:E.bottom-x.top})};d.setReference(S),f(),requestAnimationFrame(()=>s(!0))}catch(y){console.warn("BubbleMenu positioning error:",y)}},[t,d,f,p]);return C.useEffect(()=>{if(!t)return;let y=0;const b=()=>{cancelAnimationFrame(y),y=requestAnimationFrame(()=>{p()?(n(!0),g()):!o&&!l&&n(!1)})},x=({event:E})=>{o||l||d.floating.current&&E.relatedTarget&&d.floating.current.contains(E.relatedTarget)||n(!1)};return b(),t.on("selectionUpdate",b),t.on("transaction",b),t.on("focus",b),t.on("blur",x),()=>{cancelAnimationFrame(y),t.off("selectionUpdate",b),t.off("transaction",b),t.off("focus",b),t.off("blur",x)}},[t,p,g,o,l,d.floating]),!t||!e?null:m.jsxs("div",{ref:d.setFloating,style:{position:h,top:u??0,left:c??0,zIndex:1e4,visibility:r?"visible":"hidden"},className:"flex gap-1 items-center bg-background border rounded-lg p-1 shadow-lg",onMouseDown:y=>y.preventDefault(),children:[m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleBold().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("bold")?"bg-accent":""}`,"aria-label":"Bold",title:"Bold",children:m.jsx(ga,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleItalic().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("italic")?"bg-accent":""}`,"aria-label":"Italic",title:"Italic",children:m.jsx(Bh,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleUnderline().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("underline")?"bg-accent":""}`,"aria-label":"Underline",title:"Underline",children:m.jsx($h,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleStrike().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("strike")?"bg-accent":""}`,"aria-label":"Strikethrough",title:"Strikethrough",children:m.jsx(Qx,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleCode().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("code")?"bg-accent":""}`,"aria-label":"Inline code",title:"Inline code",children:m.jsx(Fs,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSubscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("subscript")?"bg-accent":""}`,"aria-label":"Subscript",title:"Subscript",children:m.jsx(ew,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().toggleSuperscript().run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("superscript")?"bg-accent":""}`,"aria-label":"Superscript",title:"Superscript",children:m.jsx(tw,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("left").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"left"})?"bg-accent":""}`,"aria-label":"Align left",title:"Align left",children:m.jsx(Ds,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("center").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"center"})?"bg-accent":""}`,"aria-label":"Align center",title:"Align center",children:m.jsx(ii,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("right").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"right"})?"bg-accent":""}`,"aria-label":"Align right",title:"Align right",children:m.jsx(li,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("button",{type:"button",onClick:()=>t.chain().focus().setTextAlign("justify").run(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive({textAlign:"justify"})?"bg-accent":""}`,"aria-label":"Justify",title:"Justify",children:m.jsx(Ph,{className:"h-4 w-4 pointer-events-none"})}),m.jsx("div",{className:"w-px bg-border h-5"}),m.jsxs(vt.Popover,{open:l,onOpenChange:a,children:[m.jsx(vt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:"p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center","aria-label":"Font size",title:"Font size",onMouseDown:y=>y.preventDefault(),children:m.jsx(ss,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(vt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-[360px] p-0",side:"top",align:"start",children:m.jsx(yw,{editor:t,className:"p-4"})})]}),m.jsxs(vt.Popover,{children:[m.jsx(vt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("link")?"bg-accent":""}`,"aria-label":"Link",title:"Link",onMouseDown:y=>y.preventDefault(),children:m.jsx(Ja,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(vt.PopoverContent,{className:"w-auto p-0",side:"top",align:"start",children:m.jsx(N2,{editor:t})})]}),m.jsxs(vt.Popover,{open:o,onOpenChange:i,children:[m.jsx(vt.PopoverTrigger,{asChild:!0,children:m.jsx("button",{type:"button",onMouseDown:y=>y.preventDefault(),className:`p-1.5 rounded hover:bg-accent transition-colors duration-100 flex items-center justify-center ${t.isActive("textStyle")||t.isActive("highlight")?"bg-accent":""}`,"aria-label":"Color / highlight",title:"Color / highlight",children:m.jsx(Hh,{className:"h-4 w-4 pointer-events-none"})})}),m.jsx(vt.PopoverContent,{onFocusOutside:y=>y.preventDefault(),onMouseDown:y=>y.stopPropagation(),className:"w-auto p-0",side:"top",align:"start",children:m.jsx(R2,{editor:t})})]}),m.jsx("div",{className:"w-px bg-border h-5"})]})};function rc(t){var e,n;return(n=(e=t.storage)==null?void 0:e.mediaPicker)==null?void 0:n.open}const _2=[{title:"Heading 1",icon:m.jsx(Ls,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run()},{title:"Heading 2",icon:m.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run()},{title:"Bullet List",icon:m.jsx(Us,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run()},{title:"Ordered List",icon:m.jsx(ci,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run()},{title:"Blockquote",icon:m.jsx(di,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run()},{title:"Code Block",icon:m.jsx(Fs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run()},{title:"Image",icon:m.jsx(es,{className:"h-4 w-4"}),command:async t=>{const e=rc(t);if(e){const r=await e();r!=null&&r.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("URL");n&&t.chain().focus().setImage({src:n}).run()}},{title:"Table",icon:m.jsx(ui,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},{title:"Horizontal Rule",icon:m.jsx(Xa,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run()},{title:"Link",icon:m.jsx(Ja,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter URL:");e&&t.chain().focus().setLink({href:e}).run()}},{title:"CSS Block",icon:m.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(e!=null){const n=`<style>${e}</style>`;t.commands.insertContentAt({from:0,to:0},n)}}},{title:"Script Block",icon:m.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(e!=null){const n=`<script>${e}<\/script>`,r=t.state.doc.content.size;t.commands.insertContentAt(r,n)}}},{title:"DIV Block",icon:m.jsx(Fr,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Optional class for DIV:",""),n=window.prompt("Optional inline style for DIV:",""),r=window.prompt("Optional content for DIV:","New block"),s=`${e?` class="${e}"`:""}${n?` style="${n}"`:""}`,i=r?`<p>${(l=>l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&quot;").replace(/'/g,"&#39;"))(r)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${s}>${i}</div>`).run()}},{title:"Alert Widget",icon:m.jsx(Qa,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setAlertWidget().run()}},{title:"CTA Widget",icon:m.jsx(Ya,{className:"h-4 w-4"}),command:t=>{t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run()}}],qh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(null),[o,i]=C.useState(null),l=C.useRef(null),a=C.useRef(null),c=C.useRef(!1),u=C.useCallback(()=>{l.current&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current.removeAttribute("data-menu-open"),l.current=null,a.current=null,s(null),n(!1)},[]),{x:d,y:h,refs:f,strategy:p}=fi({placement:"right-start",open:e,middleware:[hi(8),tc(),ec()],whileElementsMounted:Bs});C.useEffect(()=>{c.current=e},[e]),C.useEffect(()=>{r?f.setReference(r):f.setReference(null)},[r,f]);const g=C.useCallback(()=>!(!t||!t.isEditable||t.isActive("image")),[t]);C.useEffect(()=>{if(!t)return;const b=t.view.dom.parentElement;if(!b)return;const x=E=>{var T;const S=E,{handle:M,button:w}=S.detail;try{const k=t.state.selection,N=k==null?void 0:k.$from;if(N){let R=N.depth;for(;R>0&&!((T=N.node(R))!=null&&T.isBlock);)R-=1;const B=typeof N.after=="function"?N.after(R):void 0;typeof B=="number"?i(B):typeof N.pos=="number"?i(N.pos):i(null)}else i(null)}catch{i(null)}if(l.current===w&&c.current){u();return}l.current&&l.current!==w&&l.current.setAttribute("aria-expanded","false"),a.current&&a.current!==M&&a.current.removeAttribute("data-menu-open"),l.current=w,a.current=M,w.setAttribute("aria-expanded","true"),M.setAttribute("data-menu-open","true"),s(w),n(!0)};return b.addEventListener("tiptap-gutter-toggle",x),()=>{b.removeEventListener("tiptap-gutter-toggle",x)}},[t,g,u]),C.useEffect(()=>{if(!t)return;const b=()=>{g()||u()};return t.on("selectionUpdate",b),t.on("transaction",b),t.on("blur",u),()=>{t.off("selectionUpdate",b),t.off("transaction",b),t.off("blur",u)}},[t,g,u]),C.useEffect(()=>{if(!e)return;const b=E=>{const S=E.target,M=f.floating.current;if(M&&!M.contains(S)){const w=l.current;(!w||!w.contains(S))&&u()}},x=E=>{E.key==="Escape"&&u()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",x)}},[e,u,f]);const y=b=>{o!=null?t.chain().focus().insertContentAt(o,{type:"paragraph"}).setTextSelection(o+1).run():t.chain().focus().run(),b(t),u()};return!r||!e?null:m.jsx("div",{ref:f.setFloating,style:{position:p,top:h??0,left:d??0,zIndex:10001},className:"w-48 rounded-md bg-white p-1 shadow-lg max-h-[400px] overflow-auto",onMouseDown:b=>b.preventDefault(),children:m.jsx("div",{className:"flex flex-col",children:_2.map(b=>m.jsxs(ce.Button,{type:"button",variant:"ghost",className:"justify-start",onClick:()=>y(b.command),children:[b.icon,m.jsx("span",{className:"ml-2",children:b.title})]},b.title))})})},O2=[{title:"Text",description:"Start writing with plain text",icon:m.jsx(ss,{className:"h-4 w-4"}),command:t=>t.chain().focus().clearNodes().run(),category:"basic",keywords:["text","paragraph","plain"]},{title:"Heading 1",description:"Large section heading",icon:m.jsx(Ls,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:1}).run(),category:"headings",keywords:["heading","h1","title","large"]},{title:"Heading 2",description:"Medium section heading",icon:m.jsx(ai,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:2}).run(),category:"headings",keywords:["heading","h2","subtitle","medium"]},{title:"Heading 3",description:"Small section heading",icon:m.jsx(Ga,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleHeading({level:3}).run(),category:"headings",keywords:["heading","h3","small"]},{title:"Bullet List",description:"Create a simple bulleted list",icon:m.jsx(Us,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBulletList().run(),category:"lists",keywords:["bullet","list","unordered","ul"]},{title:"Numbered List",description:"Create a list with numbering",icon:m.jsx(ci,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleOrderedList().run(),category:"lists",keywords:["numbered","list","ordered","ol"]},{title:"Task List",description:"Create a list with checkboxes",icon:m.jsx(Za,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleTaskList().run(),category:"lists",keywords:["task","todo","checkbox","checklist"]},{title:"Image",description:"Insert an image",icon:m.jsx(es,{className:"h-4 w-4"}),command:async t=>{const e=rc(t);if(e){const r=await e();r!=null&&r.src&&t.chain().focus().setImage({src:r.src,alt:r.alt||void 0}).updateAttributes("image",{blurDataURL:r.blurDataURL||void 0}).run();return}const n=window.prompt("Enter image URL:");n&&t.chain().focus().setImage({src:n}).run()},category:"media",keywords:["image","picture","photo","img"]},{title:"Video",description:"Embed a video from URL",icon:m.jsx(rw,{className:"h-4 w-4"}),command:t=>{const e=window.prompt("Enter video URL (YouTube, Vimeo, etc.):");e&&t.chain().focus().insertContent(`<p><a href="${e}" target="_blank">Video: ${e}</a></p>`).run()},category:"media",keywords:["video","youtube","vimeo","embed"]},{title:"Blockquote",description:"Create a quote or citation",icon:m.jsx(di,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleBlockquote().run(),category:"advanced",keywords:["quote","blockquote","citation"]},{title:"Code Block",description:"Create a code block with syntax highlighting",icon:m.jsx(Fs,{className:"h-4 w-4"}),command:t=>t.chain().focus().toggleCodeBlock().run(),category:"advanced",keywords:["code","programming","syntax","block"]},{title:"Table",description:"Insert a table with rows and columns",icon:m.jsx(ui,{className:"h-4 w-4"}),command:t=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),category:"advanced",keywords:["table","grid","rows","columns"]},{title:"Horizontal Rule",description:"Insert a horizontal divider",icon:m.jsx(Xa,{className:"h-4 w-4"}),command:t=>t.chain().focus().setHorizontalRule().run(),category:"advanced",keywords:["divider","separator","line","hr"]},{title:"Alert",description:"Insert an alert or notice",icon:m.jsx(Qa,{className:"h-4 w-4"}),command:t=>{t.can().setAlertWidget()?t.chain().focus().setAlertWidget().run():t.chain().focus().toggleBlockquote().run()},category:"advanced",keywords:["alert","notice","warning","info"]},{title:"Call to Action",description:"Insert a call to action button",icon:m.jsx(Ya,{className:"h-4 w-4"}),command:t=>{t.can().setCtaWidget()?t.chain().focus().setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}).run():t.chain().focus().insertContent("Call to Action").run()},category:"advanced",keywords:["cta","button","action","link"]}],sg={basic:m.jsx(ss,{className:"h-3 w-3"}),headings:m.jsx(NL,{className:"h-3 w-3"}),lists:m.jsx(Us,{className:"h-3 w-3"}),media:m.jsx(es,{className:"h-3 w-3"}),advanced:m.jsx(mI,{className:"h-3 w-3"})},og={basic:"Basic",headings:"Headings",lists:"Lists",media:"Media",advanced:"Advanced"},bw=({editor:t,wrapperRef:e})=>{const[n,r]=C.useState(!1),[s,o]=C.useState(!1),[i,l]=C.useState(!1),[a,c]=C.useState(""),[u,d]=C.useState("all"),[h,f]=C.useState({top:-9999,left:-9999,width:0}),{x:p,y:g,refs:y,strategy:b,update:x}=fi({placement:"bottom-start",open:n,onOpenChange:r,middleware:[hi(10),tc({fallbackPlacements:["top-start","bottom-start","right-start"]}),ec({padding:8}),FI({apply({availableWidth:k,availableHeight:N,elements:R}){Object.assign(R.floating.style,{maxWidth:`${Math.min(400,k-16)}px`,maxHeight:`${Math.min(500,N-16)}px`})}})],whileElementsMounted:Bs}),E=C.useCallback(()=>{const{$from:k}=t.state.selection,N=k.parent;if(N.type.name==="paragraph"&&N.content.size===0||N.type.name==="heading"&&N.content.size===0)return!0;if(N.type.name==="listItem"&&N.content.size===1){const R=N.firstChild;if(R&&R.type.name==="paragraph"&&R.content.size===0)return!0}return t.isEditable},[t]),S=C.useCallback(()=>{if(!(e!=null&&e.current))return;const k=e.current.getBoundingClientRect(),N=t.view.dom.getBoundingClientRect(),B=t.view.coordsAtPos(t.state.selection.from).top-k.top,P=N.left-k.left,L=N.width;f({top:B,left:P,width:L}),x(),requestAnimationFrame(()=>l(!0))},[t,x,e]);C.useEffect(()=>{if(!t)return;let k=0;const N=()=>{cancelAnimationFrame(k),k=requestAnimationFrame(()=>{E()?(o(!0),l(!1),S()):(o(!1),r(!1),l(!1))})},R=()=>{o(!1),r(!1),l(!1)};return N(),t.on("selectionUpdate",N),t.on("transaction",N),t.on("focus",N),t.on("blur",R),()=>{cancelAnimationFrame(k),t.off("selectionUpdate",N),t.off("transaction",N),t.off("focus",N),t.off("blur",R)}},[t,E,S]);const M=k=>{k(t),r(!1),c(""),d("all")},w=O2.filter(k=>{const N=u==="all"||k.category===u,R=a===""||k.title.toLowerCase().includes(a.toLowerCase())||k.description.toLowerCase().includes(a.toLowerCase())||k.keywords.some(B=>B.toLowerCase().includes(a.toLowerCase()));return N&&R}),T=w.reduce((k,N)=>(k[N.category]||(k[N.category]=[]),k[N.category].push(N),k),{});return s?m.jsxs(m.Fragment,{children:[m.jsx("div",{style:{position:"absolute",top:h.top,left:h.left,width:h.width,visibility:i?"visible":"hidden",zIndex:1e4},className:"group",children:m.jsxs("div",{className:"relative py-4 w-[95%] mx-auto flex items-center","aria-label":"Insert block",children:[m.jsx("div",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-full h-0.5 bg-gradient-to-r from-transparent via-slate-300 to-transparent dark:via-slate-600 transform origin-center scale-x-0 opacity-0 group-hover:scale-x-100 group-hover:opacity-100 transition-all duration-300"}),m.jsxs("div",{ref:y.setReference,className:"relative z-10 cursor-pointer mx-auto",onClick:()=>r(k=>!k),children:[m.jsx("div",{className:"absolute -inset-3 rounded-full bg-primary/10 dark:bg-primary/20 scale-0 opacity-0 group-hover:scale-100 group-hover:opacity-100 transition-all duration-300 ease-out animate-pulse"}),m.jsx("div",{className:"relative bg-background border border-border p-1.5 rounded-full shadow-sm group-hover:shadow-md transition-all duration-200",children:m.jsx(uL,{className:"h-4 w-4 text-muted-foreground group-hover:text-primary transition-colors duration-200"})})]})]})}),n&&m.jsxs("div",{ref:y.setFloating,style:{position:b,top:g??0,left:p??0,zIndex:10001},className:"bg-background border border-border shadow-lg rounded-lg p-2 w-96 max-h-[500px] overflow-hidden",onMouseDown:k=>k.preventDefault(),children:[m.jsx("div",{className:"p-2 border-b border-border",children:m.jsx("input",{type:"text",placeholder:"Search blocks...",value:a,onChange:k=>c(k.target.value),className:"w-full px-3 py-2 text-sm bg-muted border border-input rounded-md focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent",autoFocus:!0})}),m.jsxs("div",{className:"flex gap-1 p-2 border-b border-border overflow-x-auto",children:[m.jsx(ce.Button,{variant:u==="all"?"default":"ghost",size:"sm",onClick:()=>d("all"),className:"text-xs whitespace-nowrap",children:"All"}),Object.entries(og).map(([k,N])=>m.jsxs(ce.Button,{variant:u===k?"default":"ghost",size:"sm",onClick:()=>d(k),className:"text-xs whitespace-nowrap flex items-center gap-1",children:[sg[k],N]},k))]}),m.jsxs("div",{className:"max-h-80 overflow-y-auto",children:[u==="all"?Object.entries(T).map(([k,N])=>m.jsxs("div",{className:"py-2",children:[m.jsxs("div",{className:"px-3 py-1 text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[sg[k],og[k]]}),N.map(R=>m.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(R.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:R.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:R.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:R.description})]})]})},R.title))]},k)):w.map(k=>m.jsx(ce.Button,{variant:"ghost",className:"w-full justify-start p-3 h-auto text-left",onClick:()=>M(k.command),children:m.jsxs("div",{className:"flex items-center gap-3 w-full",children:[m.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-md border bg-muted",children:k.icon}),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("p",{className:"font-medium text-sm",children:k.title}),m.jsx("p",{className:"text-xs text-muted-foreground truncate",children:k.description})]})]})},k.title)),w.length===0&&m.jsxs("div",{className:"p-4 text-center text-sm text-muted-foreground",children:['No blocks found for "',a,'"']})]})]})]}):null},D2=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ig=new Set(["address","article","aside","blockquote","canvas","dd","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","noscript","ol","p","pre","section","table","tfoot","ul","video","thead","tbody","tr","th","td","colgroup"]);function xw(t){const e=t.match(/^<\/?\s*([a-zA-Z0-9:-]+)/);return e?e[1].toLowerCase():null}function L2(t){return/^<\s*[^/!][^>]*>$/.test(t)}function lg(t){return/^<\s*\//.test(t)}function I2(t){if(/\/\s*>$/.test(t))return!0;const e=xw(t);return e?D2.has(e):!1}function j2(t){return/^<\s*!/.test(t)}function lu(t,e=2){if(!t)return"";const n=t.replace(/\r\n?/g,`
465
+ `).split(/(<[^>]+>)/g).filter(Boolean),r=" ".repeat(e);let s=0,o=[],i=null;for(let l=0;l<n.length;l++){const a=n[l];if(a.startsWith("<")){const c=xw(a);c&&(c==="pre"||c==="code"||c==="script"||c==="style")&&lg(a)&&(i=null),lg(a)&&s>0&&(s-=1);const u=c&&ig.has(c)||j2(a),d=`${u?r.repeat(s):""}${a.trim()}`;if(u)o.push(d);else{const h=o.length?o[o.length-1]:"";h&&!h.endsWith(`
466
+ `)?o[o.length-1]=h+a.trim():o.push(r.repeat(s)+a.trim())}c&&L2(a)&&!I2(a)&&ig.has(c)&&(s+=1,(c==="pre"||c==="code"||c==="script"||c==="style")&&(i=c))}else if(i){const c=a.split(`
467
+ `);for(const u of c)o.push(u)}else{let c=a.replace(/\s+/g," ");if(c.length>0){const u=o.length?o[o.length-1]:"";if(u&&!u.endsWith(`
468
+ `))o[o.length-1]=u+c;else{const d=c.replace(/^ +/,"");d&&o.push(r.repeat(s)+d)}}}}return o.join(`
469
+ `).replace(/\n{3,}/g,`
470
+
471
+ `)}const Kh=t=>{const[e,n]=C.useState({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0}),r=C.useCallback(()=>{if(!t){n({canUndo:!1,canRedo:!1,historyDepth:0,isHistoryEmpty:!0});return}const a=t.can().undo(),c=t.can().redo();n({canUndo:a,canRedo:c,historyDepth:a?1:0,isHistoryEmpty:!a&&!c})},[t]);C.useEffect(()=>{if(t)return r(),t.on("transaction",r),t.on("update",r),t.on("selectionUpdate",r),t.on("focus",r),t.on("blur",r),()=>{t.off("transaction",r),t.off("update",r),t.off("selectionUpdate",r),t.off("focus",r),t.off("blur",r)}},[t,r]);const s=C.useCallback(()=>{if(!t||!e.canUndo)return!1;try{console.log("useEditorHistory - Attempting undo operation");const a=t.chain().focus().undo().run();return console.log("useEditorHistory - Undo result:",a),a}catch(a){return console.error("useEditorHistory - Undo operation failed:",a),!1}},[t,e.canUndo]),o=C.useCallback(()=>{if(!t||!e.canRedo)return!1;try{console.log("useEditorHistory - Attempting redo operation");const a=t.chain().focus().redo().run();return console.log("useEditorHistory - Redo result:",a),a}catch(a){return console.error("useEditorHistory - Redo operation failed:",a),!1}},[t,e.canRedo]),i=C.useCallback(()=>{if(t)try{t.commands.clearContent(),r()}catch(a){console.warn("Clear history operation failed:",a)}},[t,r]),l=C.useCallback(()=>({...e}),[e]);return{...e,undo:s,redo:o,clearHistory:i,getHistoryState:l}},ww=(t,e)=>t?e==="undo"?t.can().undo():t.can().redo():!1,P2=(t,e)=>{if(!t||!ww(t,e))return!1;try{return e==="undo"?t.chain().focus().undo().run():t.chain().focus().redo().run()}catch(n){return console.warn(`${e} operation failed:`,n),!1}},wd=t=>{const e=typeof navigator<"u"&&navigator.platform.includes("Mac"),n=e?"Cmd":"Ctrl";return t==="undo"?`${n}+Z`:e?`${n}+Shift+Z`:`${n}+Y`},Gh=({editor:t,className:e,showLabels:n=!1,size:r="sm"})=>{const{canUndo:s,canRedo:o,undo:i,redo:l}=Kh(t);C.useEffect(()=>{if(!t)return;const u=d=>{t.isFocused&&(d.ctrlKey||d.metaKey)&&(d.key==="z"&&!d.shiftKey?(d.preventDefault(),i()):(d.key==="z"&&d.shiftKey||d.key==="y")&&(d.preventDefault(),l()))};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,i,l]);const a=r==="sm"?"sm":r==="lg"?"lg":"default",c=r==="sm"?"h-4 w-4":r==="lg"?"h-6 w-6":"h-5 w-5";return m.jsxs("div",{className:$e.cn("flex items-center gap-1",e),children:[m.jsxs(ce.Button,{variant:s?"outline":"ghost",size:a,onClick:i,disabled:!s,title:`Undo last action (${wd("undo")})`,"aria-label":"Undo last action",className:$e.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",s?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",s&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(kI,{className:$e.cn(c,"transition-colors duration-200",s?s?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Undo"})]}),m.jsxs(ce.Button,{variant:o?"outline":"ghost",size:a,onClick:l,disabled:!o,title:`Redo last undone action (${wd("redo")})`,"aria-label":"Redo last undone action",className:$e.cn("transition-all duration-200 border-2",r==="sm"?"h-8 w-8 p-0":r==="lg"?"h-10 w-10 p-0":"h-9 w-9 p-0",o?"border-primary/20 hover:border-primary/40 hover:bg-primary/10 hover:text-primary hover:scale-105 active:scale-95 shadow-sm":"opacity-40 cursor-not-allowed border-transparent",o&&"bg-primary/5",n&&"w-auto px-3"),children:[m.jsx(ZL,{className:$e.cn(c,"transition-colors duration-200",o?o?"text-primary":"text-current":"text-muted-foreground")}),n&&m.jsx("span",{className:"ml-2",children:"Redo"})]})]})},Ve=({onClick:t,isActive:e,disabled:n,children:r,title:s,ariaLabel:o,shortcut:i})=>{const l=i?`${s} (${i})`:s;return m.jsx(ce.Button,{variant:e?"default":"ghost",size:"sm",onClick:t,disabled:n,title:l,"aria-label":o||s,className:`h-8 w-8 p-0 transition-all duration-200 ${n?"opacity-40 cursor-not-allowed":"hover:bg-accent hover:text-accent-foreground hover:scale-105"}`,children:r})},B2=({editor:t})=>m.jsxs(vt.Popover,{children:[m.jsx(vt.PopoverTrigger,{asChild:!0,children:m.jsxs(ce.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Font size menu",title:"Font size menu",children:[m.jsx(ss,{className:"h-4 w-4 mr-1"}),"Size"]})}),m.jsx(vt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[360px] p-0",side:"bottom",align:"start",children:m.jsx(yw,{editor:t,className:"p-4"})})]}),H2=({editor:t})=>m.jsxs(vt.Popover,{children:[m.jsx(vt.PopoverTrigger,{asChild:!0,children:m.jsx(ce.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0","aria-label":"Color menu",title:"Color menu",children:m.jsx(Hh,{className:"h-4 w-4"})})}),m.jsx(vt.PopoverContent,{onFocusOutside:e=>e.preventDefault(),className:"w-[380px] p-0",side:"bottom",align:"start",children:m.jsx(gw,{editor:t,className:"p-4"})})]}),$2=({editor:t})=>{const e=async()=>{const s=rc(t);if(s){const i=await s();i!=null&&i.src&&(t.chain().focus().setImage({src:i.src,alt:i.alt||void 0}).run(),i.blurDataURL&&t.chain().focus().updateAttributes("image",{blurDataURL:i.blurDataURL}).run());return}const o=window.prompt("Enter image URL:");o&&t.chain().focus().setImage({src:o}).run()},n=()=>{t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()},r=()=>{const s=window.prompt("Enter URL:");s&&t.chain().focus().setLink({href:s}).run()};return m.jsxs(Ke.DropdownMenu,{children:[m.jsx(Ke.DropdownMenuTrigger,{asChild:!0,children:m.jsx(ce.Button,{variant:"ghost",size:"sm",className:"h-8 px-2",children:"Insert"})}),m.jsxs(Ke.DropdownMenuContent,{children:[m.jsxs(Ke.DropdownMenuItem,{onClick:e,children:[m.jsx(es,{className:"h-4 w-4 mr-2"}),"Image"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:n,children:[m.jsx(ui,{className:"h-4 w-4 mr-2"}),"Table"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:r,children:[m.jsx(Ja,{className:"h-4 w-4 mr-2"}),"Link"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>t.chain().focus().setHorizontalRule().run(),children:[m.jsx(Xa,{className:"h-4 w-4 mr-2"}),"Horizontal Rule"]}),m.jsx(Ke.DropdownMenuSeparator,{}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter CSS (without <style> tags):","/* your styles */");if(s!=null){const o=`<style>${s}</style>`;t.commands.insertContentAt({from:0,to:0},o)}},children:[m.jsx(Fr,{className:"h-4 w-4 mr-2"}),"CSS Block"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Enter JavaScript (without <script> tags):","// your script");if(s!=null){const o=`<script>${s}<\/script>`,i=t.state.doc.content.size;t.commands.insertContentAt(i,o)}},children:[m.jsx(Fr,{className:"h-4 w-4 mr-2"}),"Script Block"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>{const s=window.prompt("Optional class for DIV:",""),o=window.prompt("Optional inline style for DIV:",""),i=window.prompt("Optional content for DIV:","New block"),l=`${s?` class="${s}"`:""}${o?` style="${o}"`:""}`,c=i?`<p>${(u=>u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"))(i)}</p>`:"<p><br /></p>";t.chain().focus().insertContent(`<div${l}>${c}</div>`).run()},children:[m.jsx(Fr,{className:"h-4 w-4 mr-2"}),"DIV Block"]}),m.jsx(Ke.DropdownMenuSeparator,{}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>t.chain().focus().setAlertWidget().run(),children:[m.jsx(Qa,{className:"h-4 w-4 mr-2"}),"Alert Widget"]}),m.jsxs(Ke.DropdownMenuItem,{onClick:()=>t.chain().focus().setCtaWidget({text:"Learn more",url:"",style:"primary",size:"medium",textAlign:"center"}).run(),children:[m.jsx(Ya,{className:"h-4 w-4 mr-2"}),"CTA Widget"]})]})]})},z2=({editor:t})=>{const e=()=>{const s=t.getHTML(),o=new Blob([s],{type:"text/html"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download="document.html",l.click(),URL.revokeObjectURL(i)},n=()=>{const s=JSON.stringify(t.getJSON(),null,2),o=new Blob([s],{type:"application/json"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download="document.json",l.click(),URL.revokeObjectURL(i)},r=()=>{const s=t.getText(),o=new Blob([s],{type:"text/plain"}),i=URL.createObjectURL(o),l=document.createElement("a");l.href=i,l.download="document.txt",l.click(),URL.revokeObjectURL(i)};return m.jsxs(Ke.DropdownMenu,{children:[m.jsx(Ke.DropdownMenuTrigger,{asChild:!0,children:m.jsx(ce.Button,{variant:"ghost",size:"sm",className:"h-8 px-2","aria-label":"Export menu",title:"Export menu",children:m.jsx(Zx,{className:"h-4 w-4 mr-1"})})}),m.jsxs(Ke.DropdownMenuContent,{children:[m.jsx(Ke.DropdownMenuItem,{onClick:e,children:"Export as HTML"}),m.jsx(Ke.DropdownMenuItem,{onClick:n,children:"Export as JSON"}),m.jsx(Ke.DropdownMenuItem,{onClick:r,children:"Export as Text"})]})]})},Jh=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(""),[o,i]=C.useState(!1),[l,a]=C.useState(null),c=C.useRef([]);if(C.useEffect(()=>{if(!t)return;const f=g=>{try{const y=t.getHTML();s(lu(y)),n(!0)}catch{}},p="editor:openSourceView";return window.addEventListener(p,f),()=>window.removeEventListener(p,f)},[t]),!t)return null;const u=()=>{const f=t.getHTML();s(lu(f)),n(!0)},d=()=>{t.chain().focus().setContent(r).run(),n(!1)},h=()=>{for(const w of c.current)try{URL.revokeObjectURL(w)}catch{}c.current=[];const f=t.getHTML(),y=new DOMParser().parseFromString(`<div id="__content__">${f}</div>`,"text/html").body.querySelector("#__content__");Array.from(y.querySelectorAll("script")).forEach(w=>{if(!w.getAttribute("src")){const T=w.textContent||"",k=new Blob([T],{type:"text/javascript"}),N=URL.createObjectURL(k);w.setAttribute("src",N),w.textContent="",c.current.push(N)}});const E=`<!doctype html><html><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><title>Preview</title></head><body>${y.innerHTML}</body></html>`,S=new Blob([E],{type:"text/html"}),M=URL.createObjectURL(S);c.current.push(M),l&&URL.revokeObjectURL(l),a(M),i(!0)};return m.jsxs("div",{className:"border-b bg-background p-2 relative",children:[m.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[m.jsx("div",{className:"flex items-center gap-1 mr-2 p-1 rounded-md bg-muted/30 border border-border/50",children:m.jsx(Gh,{editor:t,size:"sm",showLabels:!1})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:t.isActive("heading",{level:1}),title:"Heading 1",children:m.jsx(Ls,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:t.isActive("heading",{level:2}),title:"Heading 2",children:m.jsx(ai,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:t.isActive("heading",{level:3}),title:"Heading 3",children:m.jsx(Ga,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleBold().run(),isActive:t.isActive("bold"),title:"Bold",children:m.jsx(ga,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleItalic().run(),isActive:t.isActive("italic"),title:"Italic",children:m.jsx(Bh,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleUnderline().run(),isActive:t.isActive("underline"),title:"Underline",children:m.jsx($h,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleStrike().run(),isActive:t.isActive("strike"),title:"Strikethrough",children:m.jsx(Qx,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleCode().run(),isActive:t.isActive("code"),title:"Inline Code",children:m.jsx(Fs,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleSubscript().run(),isActive:t.isActive("subscript"),title:"Subscript",children:m.jsx(ew,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleSuperscript().run(),isActive:t.isActive("superscript"),title:"Superscript",children:m.jsx(tw,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().setTextAlign("left").run(),isActive:t.isActive({textAlign:"left"}),title:"Align Left",children:m.jsx(Ds,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().setTextAlign("center").run(),isActive:t.isActive({textAlign:"center"}),title:"Align Center",children:m.jsx(ii,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().setTextAlign("right").run(),isActive:t.isActive({textAlign:"right"}),title:"Align Right",children:m.jsx(li,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().setTextAlign("justify").run(),isActive:t.isActive({textAlign:"justify"}),title:"Justify",children:m.jsx(Ph,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleBulletList().run(),isActive:t.isActive("bulletList"),title:"Bullet List",children:m.jsx(Us,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleOrderedList().run(),isActive:t.isActive("orderedList"),title:"Numbered List",children:m.jsx(ci,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleTaskList().run(),isActive:t.isActive("taskList"),title:"Task List",children:m.jsx(Za,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleBlockquote().run(),isActive:t.isActive("blockquote"),title:"Blockquote",children:m.jsx(di,{className:"h-4 w-4"})}),m.jsx(Ve,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),isActive:t.isActive("codeBlock"),title:"Code Block",children:m.jsx(Fr,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(B2,{editor:t}),m.jsx(H2,{editor:t}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx($2,{editor:t}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:u,title:"View Source (HTML)",children:m.jsx(EL,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(Ve,{onClick:h,title:"Preview (executes scripts)",children:m.jsx(SL,{className:"h-4 w-4"})}),m.jsx(Jt.Separator,{orientation:"vertical",className:"h-6 mx-1"}),m.jsx(z2,{editor:t})]}),e&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[90vw] max-w-4xl h-[70vh] flex flex-col",children:[m.jsx("div",{className:"p-3 border-b font-semibold",children:"Edit HTML Source"}),m.jsx("textarea",{className:"flex-1 p-3 font-mono text-sm outline-none resize-none bg-muted/30",value:r,onChange:f=>s(f.target.value),spellCheck:!1}),m.jsxs("div",{className:"p-3 border-t flex justify-end gap-2",children:[m.jsx(ce.Button,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"Cancel"}),m.jsx(ce.Button,{variant:"secondary",size:"sm",onClick:()=>s(lu(r)),children:"Format"}),m.jsx(ce.Button,{size:"sm",onClick:d,children:"Apply"})]})]})}),o&&m.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",children:m.jsxs("div",{className:"bg-background border rounded-md shadow-xl w-[95vw] max-w-5xl h-[80vh] flex flex-col",children:[m.jsxs("div",{className:"p-3 border-b flex items-center justify-between",children:[m.jsx("div",{className:"font-semibold",children:"Preview"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsx(ce.Button,{variant:"outline",size:"sm",onClick:()=>{h()},children:"Refresh"}),m.jsx(ce.Button,{size:"sm",onClick:()=>{for(const f of c.current)try{URL.revokeObjectURL(f)}catch{}c.current=[],l&&URL.revokeObjectURL(l),a(null),i(!1)},children:"Close"})]})]}),m.jsx("div",{className:"flex-1",children:m.jsx("iframe",{title:"Editor Preview",className:"w-full h-full",sandbox:"allow-scripts allow-same-origin allow-modals",src:l??void 0})})]})})]})},vw=({editor:t,className:e,onDragStart:n,onDragEnd:r,onNodeChange:s})=>{const o=C.useRef(null);return C.useEffect(()=>{if(!t||!o.current)return;const i=c=>{n==null||n(c)},l=c=>{r==null||r(c)},a=o.current;return a.addEventListener("dragstart",i),a.addEventListener("dragend",l),()=>{a.removeEventListener("dragstart",i),a.removeEventListener("dragend",l)}},[t,n,r]),t?m.jsx("div",{ref:o,className:$e.cn("drag-handle-button","flex items-center justify-center","w-7 h-7 rounded-md border-2","text-slate-500 hover:text-slate-700","border-slate-200/50 hover:border-slate-300","bg-slate-50/50 hover:bg-slate-100/80","active:bg-slate-200/80 active:border-slate-400","cursor-grab active:cursor-grabbing","transition-all duration-200 ease-in-out","opacity-0 group-hover:opacity-100","hover:scale-105 active:scale-95","hover:shadow-sm active:shadow-none","focus:opacity-100 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-1","dark:text-slate-400 dark:hover:text-slate-200","dark:border-slate-700/50 dark:hover:border-slate-600","dark:bg-slate-800/50 dark:hover:bg-slate-700/80","dark:active:bg-slate-600/80 dark:active:border-slate-500",e),role:"button",tabIndex:0,"aria-label":"Drag to reorder this block",title:"Hold and drag to reorder this block",draggable:!0,children:m.jsx(AL,{className:"w-4 h-4"})}):null},kw=({editor:t,className:e})=>{const[n,r]=C.useState(!1),[s,o]=C.useState("format"),[i,l]=C.useState(!1),a=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768;C.useEffect(()=>{const h=()=>{r(a())};return h(),window.addEventListener("resize",h),()=>window.removeEventListener("resize",h)},[]),C.useEffect(()=>{if(!t)return;const h=()=>{const{selection:f}=t.state;!f.empty&&a()?r(!0):i||r(!1)};return t.on("selectionUpdate",h),t.on("focus",h),t.on("blur",()=>{i||r(!1)}),()=>{t.off("selectionUpdate",h),t.off("focus",h),t.off("blur",()=>r(!1))}},[t,i]);const c=[{icon:m.jsx(ga,{className:"h-4 w-4"}),label:"Bold",action:()=>t.chain().focus().toggleBold().run(),isActive:()=>t.isActive("bold"),section:"format"},{icon:m.jsx(Bh,{className:"h-4 w-4"}),label:"Italic",action:()=>t.chain().focus().toggleItalic().run(),isActive:()=>t.isActive("italic"),section:"format"},{icon:m.jsx($h,{className:"h-4 w-4"}),label:"Underline",action:()=>t.chain().focus().toggleUnderline().run(),isActive:()=>t.isActive("underline"),section:"format"},{icon:m.jsx(Fs,{className:"h-4 w-4"}),label:"Code",action:()=>t.chain().focus().toggleCode().run(),isActive:()=>t.isActive("code"),section:"format"},{icon:m.jsx(Hh,{className:"h-4 w-4"}),label:"Highlight",action:()=>t.chain().focus().toggleHighlight().run(),isActive:()=>t.isActive("highlight"),section:"format"},{icon:m.jsx(ss,{className:"h-4 w-4"}),label:"Paragraph",action:()=>t.chain().focus().setParagraph().run(),isActive:()=>t.isActive("paragraph"),section:"blocks"},{icon:m.jsx(Ls,{className:"h-4 w-4"}),label:"Heading 1",action:()=>t.chain().focus().toggleHeading({level:1}).run(),isActive:()=>t.isActive("heading",{level:1}),section:"blocks"},{icon:m.jsx(ai,{className:"h-4 w-4"}),label:"Heading 2",action:()=>t.chain().focus().toggleHeading({level:2}).run(),isActive:()=>t.isActive("heading",{level:2}),section:"blocks"},{icon:m.jsx(Ga,{className:"h-4 w-4"}),label:"Heading 3",action:()=>t.chain().focus().toggleHeading({level:3}).run(),isActive:()=>t.isActive("heading",{level:3}),section:"blocks"},{icon:m.jsx(Us,{className:"h-4 w-4"}),label:"Bullet List",action:()=>t.chain().focus().toggleBulletList().run(),isActive:()=>t.isActive("bulletList"),section:"blocks"},{icon:m.jsx(ci,{className:"h-4 w-4"}),label:"Numbered List",action:()=>t.chain().focus().toggleOrderedList().run(),isActive:()=>t.isActive("orderedList"),section:"blocks"},{icon:m.jsx(Za,{className:"h-4 w-4"}),label:"Task List",action:()=>t.chain().focus().toggleTaskList().run(),isActive:()=>t.isActive("taskList"),section:"blocks"},{icon:m.jsx(di,{className:"h-4 w-4"}),label:"Quote",action:()=>t.chain().focus().toggleBlockquote().run(),isActive:()=>t.isActive("blockquote"),section:"blocks"},{icon:m.jsx(Ja,{className:"h-4 w-4"}),label:"Link",action:()=>{const h=window.prompt("Enter URL:");h&&t.chain().focus().setLink({href:h}).run()},isActive:()=>t.isActive("link"),section:"insert"},{icon:m.jsx(es,{className:"h-4 w-4"}),label:"Image",action:async()=>{const h=rc(t);if(h){const p=await h();p!=null&&p.src&&t.chain().focus().setImage({src:p.src,alt:p.alt||void 0}).run();return}const f=window.prompt("Enter image URL:");f&&t.chain().focus().setImage({src:f}).run()},section:"insert"},{icon:m.jsx(ui,{className:"h-4 w-4"}),label:"Table",action:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),section:"insert"},{icon:m.jsx(Ds,{className:"h-4 w-4"}),label:"Align Left",action:()=>t.chain().focus().setTextAlign("left").run(),isActive:()=>t.isActive({textAlign:"left"}),section:"align"},{icon:m.jsx(ii,{className:"h-4 w-4"}),label:"Align Center",action:()=>t.chain().focus().setTextAlign("center").run(),isActive:()=>t.isActive({textAlign:"center"}),section:"align"},{icon:m.jsx(li,{className:"h-4 w-4"}),label:"Align Right",action:()=>t.chain().focus().setTextAlign("right").run(),isActive:()=>t.isActive({textAlign:"right"}),section:"align"}],u=[{key:"format",label:"Format",icon:m.jsx(ga,{className:"h-3 w-3"})},{key:"blocks",label:"Blocks",icon:m.jsx(Ls,{className:"h-3 w-3"})},{key:"insert",label:"Insert",icon:m.jsx(es,{className:"h-3 w-3"})},{key:"align",label:"Align",icon:m.jsx(Ds,{className:"h-3 w-3"})}],d=c.filter(h=>h.section===s);return!n&&!i?null:m.jsxs("div",{className:$e.cn("fixed bottom-0 left-0 right-0 z-50 bg-background border-t border-border shadow-lg","transform transition-transform duration-300 ease-in-out",n||i?"translate-y-0":"translate-y-full",e),children:[m.jsx("div",{className:"flex justify-center py-2 border-b border-border",children:m.jsxs(ce.Button,{variant:"ghost",size:"sm",onClick:()=>l(!i),className:"flex items-center gap-2",children:[i?m.jsx(sw,{className:"h-4 w-4"}):m.jsx(qL,{className:"h-4 w-4"}),m.jsx("span",{className:"text-xs",children:i?"Close":"Tools"})]})}),(i||n)&&m.jsxs(m.Fragment,{children:[m.jsx("div",{className:"flex border-b border-border bg-muted/50",children:u.map(h=>m.jsx(ce.Button,{variant:s===h.key?"default":"ghost",size:"sm",onClick:()=>o(h.key),className:"flex-1 rounded-none text-xs py-2 h-auto",children:m.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.icon,m.jsx("span",{children:h.label})]})},h.key))}),m.jsx("div",{className:"p-2",children:m.jsx("div",{className:"flex flex-wrap gap-1 justify-center",children:d.map((h,f)=>{var p;return m.jsxs(ce.Button,{variant:(p=h.isActive)!=null&&p.call(h)?"default":"ghost",size:"sm",onClick:h.action,className:"flex flex-col items-center gap-1 h-auto py-2 px-3 min-w-[60px]",title:h.label,children:[h.icon,m.jsx("span",{className:"text-xs",children:h.label})]},f)})})})]}),m.jsx("div",{className:"h-safe-area-inset-bottom"})]})},sc=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:o=!0,className:i,onFocus:l,onBlur:a,useEnhancedFloatingMenu:c=!0,showMobileToolbar:u=!0,enableAdvancedPlaceholders:d=!0,enableFocusMode:h=!1,showKeyboardShortcuts:f=!1})=>{var T,k,N;const p=C.useRef(null),[g,y]=C.useState({isOpen:!1,searchTerm:"",replaceTerm:"",currentMatch:0,totalMatches:0,caseSensitive:!1,wholeWord:!1}),b=xb({extensions:Fh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:R})=>{e(R.getHTML())},onFocus:()=>{l==null||l()},onBlur:()=>{a==null||a()},editorProps:{attributes:{class:$e.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none p-4 min-h-[500px] w-full","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm",i)},handleKeyDown:(R,B)=>{if(B.ctrlKey||B.metaKey)switch(B.key){case"f":return B.preventDefault(),y(P=>({...P,isOpen:!P.isOpen})),!0;case"s":return B.preventDefault(),!0;default:return!1}return!1}}});C.useEffect(()=>{if(!b)return;const R=b.getHTML();if(t!==R){const{from:B,to:P}=b.state.selection;b.commands.setContent(t,{emitUpdate:!1}),b.commands.setTextSelection({from:B,to:P})}},[t,b]);const x=R=>{if(!b||!R){y(oe=>({...oe,totalMatches:0,currentMatch:0}));return}const B=b.getText(),P=g.caseSensitive?"g":"gi",L=g.wholeWord?`\\b${R}\\b`:R,H=new RegExp(L,P),se=B.match(H);y(oe=>({...oe,totalMatches:se?se.length:0,currentMatch:se?1:0}))},E=()=>{if(!b||!g.searchTerm)return;const R=b.getHTML(),B=g.caseSensitive?"g":"gi",P=g.wholeWord?`\\b${g.searchTerm}\\b`:g.searchTerm,L=new RegExp(P,B),H=R.replace(L,g.replaceTerm);b.commands.setContent(H),y(se=>({...se,totalMatches:0,currentMatch:0}))};if(!b)return null;const S=(T=b.storage)==null?void 0:T.characterCount,M=((k=S==null?void 0:S.characters)==null?void 0:k.call(S))??0,w=((N=S==null?void 0:S.words)==null?void 0:N.call(S))??0;return m.jsxs("div",{ref:p,className:$e.cn("relative w-full rounded-lg border bg-background shadow-sm","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),children:[s&&m.jsx(Jh,{editor:b}),g.isOpen&&m.jsxs("div",{className:"border-b bg-muted/50 p-3",children:[m.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[m.jsxs("div",{className:"flex items-center gap-2 flex-1",children:[m.jsx(aI,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ps.Input,{placeholder:"Search...",value:g.searchTerm,onChange:R=>{const B=R.target.value;y(P=>({...P,searchTerm:B})),x(B)},className:"h-8"}),m.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:g.totalMatches>0?`${g.currentMatch}/${g.totalMatches}`:"No matches"})]}),m.jsx(ce.Button,{variant:"ghost",size:"sm",onClick:()=>y(R=>({...R,isOpen:!1})),children:m.jsx(sw,{className:"h-4 w-4"})})]}),m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx(eI,{className:"h-4 w-4 text-muted-foreground"}),m.jsx(ps.Input,{placeholder:"Replace with...",value:g.replaceTerm,onChange:R=>y(B=>({...B,replaceTerm:R.target.value})),className:"h-8 flex-1"}),m.jsx(ce.Button,{variant:"outline",size:"sm",onClick:E,disabled:!g.searchTerm||g.totalMatches===0,children:"Replace All"})]})]}),m.jsx(Wh,{editor:b}),c?m.jsx(bw,{editor:b,wrapperRef:p}):m.jsx(qh,{editor:b}),m.jsx(vw,{editor:b,onDragStart:R=>{console.log("Drag started:",R),document.body.classList.add("dragging")},onDragEnd:R=>{console.log("Drag ended:",R),document.body.classList.remove("dragging")},onNodeChange:({node:R,editor:B,pos:P})=>{R&&console.log("Hovering over node:",R.type.name,"at position:",P)}}),m.jsx(yb,{editor:b}),o&&S&&m.jsxs("div",{className:"absolute bottom-2 right-2 z-10 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[M," characters / ",w," words"]}),f&&m.jsxs("div",{className:"absolute bottom-2 left-2 text-xs text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border opacity-0 hover:opacity-100 transition-opacity",children:[m.jsx("div",{children:"Ctrl+F: Search"}),m.jsx("div",{children:"Ctrl+S: Save"}),m.jsx("div",{children:"/: Commands"}),m.jsx("div",{children:"Ctrl+K: Insert Link"}),m.jsx("div",{children:"Ctrl+Shift+H: Highlight"}),m.jsx("div",{children:"Ctrl+Alt+1-6: Headings"})]}),u&&m.jsx(kw,{editor:b})]})},F2=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{x:o,y:i,refs:l,strategy:a,update:c}=fi({placement:"top",strategy:"fixed",open:e,onOpenChange:n,middleware:[hi(-12)],whileElementsMounted:Bs}),u=C.useCallback(()=>t.isActive("image"),[t]),d=t.getAttributes("image")||{},h=C.useCallback(()=>{const{state:y,view:b}=t,x=()=>{var M,w;try{if(y.selection instanceof K){const N=b.nodeDOM(y.selection.from);if(N){const R=((M=N.closest)==null?void 0:M.call(N,".tiptap-image-wrapper"))??N;return R.querySelector("img")??R}}const T=b.dom.querySelector(".tiptap-image-wrapper.ProseMirror-selectednode");if(T)return T.querySelector("img")??T;const k=b.dom.querySelector(".ProseMirror-selectednode");if(k){const N=((w=k.closest)==null?void 0:w.call(k,".tiptap-image-wrapper"))??k;return N.querySelector("img")??N}}catch{}return null},E=h._lastEl,S=x()??E;if(S){h._lastEl=S;const M={getBoundingClientRect:()=>{const w=x()??h._lastEl;return w?w.getBoundingClientRect():new DOMRect(0,0,0,0)}};l.setReference(M)}else{const M=b.coordsAtPos(y.selection.from),w={getBoundingClientRect:()=>new DOMRect(M.left,M.top,0,0)};l.setReference(w)}requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,l,c]);if(C.useEffect(()=>{const y=()=>{const b=u();n(b),s(!1),b&&h()};return y(),t.on("selectionUpdate",y),t.on("transaction",y),t.on("focus",y),t.on("blur",()=>n(!1)),()=>{t.off("selectionUpdate",y),t.off("transaction",y),t.off("focus",y)}},[t,u,h]),!e)return null;const f=y=>{t.chain().focus().updateAttributes("image",{align:y}).run(),requestAnimationFrame(()=>h())},p=()=>{t.chain().focus().deleteSelection().run()},g=()=>{const y=d==null?void 0:d.src;if(y)try{const b=document.createElement("a");b.href=y;const x=(y.split("?")[0]||"").split("/").pop()||"image";b.download=x,document.body.appendChild(b),b.click(),b.remove()}catch{}};return m.jsxs("div",{ref:l.setFloating,style:{position:a,top:i??0,left:o??0,zIndex:10002,visibility:r?"visible":"hidden",pointerEvents:"auto"},className:"bg-background/95 backdrop-blur border rounded-full shadow-lg px-3 py-2 flex items-center gap-1",onMouseDown:y=>y.preventDefault(),children:[m.jsx(ce.Button,{size:"icon",variant:d.align==="left"?"default":"ghost",title:"Align left",onClick:()=>f("left"),children:m.jsx(Ds,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:d.align==="center"?"default":"ghost",title:"Align center",onClick:()=>f("center"),children:m.jsx(ii,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:d.align==="right"?"default":"ghost",title:"Align right",onClick:()=>f("right"),children:m.jsx(li,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",title:"Download",onClick:g,children:m.jsx(Zx,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",title:"Delete",onClick:p,children:m.jsx(nw,{className:"h-4 w-4"})})]})},ag=t=>t.isActive("table")||t.isActive("tableCell")||t.isActive("tableHeader")||t.isActive("tableRow"),U2=({editor:t})=>{const[e,n]=C.useState(!1),[r,s]=C.useState(!1),{refs:o,x:i,y:l,strategy:a,update:c}=fi({placement:"bottom",strategy:"fixed",middleware:[hi(12),tc(),ec()],whileElementsMounted:Bs,open:e,onOpenChange:n}),u=C.useCallback(()=>{var R;const{state:k,view:N}=t;try{const{from:B}=k.selection,{node:P}=N.domAtPos(B);let L=null;return P.nodeType===Node.ELEMENT_NODE?L=P:(P.nodeType===Node.TEXT_NODE||P!=null&&P.parentElement)&&(L=P.parentElement),((R=L==null?void 0:L.closest)==null?void 0:R.call(L,"td, th"))??null}catch{return null}},[t]),d=C.useCallback(()=>{const k=u();return(k==null?void 0:k.closest("table"))??null},[u]),h=C.useCallback(()=>{if(!ag(t)){n(!1);return}const k=d();if(!k){n(!1);return}o.setReference(k),n(!0),s(!1),requestAnimationFrame(()=>{c(),requestAnimationFrame(()=>s(!0))})},[t,o,d,c]);if(C.useEffect(()=>{const k=()=>{ag(t)?h():n(!1)},N=()=>n(!1);return k(),t.on("selectionUpdate",k),t.on("transaction",k),t.on("focus",k),t.on("blur",N),()=>{t.off("selectionUpdate",k),t.off("transaction",k),t.off("focus",k),t.off("blur",N)}},[t,h]),!e)return null;const f=t.can(),p=typeof f.addRowAfter=="function"?f.addRowAfter():!1,g=typeof f.deleteRow=="function"?f.deleteRow():!1,y=typeof f.addColumnAfter=="function"?f.addColumnAfter():!1,b=typeof f.deleteColumn=="function"?f.deleteColumn():!1,x=typeof f.deleteTable=="function"?f.deleteTable():!1,E=()=>{t.chain().focus().addRowAfter().run(),h()},S=()=>{t.chain().focus().deleteRow().run(),h()},M=()=>{t.chain().focus().addColumnAfter().run(),h()},w=()=>{t.chain().focus().deleteColumn().run(),h()},T=()=>{t.chain().focus().deleteTable().run(),n(!1)};return m.jsxs("div",{ref:o.setFloating,style:{position:a,top:l??0,left:i??0,zIndex:10002,visibility:r?"visible":"hidden"},className:"flex items-center gap-1 rounded-full border bg-background/95 px-2 py-1 shadow-lg",onMouseDown:k=>k.preventDefault(),children:[m.jsx(ce.Button,{size:"icon",variant:"ghost",onClick:E,disabled:!p,title:"Add row below","aria-label":"Add row below",children:m.jsx(iI,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",onClick:S,disabled:!g,title:"Delete current row","aria-label":"Delete current row",children:m.jsx(sI,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",onClick:M,disabled:!y,title:"Add column to the right","aria-label":"Add column to the right",children:m.jsx(bL,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",onClick:w,disabled:!b,title:"Delete current column","aria-label":"Delete current column",children:m.jsx(gL,{className:"h-4 w-4"})}),m.jsx(ce.Button,{size:"icon",variant:"ghost",onClick:T,disabled:!x,title:"Delete table","aria-label":"Delete table",children:m.jsx(nw,{className:"h-4 w-4"})})]})},Sw=({content:t,onChange:e,placeholder:n,editable:r=!0,showToolbar:s=!0,showCharacterCount:o=!0,className:i,onFocus:l,onBlur:a,openImagePicker:c})=>{var g,y,b;const u=C.useRef(null),d=xb({extensions:Fh,content:t,editable:r,immediatelyRender:!1,onUpdate:({editor:x})=>e(x.getHTML()),onFocus:()=>{l==null||l()},onBlur:()=>{a==null||a()},editorProps:{attributes:{class:$e.cn("prose dark:prose-invert prose-sm sm:prose-base lg:prose-lg xl:prose-2xl","mx-auto focus:outline-none min-h-[500px] w-full","pl-12 pr-4 py-4","prose-headings:scroll-mt-[80px] prose-headings:font-semibold","prose-h1:text-4xl prose-h2:text-3xl prose-h3:text-2xl","prose-p:leading-7 prose-li:leading-7","prose-pre:bg-muted prose-pre:border prose-pre:rounded-lg","prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded","prose-blockquote:border-l-4 prose-blockquote:border-primary prose-blockquote:pl-4","prose-table:border-collapse prose-table:border prose-table:border-border","prose-th:border prose-th:border-border prose-th:bg-muted prose-th:p-2","prose-td:border prose-td:border-border prose-td:p-2","prose-img:rounded-lg prose-img:shadow-sm")}}});if(C.useEffect(()=>{if(!d)return;const{setOpenImagePicker:x}=require("./utils/mediaPicker");return x(d,c),()=>x(d,void 0)},[d,c]),C.useEffect(()=>{if(!d)return;const x=d.getHTML();if(t!==x){const{from:E,to:S}=d.state.selection;d.commands.setContent(t,{emitUpdate:!1}),d.commands.setTextSelection({from:E,to:S})}},[t,d]),!d)return null;const h=(g=d.storage)==null?void 0:g.characterCount,f=((y=h==null?void 0:h.characters)==null?void 0:y.call(h))??0,p=((b=h==null?void 0:h.words)==null?void 0:b.call(h))??0;return m.jsxs("div",{ref:u,className:$e.cn("relative w-full rounded-lg border bg-background shadow-sm","flex flex-col h-full min-h-0","focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",i),children:[s&&m.jsx(Jh,{editor:d}),m.jsx(Wh,{editor:d}),m.jsx(qh,{editor:d}),m.jsx(F2,{editor:d}),m.jsx(U2,{editor:d}),m.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:m.jsx(yb,{editor:d})}),o&&h&&m.jsxs("div",{className:"absolute bottom-2 right-2 text-xs z-10 text-muted-foreground bg-background/80 backdrop-blur-sm rounded px-2 py-1 border",children:[f," characters / ",p," words"]})]})},Cw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:$e.cn("flex items-center gap-1 rounded-md bg-background p-1",t),...e}));Cw.displayName="Toolbar";const Ew=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:$e.cn("flex items-center gap-1",t),...e}));Ew.displayName="ToolbarGroup";const Mw=C.forwardRef(({className:t,isActive:e,...n},r)=>m.jsx("button",{ref:r,className:$e.cn("inline-flex items-center justify-center rounded-md p-1.5 text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{"bg-accent text-accent-foreground":e},t),...n}));Mw.displayName="ToolbarButton";const Aw=C.forwardRef(({className:t,...e},n)=>m.jsx("div",{ref:n,className:$e.cn("mx-1 h-7 w-px bg-muted",t),...e}));Aw.displayName="ToolbarSeparator";const V2=({html:t,className:e})=>{const n=C.useRef(null);return C.useEffect(()=>{const r=n.current;if(!r)return;r.innerHTML=t;const s=[];return Array.from(r.querySelectorAll("script")).forEach(i=>{var a;const l=document.createElement("script");for(const c of Array.from(i.attributes))l.setAttribute(c.name,c.value);if(i.src)l.src=i.src;else{const c=i.textContent||"",u=new Blob([c],{type:l.type||"text/javascript"}),d=URL.createObjectURL(u);l.src=d,l.async=!1,s.push(d)}(a=i.parentNode)==null||a.insertBefore(l,i),i.remove()}),()=>{s.forEach(i=>{try{URL.revokeObjectURL(i)}catch{}})}},[t]),m.jsx("div",{ref:n,className:e})},W2=fe.create({name:"enhancedFocus",addOptions(){return{className:"has-focus",mode:"all",showFocusRing:!0,highlightSelection:!0,dimUnfocused:!1,animateTransitions:!0}},addProseMirrorPlugins(){return[new me({key:new ye("enhancedFocus"),props:{decorations:({doc:t,selection:e})=>{const{from:n,to:r}=e,s=[];if(t.nodesBetween(n,r,(o,i)=>{const l=De.node(i,i+o.nodeSize,{class:this.options.className});s.push(l)}),this.options.highlightSelection&&n!==r){const o=De.inline(n,r,{class:"selection-highlight"});s.push(o)}if(this.options.showFocusRing){const o=De.widget(n,()=>{const i=document.createElement("div");return i.className="focus-ring",i});s.push(o)}return be.create(t,s)}},view:()=>({update:(t,e)=>{const{state:n}=t,{selection:r}=n,s=e.selection;r.eq(s)||this.editor.emit("selectionUpdate",{editor:this.editor,transaction:n.tr})}})})]},addGlobalAttributes(){return[{types:["paragraph","heading","blockquote","codeBlock","listItem"],attributes:{"data-focused":{default:null,renderHTML:t=>t["data-focused"]?{"data-focused":t["data-focused"]}:{}}}}]},onCreate(){const t=this.editor.view.dom;this.options.animateTransitions&&t.classList.add("focus-transitions"),this.options.dimUnfocused&&t.classList.add("dim-unfocused")},onSelectionUpdate(){const{state:t}=this.editor,{selection:e}=t,{from:n,to:r}=e,s=t.tr;let o=!1;t.doc.descendants((i,l)=>{if(i.isText||i.isLeaf)return;const a=l,c=l+i.nodeSize,u=n>=a&&r<=c,d=i.attrs["data-focused"];u&&!d?(s.setNodeMarkup(l,void 0,{...i.attrs,"data-focused":"true"}),o=!0):!u&&d&&(s.setNodeMarkup(l,void 0,{...i.attrs,"data-focused":null}),o=!0)}),o&&this.editor.view.dispatch(s)},addStorage(){return{isFocused:!1}},onFocus(){this.editor.view.dom.classList.add("editor-focused"),this.storage.isFocused=!0},onBlur(){this.editor.view.dom.classList.remove("editor-focused"),this.storage.isFocused=!1}}),q2=fe.create({name:"keyboardShortcuts",addOptions(){return{enableAdvancedShortcuts:!0,enableCustomShortcuts:!0,showShortcutHints:!1}},addKeyboardShortcuts(){const t={};return this.options.enableAdvancedShortcuts&&(t["Mod-Shift-x"]=()=>this.editor.commands.toggleStrike(),t["Mod-Shift-h"]=()=>this.editor.commands.toggleHighlight(),t["Mod-Shift-c"]=()=>this.editor.commands.toggleCode(),t["Mod-Alt-1"]=()=>this.editor.commands.toggleHeading({level:1}),t["Mod-Alt-2"]=()=>this.editor.commands.toggleHeading({level:2}),t["Mod-Alt-3"]=()=>this.editor.commands.toggleHeading({level:3}),t["Mod-Alt-4"]=()=>this.editor.commands.toggleHeading({level:4}),t["Mod-Alt-5"]=()=>this.editor.commands.toggleHeading({level:5}),t["Mod-Alt-6"]=()=>this.editor.commands.toggleHeading({level:6}),t["Mod-Alt-0"]=()=>this.editor.commands.setParagraph(),t["Mod-Shift-8"]=()=>this.editor.commands.toggleBulletList(),t["Mod-Shift-7"]=()=>this.editor.commands.toggleOrderedList(),t["Mod-Shift-9"]=()=>this.editor.commands.toggleTaskList(),t["Mod-Shift-b"]=()=>this.editor.commands.toggleBlockquote(),t["Mod-Alt-c"]=()=>this.editor.commands.toggleCodeBlock(),t["Mod-Shift-minus"]=()=>this.editor.commands.setHorizontalRule(),t["Mod-Shift-l"]=()=>this.editor.commands.setTextAlign("left"),t["Mod-Shift-e"]=()=>this.editor.commands.setTextAlign("center"),t["Mod-Shift-r"]=()=>this.editor.commands.setTextAlign("right"),t["Mod-Shift-j"]=()=>this.editor.commands.setTextAlign("justify"),t["Mod-comma"]=()=>this.editor.commands.toggleSubscript(),t["Mod-period"]=()=>this.editor.commands.toggleSuperscript(),t["Mod-Alt-t"]=()=>this.editor.can().insertTable()?this.editor.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}):!1,t["Mod-Home"]=()=>this.editor.commands.focus("start"),t["Mod-End"]=()=>this.editor.commands.focus("end"),t["Mod-a"]=()=>this.editor.commands.selectAll(),t["Mod-\\"]=()=>this.editor.commands.unsetAllMarks()&&this.editor.commands.clearNodes(),t["Mod-k"]=()=>{const e=window.prompt("Enter URL:");return e?this.editor.commands.setLink({href:e}):!1},t["Mod-Shift-i"]=()=>{const e=window.prompt("Enter image URL:");return e?this.editor.commands.setImage({src:e}):!1},t["Alt-ArrowUp"]=()=>{const{selection:e}=this.editor.state,{$from:n}=e,r=n.nodeBefore;if(r){const s=n.pos-r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Alt-ArrowDown"]=()=>{const{selection:e}=this.editor.state,{$to:n}=e,r=n.nodeAfter;if(r){const s=n.pos+r.nodeSize;return this.editor.commands.setTextSelection(s)}return!1},t["Mod-Shift-d"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt(r,`
472
+ ${s}`):!1},t["Mod-Shift-k"]=()=>{const{selection:e}=this.editor.state,{$from:n,$to:r}=e,s=n.start(),o=r.end();return this.editor.commands.deleteRange({from:s,to:o})},t["Mod-Backspace"]=()=>{const{selection:e}=this.editor.state,{from:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const o=r.parent.textContent,i=r.parentOffset;for(let l=i-1;l>=0;l--){if(/\s/.test(o[l])){s=n-(i-l-1);break}l===0&&(s=n-i)}return this.editor.commands.deleteRange({from:s,to:n})},t["Mod-Delete"]=()=>{const{selection:e}=this.editor.state,{to:n}=e,r=this.editor.state.doc.resolve(n);let s=n;const o=r.parent.textContent,i=r.parentOffset;for(let l=i;l<o.length;l++){if(/\s/.test(o[l])){s=n+(l-i);break}l===o.length-1&&(s=n+(o.length-i))}return this.editor.commands.deleteRange({from:n,to:s})}),this.options.enableCustomShortcuts&&(t["Mod-Shift-a"]=()=>this.editor.can().setAlertWidget()?this.editor.commands.setAlertWidget():!1,t["Mod-Shift-t"]=()=>this.editor.can().setCtaWidget()?this.editor.commands.setCtaWidget({text:"Click me",url:"#",style:"primary",size:"medium",textAlign:"center"}):!1,t["Mod-Shift-f"]=()=>(this.editor.view.dom.classList.toggle("focus-mode"),!0),t["Mod-Shift-w"]=()=>(this.editor.view.dom.classList.toggle("writing-mode"),!0),t["Mod-Shift-u"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toUpperCase()):!1},t["Mod-Shift-l"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);return s?this.editor.commands.insertContentAt({from:n,to:r},s.toLowerCase()):!1},t["Mod-Shift-p"]=()=>{const{selection:e}=this.editor.state,{from:n,to:r}=e,s=this.editor.state.doc.textBetween(n,r);if(s){const o=s.replace(/\w\S*/g,i=>i.charAt(0).toUpperCase()+i.substr(1).toLowerCase());return this.editor.commands.insertContentAt({from:n,to:r},o)}return!1}),t},addStorage(){return{shortcuts:{},hints:[]}},onCreate(){this.options.showShortcutHints&&(this.storage.shortcuts={},this.storage.hints=[{category:"Text Formatting",shortcuts:[{keys:"Cmd/Ctrl + B",action:"Bold"},{keys:"Cmd/Ctrl + I",action:"Italic"},{keys:"Cmd/Ctrl + U",action:"Underline"},{keys:"Cmd/Ctrl + Shift + X",action:"Strikethrough"},{keys:"Cmd/Ctrl + Shift + H",action:"Highlight"},{keys:"Cmd/Ctrl + E",action:"Inline Code"}]},{category:"Headings",shortcuts:[{keys:"Cmd/Ctrl + Alt + 1-6",action:"Heading 1-6"},{keys:"Cmd/Ctrl + Alt + 0",action:"Paragraph"}]},{category:"Lists",shortcuts:[{keys:"Cmd/Ctrl + Shift + 8",action:"Bullet List"},{keys:"Cmd/Ctrl + Shift + 7",action:"Numbered List"},{keys:"Cmd/Ctrl + Shift + 9",action:"Task List"}]},{category:"Blocks",shortcuts:[{keys:"Cmd/Ctrl + Shift + B",action:"Blockquote"},{keys:"Cmd/Ctrl + Alt + C",action:"Code Block"},{keys:"Cmd/Ctrl + Alt + T",action:"Table"}]},{category:"Navigation",shortcuts:[{keys:"Cmd/Ctrl + A",action:"Select All"},{keys:"Cmd/Ctrl + Home",action:"Go to Start"},{keys:"Cmd/Ctrl + End",action:"Go to End"}]},{category:"Advanced",shortcuts:[{keys:"Cmd/Ctrl + K",action:"Insert Link"},{keys:"Cmd/Ctrl + Shift + I",action:"Insert Image"},{keys:"Cmd/Ctrl + \\",action:"Clear Formatting"}]}])}}),K2=()=>{const[t,e]=C.useState("<p>Start testing...</p>"),[n,r]=C.useState([]),[s,o]=C.useState(!1),[i,l]=C.useState(""),a=w=>({name:w,tests:[],status:"pending"}),c=(w,T)=>{r(k=>k.map(N=>{if(N.name===w){const R=[...N.tests,T],B=R.some(H=>H.status==="fail"),P=R.some(H=>H.status==="warning"),L=R.every(H=>H.status!=="pending");return{...N,tests:R,status:B?"fail":P?"warning":L?"pass":"pending"}}return N}))},u=w=>new Promise(T=>setTimeout(T,w)),d=async()=>{var T,k;const w="Drag and Drop";l(w);try{const N=document.querySelectorAll(".drag-handle, .drag-handle-button");c(w,{name:"Drag Handle Presence",status:N.length>0?"pass":"fail",message:N.length>0?"Drag handles found":"No drag handles detected",details:`Found ${N.length} drag handle elements`});const R=((k=(T=document.querySelector("style"))==null?void 0:T.textContent)==null?void 0:k.includes("drag-handle"))||Array.from(document.styleSheets).some(P=>{try{return Array.from(P.cssRules).some(L=>L.cssText.includes("drag-handle"))}catch{return!1}});c(w,{name:"Drag Handle CSS",status:R?"pass":"warning",message:R?"Drag handle CSS loaded":"Drag handle CSS may not be loaded",details:"Check if drag-handle.css is properly imported"});const B=document.querySelectorAll('[data-draggable="true"]');c(w,{name:"Draggable Nodes",status:B.length>0?"pass":"warning",message:B.length>0?"Draggable nodes found":"No draggable nodes detected",details:`Found ${B.length} draggable nodes`})}catch(N){c(w,{name:"Drag and Drop Test",status:"fail",message:"Test failed with error",details:N instanceof Error?N.message:"Unknown error"})}},h=async()=>{const w="Undo/Redo System";l(w);try{const T=document.querySelectorAll('[aria-label*="Undo"], [title*="Undo"]'),k=document.querySelectorAll('[aria-label*="Redo"], [title*="Redo"]');c(w,{name:"Undo/Redo Buttons",status:T.length>0&&k.length>0?"pass":"fail",message:`Found ${T.length} undo and ${k.length} redo buttons`,details:"Undo/Redo buttons should be present in toolbar"}),e("<p>Test content for undo</p>"),await u(100),c(w,{name:"History State Change",status:"pass",message:"Content change detected",details:"History system should track this change"});const N=typeof document<"u"&&document.addEventListener!==void 0;c(w,{name:"Keyboard Shortcuts",status:N?"pass":"warning",message:"Keyboard event system available",details:"Ctrl+Z and Ctrl+Y shortcuts should work"})}catch(T){c(w,{name:"Undo/Redo Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},f=async()=>{const w="Enhanced Floating Menu";l(w);try{const T=document.querySelectorAll('[aria-label*="Insert"], .enhanced-floating-menu');c(w,{name:"Floating Menu Trigger",status:T.length>0?"pass":"warning",message:T.length>0?"Floating menu trigger found":"No floating menu trigger detected",details:"Should appear on empty paragraphs"});const k=document.querySelectorAll('input[placeholder*="Search"], .search-input');c(w,{name:"Search Functionality",status:k.length>0?"pass":"warning",message:k.length>0?"Search input found":"Search input not visible",details:"Search should be available when menu is open"});const N=document.querySelectorAll("[data-category], .category-button");c(w,{name:"Category Filters",status:N.length>0?"pass":"warning",message:N.length>0?"Category filters found":"Category filters not visible",details:"Should have Basic, Headings, Lists, Media, Advanced categories"})}catch(T){c(w,{name:"Enhanced Floating Menu Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},p=async()=>{const w="Advanced Placeholders";l(w);try{const T=Array.from(document.styleSheets).some(R=>{try{return Array.from(R.cssRules).some(B=>B.cssText.includes("is-empty")||B.cssText.includes("placeholder"))}catch{return!1}});c(w,{name:"Placeholder CSS",status:T?"pass":"warning",message:T?"Placeholder CSS loaded":"Placeholder CSS may not be loaded",details:"Check if advanced-features.css is properly imported"});const k=document.querySelectorAll(".is-empty, .is-editor-empty");c(w,{name:"Empty Node Detection",status:k.length>=0?"pass":"warning",message:`Found ${k.length} empty nodes`,details:"Empty nodes should have placeholder classes"}),e("<p></p>"),await u(100);const N=document.querySelectorAll("[data-placeholder]");c(w,{name:"Placeholder Content",status:N.length>0?"pass":"warning",message:N.length>0?"Placeholder content found":"No placeholder content detected",details:"Should show contextual placeholders for different node types"})}catch(T){c(w,{name:"Advanced Placeholders Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},g=async()=>{const w="Focus Management";l(w);try{const T=document.querySelectorAll(".has-focus, .editor-focused");c(w,{name:"Focus Classes",status:T.length>=0?"pass":"warning",message:`Found ${T.length} focus elements`,details:"Focus classes should be applied to active elements"});const k=document.querySelectorAll(".focus-ring");c(w,{name:"Focus Ring",status:k.length>=0?"pass":"warning",message:`Found ${k.length} focus rings`,details:"Focus rings provide visual feedback"}),c(w,{name:"Selection Highlighting",status:"pass",message:"Selection highlighting system available",details:"Enhanced selection visibility should work"})}catch(T){c(w,{name:"Focus Management Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},y=async()=>{const w="Mobile Experience";l(w);try{const T=document.querySelectorAll('.mobile-toolbar, [class*="mobile"]');c(w,{name:"Mobile Toolbar",status:T.length>0?"pass":"warning",message:T.length>0?"Mobile toolbar found":"Mobile toolbar not detected",details:"Should appear on mobile devices or small screens"});const k=Array.from(document.styleSheets).some(R=>{try{return Array.from(R.cssRules).some(B=>B.cssText.includes("@media")&&B.cssText.includes("768px"))}catch{return!1}});c(w,{name:"Responsive CSS",status:k?"pass":"warning",message:k?"Responsive CSS found":"Responsive CSS may not be loaded",details:"Should have mobile breakpoints"});const N=document.querySelectorAll('[class*="touch"], .toolbar-item');c(w,{name:"Touch-Friendly Elements",status:N.length>0?"pass":"warning",message:N.length>0?"Touch-friendly elements found":"No touch-friendly elements detected",details:"Should have larger touch targets for mobile"})}catch(T){c(w,{name:"Mobile Experience Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},b=async()=>{const w="Keyboard Shortcuts";l(w);try{c(w,{name:"Keyboard Shortcuts Available",status:"pass",message:`${["Ctrl+B","Ctrl+I","Ctrl+U","Ctrl+Shift+X","Ctrl+Shift+H","Ctrl+Alt+1","Ctrl+Alt+2","Ctrl+Alt+3","Ctrl+K","Ctrl+\\"].length} keyboard shortcuts configured`,details:"Text formatting, headings, lists, and advanced shortcuts"});const k=document.querySelectorAll('[title*="Ctrl"], [title*="Cmd"]');c(w,{name:"Shortcut Hints",status:k.length>0?"pass":"warning",message:k.length>0?"Shortcut hints found":"No shortcut hints detected",details:"Tooltips should show keyboard shortcuts"}),c(w,{name:"Conflict Prevention",status:"pass",message:"Keyboard shortcuts use standard patterns",details:"Should not conflict with browser shortcuts"})}catch(T){c(w,{name:"Keyboard Shortcuts Test",status:"fail",message:"Test failed with error",details:T instanceof Error?T.message:"Unknown error"})}},x=async()=>{o(!0),r([a("Drag and Drop"),a("Undo/Redo System"),a("Enhanced Floating Menu"),a("Advanced Placeholders"),a("Focus Management"),a("Mobile Experience"),a("Keyboard Shortcuts")]);try{await d(),await u(500),await h(),await u(500),await f(),await u(500),await p(),await u(500),await g(),await u(500),await y(),await u(500),await b()}catch(w){console.error("Test suite failed:",w)}finally{o(!1),l("")}},E=()=>{r([]),e("<p>Start testing...</p>"),l("")},S=w=>{switch(w){case"pass":return m.jsx(aL,{className:"h-4 w-4 text-green-500"});case"fail":return m.jsx(hL,{className:"h-4 w-4 text-red-500"});case"warning":return m.jsx(qm,{className:"h-4 w-4 text-yellow-500"});default:return m.jsx(qm,{className:"h-4 w-4 text-gray-400"})}},M=w=>{const T={pass:"bg-green-100 text-green-800",fail:"bg-red-100 text-red-800",warning:"bg-yellow-100 text-yellow-800",pending:"bg-gray-100 text-gray-800"};return m.jsx(Jw.Badge,{className:T[w]||T.pending,children:w.toUpperCase()})};return m.jsxs("div",{className:"max-w-6xl mx-auto p-6 space-y-6",children:[m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx("h1",{className:"text-3xl font-bold",children:"Tiptap v3 Feature Validation"}),m.jsxs("div",{className:"flex gap-2",children:[m.jsxs(ce.Button,{onClick:E,variant:"outline",disabled:s,children:[m.jsx(nI,{className:"h-4 w-4 mr-2"}),"Reset"]}),m.jsxs(ce.Button,{onClick:x,disabled:s,children:[m.jsx(YL,{className:"h-4 w-4 mr-2"}),s?"Running Tests...":"Run All Tests"]})]})]}),s&&i&&m.jsx(ft.Card,{children:m.jsx(ft.CardContent,{className:"pt-6",children:m.jsxs("div",{className:"flex items-center gap-2",children:[m.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-primary"}),m.jsxs("span",{children:["Running: ",i]})]})})}),m.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Test Results"}),n.map(w=>m.jsxs(ft.Card,{children:[m.jsx(ft.CardHeader,{className:"pb-3",children:m.jsxs("div",{className:"flex items-center justify-between",children:[m.jsx(ft.CardTitle,{className:"text-lg",children:w.name}),M(w.status)]})}),m.jsxs(ft.CardContent,{className:"space-y-2",children:[w.tests.map((T,k)=>m.jsxs("div",{className:"flex items-start gap-2 p-2 rounded border",children:[S(T.status),m.jsxs("div",{className:"flex-1 min-w-0",children:[m.jsx("div",{className:"font-medium text-sm",children:T.name}),m.jsx("div",{className:"text-xs text-muted-foreground",children:T.message}),T.details&&m.jsx("div",{className:"text-xs text-muted-foreground mt-1 opacity-75",children:T.details})]})]},k)),w.tests.length===0&&w.status==="pending"&&m.jsx("div",{className:"text-sm text-muted-foreground",children:"No tests run yet"})]})]},w.name))]}),m.jsxs("div",{className:"space-y-4",children:[m.jsx("h2",{className:"text-xl font-semibold",children:"Live Editor Test"}),m.jsx(ft.Card,{children:m.jsx(ft.CardContent,{className:"pt-6",children:m.jsx(sc,{content:t,onChange:e,useEnhancedFloatingMenu:!0,showMobileToolbar:!0,enableAdvancedPlaceholders:!0,enableFocusMode:!1,showKeyboardShortcuts:!0,className:"min-h-[400px]"})})}),m.jsxs(ft.Card,{children:[m.jsx(ft.CardHeader,{children:m.jsx(ft.CardTitle,{className:"text-lg",children:"Test Instructions"})}),m.jsxs(ft.CardContent,{className:"text-sm space-y-2",children:[m.jsx("p",{children:"• Try typing in the editor to test placeholders"}),m.jsx("p",{children:"• Create empty paragraphs to test floating menu"}),m.jsx("p",{children:"• Use keyboard shortcuts (Ctrl+B, Ctrl+I, etc.)"}),m.jsx("p",{children:"• Test undo/redo with Ctrl+Z/Ctrl+Y"}),m.jsx("p",{children:"• Hover over elements to see drag handles"}),m.jsx("p",{children:"• Resize window to test mobile toolbar"})]})]})]})]})]})},G2=()=>{const[t,e]=C.useState(`
473
+ <h1>Undo/Redo Test Document</h1>
474
+ <p>This document tests the enhanced undo/redo functionality with various content types.</p>
475
+
476
+ <h2>Text Formatting</h2>
477
+ <p>Try making text <strong>bold</strong>, <em>italic</em>, or <u>underlined</u>.</p>
478
+
479
+ <h2>Lists</h2>
480
+ <ul>
481
+ <li>Bullet list item 1</li>
482
+ <li>Bullet list item 2</li>
483
+ </ul>
484
+
485
+ <ol>
486
+ <li>Numbered list item 1</li>
487
+ <li>Numbered list item 2</li>
488
+ </ol>
489
+
490
+ <ul data-type="taskList">
491
+ <li data-type="taskItem" data-checked="false">Task item 1</li>
492
+ <li data-type="taskItem" data-checked="true">Completed task</li>
493
+ </ul>
494
+
495
+ <h2>Code Block</h2>
496
+ <pre><code class="language-javascript">console.log('Hello, world!');</code></pre>
497
+
498
+ <h2>Table</h2>
499
+ <table>
500
+ <tr>
501
+ <th>Header 1</th>
502
+ <th>Header 2</th>
503
+ </tr>
504
+ <tr>
505
+ <td>Cell 1</td>
506
+ <td>Cell 2</td>
507
+ </tr>
508
+ </table>
509
+
510
+ <p>Try editing any content above and use the undo/redo buttons or keyboard shortcuts!</p>
511
+ `),[n]=C.useState(null),r=Kh(n),s=[{name:"Add Bold Text",action:()=>{n&&n.chain().focus().insertContent("<p><strong>Bold text added!</strong></p>").run()}},{name:"Add Heading",action:()=>{n&&n.chain().focus().insertContent("<h3>New Heading Added</h3>").run()}},{name:"Add List Item",action:()=>{n&&n.chain().focus().insertContent("<ul><li>New list item</li></ul>").run()}},{name:"Add Table",action:()=>{n&&n.chain().focus().insertTable({rows:2,cols:2,withHeaderRow:!0}).run()}},{name:"Clear All Content",action:()=>{n&&n.chain().focus().clearContent().run()}}];return m.jsx("div",{className:"max-w-4xl mx-auto p-6 space-y-6",children:m.jsxs(ft.Card,{children:[m.jsx(ft.CardHeader,{children:m.jsx(ft.CardTitle,{children:"Enhanced Undo/Redo Test"})}),m.jsxs(ft.CardContent,{className:"space-y-4",children:[m.jsxs("div",{className:"flex items-center gap-4 p-4 bg-muted rounded-lg",children:[m.jsx("div",{className:"text-sm",children:m.jsx("strong",{children:"History State:"})}),m.jsxs("div",{className:"text-sm",children:["Can Undo: ",m.jsx("span",{className:r.canUndo?"text-green-600":"text-red-600",children:r.canUndo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["Can Redo: ",m.jsx("span",{className:r.canRedo?"text-green-600":"text-red-600",children:r.canRedo?"Yes":"No"})]}),m.jsxs("div",{className:"text-sm",children:["History Empty: ",m.jsx("span",{className:r.isHistoryEmpty?"text-orange-600":"text-blue-600",children:r.isHistoryEmpty?"Yes":"No"})]})]}),m.jsxs("div",{className:"flex items-center gap-4 p-4 border rounded-lg",children:[m.jsx("div",{className:"text-sm font-medium",children:"Enhanced Controls:"}),m.jsx(Gh,{editor:n,size:"md",showLabels:!0,className:"border rounded p-2"}),m.jsx("div",{className:"text-xs text-muted-foreground",children:"Keyboard: Ctrl+Z (Undo), Ctrl+Y (Redo)"})]}),m.jsxs("div",{className:"space-y-2",children:[m.jsx("div",{className:"text-sm font-medium",children:"Test Actions:"}),m.jsx("div",{className:"flex flex-wrap gap-2",children:s.map((o,i)=>m.jsx(ce.Button,{variant:"outline",size:"sm",onClick:o.action,disabled:!n,children:o.name},i))})]}),m.jsx("div",{className:"border rounded-lg",children:m.jsx(sc,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,onFocus:()=>console.log("Editor focused"),onBlur:()=>console.log("Editor blurred")})}),m.jsxs("div",{className:"text-sm text-muted-foreground space-y-2",children:[m.jsx("p",{children:m.jsx("strong",{children:"Test Instructions:"})}),m.jsxs("ul",{className:"list-disc list-inside space-y-1",children:[m.jsx("li",{children:"Use the test actions above to add content"}),m.jsx("li",{children:"Try editing text directly in the editor"}),m.jsx("li",{children:"Use Ctrl+Z to undo changes"}),m.jsx("li",{children:"Use Ctrl+Y to redo changes"}),m.jsx("li",{children:"Try dragging content around (if drag handles are visible)"}),m.jsx("li",{children:"Watch the history state indicators update in real-time"}),m.jsx("li",{children:"Test with different content types: text, headings, lists, tables, etc."})]})]})]})]})})},J2=()=>{const[t,e]=C.useState(`
512
+ <h1>Enhanced NotionEditor Test</h1>
513
+ <p>This is a test of the enhanced NotionEditor with undo/redo buttons and improved drag handles.</p>
514
+ <h2>Drag Handle UX Improvements:</h2>
515
+ <ul>
516
+ <li>✅ Drag handles appear when hovering anywhere on the content block (not just the handle area)</li>
517
+ <li>✅ Drag handles are properly centered within each content section</li>
518
+ <li>✅ Expanded hover detection covers entire paragraphs, headings, and lists</li>
519
+ <li>✅ Enhanced visual feedback and smooth transitions</li>
520
+ <li>✅ Responsive design works on mobile devices</li>
521
+ </ul>
522
+ <h3>Test Different Content Types:</h3>
523
+ <p>Hover over this paragraph - the drag handle should appear when hovering anywhere on this text, not just where the handle is positioned.</p>
524
+ <blockquote>
525
+ <p>Hover over this blockquote to test drag handle visibility and centering.</p>
526
+ </blockquote>
527
+ <ol>
528
+ <li>First ordered list item - test drag handle on lists</li>
529
+ <li>Second item - drag handle should be centered vertically</li>
530
+ </ol>
531
+ <p>Try typing some text and then using the undo/redo buttons in the toolbar.</p>
532
+ `);return m.jsxs("div",{className:"p-6 max-w-4xl mx-auto",children:[m.jsx("h1",{className:"text-2xl font-bold mb-4",children:"NotionEditor Enhanced Features Test"}),m.jsxs("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Drag Handle UX Test Instructions:"}),m.jsxs("ol",{className:"list-decimal list-inside text-blue-700 space-y-1",children:[m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"target",children:"🎯"})," ",m.jsx("strong",{children:"Expanded Hover Area:"})," Hover anywhere on a content block (not just the handle area) - drag handle should appear"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"pushpin",children:"📍"})," ",m.jsx("strong",{children:"Proper Centering:"})," Verify drag handles are vertically centered within each content section"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"refresh arrows",children:"🔄"})," ",m.jsx("strong",{children:"Content Types:"})," Test on paragraphs, headings, lists, and blockquotes"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"mobile phone",children:"📱"})," ",m.jsx("strong",{children:"Mobile Responsive:"})," Check that drag handles work properly on smaller screens"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"sparkles",children:"✨"})," ",m.jsx("strong",{children:"Visual Feedback:"})," Notice smooth transitions and enhanced styling"]}),m.jsxs("li",{children:[m.jsx("span",{role:"img","aria-label":"computer mouse",children:"🖱️"})," ",m.jsx("strong",{children:"Drag Functionality:"})," Try dragging blocks to reorder them"]})]})]}),m.jsx("div",{className:"border border-gray-200 rounded-lg",children:m.jsx(Sw,{content:t,onChange:e,showToolbar:!0,showCharacterCount:!0,className:"min-h-[600px]"})}),m.jsxs("div",{className:"mt-4 p-4 bg-gray-50 border border-gray-200 rounded-lg",children:[m.jsx("h3",{className:"font-semibold mb-2",children:"Current Content (JSON):"}),m.jsx("pre",{className:"text-xs bg-white p-2 rounded border overflow-auto max-h-32",children:JSON.stringify(t,null,2)})]})]})};exports.AdvancedPlaceholder=Gx;exports.AlertWidget=Jx;exports.CtaWidgetNode=Yx;exports.DragHandle=vw;exports.DraggableNodes=iw;exports.Editor=sc;exports.EditorBubbleMenu=Wh;exports.EditorFloatingMenu=qh;exports.EditorToolbar=Jh;exports.EnhancedFloatingMenu=bw;exports.EnhancedFocus=W2;exports.FeatureValidationTest=K2;exports.HtmlContent=V2;exports.KeyboardShortcuts=q2;exports.MobileToolbar=kw;exports.NotionEditor=Sw;exports.NotionEditorEnhancedTest=J2;exports.SlashCommand=ow;exports.SlashCommandList=zh;exports.Toolbar=Cw;exports.ToolbarButton=Mw;exports.ToolbarGroup=Ew;exports.ToolbarSeparator=Aw;exports.TrailingNode=Kx;exports.UndoRedoButtons=Gh;exports.UndoRedoTest=G2;exports.canExecuteHistoryAction=ww;exports.default=sc;exports.editorExtensions=Fh;exports.executeHistoryAction=P2;exports.getHistoryShortcut=wd;exports.useEditorHistory=Kh;