openwriter 0.6.1 → 0.6.3

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.
@@ -0,0 +1,209 @@
1
+ (function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const l of i.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();function Bu(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var zf={exports:{}},hl={},$f={exports:{}},ct={};/**
2
+ * @license React
3
+ * react.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its 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 $y;function pE(){if($y)return ct;$y=1;var t=Symbol.for("react.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.iterator;function y(A){return A===null||typeof A!="object"?null:(A=m&&A[m]||A["@@iterator"],typeof A=="function"?A:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,w={};function k(A,R,Y){this.props=A,this.context=R,this.refs=w,this.updater=Y||b}k.prototype.isReactComponent={},k.prototype.setState=function(A,R){if(typeof A!="object"&&typeof A!="function"&&A!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,A,R,"setState")},k.prototype.forceUpdate=function(A){this.updater.enqueueForceUpdate(this,A,"forceUpdate")};function N(){}N.prototype=k.prototype;function T(A,R,Y){this.props=A,this.context=R,this.refs=w,this.updater=Y||b}var I=T.prototype=new N;I.constructor=T,v(I,k.prototype),I.isPureReactComponent=!0;var _=Array.isArray,M=Object.prototype.hasOwnProperty,O={current:null},P={key:!0,ref:!0,__self:!0,__source:!0};function $(A,R,Y){var se,fe={},Z=null,me=null;if(R!=null)for(se in R.ref!==void 0&&(me=R.ref),R.key!==void 0&&(Z=""+R.key),R)M.call(R,se)&&!P.hasOwnProperty(se)&&(fe[se]=R[se]);var Le=arguments.length-2;if(Le===1)fe.children=Y;else if(1<Le){for(var Ze=Array(Le),ce=0;ce<Le;ce++)Ze[ce]=arguments[ce+2];fe.children=Ze}if(A&&A.defaultProps)for(se in Le=A.defaultProps,Le)fe[se]===void 0&&(fe[se]=Le[se]);return{$$typeof:t,type:A,key:Z,ref:me,props:fe,_owner:O.current}}function B(A,R){return{$$typeof:t,type:A.type,key:R,ref:A.ref,props:A.props,_owner:A._owner}}function W(A){return typeof A=="object"&&A!==null&&A.$$typeof===t}function J(A){var R={"=":"=0",":":"=2"};return"$"+A.replace(/[=:]/g,function(Y){return R[Y]})}var F=/\/+/g;function re(A,R){return typeof A=="object"&&A!==null&&A.key!=null?J(""+A.key):R.toString(36)}function G(A,R,Y,se,fe){var Z=typeof A;(Z==="undefined"||Z==="boolean")&&(A=null);var me=!1;if(A===null)me=!0;else switch(Z){case"string":case"number":me=!0;break;case"object":switch(A.$$typeof){case t:case e:me=!0}}if(me)return me=A,fe=fe(me),A=se===""?"."+re(me,0):se,_(fe)?(Y="",A!=null&&(Y=A.replace(F,"$&/")+"/"),G(fe,R,Y,"",function(ce){return ce})):fe!=null&&(W(fe)&&(fe=B(fe,Y+(!fe.key||me&&me.key===fe.key?"":(""+fe.key).replace(F,"$&/")+"/")+A)),R.push(fe)),1;if(me=0,se=se===""?".":se+":",_(A))for(var Le=0;Le<A.length;Le++){Z=A[Le];var Ze=se+re(Z,Le);me+=G(Z,R,Y,Ze,fe)}else if(Ze=y(A),typeof Ze=="function")for(A=Ze.call(A),Le=0;!(Z=A.next()).done;)Z=Z.value,Ze=se+re(Z,Le++),me+=G(Z,R,Y,Ze,fe);else if(Z==="object")throw R=String(A),Error("Objects are not valid as a React child (found: "+(R==="[object Object]"?"object with keys {"+Object.keys(A).join(", ")+"}":R)+"). If you meant to render a collection of children, use an array instead.");return me}function te(A,R,Y){if(A==null)return A;var se=[],fe=0;return G(A,se,"","",function(Z){return R.call(Y,Z,fe++)}),se}function U(A){if(A._status===-1){var R=A._result;R=R(),R.then(function(Y){(A._status===0||A._status===-1)&&(A._status=1,A._result=Y)},function(Y){(A._status===0||A._status===-1)&&(A._status=2,A._result=Y)}),A._status===-1&&(A._status=0,A._result=R)}if(A._status===1)return A._result.default;throw A._result}var ne={current:null},H={transition:null},X={ReactCurrentDispatcher:ne,ReactCurrentBatchConfig:H,ReactCurrentOwner:O};function K(){throw Error("act(...) is not supported in production builds of React.")}return ct.Children={map:te,forEach:function(A,R,Y){te(A,function(){R.apply(this,arguments)},Y)},count:function(A){var R=0;return te(A,function(){R++}),R},toArray:function(A){return te(A,function(R){return R})||[]},only:function(A){if(!W(A))throw Error("React.Children.only expected to receive a single React element child.");return A}},ct.Component=k,ct.Fragment=n,ct.Profiler=s,ct.PureComponent=T,ct.StrictMode=r,ct.Suspense=u,ct.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=X,ct.act=K,ct.cloneElement=function(A,R,Y){if(A==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+A+".");var se=v({},A.props),fe=A.key,Z=A.ref,me=A._owner;if(R!=null){if(R.ref!==void 0&&(Z=R.ref,me=O.current),R.key!==void 0&&(fe=""+R.key),A.type&&A.type.defaultProps)var Le=A.type.defaultProps;for(Ze in R)M.call(R,Ze)&&!P.hasOwnProperty(Ze)&&(se[Ze]=R[Ze]===void 0&&Le!==void 0?Le[Ze]:R[Ze])}var Ze=arguments.length-2;if(Ze===1)se.children=Y;else if(1<Ze){Le=Array(Ze);for(var ce=0;ce<Ze;ce++)Le[ce]=arguments[ce+2];se.children=Le}return{$$typeof:t,type:A.type,key:fe,ref:Z,props:se,_owner:me}},ct.createContext=function(A){return A={$$typeof:l,_currentValue:A,_currentValue2:A,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},A.Provider={$$typeof:i,_context:A},A.Consumer=A},ct.createElement=$,ct.createFactory=function(A){var R=$.bind(null,A);return R.type=A,R},ct.createRef=function(){return{current:null}},ct.forwardRef=function(A){return{$$typeof:c,render:A}},ct.isValidElement=W,ct.lazy=function(A){return{$$typeof:p,_payload:{_status:-1,_result:A},_init:U}},ct.memo=function(A,R){return{$$typeof:f,type:A,compare:R===void 0?null:R}},ct.startTransition=function(A){var R=H.transition;H.transition={};try{A()}finally{H.transition=R}},ct.unstable_act=K,ct.useCallback=function(A,R){return ne.current.useCallback(A,R)},ct.useContext=function(A){return ne.current.useContext(A)},ct.useDebugValue=function(){},ct.useDeferredValue=function(A){return ne.current.useDeferredValue(A)},ct.useEffect=function(A,R){return ne.current.useEffect(A,R)},ct.useId=function(){return ne.current.useId()},ct.useImperativeHandle=function(A,R,Y){return ne.current.useImperativeHandle(A,R,Y)},ct.useInsertionEffect=function(A,R){return ne.current.useInsertionEffect(A,R)},ct.useLayoutEffect=function(A,R){return ne.current.useLayoutEffect(A,R)},ct.useMemo=function(A,R){return ne.current.useMemo(A,R)},ct.useReducer=function(A,R,Y){return ne.current.useReducer(A,R,Y)},ct.useRef=function(A){return ne.current.useRef(A)},ct.useState=function(A){return ne.current.useState(A)},ct.useSyncExternalStore=function(A,R,Y){return ne.current.useSyncExternalStore(A,R,Y)},ct.useTransition=function(){return ne.current.useTransition()},ct.version="18.3.1",ct}var Fy;function Kl(){return Fy||(Fy=1,$f.exports=pE()),$f.exports}/**
10
+ * @license React
11
+ * react-jsx-runtime.production.min.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its 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 Uy;function mE(){if(Uy)return hl;Uy=1;var t=Kl(),e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,f){var p,m={},y=null,b=null;f!==void 0&&(y=""+f),u.key!==void 0&&(y=""+u.key),u.ref!==void 0&&(b=u.ref);for(p in u)r.call(u,p)&&!i.hasOwnProperty(p)&&(m[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)m[p]===void 0&&(m[p]=u[p]);return{$$typeof:e,type:c,key:y,ref:b,props:m,_owner:s.current}}return hl.Fragment=n,hl.jsx=l,hl.jsxs=l,hl}var Hy;function gE(){return Hy||(Hy=1,zf.exports=mE()),zf.exports}var d=gE(),E=Kl();const qs=Bu(E);var ic={},Ff={exports:{}},Yn={},Uf={exports:{}},Hf={};/**
18
+ * @license React
19
+ * scheduler.production.min.js
20
+ *
21
+ * Copyright (c) Facebook, Inc. and its affiliates.
22
+ *
23
+ * This source code is licensed under the MIT license found in the
24
+ * LICENSE file in the root directory of this source tree.
25
+ */var Wy;function yE(){return Wy||(Wy=1,(function(t){function e(H,X){var K=H.length;H.push(X);e:for(;0<K;){var A=K-1>>>1,R=H[A];if(0<s(R,X))H[A]=X,H[K]=R,K=A;else break e}}function n(H){return H.length===0?null:H[0]}function r(H){if(H.length===0)return null;var X=H[0],K=H.pop();if(K!==X){H[0]=K;e:for(var A=0,R=H.length,Y=R>>>1;A<Y;){var se=2*(A+1)-1,fe=H[se],Z=se+1,me=H[Z];if(0>s(fe,K))Z<R&&0>s(me,fe)?(H[A]=me,H[Z]=K,A=Z):(H[A]=fe,H[se]=K,A=se);else if(Z<R&&0>s(me,K))H[A]=me,H[Z]=K,A=Z;else break e}}return X}function s(H,X){var K=H.sortIndex-X.sortIndex;return K!==0?K:H.id-X.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;t.unstable_now=function(){return i.now()}}else{var l=Date,c=l.now();t.unstable_now=function(){return l.now()-c}}var u=[],f=[],p=1,m=null,y=3,b=!1,v=!1,w=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function I(H){for(var X=n(f);X!==null;){if(X.callback===null)r(f);else if(X.startTime<=H)r(f),X.sortIndex=X.expirationTime,e(u,X);else break;X=n(f)}}function _(H){if(w=!1,I(H),!v)if(n(u)!==null)v=!0,U(M);else{var X=n(f);X!==null&&ne(_,X.startTime-H)}}function M(H,X){v=!1,w&&(w=!1,N($),$=-1),b=!0;var K=y;try{for(I(X),m=n(u);m!==null&&(!(m.expirationTime>X)||H&&!J());){var A=m.callback;if(typeof A=="function"){m.callback=null,y=m.priorityLevel;var R=A(m.expirationTime<=X);X=t.unstable_now(),typeof R=="function"?m.callback=R:m===n(u)&&r(u),I(X)}else r(u);m=n(u)}if(m!==null)var Y=!0;else{var se=n(f);se!==null&&ne(_,se.startTime-X),Y=!1}return Y}finally{m=null,y=K,b=!1}}var O=!1,P=null,$=-1,B=5,W=-1;function J(){return!(t.unstable_now()-W<B)}function F(){if(P!==null){var H=t.unstable_now();W=H;var X=!0;try{X=P(!0,H)}finally{X?re():(O=!1,P=null)}}else O=!1}var re;if(typeof T=="function")re=function(){T(F)};else if(typeof MessageChannel<"u"){var G=new MessageChannel,te=G.port2;G.port1.onmessage=F,re=function(){te.postMessage(null)}}else re=function(){k(F,0)};function U(H){P=H,O||(O=!0,re())}function ne(H,X){$=k(function(){H(t.unstable_now())},X)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(H){H.callback=null},t.unstable_continueExecution=function(){v||b||(v=!0,U(M))},t.unstable_forceFrameRate=function(H){0>H||125<H?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):B=0<H?Math.floor(1e3/H):5},t.unstable_getCurrentPriorityLevel=function(){return y},t.unstable_getFirstCallbackNode=function(){return n(u)},t.unstable_next=function(H){switch(y){case 1:case 2:case 3:var X=3;break;default:X=y}var K=y;y=X;try{return H()}finally{y=K}},t.unstable_pauseExecution=function(){},t.unstable_requestPaint=function(){},t.unstable_runWithPriority=function(H,X){switch(H){case 1:case 2:case 3:case 4:case 5:break;default:H=3}var K=y;y=H;try{return X()}finally{y=K}},t.unstable_scheduleCallback=function(H,X,K){var A=t.unstable_now();switch(typeof K=="object"&&K!==null?(K=K.delay,K=typeof K=="number"&&0<K?A+K:A):K=A,H){case 1:var R=-1;break;case 2:R=250;break;case 5:R=1073741823;break;case 4:R=1e4;break;default:R=5e3}return R=K+R,H={id:p++,callback:X,priorityLevel:H,startTime:K,expirationTime:R,sortIndex:-1},K>A?(H.sortIndex=K,e(f,H),n(u)===null&&H===n(f)&&(w?(N($),$=-1):w=!0,ne(_,K-A))):(H.sortIndex=R,e(u,H),v||b||(v=!0,U(M))),H},t.unstable_shouldYield=J,t.unstable_wrapCallback=function(H){var X=y;return function(){var K=y;y=X;try{return H.apply(this,arguments)}finally{y=K}}}})(Hf)),Hf}var Vy;function bE(){return Vy||(Vy=1,Uf.exports=yE()),Uf.exports}/**
26
+ * @license React
27
+ * react-dom.production.min.js
28
+ *
29
+ * Copyright (c) Facebook, Inc. and its affiliates.
30
+ *
31
+ * This source code is licensed under the MIT license found in the
32
+ * LICENSE file in the root directory of this source tree.
33
+ */var Ky;function vE(){if(Ky)return Yn;Ky=1;var t=Kl(),e=bE();function n(o){for(var a="https://reactjs.org/docs/error-decoder.html?invariant="+o,h=1;h<arguments.length;h++)a+="&args[]="+encodeURIComponent(arguments[h]);return"Minified React error #"+o+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function i(o,a){l(o,a),l(o+"Capture",a)}function l(o,a){for(s[o]=a,o=0;o<a.length;o++)r.add(a[o])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,f=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,p={},m={};function y(o){return u.call(m,o)?!0:u.call(p,o)?!1:f.test(o)?m[o]=!0:(p[o]=!0,!1)}function b(o,a,h,g){if(h!==null&&h.type===0)return!1;switch(typeof a){case"function":case"symbol":return!0;case"boolean":return g?!1:h!==null?!h.acceptsBooleans:(o=o.toLowerCase().slice(0,5),o!=="data-"&&o!=="aria-");default:return!1}}function v(o,a,h,g){if(a===null||typeof a>"u"||b(o,a,h,g))return!0;if(g)return!1;if(h!==null)switch(h.type){case 3:return!a;case 4:return a===!1;case 5:return isNaN(a);case 6:return isNaN(a)||1>a}return!1}function w(o,a,h,g,x,S,C){this.acceptsBooleans=a===2||a===3||a===4,this.attributeName=g,this.attributeNamespace=x,this.mustUseProperty=h,this.propertyName=o,this.type=a,this.sanitizeURL=S,this.removeEmptyString=C}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(o){k[o]=new w(o,0,!1,o,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(o){var a=o[0];k[a]=new w(a,1,!1,o[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(o){k[o]=new w(o,2,!1,o.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(o){k[o]=new w(o,2,!1,o,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(o){k[o]=new w(o,3,!1,o.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(o){k[o]=new w(o,3,!0,o,null,!1,!1)}),["capture","download"].forEach(function(o){k[o]=new w(o,4,!1,o,null,!1,!1)}),["cols","rows","size","span"].forEach(function(o){k[o]=new w(o,6,!1,o,null,!1,!1)}),["rowSpan","start"].forEach(function(o){k[o]=new w(o,5,!1,o.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function T(o){return o[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(o){var a=o.replace(N,T);k[a]=new w(a,1,!1,o,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(o){var a=o.replace(N,T);k[a]=new w(a,1,!1,o,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(o){var a=o.replace(N,T);k[a]=new w(a,1,!1,o,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!1,!1)}),k.xlinkHref=new w("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(o){k[o]=new w(o,1,!1,o.toLowerCase(),null,!0,!0)});function I(o,a,h,g){var x=k.hasOwnProperty(a)?k[a]:null;(x!==null?x.type!==0:g||!(2<a.length)||a[0]!=="o"&&a[0]!=="O"||a[1]!=="n"&&a[1]!=="N")&&(v(a,h,x,g)&&(h=null),g||x===null?y(a)&&(h===null?o.removeAttribute(a):o.setAttribute(a,""+h)):x.mustUseProperty?o[x.propertyName]=h===null?x.type===3?!1:"":h:(a=x.attributeName,g=x.attributeNamespace,h===null?o.removeAttribute(a):(x=x.type,h=x===3||x===4&&h===!0?"":""+h,g?o.setAttributeNS(g,a,h):o.setAttribute(a,h))))}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,M=Symbol.for("react.element"),O=Symbol.for("react.portal"),P=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),B=Symbol.for("react.profiler"),W=Symbol.for("react.provider"),J=Symbol.for("react.context"),F=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),G=Symbol.for("react.suspense_list"),te=Symbol.for("react.memo"),U=Symbol.for("react.lazy"),ne=Symbol.for("react.offscreen"),H=Symbol.iterator;function X(o){return o===null||typeof o!="object"?null:(o=H&&o[H]||o["@@iterator"],typeof o=="function"?o:null)}var K=Object.assign,A;function R(o){if(A===void 0)try{throw Error()}catch(h){var a=h.stack.trim().match(/\n( *(at )?)/);A=a&&a[1]||""}return`
34
+ `+A+o}var Y=!1;function se(o,a){if(!o||Y)return"";Y=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(a)if(a=function(){throw Error()},Object.defineProperty(a.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(a,[])}catch(Q){var g=Q}Reflect.construct(o,[],a)}else{try{a.call()}catch(Q){g=Q}o.call(a.prototype)}else{try{throw Error()}catch(Q){g=Q}o()}}catch(Q){if(Q&&g&&typeof Q.stack=="string"){for(var x=Q.stack.split(`
35
+ `),S=g.stack.split(`
36
+ `),C=x.length-1,j=S.length-1;1<=C&&0<=j&&x[C]!==S[j];)j--;for(;1<=C&&0<=j;C--,j--)if(x[C]!==S[j]){if(C!==1||j!==1)do if(C--,j--,0>j||x[C]!==S[j]){var D=`
37
+ `+x[C].replace(" at new "," at ");return o.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",o.displayName)),D}while(1<=C&&0<=j);break}}}finally{Y=!1,Error.prepareStackTrace=h}return(o=o?o.displayName||o.name:"")?R(o):""}function fe(o){switch(o.tag){case 5:return R(o.type);case 16:return R("Lazy");case 13:return R("Suspense");case 19:return R("SuspenseList");case 0:case 2:case 15:return o=se(o.type,!1),o;case 11:return o=se(o.type.render,!1),o;case 1:return o=se(o.type,!0),o;default:return""}}function Z(o){if(o==null)return null;if(typeof o=="function")return o.displayName||o.name||null;if(typeof o=="string")return o;switch(o){case P:return"Fragment";case O:return"Portal";case B:return"Profiler";case $:return"StrictMode";case re:return"Suspense";case G:return"SuspenseList"}if(typeof o=="object")switch(o.$$typeof){case J:return(o.displayName||"Context")+".Consumer";case W:return(o._context.displayName||"Context")+".Provider";case F:var a=o.render;return o=o.displayName,o||(o=a.displayName||a.name||"",o=o!==""?"ForwardRef("+o+")":"ForwardRef"),o;case te:return a=o.displayName||null,a!==null?a:Z(o.type)||"Memo";case U:a=o._payload,o=o._init;try{return Z(o(a))}catch{}}return null}function me(o){var a=o.type;switch(o.tag){case 24:return"Cache";case 9:return(a.displayName||"Context")+".Consumer";case 10:return(a._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return o=a.render,o=o.displayName||o.name||"",a.displayName||(o!==""?"ForwardRef("+o+")":"ForwardRef");case 7:return"Fragment";case 5:return a;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Z(a);case 8:return a===$?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a}return null}function Le(o){switch(typeof o){case"boolean":case"number":case"string":case"undefined":return o;case"object":return o;default:return""}}function Ze(o){var a=o.type;return(o=o.nodeName)&&o.toLowerCase()==="input"&&(a==="checkbox"||a==="radio")}function ce(o){var a=Ze(o)?"checked":"value",h=Object.getOwnPropertyDescriptor(o.constructor.prototype,a),g=""+o[a];if(!o.hasOwnProperty(a)&&typeof h<"u"&&typeof h.get=="function"&&typeof h.set=="function"){var x=h.get,S=h.set;return Object.defineProperty(o,a,{configurable:!0,get:function(){return x.call(this)},set:function(C){g=""+C,S.call(this,C)}}),Object.defineProperty(o,a,{enumerable:h.enumerable}),{getValue:function(){return g},setValue:function(C){g=""+C},stopTracking:function(){o._valueTracker=null,delete o[a]}}}}function ve(o){o._valueTracker||(o._valueTracker=ce(o))}function ie(o){if(!o)return!1;var a=o._valueTracker;if(!a)return!0;var h=a.getValue(),g="";return o&&(g=Ze(o)?o.checked?"true":"false":o.value),o=g,o!==h?(a.setValue(o),!0):!1}function Be(o){if(o=o||(typeof document<"u"?document:void 0),typeof o>"u")return null;try{return o.activeElement||o.body}catch{return o.body}}function Te(o,a){var h=a.checked;return K({},a,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:h??o._wrapperState.initialChecked})}function Ue(o,a){var h=a.defaultValue==null?"":a.defaultValue,g=a.checked!=null?a.checked:a.defaultChecked;h=Le(a.value!=null?a.value:h),o._wrapperState={initialChecked:g,initialValue:h,controlled:a.type==="checkbox"||a.type==="radio"?a.checked!=null:a.value!=null}}function Ee(o,a){a=a.checked,a!=null&&I(o,"checked",a,!1)}function Qe(o,a){Ee(o,a);var h=Le(a.value),g=a.type;if(h!=null)g==="number"?(h===0&&o.value===""||o.value!=h)&&(o.value=""+h):o.value!==""+h&&(o.value=""+h);else if(g==="submit"||g==="reset"){o.removeAttribute("value");return}a.hasOwnProperty("value")?vt(o,a.type,h):a.hasOwnProperty("defaultValue")&&vt(o,a.type,Le(a.defaultValue)),a.checked==null&&a.defaultChecked!=null&&(o.defaultChecked=!!a.defaultChecked)}function tt(o,a,h){if(a.hasOwnProperty("value")||a.hasOwnProperty("defaultValue")){var g=a.type;if(!(g!=="submit"&&g!=="reset"||a.value!==void 0&&a.value!==null))return;a=""+o._wrapperState.initialValue,h||a===o.value||(o.value=a),o.defaultValue=a}h=o.name,h!==""&&(o.name=""),o.defaultChecked=!!o._wrapperState.initialChecked,h!==""&&(o.name=h)}function vt(o,a,h){(a!=="number"||Be(o.ownerDocument)!==o)&&(h==null?o.defaultValue=""+o._wrapperState.initialValue:o.defaultValue!==""+h&&(o.defaultValue=""+h))}var Ce=Array.isArray;function ke(o,a,h,g){if(o=o.options,a){a={};for(var x=0;x<h.length;x++)a["$"+h[x]]=!0;for(h=0;h<o.length;h++)x=a.hasOwnProperty("$"+o[h].value),o[h].selected!==x&&(o[h].selected=x),x&&g&&(o[h].defaultSelected=!0)}else{for(h=""+Le(h),a=null,x=0;x<o.length;x++){if(o[x].value===h){o[x].selected=!0,g&&(o[x].defaultSelected=!0);return}a!==null||o[x].disabled||(a=o[x])}a!==null&&(a.selected=!0)}}function at(o,a){if(a.dangerouslySetInnerHTML!=null)throw Error(n(91));return K({},a,{value:void 0,defaultValue:void 0,children:""+o._wrapperState.initialValue})}function ft(o,a){var h=a.value;if(h==null){if(h=a.children,a=a.defaultValue,h!=null){if(a!=null)throw Error(n(92));if(Ce(h)){if(1<h.length)throw Error(n(93));h=h[0]}a=h}a==null&&(a=""),h=a}o._wrapperState={initialValue:Le(h)}}function st(o,a){var h=Le(a.value),g=Le(a.defaultValue);h!=null&&(h=""+h,h!==o.value&&(o.value=h),a.defaultValue==null&&o.defaultValue!==h&&(o.defaultValue=h)),g!=null&&(o.defaultValue=""+g)}function ht(o){var a=o.textContent;a===o._wrapperState.initialValue&&a!==""&&a!==null&&(o.value=a)}function zt(o){switch(o){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function Ct(o,a){return o==null||o==="http://www.w3.org/1999/xhtml"?zt(a):o==="http://www.w3.org/2000/svg"&&a==="foreignObject"?"http://www.w3.org/1999/xhtml":o}var Vt,xn=(function(o){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(a,h,g,x){MSApp.execUnsafeLocalFunction(function(){return o(a,h,g,x)})}:o})(function(o,a){if(o.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in o)o.innerHTML=a;else{for(Vt=Vt||document.createElement("div"),Vt.innerHTML="<svg>"+a.valueOf().toString()+"</svg>",a=Vt.firstChild;o.firstChild;)o.removeChild(o.firstChild);for(;a.firstChild;)o.appendChild(a.firstChild)}});function ee(o,a){if(a){var h=o.firstChild;if(h&&h===o.lastChild&&h.nodeType===3){h.nodeValue=a;return}}o.textContent=a}var He={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},We=["Webkit","ms","Moz","O"];Object.keys(He).forEach(function(o){We.forEach(function(a){a=a+o.charAt(0).toUpperCase()+o.substring(1),He[a]=He[o]})});function _t(o,a,h){return a==null||typeof a=="boolean"||a===""?"":h||typeof a!="number"||a===0||He.hasOwnProperty(o)&&He[o]?(""+a).trim():a+"px"}function nt(o,a){o=o.style;for(var h in a)if(a.hasOwnProperty(h)){var g=h.indexOf("--")===0,x=_t(h,a[h],g);h==="float"&&(h="cssFloat"),g?o.setProperty(h,x):o[h]=x}}var it=K({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function qe(o,a){if(a){if(it[o]&&(a.children!=null||a.dangerouslySetInnerHTML!=null))throw Error(n(137,o));if(a.dangerouslySetInnerHTML!=null){if(a.children!=null)throw Error(n(60));if(typeof a.dangerouslySetInnerHTML!="object"||!("__html"in a.dangerouslySetInnerHTML))throw Error(n(61))}if(a.style!=null&&typeof a.style!="object")throw Error(n(62))}}function Wn(o,a){if(o.indexOf("-")===-1)return typeof a.is=="string";switch(o){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var un=null;function le(o){return o=o.target||o.srcElement||window,o.correspondingUseElement&&(o=o.correspondingUseElement),o.nodeType===3?o.parentNode:o}var be=null,$e=null,Tt=null;function Kt(o){if(o=Xo(o)){if(typeof be!="function")throw Error(n(280));var a=o.stateNode;a&&(a=xa(a),be(o.stateNode,o.type,a))}}function L(o){$e?Tt?Tt.push(o):Tt=[o]:$e=o}function oe(){if($e){var o=$e,a=Tt;if(Tt=$e=null,Kt(o),a)for(o=0;o<a.length;o++)Kt(a[o])}}function xe(o,a){return o(a)}function Je(){}var Et=!1;function Mt(o,a,h){if(Et)return o(a,h);Et=!0;try{return xe(o,a,h)}finally{Et=!1,($e!==null||Tt!==null)&&(Je(),oe())}}function Me(o,a){var h=o.stateNode;if(h===null)return null;var g=xa(h);if(g===null)return null;h=g[a];e:switch(a){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(o=o.type,g=!(o==="button"||o==="input"||o==="select"||o==="textarea")),o=!g;break e;default:o=!1}if(o)return null;if(h&&typeof h!="function")throw Error(n(231,a,typeof h));return h}var _e=!1;if(c)try{var Ve={};Object.defineProperty(Ve,"passive",{get:function(){_e=!0}}),window.addEventListener("test",Ve,Ve),window.removeEventListener("test",Ve,Ve)}catch{_e=!1}function rn(o,a,h,g,x,S,C,j,D){var Q=Array.prototype.slice.call(arguments,3);try{a.apply(h,Q)}catch(de){this.onError(de)}}var Rt=!1,Rr=null,hs=!1,ti=null,sd={onError:function(o){Rt=!0,Rr=o}};function Ro(o,a,h,g,x,S,C,j,D){Rt=!1,Rr=null,rn.apply(sd,arguments)}function id(o,a,h,g,x,S,C,j,D){if(Ro.apply(this,arguments),Rt){if(Rt){var Q=Rr;Rt=!1,Rr=null}else throw Error(n(198));hs||(hs=!0,ti=Q)}}function Kr(o){var a=o,h=o;if(o.alternate)for(;a.return;)a=a.return;else{o=a;do a=o,(a.flags&4098)!==0&&(h=a.return),o=a.return;while(o)}return a.tag===3?h:null}function Xl(o){if(o.tag===13){var a=o.memoizedState;if(a===null&&(o=o.alternate,o!==null&&(a=o.memoizedState)),a!==null)return a.dehydrated}return null}function Io(o){if(Kr(o)!==o)throw Error(n(188))}function zi(o){var a=o.alternate;if(!a){if(a=Kr(o),a===null)throw Error(n(188));return a!==o?null:o}for(var h=o,g=a;;){var x=h.return;if(x===null)break;var S=x.alternate;if(S===null){if(g=x.return,g!==null){h=g;continue}break}if(x.child===S.child){for(S=x.child;S;){if(S===h)return Io(x),o;if(S===g)return Io(x),a;S=S.sibling}throw Error(n(188))}if(h.return!==g.return)h=x,g=S;else{for(var C=!1,j=x.child;j;){if(j===h){C=!0,h=x,g=S;break}if(j===g){C=!0,g=x,h=S;break}j=j.sibling}if(!C){for(j=S.child;j;){if(j===h){C=!0,h=S,g=x;break}if(j===g){C=!0,g=S,h=x;break}j=j.sibling}if(!C)throw Error(n(189))}}if(h.alternate!==g)throw Error(n(190))}if(h.tag!==3)throw Error(n(188));return h.stateNode.current===h?o:a}function Zl(o){return o=zi(o),o!==null?ea(o):null}function ea(o){if(o.tag===5||o.tag===6)return o;for(o=o.child;o!==null;){var a=ea(o);if(a!==null)return a;o=o.sibling}return null}var ta=e.unstable_scheduleCallback,vr=e.unstable_cancelCallback,na=e.unstable_shouldYield,ra=e.unstable_requestPaint,Ft=e.unstable_now,od=e.unstable_getCurrentPriorityLevel,jo=e.unstable_ImmediatePriority,ni=e.unstable_UserBlockingPriority,$i=e.unstable_NormalPriority,ge=e.unstable_LowPriority,De=e.unstable_IdlePriority,ot=null,ut=null;function Zt(o){if(ut&&typeof ut.onCommitFiberRoot=="function")try{ut.onCommitFiberRoot(ot,o,void 0,(o.current.flags&128)===128)}catch{}}var Ut=Math.clz32?Math.clz32:Pn,Ir=Math.log,Fi=Math.LN2;function Pn(o){return o>>>=0,o===0?32:31-(Ir(o)/Fi|0)|0}var Bn=64,ri=4194304;function ps(o){switch(o&-o){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return o&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return o&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return o}}function si(o,a){var h=o.pendingLanes;if(h===0)return 0;var g=0,x=o.suspendedLanes,S=o.pingedLanes,C=h&268435455;if(C!==0){var j=C&~x;j!==0?g=ps(j):(S&=C,S!==0&&(g=ps(S)))}else C=h&~x,C!==0?g=ps(C):S!==0&&(g=ps(S));if(g===0)return 0;if(a!==0&&a!==g&&(a&x)===0&&(x=g&-g,S=a&-a,x>=S||x===16&&(S&4194240)!==0))return a;if((g&4)!==0&&(g|=h&16),a=o.entangledLanes,a!==0)for(o=o.entanglements,a&=g;0<a;)h=31-Ut(a),x=1<<h,g|=o[h],a&=~x;return g}function ld(o,a){switch(o){case 1:case 2:case 4:return a+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return a+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function ad(o,a){for(var h=o.suspendedLanes,g=o.pingedLanes,x=o.expirationTimes,S=o.pendingLanes;0<S;){var C=31-Ut(S),j=1<<C,D=x[C];D===-1?((j&h)===0||(j&g)!==0)&&(x[C]=ld(j,a)):D<=a&&(o.expiredLanes|=j),S&=~j}}function Lo(o){return o=o.pendingLanes&-1073741825,o!==0?o:o&1073741824?1073741824:0}function sa(){var o=Bn;return Bn<<=1,(Bn&4194240)===0&&(Bn=64),o}function ms(o){for(var a=[],h=0;31>h;h++)a.push(o);return a}function gs(o,a,h){o.pendingLanes|=a,a!==536870912&&(o.suspendedLanes=0,o.pingedLanes=0),o=o.eventTimes,a=31-Ut(a),o[a]=h}function or(o,a){var h=o.pendingLanes&~a;o.pendingLanes=a,o.suspendedLanes=0,o.pingedLanes=0,o.expiredLanes&=a,o.mutableReadLanes&=a,o.entangledLanes&=a,a=o.entanglements;var g=o.eventTimes;for(o=o.expirationTimes;0<h;){var x=31-Ut(h),S=1<<x;a[x]=0,g[x]=-1,o[x]=-1,h&=~S}}function Do(o,a){var h=o.entangledLanes|=a;for(o=o.entanglements;h;){var g=31-Ut(h),x=1<<g;x&a|o[g]&a&&(o[g]|=a),h&=~x}}var pt=0;function rt(o){return o&=-o,1<o?4<o?(o&268435455)!==0?16:536870912:4:1}var Po,en,St,ii,jr,oi=!1,ys=[],we=null,Ae=null,Xe=null,dt=new Map,Gt=new Map,dn=[],cd="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function ia(o,a){switch(o){case"focusin":case"focusout":we=null;break;case"dragenter":case"dragleave":Ae=null;break;case"mouseover":case"mouseout":Xe=null;break;case"pointerover":case"pointerout":dt.delete(a.pointerId);break;case"gotpointercapture":case"lostpointercapture":Gt.delete(a.pointerId)}}function Bo(o,a,h,g,x,S){return o===null||o.nativeEvent!==S?(o={blockedOn:a,domEventName:h,eventSystemFlags:g,nativeEvent:S,targetContainers:[x]},a!==null&&(a=Xo(a),a!==null&&en(a)),o):(o.eventSystemFlags|=g,a=o.targetContainers,x!==null&&a.indexOf(x)===-1&&a.push(x),o)}function P1(o,a,h,g,x){switch(a){case"focusin":return we=Bo(we,o,a,h,g,x),!0;case"dragenter":return Ae=Bo(Ae,o,a,h,g,x),!0;case"mouseover":return Xe=Bo(Xe,o,a,h,g,x),!0;case"pointerover":var S=x.pointerId;return dt.set(S,Bo(dt.get(S)||null,o,a,h,g,x)),!0;case"gotpointercapture":return S=x.pointerId,Gt.set(S,Bo(Gt.get(S)||null,o,a,h,g,x)),!0}return!1}function Em(o){var a=li(o.target);if(a!==null){var h=Kr(a);if(h!==null){if(a=h.tag,a===13){if(a=Xl(h),a!==null){o.blockedOn=a,jr(o.priority,function(){St(h)});return}}else if(a===3&&h.stateNode.current.memoizedState.isDehydrated){o.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}o.blockedOn=null}function oa(o){if(o.blockedOn!==null)return!1;for(var a=o.targetContainers;0<a.length;){var h=dd(o.domEventName,o.eventSystemFlags,a[0],o.nativeEvent);if(h===null){h=o.nativeEvent;var g=new h.constructor(h.type,h);un=g,h.target.dispatchEvent(g),un=null}else return a=Xo(h),a!==null&&en(a),o.blockedOn=h,!1;a.shift()}return!0}function Nm(o,a,h){oa(o)&&h.delete(a)}function B1(){oi=!1,we!==null&&oa(we)&&(we=null),Ae!==null&&oa(Ae)&&(Ae=null),Xe!==null&&oa(Xe)&&(Xe=null),dt.forEach(Nm),Gt.forEach(Nm)}function zo(o,a){o.blockedOn===a&&(o.blockedOn=null,oi||(oi=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,B1)))}function $o(o){function a(x){return zo(x,o)}if(0<ys.length){zo(ys[0],o);for(var h=1;h<ys.length;h++){var g=ys[h];g.blockedOn===o&&(g.blockedOn=null)}}for(we!==null&&zo(we,o),Ae!==null&&zo(Ae,o),Xe!==null&&zo(Xe,o),dt.forEach(a),Gt.forEach(a),h=0;h<dn.length;h++)g=dn[h],g.blockedOn===o&&(g.blockedOn=null);for(;0<dn.length&&(h=dn[0],h.blockedOn===null);)Em(h),h.blockedOn===null&&dn.shift()}var Ui=_.ReactCurrentBatchConfig,la=!0;function z1(o,a,h,g){var x=pt,S=Ui.transition;Ui.transition=null;try{pt=1,ud(o,a,h,g)}finally{pt=x,Ui.transition=S}}function $1(o,a,h,g){var x=pt,S=Ui.transition;Ui.transition=null;try{pt=4,ud(o,a,h,g)}finally{pt=x,Ui.transition=S}}function ud(o,a,h,g){if(la){var x=dd(o,a,h,g);if(x===null)Td(o,a,g,aa,h),ia(o,g);else if(P1(x,o,a,h,g))g.stopPropagation();else if(ia(o,g),a&4&&-1<cd.indexOf(o)){for(;x!==null;){var S=Xo(x);if(S!==null&&Po(S),S=dd(o,a,h,g),S===null&&Td(o,a,g,aa,h),S===x)break;x=S}x!==null&&g.stopPropagation()}else Td(o,a,g,null,h)}}var aa=null;function dd(o,a,h,g){if(aa=null,o=le(g),o=li(o),o!==null)if(a=Kr(o),a===null)o=null;else if(h=a.tag,h===13){if(o=Xl(a),o!==null)return o;o=null}else if(h===3){if(a.stateNode.current.memoizedState.isDehydrated)return a.tag===3?a.stateNode.containerInfo:null;o=null}else a!==o&&(o=null);return aa=o,null}function Cm(o){switch(o){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(od()){case jo:return 1;case ni:return 4;case $i:case ge:return 16;case De:return 536870912;default:return 16}default:return 16}}var bs=null,fd=null,ca=null;function _m(){if(ca)return ca;var o,a=fd,h=a.length,g,x="value"in bs?bs.value:bs.textContent,S=x.length;for(o=0;o<h&&a[o]===x[o];o++);var C=h-o;for(g=1;g<=C&&a[h-g]===x[S-g];g++);return ca=x.slice(o,1<g?1-g:void 0)}function ua(o){var a=o.keyCode;return"charCode"in o?(o=o.charCode,o===0&&a===13&&(o=13)):o=a,o===10&&(o=13),32<=o||o===13?o:0}function da(){return!0}function Tm(){return!1}function Zn(o){function a(h,g,x,S,C){this._reactName=h,this._targetInst=x,this.type=g,this.nativeEvent=S,this.target=C,this.currentTarget=null;for(var j in o)o.hasOwnProperty(j)&&(h=o[j],this[j]=h?h(S):S[j]);return this.isDefaultPrevented=(S.defaultPrevented!=null?S.defaultPrevented:S.returnValue===!1)?da:Tm,this.isPropagationStopped=Tm,this}return K(a.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=da)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=da)},persist:function(){},isPersistent:da}),a}var Hi={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(o){return o.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hd=Zn(Hi),Fo=K({},Hi,{view:0,detail:0}),F1=Zn(Fo),pd,md,Uo,fa=K({},Fo,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:yd,button:0,buttons:0,relatedTarget:function(o){return o.relatedTarget===void 0?o.fromElement===o.srcElement?o.toElement:o.fromElement:o.relatedTarget},movementX:function(o){return"movementX"in o?o.movementX:(o!==Uo&&(Uo&&o.type==="mousemove"?(pd=o.screenX-Uo.screenX,md=o.screenY-Uo.screenY):md=pd=0,Uo=o),pd)},movementY:function(o){return"movementY"in o?o.movementY:md}}),Mm=Zn(fa),U1=K({},fa,{dataTransfer:0}),H1=Zn(U1),W1=K({},Fo,{relatedTarget:0}),gd=Zn(W1),V1=K({},Hi,{animationName:0,elapsedTime:0,pseudoElement:0}),K1=Zn(V1),G1=K({},Hi,{clipboardData:function(o){return"clipboardData"in o?o.clipboardData:window.clipboardData}}),q1=Zn(G1),J1=K({},Hi,{data:0}),Am=Zn(J1),Y1={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Q1={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},X1={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Z1(o){var a=this.nativeEvent;return a.getModifierState?a.getModifierState(o):(o=X1[o])?!!a[o]:!1}function yd(){return Z1}var eS=K({},Fo,{key:function(o){if(o.key){var a=Y1[o.key]||o.key;if(a!=="Unidentified")return a}return o.type==="keypress"?(o=ua(o),o===13?"Enter":String.fromCharCode(o)):o.type==="keydown"||o.type==="keyup"?Q1[o.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:yd,charCode:function(o){return o.type==="keypress"?ua(o):0},keyCode:function(o){return o.type==="keydown"||o.type==="keyup"?o.keyCode:0},which:function(o){return o.type==="keypress"?ua(o):o.type==="keydown"||o.type==="keyup"?o.keyCode:0}}),tS=Zn(eS),nS=K({},fa,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Om=Zn(nS),rS=K({},Fo,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:yd}),sS=Zn(rS),iS=K({},Hi,{propertyName:0,elapsedTime:0,pseudoElement:0}),oS=Zn(iS),lS=K({},fa,{deltaX:function(o){return"deltaX"in o?o.deltaX:"wheelDeltaX"in o?-o.wheelDeltaX:0},deltaY:function(o){return"deltaY"in o?o.deltaY:"wheelDeltaY"in o?-o.wheelDeltaY:"wheelDelta"in o?-o.wheelDelta:0},deltaZ:0,deltaMode:0}),aS=Zn(lS),cS=[9,13,27,32],bd=c&&"CompositionEvent"in window,Ho=null;c&&"documentMode"in document&&(Ho=document.documentMode);var uS=c&&"TextEvent"in window&&!Ho,Rm=c&&(!bd||Ho&&8<Ho&&11>=Ho),Im=" ",jm=!1;function Lm(o,a){switch(o){case"keyup":return cS.indexOf(a.keyCode)!==-1;case"keydown":return a.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dm(o){return o=o.detail,typeof o=="object"&&"data"in o?o.data:null}var Wi=!1;function dS(o,a){switch(o){case"compositionend":return Dm(a);case"keypress":return a.which!==32?null:(jm=!0,Im);case"textInput":return o=a.data,o===Im&&jm?null:o;default:return null}}function fS(o,a){if(Wi)return o==="compositionend"||!bd&&Lm(o,a)?(o=_m(),ca=fd=bs=null,Wi=!1,o):null;switch(o){case"paste":return null;case"keypress":if(!(a.ctrlKey||a.altKey||a.metaKey)||a.ctrlKey&&a.altKey){if(a.char&&1<a.char.length)return a.char;if(a.which)return String.fromCharCode(a.which)}return null;case"compositionend":return Rm&&a.locale!=="ko"?null:a.data;default:return null}}var hS={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Pm(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a==="input"?!!hS[o.type]:a==="textarea"}function Bm(o,a,h,g){L(g),a=ya(a,"onChange"),0<a.length&&(h=new hd("onChange","change",null,h,g),o.push({event:h,listeners:a}))}var Wo=null,Vo=null;function pS(o){ng(o,0)}function ha(o){var a=Ji(o);if(ie(a))return o}function mS(o,a){if(o==="change")return a}var zm=!1;if(c){var vd;if(c){var xd="oninput"in document;if(!xd){var $m=document.createElement("div");$m.setAttribute("oninput","return;"),xd=typeof $m.oninput=="function"}vd=xd}else vd=!1;zm=vd&&(!document.documentMode||9<document.documentMode)}function Fm(){Wo&&(Wo.detachEvent("onpropertychange",Um),Vo=Wo=null)}function Um(o){if(o.propertyName==="value"&&ha(Vo)){var a=[];Bm(a,Vo,o,le(o)),Mt(pS,a)}}function gS(o,a,h){o==="focusin"?(Fm(),Wo=a,Vo=h,Wo.attachEvent("onpropertychange",Um)):o==="focusout"&&Fm()}function yS(o){if(o==="selectionchange"||o==="keyup"||o==="keydown")return ha(Vo)}function bS(o,a){if(o==="click")return ha(a)}function vS(o,a){if(o==="input"||o==="change")return ha(a)}function xS(o,a){return o===a&&(o!==0||1/o===1/a)||o!==o&&a!==a}var xr=typeof Object.is=="function"?Object.is:xS;function Ko(o,a){if(xr(o,a))return!0;if(typeof o!="object"||o===null||typeof a!="object"||a===null)return!1;var h=Object.keys(o),g=Object.keys(a);if(h.length!==g.length)return!1;for(g=0;g<h.length;g++){var x=h[g];if(!u.call(a,x)||!xr(o[x],a[x]))return!1}return!0}function Hm(o){for(;o&&o.firstChild;)o=o.firstChild;return o}function Wm(o,a){var h=Hm(o);o=0;for(var g;h;){if(h.nodeType===3){if(g=o+h.textContent.length,o<=a&&g>=a)return{node:h,offset:a-o};o=g}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Hm(h)}}function Vm(o,a){return o&&a?o===a?!0:o&&o.nodeType===3?!1:a&&a.nodeType===3?Vm(o,a.parentNode):"contains"in o?o.contains(a):o.compareDocumentPosition?!!(o.compareDocumentPosition(a)&16):!1:!1}function Km(){for(var o=window,a=Be();a instanceof o.HTMLIFrameElement;){try{var h=typeof a.contentWindow.location.href=="string"}catch{h=!1}if(h)o=a.contentWindow;else break;a=Be(o.document)}return a}function wd(o){var a=o&&o.nodeName&&o.nodeName.toLowerCase();return a&&(a==="input"&&(o.type==="text"||o.type==="search"||o.type==="tel"||o.type==="url"||o.type==="password")||a==="textarea"||o.contentEditable==="true")}function wS(o){var a=Km(),h=o.focusedElem,g=o.selectionRange;if(a!==h&&h&&h.ownerDocument&&Vm(h.ownerDocument.documentElement,h)){if(g!==null&&wd(h)){if(a=g.start,o=g.end,o===void 0&&(o=a),"selectionStart"in h)h.selectionStart=a,h.selectionEnd=Math.min(o,h.value.length);else if(o=(a=h.ownerDocument||document)&&a.defaultView||window,o.getSelection){o=o.getSelection();var x=h.textContent.length,S=Math.min(g.start,x);g=g.end===void 0?S:Math.min(g.end,x),!o.extend&&S>g&&(x=g,g=S,S=x),x=Wm(h,S);var C=Wm(h,g);x&&C&&(o.rangeCount!==1||o.anchorNode!==x.node||o.anchorOffset!==x.offset||o.focusNode!==C.node||o.focusOffset!==C.offset)&&(a=a.createRange(),a.setStart(x.node,x.offset),o.removeAllRanges(),S>g?(o.addRange(a),o.extend(C.node,C.offset)):(a.setEnd(C.node,C.offset),o.addRange(a)))}}for(a=[],o=h;o=o.parentNode;)o.nodeType===1&&a.push({element:o,left:o.scrollLeft,top:o.scrollTop});for(typeof h.focus=="function"&&h.focus(),h=0;h<a.length;h++)o=a[h],o.element.scrollLeft=o.left,o.element.scrollTop=o.top}}var kS=c&&"documentMode"in document&&11>=document.documentMode,Vi=null,kd=null,Go=null,Sd=!1;function Gm(o,a,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Sd||Vi==null||Vi!==Be(g)||(g=Vi,"selectionStart"in g&&wd(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Go&&Ko(Go,g)||(Go=g,g=ya(kd,"onSelect"),0<g.length&&(a=new hd("onSelect","select",null,a,h),o.push({event:a,listeners:g}),a.target=Vi)))}function pa(o,a){var h={};return h[o.toLowerCase()]=a.toLowerCase(),h["Webkit"+o]="webkit"+a,h["Moz"+o]="moz"+a,h}var Ki={animationend:pa("Animation","AnimationEnd"),animationiteration:pa("Animation","AnimationIteration"),animationstart:pa("Animation","AnimationStart"),transitionend:pa("Transition","TransitionEnd")},Ed={},qm={};c&&(qm=document.createElement("div").style,"AnimationEvent"in window||(delete Ki.animationend.animation,delete Ki.animationiteration.animation,delete Ki.animationstart.animation),"TransitionEvent"in window||delete Ki.transitionend.transition);function ma(o){if(Ed[o])return Ed[o];if(!Ki[o])return o;var a=Ki[o],h;for(h in a)if(a.hasOwnProperty(h)&&h in qm)return Ed[o]=a[h];return o}var Jm=ma("animationend"),Ym=ma("animationiteration"),Qm=ma("animationstart"),Xm=ma("transitionend"),Zm=new Map,eg="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function vs(o,a){Zm.set(o,a),i(a,[o])}for(var Nd=0;Nd<eg.length;Nd++){var Cd=eg[Nd],SS=Cd.toLowerCase(),ES=Cd[0].toUpperCase()+Cd.slice(1);vs(SS,"on"+ES)}vs(Jm,"onAnimationEnd"),vs(Ym,"onAnimationIteration"),vs(Qm,"onAnimationStart"),vs("dblclick","onDoubleClick"),vs("focusin","onFocus"),vs("focusout","onBlur"),vs(Xm,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),i("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),i("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),i("onBeforeInput",["compositionend","keypress","textInput","paste"]),i("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),i("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var qo="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),NS=new Set("cancel close invalid load scroll toggle".split(" ").concat(qo));function tg(o,a,h){var g=o.type||"unknown-event";o.currentTarget=h,id(g,a,void 0,o),o.currentTarget=null}function ng(o,a){a=(a&4)!==0;for(var h=0;h<o.length;h++){var g=o[h],x=g.event;g=g.listeners;e:{var S=void 0;if(a)for(var C=g.length-1;0<=C;C--){var j=g[C],D=j.instance,Q=j.currentTarget;if(j=j.listener,D!==S&&x.isPropagationStopped())break e;tg(x,j,Q),S=D}else for(C=0;C<g.length;C++){if(j=g[C],D=j.instance,Q=j.currentTarget,j=j.listener,D!==S&&x.isPropagationStopped())break e;tg(x,j,Q),S=D}}}if(hs)throw o=ti,hs=!1,ti=null,o}function Dt(o,a){var h=a[jd];h===void 0&&(h=a[jd]=new Set);var g=o+"__bubble";h.has(g)||(rg(a,o,2,!1),h.add(g))}function _d(o,a,h){var g=0;a&&(g|=4),rg(h,o,g,a)}var ga="_reactListening"+Math.random().toString(36).slice(2);function Jo(o){if(!o[ga]){o[ga]=!0,r.forEach(function(h){h!=="selectionchange"&&(NS.has(h)||_d(h,!1,o),_d(h,!0,o))});var a=o.nodeType===9?o:o.ownerDocument;a===null||a[ga]||(a[ga]=!0,_d("selectionchange",!1,a))}}function rg(o,a,h,g){switch(Cm(a)){case 1:var x=z1;break;case 4:x=$1;break;default:x=ud}h=x.bind(null,a,h,o),x=void 0,!_e||a!=="touchstart"&&a!=="touchmove"&&a!=="wheel"||(x=!0),g?x!==void 0?o.addEventListener(a,h,{capture:!0,passive:x}):o.addEventListener(a,h,!0):x!==void 0?o.addEventListener(a,h,{passive:x}):o.addEventListener(a,h,!1)}function Td(o,a,h,g,x){var S=g;if((a&1)===0&&(a&2)===0&&g!==null)e:for(;;){if(g===null)return;var C=g.tag;if(C===3||C===4){var j=g.stateNode.containerInfo;if(j===x||j.nodeType===8&&j.parentNode===x)break;if(C===4)for(C=g.return;C!==null;){var D=C.tag;if((D===3||D===4)&&(D=C.stateNode.containerInfo,D===x||D.nodeType===8&&D.parentNode===x))return;C=C.return}for(;j!==null;){if(C=li(j),C===null)return;if(D=C.tag,D===5||D===6){g=S=C;continue e}j=j.parentNode}}g=g.return}Mt(function(){var Q=S,de=le(h),he=[];e:{var ue=Zm.get(o);if(ue!==void 0){var Ne=hd,Re=o;switch(o){case"keypress":if(ua(h)===0)break e;case"keydown":case"keyup":Ne=tS;break;case"focusin":Re="focus",Ne=gd;break;case"focusout":Re="blur",Ne=gd;break;case"beforeblur":case"afterblur":Ne=gd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ne=Mm;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ne=H1;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ne=sS;break;case Jm:case Ym:case Qm:Ne=K1;break;case Xm:Ne=oS;break;case"scroll":Ne=F1;break;case"wheel":Ne=aS;break;case"copy":case"cut":case"paste":Ne=q1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ne=Om}var Ie=(a&4)!==0,tn=!Ie&&o==="scroll",V=Ie?ue!==null?ue+"Capture":null:ue;Ie=[];for(var z=Q,q;z!==null;){q=z;var ye=q.stateNode;if(q.tag===5&&ye!==null&&(q=ye,V!==null&&(ye=Me(z,V),ye!=null&&Ie.push(Yo(z,ye,q)))),tn)break;z=z.return}0<Ie.length&&(ue=new Ne(ue,Re,null,h,de),he.push({event:ue,listeners:Ie}))}}if((a&7)===0){e:{if(ue=o==="mouseover"||o==="pointerover",Ne=o==="mouseout"||o==="pointerout",ue&&h!==un&&(Re=h.relatedTarget||h.fromElement)&&(li(Re)||Re[Gr]))break e;if((Ne||ue)&&(ue=de.window===de?de:(ue=de.ownerDocument)?ue.defaultView||ue.parentWindow:window,Ne?(Re=h.relatedTarget||h.toElement,Ne=Q,Re=Re?li(Re):null,Re!==null&&(tn=Kr(Re),Re!==tn||Re.tag!==5&&Re.tag!==6)&&(Re=null)):(Ne=null,Re=Q),Ne!==Re)){if(Ie=Mm,ye="onMouseLeave",V="onMouseEnter",z="mouse",(o==="pointerout"||o==="pointerover")&&(Ie=Om,ye="onPointerLeave",V="onPointerEnter",z="pointer"),tn=Ne==null?ue:Ji(Ne),q=Re==null?ue:Ji(Re),ue=new Ie(ye,z+"leave",Ne,h,de),ue.target=tn,ue.relatedTarget=q,ye=null,li(de)===Q&&(Ie=new Ie(V,z+"enter",Re,h,de),Ie.target=q,Ie.relatedTarget=tn,ye=Ie),tn=ye,Ne&&Re)t:{for(Ie=Ne,V=Re,z=0,q=Ie;q;q=Gi(q))z++;for(q=0,ye=V;ye;ye=Gi(ye))q++;for(;0<z-q;)Ie=Gi(Ie),z--;for(;0<q-z;)V=Gi(V),q--;for(;z--;){if(Ie===V||V!==null&&Ie===V.alternate)break t;Ie=Gi(Ie),V=Gi(V)}Ie=null}else Ie=null;Ne!==null&&sg(he,ue,Ne,Ie,!1),Re!==null&&tn!==null&&sg(he,tn,Re,Ie,!0)}}e:{if(ue=Q?Ji(Q):window,Ne=ue.nodeName&&ue.nodeName.toLowerCase(),Ne==="select"||Ne==="input"&&ue.type==="file")var je=mS;else if(Pm(ue))if(zm)je=vS;else{je=yS;var Ke=gS}else(Ne=ue.nodeName)&&Ne.toLowerCase()==="input"&&(ue.type==="checkbox"||ue.type==="radio")&&(je=bS);if(je&&(je=je(o,Q))){Bm(he,je,h,de);break e}Ke&&Ke(o,ue,Q),o==="focusout"&&(Ke=ue._wrapperState)&&Ke.controlled&&ue.type==="number"&&vt(ue,"number",ue.value)}switch(Ke=Q?Ji(Q):window,o){case"focusin":(Pm(Ke)||Ke.contentEditable==="true")&&(Vi=Ke,kd=Q,Go=null);break;case"focusout":Go=kd=Vi=null;break;case"mousedown":Sd=!0;break;case"contextmenu":case"mouseup":case"dragend":Sd=!1,Gm(he,h,de);break;case"selectionchange":if(kS)break;case"keydown":case"keyup":Gm(he,h,de)}var Ge;if(bd)e:{switch(o){case"compositionstart":var et="onCompositionStart";break e;case"compositionend":et="onCompositionEnd";break e;case"compositionupdate":et="onCompositionUpdate";break e}et=void 0}else Wi?Lm(o,h)&&(et="onCompositionEnd"):o==="keydown"&&h.keyCode===229&&(et="onCompositionStart");et&&(Rm&&h.locale!=="ko"&&(Wi||et!=="onCompositionStart"?et==="onCompositionEnd"&&Wi&&(Ge=_m()):(bs=de,fd="value"in bs?bs.value:bs.textContent,Wi=!0)),Ke=ya(Q,et),0<Ke.length&&(et=new Am(et,o,null,h,de),he.push({event:et,listeners:Ke}),Ge?et.data=Ge:(Ge=Dm(h),Ge!==null&&(et.data=Ge)))),(Ge=uS?dS(o,h):fS(o,h))&&(Q=ya(Q,"onBeforeInput"),0<Q.length&&(de=new Am("onBeforeInput","beforeinput",null,h,de),he.push({event:de,listeners:Q}),de.data=Ge))}ng(he,a)})}function Yo(o,a,h){return{instance:o,listener:a,currentTarget:h}}function ya(o,a){for(var h=a+"Capture",g=[];o!==null;){var x=o,S=x.stateNode;x.tag===5&&S!==null&&(x=S,S=Me(o,h),S!=null&&g.unshift(Yo(o,S,x)),S=Me(o,a),S!=null&&g.push(Yo(o,S,x))),o=o.return}return g}function Gi(o){if(o===null)return null;do o=o.return;while(o&&o.tag!==5);return o||null}function sg(o,a,h,g,x){for(var S=a._reactName,C=[];h!==null&&h!==g;){var j=h,D=j.alternate,Q=j.stateNode;if(D!==null&&D===g)break;j.tag===5&&Q!==null&&(j=Q,x?(D=Me(h,S),D!=null&&C.unshift(Yo(h,D,j))):x||(D=Me(h,S),D!=null&&C.push(Yo(h,D,j)))),h=h.return}C.length!==0&&o.push({event:a,listeners:C})}var CS=/\r\n?/g,_S=/\u0000|\uFFFD/g;function ig(o){return(typeof o=="string"?o:""+o).replace(CS,`
38
+ `).replace(_S,"")}function ba(o,a,h){if(a=ig(a),ig(o)!==a&&h)throw Error(n(425))}function va(){}var Md=null,Ad=null;function Od(o,a){return o==="textarea"||o==="noscript"||typeof a.children=="string"||typeof a.children=="number"||typeof a.dangerouslySetInnerHTML=="object"&&a.dangerouslySetInnerHTML!==null&&a.dangerouslySetInnerHTML.__html!=null}var Rd=typeof setTimeout=="function"?setTimeout:void 0,TS=typeof clearTimeout=="function"?clearTimeout:void 0,og=typeof Promise=="function"?Promise:void 0,MS=typeof queueMicrotask=="function"?queueMicrotask:typeof og<"u"?function(o){return og.resolve(null).then(o).catch(AS)}:Rd;function AS(o){setTimeout(function(){throw o})}function Id(o,a){var h=a,g=0;do{var x=h.nextSibling;if(o.removeChild(h),x&&x.nodeType===8)if(h=x.data,h==="/$"){if(g===0){o.removeChild(x),$o(a);return}g--}else h!=="$"&&h!=="$?"&&h!=="$!"||g++;h=x}while(h);$o(a)}function xs(o){for(;o!=null;o=o.nextSibling){var a=o.nodeType;if(a===1||a===3)break;if(a===8){if(a=o.data,a==="$"||a==="$!"||a==="$?")break;if(a==="/$")return null}}return o}function lg(o){o=o.previousSibling;for(var a=0;o;){if(o.nodeType===8){var h=o.data;if(h==="$"||h==="$!"||h==="$?"){if(a===0)return o;a--}else h==="/$"&&a++}o=o.previousSibling}return null}var qi=Math.random().toString(36).slice(2),Lr="__reactFiber$"+qi,Qo="__reactProps$"+qi,Gr="__reactContainer$"+qi,jd="__reactEvents$"+qi,OS="__reactListeners$"+qi,RS="__reactHandles$"+qi;function li(o){var a=o[Lr];if(a)return a;for(var h=o.parentNode;h;){if(a=h[Gr]||h[Lr]){if(h=a.alternate,a.child!==null||h!==null&&h.child!==null)for(o=lg(o);o!==null;){if(h=o[Lr])return h;o=lg(o)}return a}o=h,h=o.parentNode}return null}function Xo(o){return o=o[Lr]||o[Gr],!o||o.tag!==5&&o.tag!==6&&o.tag!==13&&o.tag!==3?null:o}function Ji(o){if(o.tag===5||o.tag===6)return o.stateNode;throw Error(n(33))}function xa(o){return o[Qo]||null}var Ld=[],Yi=-1;function ws(o){return{current:o}}function Pt(o){0>Yi||(o.current=Ld[Yi],Ld[Yi]=null,Yi--)}function It(o,a){Yi++,Ld[Yi]=o.current,o.current=a}var ks={},Mn=ws(ks),Vn=ws(!1),ai=ks;function Qi(o,a){var h=o.type.contextTypes;if(!h)return ks;var g=o.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===a)return g.__reactInternalMemoizedMaskedChildContext;var x={},S;for(S in h)x[S]=a[S];return g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=a,o.__reactInternalMemoizedMaskedChildContext=x),x}function Kn(o){return o=o.childContextTypes,o!=null}function wa(){Pt(Vn),Pt(Mn)}function ag(o,a,h){if(Mn.current!==ks)throw Error(n(168));It(Mn,a),It(Vn,h)}function cg(o,a,h){var g=o.stateNode;if(a=a.childContextTypes,typeof g.getChildContext!="function")return h;g=g.getChildContext();for(var x in g)if(!(x in a))throw Error(n(108,me(o)||"Unknown",x));return K({},h,g)}function ka(o){return o=(o=o.stateNode)&&o.__reactInternalMemoizedMergedChildContext||ks,ai=Mn.current,It(Mn,o),It(Vn,Vn.current),!0}function ug(o,a,h){var g=o.stateNode;if(!g)throw Error(n(169));h?(o=cg(o,a,ai),g.__reactInternalMemoizedMergedChildContext=o,Pt(Vn),Pt(Mn),It(Mn,o)):Pt(Vn),It(Vn,h)}var qr=null,Sa=!1,Dd=!1;function dg(o){qr===null?qr=[o]:qr.push(o)}function IS(o){Sa=!0,dg(o)}function Ss(){if(!Dd&&qr!==null){Dd=!0;var o=0,a=pt;try{var h=qr;for(pt=1;o<h.length;o++){var g=h[o];do g=g(!0);while(g!==null)}qr=null,Sa=!1}catch(x){throw qr!==null&&(qr=qr.slice(o+1)),ta(jo,Ss),x}finally{pt=a,Dd=!1}}return null}var Xi=[],Zi=0,Ea=null,Na=0,lr=[],ar=0,ci=null,Jr=1,Yr="";function ui(o,a){Xi[Zi++]=Na,Xi[Zi++]=Ea,Ea=o,Na=a}function fg(o,a,h){lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ci,ci=o;var g=Jr;o=Yr;var x=32-Ut(g)-1;g&=~(1<<x),h+=1;var S=32-Ut(a)+x;if(30<S){var C=x-x%5;S=(g&(1<<C)-1).toString(32),g>>=C,x-=C,Jr=1<<32-Ut(a)+x|h<<x|g,Yr=S+o}else Jr=1<<S|h<<x|g,Yr=o}function Pd(o){o.return!==null&&(ui(o,1),fg(o,1,0))}function Bd(o){for(;o===Ea;)Ea=Xi[--Zi],Xi[Zi]=null,Na=Xi[--Zi],Xi[Zi]=null;for(;o===ci;)ci=lr[--ar],lr[ar]=null,Yr=lr[--ar],lr[ar]=null,Jr=lr[--ar],lr[ar]=null}var er=null,tr=null,$t=!1,wr=null;function hg(o,a){var h=fr(5,null,null,0);h.elementType="DELETED",h.stateNode=a,h.return=o,a=o.deletions,a===null?(o.deletions=[h],o.flags|=16):a.push(h)}function pg(o,a){switch(o.tag){case 5:var h=o.type;return a=a.nodeType!==1||h.toLowerCase()!==a.nodeName.toLowerCase()?null:a,a!==null?(o.stateNode=a,er=o,tr=xs(a.firstChild),!0):!1;case 6:return a=o.pendingProps===""||a.nodeType!==3?null:a,a!==null?(o.stateNode=a,er=o,tr=null,!0):!1;case 13:return a=a.nodeType!==8?null:a,a!==null?(h=ci!==null?{id:Jr,overflow:Yr}:null,o.memoizedState={dehydrated:a,treeContext:h,retryLane:1073741824},h=fr(18,null,null,0),h.stateNode=a,h.return=o,o.child=h,er=o,tr=null,!0):!1;default:return!1}}function zd(o){return(o.mode&1)!==0&&(o.flags&128)===0}function $d(o){if($t){var a=tr;if(a){var h=a;if(!pg(o,a)){if(zd(o))throw Error(n(418));a=xs(h.nextSibling);var g=er;a&&pg(o,a)?hg(g,h):(o.flags=o.flags&-4097|2,$t=!1,er=o)}}else{if(zd(o))throw Error(n(418));o.flags=o.flags&-4097|2,$t=!1,er=o}}}function mg(o){for(o=o.return;o!==null&&o.tag!==5&&o.tag!==3&&o.tag!==13;)o=o.return;er=o}function Ca(o){if(o!==er)return!1;if(!$t)return mg(o),$t=!0,!1;var a;if((a=o.tag!==3)&&!(a=o.tag!==5)&&(a=o.type,a=a!=="head"&&a!=="body"&&!Od(o.type,o.memoizedProps)),a&&(a=tr)){if(zd(o))throw gg(),Error(n(418));for(;a;)hg(o,a),a=xs(a.nextSibling)}if(mg(o),o.tag===13){if(o=o.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(n(317));e:{for(o=o.nextSibling,a=0;o;){if(o.nodeType===8){var h=o.data;if(h==="/$"){if(a===0){tr=xs(o.nextSibling);break e}a--}else h!=="$"&&h!=="$!"&&h!=="$?"||a++}o=o.nextSibling}tr=null}}else tr=er?xs(o.stateNode.nextSibling):null;return!0}function gg(){for(var o=tr;o;)o=xs(o.nextSibling)}function eo(){tr=er=null,$t=!1}function Fd(o){wr===null?wr=[o]:wr.push(o)}var jS=_.ReactCurrentBatchConfig;function Zo(o,a,h){if(o=h.ref,o!==null&&typeof o!="function"&&typeof o!="object"){if(h._owner){if(h=h._owner,h){if(h.tag!==1)throw Error(n(309));var g=h.stateNode}if(!g)throw Error(n(147,o));var x=g,S=""+o;return a!==null&&a.ref!==null&&typeof a.ref=="function"&&a.ref._stringRef===S?a.ref:(a=function(C){var j=x.refs;C===null?delete j[S]:j[S]=C},a._stringRef=S,a)}if(typeof o!="string")throw Error(n(284));if(!h._owner)throw Error(n(290,o))}return o}function _a(o,a){throw o=Object.prototype.toString.call(a),Error(n(31,o==="[object Object]"?"object with keys {"+Object.keys(a).join(", ")+"}":o))}function yg(o){var a=o._init;return a(o._payload)}function bg(o){function a(V,z){if(o){var q=V.deletions;q===null?(V.deletions=[z],V.flags|=16):q.push(z)}}function h(V,z){if(!o)return null;for(;z!==null;)a(V,z),z=z.sibling;return null}function g(V,z){for(V=new Map;z!==null;)z.key!==null?V.set(z.key,z):V.set(z.index,z),z=z.sibling;return V}function x(V,z){return V=Os(V,z),V.index=0,V.sibling=null,V}function S(V,z,q){return V.index=q,o?(q=V.alternate,q!==null?(q=q.index,q<z?(V.flags|=2,z):q):(V.flags|=2,z)):(V.flags|=1048576,z)}function C(V){return o&&V.alternate===null&&(V.flags|=2),V}function j(V,z,q,ye){return z===null||z.tag!==6?(z=If(q,V.mode,ye),z.return=V,z):(z=x(z,q),z.return=V,z)}function D(V,z,q,ye){var je=q.type;return je===P?de(V,z,q.props.children,ye,q.key):z!==null&&(z.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===U&&yg(je)===z.type)?(ye=x(z,q.props),ye.ref=Zo(V,z,q),ye.return=V,ye):(ye=Qa(q.type,q.key,q.props,null,V.mode,ye),ye.ref=Zo(V,z,q),ye.return=V,ye)}function Q(V,z,q,ye){return z===null||z.tag!==4||z.stateNode.containerInfo!==q.containerInfo||z.stateNode.implementation!==q.implementation?(z=jf(q,V.mode,ye),z.return=V,z):(z=x(z,q.children||[]),z.return=V,z)}function de(V,z,q,ye,je){return z===null||z.tag!==7?(z=bi(q,V.mode,ye,je),z.return=V,z):(z=x(z,q),z.return=V,z)}function he(V,z,q){if(typeof z=="string"&&z!==""||typeof z=="number")return z=If(""+z,V.mode,q),z.return=V,z;if(typeof z=="object"&&z!==null){switch(z.$$typeof){case M:return q=Qa(z.type,z.key,z.props,null,V.mode,q),q.ref=Zo(V,null,z),q.return=V,q;case O:return z=jf(z,V.mode,q),z.return=V,z;case U:var ye=z._init;return he(V,ye(z._payload),q)}if(Ce(z)||X(z))return z=bi(z,V.mode,q,null),z.return=V,z;_a(V,z)}return null}function ue(V,z,q,ye){var je=z!==null?z.key:null;if(typeof q=="string"&&q!==""||typeof q=="number")return je!==null?null:j(V,z,""+q,ye);if(typeof q=="object"&&q!==null){switch(q.$$typeof){case M:return q.key===je?D(V,z,q,ye):null;case O:return q.key===je?Q(V,z,q,ye):null;case U:return je=q._init,ue(V,z,je(q._payload),ye)}if(Ce(q)||X(q))return je!==null?null:de(V,z,q,ye,null);_a(V,q)}return null}function Ne(V,z,q,ye,je){if(typeof ye=="string"&&ye!==""||typeof ye=="number")return V=V.get(q)||null,j(z,V,""+ye,je);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case M:return V=V.get(ye.key===null?q:ye.key)||null,D(z,V,ye,je);case O:return V=V.get(ye.key===null?q:ye.key)||null,Q(z,V,ye,je);case U:var Ke=ye._init;return Ne(V,z,q,Ke(ye._payload),je)}if(Ce(ye)||X(ye))return V=V.get(q)||null,de(z,V,ye,je,null);_a(z,ye)}return null}function Re(V,z,q,ye){for(var je=null,Ke=null,Ge=z,et=z=0,pn=null;Ge!==null&&et<q.length;et++){Ge.index>et?(pn=Ge,Ge=null):pn=Ge.sibling;var yt=ue(V,Ge,q[et],ye);if(yt===null){Ge===null&&(Ge=pn);break}o&&Ge&&yt.alternate===null&&a(V,Ge),z=S(yt,z,et),Ke===null?je=yt:Ke.sibling=yt,Ke=yt,Ge=pn}if(et===q.length)return h(V,Ge),$t&&ui(V,et),je;if(Ge===null){for(;et<q.length;et++)Ge=he(V,q[et],ye),Ge!==null&&(z=S(Ge,z,et),Ke===null?je=Ge:Ke.sibling=Ge,Ke=Ge);return $t&&ui(V,et),je}for(Ge=g(V,Ge);et<q.length;et++)pn=Ne(Ge,V,et,q[et],ye),pn!==null&&(o&&pn.alternate!==null&&Ge.delete(pn.key===null?et:pn.key),z=S(pn,z,et),Ke===null?je=pn:Ke.sibling=pn,Ke=pn);return o&&Ge.forEach(function(Rs){return a(V,Rs)}),$t&&ui(V,et),je}function Ie(V,z,q,ye){var je=X(q);if(typeof je!="function")throw Error(n(150));if(q=je.call(q),q==null)throw Error(n(151));for(var Ke=je=null,Ge=z,et=z=0,pn=null,yt=q.next();Ge!==null&&!yt.done;et++,yt=q.next()){Ge.index>et?(pn=Ge,Ge=null):pn=Ge.sibling;var Rs=ue(V,Ge,yt.value,ye);if(Rs===null){Ge===null&&(Ge=pn);break}o&&Ge&&Rs.alternate===null&&a(V,Ge),z=S(Rs,z,et),Ke===null?je=Rs:Ke.sibling=Rs,Ke=Rs,Ge=pn}if(yt.done)return h(V,Ge),$t&&ui(V,et),je;if(Ge===null){for(;!yt.done;et++,yt=q.next())yt=he(V,yt.value,ye),yt!==null&&(z=S(yt,z,et),Ke===null?je=yt:Ke.sibling=yt,Ke=yt);return $t&&ui(V,et),je}for(Ge=g(V,Ge);!yt.done;et++,yt=q.next())yt=Ne(Ge,V,et,yt.value,ye),yt!==null&&(o&&yt.alternate!==null&&Ge.delete(yt.key===null?et:yt.key),z=S(yt,z,et),Ke===null?je=yt:Ke.sibling=yt,Ke=yt);return o&&Ge.forEach(function(hE){return a(V,hE)}),$t&&ui(V,et),je}function tn(V,z,q,ye){if(typeof q=="object"&&q!==null&&q.type===P&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case M:e:{for(var je=q.key,Ke=z;Ke!==null;){if(Ke.key===je){if(je=q.type,je===P){if(Ke.tag===7){h(V,Ke.sibling),z=x(Ke,q.props.children),z.return=V,V=z;break e}}else if(Ke.elementType===je||typeof je=="object"&&je!==null&&je.$$typeof===U&&yg(je)===Ke.type){h(V,Ke.sibling),z=x(Ke,q.props),z.ref=Zo(V,Ke,q),z.return=V,V=z;break e}h(V,Ke);break}else a(V,Ke);Ke=Ke.sibling}q.type===P?(z=bi(q.props.children,V.mode,ye,q.key),z.return=V,V=z):(ye=Qa(q.type,q.key,q.props,null,V.mode,ye),ye.ref=Zo(V,z,q),ye.return=V,V=ye)}return C(V);case O:e:{for(Ke=q.key;z!==null;){if(z.key===Ke)if(z.tag===4&&z.stateNode.containerInfo===q.containerInfo&&z.stateNode.implementation===q.implementation){h(V,z.sibling),z=x(z,q.children||[]),z.return=V,V=z;break e}else{h(V,z);break}else a(V,z);z=z.sibling}z=jf(q,V.mode,ye),z.return=V,V=z}return C(V);case U:return Ke=q._init,tn(V,z,Ke(q._payload),ye)}if(Ce(q))return Re(V,z,q,ye);if(X(q))return Ie(V,z,q,ye);_a(V,q)}return typeof q=="string"&&q!==""||typeof q=="number"?(q=""+q,z!==null&&z.tag===6?(h(V,z.sibling),z=x(z,q),z.return=V,V=z):(h(V,z),z=If(q,V.mode,ye),z.return=V,V=z),C(V)):h(V,z)}return tn}var to=bg(!0),vg=bg(!1),Ta=ws(null),Ma=null,no=null,Ud=null;function Hd(){Ud=no=Ma=null}function Wd(o){var a=Ta.current;Pt(Ta),o._currentValue=a}function Vd(o,a,h){for(;o!==null;){var g=o.alternate;if((o.childLanes&a)!==a?(o.childLanes|=a,g!==null&&(g.childLanes|=a)):g!==null&&(g.childLanes&a)!==a&&(g.childLanes|=a),o===h)break;o=o.return}}function ro(o,a){Ma=o,Ud=no=null,o=o.dependencies,o!==null&&o.firstContext!==null&&((o.lanes&a)!==0&&(Gn=!0),o.firstContext=null)}function cr(o){var a=o._currentValue;if(Ud!==o)if(o={context:o,memoizedValue:a,next:null},no===null){if(Ma===null)throw Error(n(308));no=o,Ma.dependencies={lanes:0,firstContext:o}}else no=no.next=o;return a}var di=null;function Kd(o){di===null?di=[o]:di.push(o)}function xg(o,a,h,g){var x=a.interleaved;return x===null?(h.next=h,Kd(a)):(h.next=x.next,x.next=h),a.interleaved=h,Qr(o,g)}function Qr(o,a){o.lanes|=a;var h=o.alternate;for(h!==null&&(h.lanes|=a),h=o,o=o.return;o!==null;)o.childLanes|=a,h=o.alternate,h!==null&&(h.childLanes|=a),h=o,o=o.return;return h.tag===3?h.stateNode:null}var Es=!1;function Gd(o){o.updateQueue={baseState:o.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wg(o,a){o=o.updateQueue,a.updateQueue===o&&(a.updateQueue={baseState:o.baseState,firstBaseUpdate:o.firstBaseUpdate,lastBaseUpdate:o.lastBaseUpdate,shared:o.shared,effects:o.effects})}function Xr(o,a){return{eventTime:o,lane:a,tag:0,payload:null,callback:null,next:null}}function Ns(o,a,h){var g=o.updateQueue;if(g===null)return null;if(g=g.shared,(mt&2)!==0){var x=g.pending;return x===null?a.next=a:(a.next=x.next,x.next=a),g.pending=a,Qr(o,h)}return x=g.interleaved,x===null?(a.next=a,Kd(g)):(a.next=x.next,x.next=a),g.interleaved=a,Qr(o,h)}function Aa(o,a,h){if(a=a.updateQueue,a!==null&&(a=a.shared,(h&4194240)!==0)){var g=a.lanes;g&=o.pendingLanes,h|=g,a.lanes=h,Do(o,h)}}function kg(o,a){var h=o.updateQueue,g=o.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var x=null,S=null;if(h=h.firstBaseUpdate,h!==null){do{var C={eventTime:h.eventTime,lane:h.lane,tag:h.tag,payload:h.payload,callback:h.callback,next:null};S===null?x=S=C:S=S.next=C,h=h.next}while(h!==null);S===null?x=S=a:S=S.next=a}else x=S=a;h={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:S,shared:g.shared,effects:g.effects},o.updateQueue=h;return}o=h.lastBaseUpdate,o===null?h.firstBaseUpdate=a:o.next=a,h.lastBaseUpdate=a}function Oa(o,a,h,g){var x=o.updateQueue;Es=!1;var S=x.firstBaseUpdate,C=x.lastBaseUpdate,j=x.shared.pending;if(j!==null){x.shared.pending=null;var D=j,Q=D.next;D.next=null,C===null?S=Q:C.next=Q,C=D;var de=o.alternate;de!==null&&(de=de.updateQueue,j=de.lastBaseUpdate,j!==C&&(j===null?de.firstBaseUpdate=Q:j.next=Q,de.lastBaseUpdate=D))}if(S!==null){var he=x.baseState;C=0,de=Q=D=null,j=S;do{var ue=j.lane,Ne=j.eventTime;if((g&ue)===ue){de!==null&&(de=de.next={eventTime:Ne,lane:0,tag:j.tag,payload:j.payload,callback:j.callback,next:null});e:{var Re=o,Ie=j;switch(ue=a,Ne=h,Ie.tag){case 1:if(Re=Ie.payload,typeof Re=="function"){he=Re.call(Ne,he,ue);break e}he=Re;break e;case 3:Re.flags=Re.flags&-65537|128;case 0:if(Re=Ie.payload,ue=typeof Re=="function"?Re.call(Ne,he,ue):Re,ue==null)break e;he=K({},he,ue);break e;case 2:Es=!0}}j.callback!==null&&j.lane!==0&&(o.flags|=64,ue=x.effects,ue===null?x.effects=[j]:ue.push(j))}else Ne={eventTime:Ne,lane:ue,tag:j.tag,payload:j.payload,callback:j.callback,next:null},de===null?(Q=de=Ne,D=he):de=de.next=Ne,C|=ue;if(j=j.next,j===null){if(j=x.shared.pending,j===null)break;ue=j,j=ue.next,ue.next=null,x.lastBaseUpdate=ue,x.shared.pending=null}}while(!0);if(de===null&&(D=he),x.baseState=D,x.firstBaseUpdate=Q,x.lastBaseUpdate=de,a=x.shared.interleaved,a!==null){x=a;do C|=x.lane,x=x.next;while(x!==a)}else S===null&&(x.shared.lanes=0);pi|=C,o.lanes=C,o.memoizedState=he}}function Sg(o,a,h){if(o=a.effects,a.effects=null,o!==null)for(a=0;a<o.length;a++){var g=o[a],x=g.callback;if(x!==null){if(g.callback=null,g=h,typeof x!="function")throw Error(n(191,x));x.call(g)}}}var el={},Dr=ws(el),tl=ws(el),nl=ws(el);function fi(o){if(o===el)throw Error(n(174));return o}function qd(o,a){switch(It(nl,a),It(tl,o),It(Dr,el),o=a.nodeType,o){case 9:case 11:a=(a=a.documentElement)?a.namespaceURI:Ct(null,"");break;default:o=o===8?a.parentNode:a,a=o.namespaceURI||null,o=o.tagName,a=Ct(a,o)}Pt(Dr),It(Dr,a)}function so(){Pt(Dr),Pt(tl),Pt(nl)}function Eg(o){fi(nl.current);var a=fi(Dr.current),h=Ct(a,o.type);a!==h&&(It(tl,o),It(Dr,h))}function Jd(o){tl.current===o&&(Pt(Dr),Pt(tl))}var Ht=ws(0);function Ra(o){for(var a=o;a!==null;){if(a.tag===13){var h=a.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||h.data==="$?"||h.data==="$!"))return a}else if(a.tag===19&&a.memoizedProps.revealOrder!==void 0){if((a.flags&128)!==0)return a}else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===o)break;for(;a.sibling===null;){if(a.return===null||a.return===o)return null;a=a.return}a.sibling.return=a.return,a=a.sibling}return null}var Yd=[];function Qd(){for(var o=0;o<Yd.length;o++)Yd[o]._workInProgressVersionPrimary=null;Yd.length=0}var Ia=_.ReactCurrentDispatcher,Xd=_.ReactCurrentBatchConfig,hi=0,Wt=null,an=null,fn=null,ja=!1,rl=!1,sl=0,LS=0;function An(){throw Error(n(321))}function Zd(o,a){if(a===null)return!1;for(var h=0;h<a.length&&h<o.length;h++)if(!xr(o[h],a[h]))return!1;return!0}function ef(o,a,h,g,x,S){if(hi=S,Wt=a,a.memoizedState=null,a.updateQueue=null,a.lanes=0,Ia.current=o===null||o.memoizedState===null?zS:$S,o=h(g,x),rl){S=0;do{if(rl=!1,sl=0,25<=S)throw Error(n(301));S+=1,fn=an=null,a.updateQueue=null,Ia.current=FS,o=h(g,x)}while(rl)}if(Ia.current=Pa,a=an!==null&&an.next!==null,hi=0,fn=an=Wt=null,ja=!1,a)throw Error(n(300));return o}function tf(){var o=sl!==0;return sl=0,o}function Pr(){var o={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return fn===null?Wt.memoizedState=fn=o:fn=fn.next=o,fn}function ur(){if(an===null){var o=Wt.alternate;o=o!==null?o.memoizedState:null}else o=an.next;var a=fn===null?Wt.memoizedState:fn.next;if(a!==null)fn=a,an=o;else{if(o===null)throw Error(n(310));an=o,o={memoizedState:an.memoizedState,baseState:an.baseState,baseQueue:an.baseQueue,queue:an.queue,next:null},fn===null?Wt.memoizedState=fn=o:fn=fn.next=o}return fn}function il(o,a){return typeof a=="function"?a(o):a}function nf(o){var a=ur(),h=a.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=o;var g=an,x=g.baseQueue,S=h.pending;if(S!==null){if(x!==null){var C=x.next;x.next=S.next,S.next=C}g.baseQueue=x=S,h.pending=null}if(x!==null){S=x.next,g=g.baseState;var j=C=null,D=null,Q=S;do{var de=Q.lane;if((hi&de)===de)D!==null&&(D=D.next={lane:0,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null}),g=Q.hasEagerState?Q.eagerState:o(g,Q.action);else{var he={lane:de,action:Q.action,hasEagerState:Q.hasEagerState,eagerState:Q.eagerState,next:null};D===null?(j=D=he,C=g):D=D.next=he,Wt.lanes|=de,pi|=de}Q=Q.next}while(Q!==null&&Q!==S);D===null?C=g:D.next=j,xr(g,a.memoizedState)||(Gn=!0),a.memoizedState=g,a.baseState=C,a.baseQueue=D,h.lastRenderedState=g}if(o=h.interleaved,o!==null){x=o;do S=x.lane,Wt.lanes|=S,pi|=S,x=x.next;while(x!==o)}else x===null&&(h.lanes=0);return[a.memoizedState,h.dispatch]}function rf(o){var a=ur(),h=a.queue;if(h===null)throw Error(n(311));h.lastRenderedReducer=o;var g=h.dispatch,x=h.pending,S=a.memoizedState;if(x!==null){h.pending=null;var C=x=x.next;do S=o(S,C.action),C=C.next;while(C!==x);xr(S,a.memoizedState)||(Gn=!0),a.memoizedState=S,a.baseQueue===null&&(a.baseState=S),h.lastRenderedState=S}return[S,g]}function Ng(){}function Cg(o,a){var h=Wt,g=ur(),x=a(),S=!xr(g.memoizedState,x);if(S&&(g.memoizedState=x,Gn=!0),g=g.queue,sf(Mg.bind(null,h,g,o),[o]),g.getSnapshot!==a||S||fn!==null&&fn.memoizedState.tag&1){if(h.flags|=2048,ol(9,Tg.bind(null,h,g,x,a),void 0,null),hn===null)throw Error(n(349));(hi&30)!==0||_g(h,a,x)}return x}function _g(o,a,h){o.flags|=16384,o={getSnapshot:a,value:h},a=Wt.updateQueue,a===null?(a={lastEffect:null,stores:null},Wt.updateQueue=a,a.stores=[o]):(h=a.stores,h===null?a.stores=[o]:h.push(o))}function Tg(o,a,h,g){a.value=h,a.getSnapshot=g,Ag(a)&&Og(o)}function Mg(o,a,h){return h(function(){Ag(a)&&Og(o)})}function Ag(o){var a=o.getSnapshot;o=o.value;try{var h=a();return!xr(o,h)}catch{return!0}}function Og(o){var a=Qr(o,1);a!==null&&Nr(a,o,1,-1)}function Rg(o){var a=Pr();return typeof o=="function"&&(o=o()),a.memoizedState=a.baseState=o,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:il,lastRenderedState:o},a.queue=o,o=o.dispatch=BS.bind(null,Wt,o),[a.memoizedState,o]}function ol(o,a,h,g){return o={tag:o,create:a,destroy:h,deps:g,next:null},a=Wt.updateQueue,a===null?(a={lastEffect:null,stores:null},Wt.updateQueue=a,a.lastEffect=o.next=o):(h=a.lastEffect,h===null?a.lastEffect=o.next=o:(g=h.next,h.next=o,o.next=g,a.lastEffect=o)),o}function Ig(){return ur().memoizedState}function La(o,a,h,g){var x=Pr();Wt.flags|=o,x.memoizedState=ol(1|a,h,void 0,g===void 0?null:g)}function Da(o,a,h,g){var x=ur();g=g===void 0?null:g;var S=void 0;if(an!==null){var C=an.memoizedState;if(S=C.destroy,g!==null&&Zd(g,C.deps)){x.memoizedState=ol(a,h,S,g);return}}Wt.flags|=o,x.memoizedState=ol(1|a,h,S,g)}function jg(o,a){return La(8390656,8,o,a)}function sf(o,a){return Da(2048,8,o,a)}function Lg(o,a){return Da(4,2,o,a)}function Dg(o,a){return Da(4,4,o,a)}function Pg(o,a){if(typeof a=="function")return o=o(),a(o),function(){a(null)};if(a!=null)return o=o(),a.current=o,function(){a.current=null}}function Bg(o,a,h){return h=h!=null?h.concat([o]):null,Da(4,4,Pg.bind(null,a,o),h)}function of(){}function zg(o,a){var h=ur();a=a===void 0?null:a;var g=h.memoizedState;return g!==null&&a!==null&&Zd(a,g[1])?g[0]:(h.memoizedState=[o,a],o)}function $g(o,a){var h=ur();a=a===void 0?null:a;var g=h.memoizedState;return g!==null&&a!==null&&Zd(a,g[1])?g[0]:(o=o(),h.memoizedState=[o,a],o)}function Fg(o,a,h){return(hi&21)===0?(o.baseState&&(o.baseState=!1,Gn=!0),o.memoizedState=h):(xr(h,a)||(h=sa(),Wt.lanes|=h,pi|=h,o.baseState=!0),a)}function DS(o,a){var h=pt;pt=h!==0&&4>h?h:4,o(!0);var g=Xd.transition;Xd.transition={};try{o(!1),a()}finally{pt=h,Xd.transition=g}}function Ug(){return ur().memoizedState}function PS(o,a,h){var g=Ms(o);if(h={lane:g,action:h,hasEagerState:!1,eagerState:null,next:null},Hg(o))Wg(a,h);else if(h=xg(o,a,h,g),h!==null){var x=$n();Nr(h,o,g,x),Vg(h,a,g)}}function BS(o,a,h){var g=Ms(o),x={lane:g,action:h,hasEagerState:!1,eagerState:null,next:null};if(Hg(o))Wg(a,x);else{var S=o.alternate;if(o.lanes===0&&(S===null||S.lanes===0)&&(S=a.lastRenderedReducer,S!==null))try{var C=a.lastRenderedState,j=S(C,h);if(x.hasEagerState=!0,x.eagerState=j,xr(j,C)){var D=a.interleaved;D===null?(x.next=x,Kd(a)):(x.next=D.next,D.next=x),a.interleaved=x;return}}catch{}finally{}h=xg(o,a,x,g),h!==null&&(x=$n(),Nr(h,o,g,x),Vg(h,a,g))}}function Hg(o){var a=o.alternate;return o===Wt||a!==null&&a===Wt}function Wg(o,a){rl=ja=!0;var h=o.pending;h===null?a.next=a:(a.next=h.next,h.next=a),o.pending=a}function Vg(o,a,h){if((h&4194240)!==0){var g=a.lanes;g&=o.pendingLanes,h|=g,a.lanes=h,Do(o,h)}}var Pa={readContext:cr,useCallback:An,useContext:An,useEffect:An,useImperativeHandle:An,useInsertionEffect:An,useLayoutEffect:An,useMemo:An,useReducer:An,useRef:An,useState:An,useDebugValue:An,useDeferredValue:An,useTransition:An,useMutableSource:An,useSyncExternalStore:An,useId:An,unstable_isNewReconciler:!1},zS={readContext:cr,useCallback:function(o,a){return Pr().memoizedState=[o,a===void 0?null:a],o},useContext:cr,useEffect:jg,useImperativeHandle:function(o,a,h){return h=h!=null?h.concat([o]):null,La(4194308,4,Pg.bind(null,a,o),h)},useLayoutEffect:function(o,a){return La(4194308,4,o,a)},useInsertionEffect:function(o,a){return La(4,2,o,a)},useMemo:function(o,a){var h=Pr();return a=a===void 0?null:a,o=o(),h.memoizedState=[o,a],o},useReducer:function(o,a,h){var g=Pr();return a=h!==void 0?h(a):a,g.memoizedState=g.baseState=a,o={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:o,lastRenderedState:a},g.queue=o,o=o.dispatch=PS.bind(null,Wt,o),[g.memoizedState,o]},useRef:function(o){var a=Pr();return o={current:o},a.memoizedState=o},useState:Rg,useDebugValue:of,useDeferredValue:function(o){return Pr().memoizedState=o},useTransition:function(){var o=Rg(!1),a=o[0];return o=DS.bind(null,o[1]),Pr().memoizedState=o,[a,o]},useMutableSource:function(){},useSyncExternalStore:function(o,a,h){var g=Wt,x=Pr();if($t){if(h===void 0)throw Error(n(407));h=h()}else{if(h=a(),hn===null)throw Error(n(349));(hi&30)!==0||_g(g,a,h)}x.memoizedState=h;var S={value:h,getSnapshot:a};return x.queue=S,jg(Mg.bind(null,g,S,o),[o]),g.flags|=2048,ol(9,Tg.bind(null,g,S,h,a),void 0,null),h},useId:function(){var o=Pr(),a=hn.identifierPrefix;if($t){var h=Yr,g=Jr;h=(g&~(1<<32-Ut(g)-1)).toString(32)+h,a=":"+a+"R"+h,h=sl++,0<h&&(a+="H"+h.toString(32)),a+=":"}else h=LS++,a=":"+a+"r"+h.toString(32)+":";return o.memoizedState=a},unstable_isNewReconciler:!1},$S={readContext:cr,useCallback:zg,useContext:cr,useEffect:sf,useImperativeHandle:Bg,useInsertionEffect:Lg,useLayoutEffect:Dg,useMemo:$g,useReducer:nf,useRef:Ig,useState:function(){return nf(il)},useDebugValue:of,useDeferredValue:function(o){var a=ur();return Fg(a,an.memoizedState,o)},useTransition:function(){var o=nf(il)[0],a=ur().memoizedState;return[o,a]},useMutableSource:Ng,useSyncExternalStore:Cg,useId:Ug,unstable_isNewReconciler:!1},FS={readContext:cr,useCallback:zg,useContext:cr,useEffect:sf,useImperativeHandle:Bg,useInsertionEffect:Lg,useLayoutEffect:Dg,useMemo:$g,useReducer:rf,useRef:Ig,useState:function(){return rf(il)},useDebugValue:of,useDeferredValue:function(o){var a=ur();return an===null?a.memoizedState=o:Fg(a,an.memoizedState,o)},useTransition:function(){var o=rf(il)[0],a=ur().memoizedState;return[o,a]},useMutableSource:Ng,useSyncExternalStore:Cg,useId:Ug,unstable_isNewReconciler:!1};function kr(o,a){if(o&&o.defaultProps){a=K({},a),o=o.defaultProps;for(var h in o)a[h]===void 0&&(a[h]=o[h]);return a}return a}function lf(o,a,h,g){a=o.memoizedState,h=h(g,a),h=h==null?a:K({},a,h),o.memoizedState=h,o.lanes===0&&(o.updateQueue.baseState=h)}var Ba={isMounted:function(o){return(o=o._reactInternals)?Kr(o)===o:!1},enqueueSetState:function(o,a,h){o=o._reactInternals;var g=$n(),x=Ms(o),S=Xr(g,x);S.payload=a,h!=null&&(S.callback=h),a=Ns(o,S,x),a!==null&&(Nr(a,o,x,g),Aa(a,o,x))},enqueueReplaceState:function(o,a,h){o=o._reactInternals;var g=$n(),x=Ms(o),S=Xr(g,x);S.tag=1,S.payload=a,h!=null&&(S.callback=h),a=Ns(o,S,x),a!==null&&(Nr(a,o,x,g),Aa(a,o,x))},enqueueForceUpdate:function(o,a){o=o._reactInternals;var h=$n(),g=Ms(o),x=Xr(h,g);x.tag=2,a!=null&&(x.callback=a),a=Ns(o,x,g),a!==null&&(Nr(a,o,g,h),Aa(a,o,g))}};function Kg(o,a,h,g,x,S,C){return o=o.stateNode,typeof o.shouldComponentUpdate=="function"?o.shouldComponentUpdate(g,S,C):a.prototype&&a.prototype.isPureReactComponent?!Ko(h,g)||!Ko(x,S):!0}function Gg(o,a,h){var g=!1,x=ks,S=a.contextType;return typeof S=="object"&&S!==null?S=cr(S):(x=Kn(a)?ai:Mn.current,g=a.contextTypes,S=(g=g!=null)?Qi(o,x):ks),a=new a(h,S),o.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ba,o.stateNode=a,a._reactInternals=o,g&&(o=o.stateNode,o.__reactInternalMemoizedUnmaskedChildContext=x,o.__reactInternalMemoizedMaskedChildContext=S),a}function qg(o,a,h,g){o=a.state,typeof a.componentWillReceiveProps=="function"&&a.componentWillReceiveProps(h,g),typeof a.UNSAFE_componentWillReceiveProps=="function"&&a.UNSAFE_componentWillReceiveProps(h,g),a.state!==o&&Ba.enqueueReplaceState(a,a.state,null)}function af(o,a,h,g){var x=o.stateNode;x.props=h,x.state=o.memoizedState,x.refs={},Gd(o);var S=a.contextType;typeof S=="object"&&S!==null?x.context=cr(S):(S=Kn(a)?ai:Mn.current,x.context=Qi(o,S)),x.state=o.memoizedState,S=a.getDerivedStateFromProps,typeof S=="function"&&(lf(o,a,S,h),x.state=o.memoizedState),typeof a.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(a=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),a!==x.state&&Ba.enqueueReplaceState(x,x.state,null),Oa(o,h,x,g),x.state=o.memoizedState),typeof x.componentDidMount=="function"&&(o.flags|=4194308)}function io(o,a){try{var h="",g=a;do h+=fe(g),g=g.return;while(g);var x=h}catch(S){x=`
39
+ Error generating stack: `+S.message+`
40
+ `+S.stack}return{value:o,source:a,stack:x,digest:null}}function cf(o,a,h){return{value:o,source:null,stack:h??null,digest:a??null}}function uf(o,a){try{console.error(a.value)}catch(h){setTimeout(function(){throw h})}}var US=typeof WeakMap=="function"?WeakMap:Map;function Jg(o,a,h){h=Xr(-1,h),h.tag=3,h.payload={element:null};var g=a.value;return h.callback=function(){Va||(Va=!0,Nf=g),uf(o,a)},h}function Yg(o,a,h){h=Xr(-1,h),h.tag=3;var g=o.type.getDerivedStateFromError;if(typeof g=="function"){var x=a.value;h.payload=function(){return g(x)},h.callback=function(){uf(o,a)}}var S=o.stateNode;return S!==null&&typeof S.componentDidCatch=="function"&&(h.callback=function(){uf(o,a),typeof g!="function"&&(_s===null?_s=new Set([this]):_s.add(this));var C=a.stack;this.componentDidCatch(a.value,{componentStack:C!==null?C:""})}),h}function Qg(o,a,h){var g=o.pingCache;if(g===null){g=o.pingCache=new US;var x=new Set;g.set(a,x)}else x=g.get(a),x===void 0&&(x=new Set,g.set(a,x));x.has(h)||(x.add(h),o=nE.bind(null,o,a,h),a.then(o,o))}function Xg(o){do{var a;if((a=o.tag===13)&&(a=o.memoizedState,a=a!==null?a.dehydrated!==null:!0),a)return o;o=o.return}while(o!==null);return null}function Zg(o,a,h,g,x){return(o.mode&1)===0?(o===a?o.flags|=65536:(o.flags|=128,h.flags|=131072,h.flags&=-52805,h.tag===1&&(h.alternate===null?h.tag=17:(a=Xr(-1,1),a.tag=2,Ns(h,a,1))),h.lanes|=1),o):(o.flags|=65536,o.lanes=x,o)}var HS=_.ReactCurrentOwner,Gn=!1;function zn(o,a,h,g){a.child=o===null?vg(a,null,h,g):to(a,o.child,h,g)}function ey(o,a,h,g,x){h=h.render;var S=a.ref;return ro(a,x),g=ef(o,a,h,g,S,x),h=tf(),o!==null&&!Gn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):($t&&h&&Pd(a),a.flags|=1,zn(o,a,g,x),a.child)}function ty(o,a,h,g,x){if(o===null){var S=h.type;return typeof S=="function"&&!Rf(S)&&S.defaultProps===void 0&&h.compare===null&&h.defaultProps===void 0?(a.tag=15,a.type=S,ny(o,a,S,g,x)):(o=Qa(h.type,null,g,a,a.mode,x),o.ref=a.ref,o.return=a,a.child=o)}if(S=o.child,(o.lanes&x)===0){var C=S.memoizedProps;if(h=h.compare,h=h!==null?h:Ko,h(C,g)&&o.ref===a.ref)return Zr(o,a,x)}return a.flags|=1,o=Os(S,g),o.ref=a.ref,o.return=a,a.child=o}function ny(o,a,h,g,x){if(o!==null){var S=o.memoizedProps;if(Ko(S,g)&&o.ref===a.ref)if(Gn=!1,a.pendingProps=g=S,(o.lanes&x)!==0)(o.flags&131072)!==0&&(Gn=!0);else return a.lanes=o.lanes,Zr(o,a,x)}return df(o,a,h,g,x)}function ry(o,a,h){var g=a.pendingProps,x=g.children,S=o!==null?o.memoizedState:null;if(g.mode==="hidden")if((a.mode&1)===0)a.memoizedState={baseLanes:0,cachePool:null,transitions:null},It(lo,nr),nr|=h;else{if((h&1073741824)===0)return o=S!==null?S.baseLanes|h:h,a.lanes=a.childLanes=1073741824,a.memoizedState={baseLanes:o,cachePool:null,transitions:null},a.updateQueue=null,It(lo,nr),nr|=o,null;a.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=S!==null?S.baseLanes:h,It(lo,nr),nr|=g}else S!==null?(g=S.baseLanes|h,a.memoizedState=null):g=h,It(lo,nr),nr|=g;return zn(o,a,x,h),a.child}function sy(o,a){var h=a.ref;(o===null&&h!==null||o!==null&&o.ref!==h)&&(a.flags|=512,a.flags|=2097152)}function df(o,a,h,g,x){var S=Kn(h)?ai:Mn.current;return S=Qi(a,S),ro(a,x),h=ef(o,a,h,g,S,x),g=tf(),o!==null&&!Gn?(a.updateQueue=o.updateQueue,a.flags&=-2053,o.lanes&=~x,Zr(o,a,x)):($t&&g&&Pd(a),a.flags|=1,zn(o,a,h,x),a.child)}function iy(o,a,h,g,x){if(Kn(h)){var S=!0;ka(a)}else S=!1;if(ro(a,x),a.stateNode===null)$a(o,a),Gg(a,h,g),af(a,h,g,x),g=!0;else if(o===null){var C=a.stateNode,j=a.memoizedProps;C.props=j;var D=C.context,Q=h.contextType;typeof Q=="object"&&Q!==null?Q=cr(Q):(Q=Kn(h)?ai:Mn.current,Q=Qi(a,Q));var de=h.getDerivedStateFromProps,he=typeof de=="function"||typeof C.getSnapshotBeforeUpdate=="function";he||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(j!==g||D!==Q)&&qg(a,C,g,Q),Es=!1;var ue=a.memoizedState;C.state=ue,Oa(a,g,C,x),D=a.memoizedState,j!==g||ue!==D||Vn.current||Es?(typeof de=="function"&&(lf(a,h,de,g),D=a.memoizedState),(j=Es||Kg(a,h,j,g,ue,D,Q))?(he||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount()),typeof C.componentDidMount=="function"&&(a.flags|=4194308)):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),a.memoizedProps=g,a.memoizedState=D),C.props=g,C.state=D,C.context=Q,g=j):(typeof C.componentDidMount=="function"&&(a.flags|=4194308),g=!1)}else{C=a.stateNode,wg(o,a),j=a.memoizedProps,Q=a.type===a.elementType?j:kr(a.type,j),C.props=Q,he=a.pendingProps,ue=C.context,D=h.contextType,typeof D=="object"&&D!==null?D=cr(D):(D=Kn(h)?ai:Mn.current,D=Qi(a,D));var Ne=h.getDerivedStateFromProps;(de=typeof Ne=="function"||typeof C.getSnapshotBeforeUpdate=="function")||typeof C.UNSAFE_componentWillReceiveProps!="function"&&typeof C.componentWillReceiveProps!="function"||(j!==he||ue!==D)&&qg(a,C,g,D),Es=!1,ue=a.memoizedState,C.state=ue,Oa(a,g,C,x);var Re=a.memoizedState;j!==he||ue!==Re||Vn.current||Es?(typeof Ne=="function"&&(lf(a,h,Ne,g),Re=a.memoizedState),(Q=Es||Kg(a,h,Q,g,ue,Re,D)||!1)?(de||typeof C.UNSAFE_componentWillUpdate!="function"&&typeof C.componentWillUpdate!="function"||(typeof C.componentWillUpdate=="function"&&C.componentWillUpdate(g,Re,D),typeof C.UNSAFE_componentWillUpdate=="function"&&C.UNSAFE_componentWillUpdate(g,Re,D)),typeof C.componentDidUpdate=="function"&&(a.flags|=4),typeof C.getSnapshotBeforeUpdate=="function"&&(a.flags|=1024)):(typeof C.componentDidUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=1024),a.memoizedProps=g,a.memoizedState=Re),C.props=g,C.state=Re,C.context=D,g=Q):(typeof C.componentDidUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=4),typeof C.getSnapshotBeforeUpdate!="function"||j===o.memoizedProps&&ue===o.memoizedState||(a.flags|=1024),g=!1)}return ff(o,a,h,g,S,x)}function ff(o,a,h,g,x,S){sy(o,a);var C=(a.flags&128)!==0;if(!g&&!C)return x&&ug(a,h,!1),Zr(o,a,S);g=a.stateNode,HS.current=a;var j=C&&typeof h.getDerivedStateFromError!="function"?null:g.render();return a.flags|=1,o!==null&&C?(a.child=to(a,o.child,null,S),a.child=to(a,null,j,S)):zn(o,a,j,S),a.memoizedState=g.state,x&&ug(a,h,!0),a.child}function oy(o){var a=o.stateNode;a.pendingContext?ag(o,a.pendingContext,a.pendingContext!==a.context):a.context&&ag(o,a.context,!1),qd(o,a.containerInfo)}function ly(o,a,h,g,x){return eo(),Fd(x),a.flags|=256,zn(o,a,h,g),a.child}var hf={dehydrated:null,treeContext:null,retryLane:0};function pf(o){return{baseLanes:o,cachePool:null,transitions:null}}function ay(o,a,h){var g=a.pendingProps,x=Ht.current,S=!1,C=(a.flags&128)!==0,j;if((j=C)||(j=o!==null&&o.memoizedState===null?!1:(x&2)!==0),j?(S=!0,a.flags&=-129):(o===null||o.memoizedState!==null)&&(x|=1),It(Ht,x&1),o===null)return $d(a),o=a.memoizedState,o!==null&&(o=o.dehydrated,o!==null)?((a.mode&1)===0?a.lanes=1:o.data==="$!"?a.lanes=8:a.lanes=1073741824,null):(C=g.children,o=g.fallback,S?(g=a.mode,S=a.child,C={mode:"hidden",children:C},(g&1)===0&&S!==null?(S.childLanes=0,S.pendingProps=C):S=Xa(C,g,0,null),o=bi(o,g,h,null),S.return=a,o.return=a,S.sibling=o,a.child=S,a.child.memoizedState=pf(h),a.memoizedState=hf,o):mf(a,C));if(x=o.memoizedState,x!==null&&(j=x.dehydrated,j!==null))return WS(o,a,C,g,j,x,h);if(S){S=g.fallback,C=a.mode,x=o.child,j=x.sibling;var D={mode:"hidden",children:g.children};return(C&1)===0&&a.child!==x?(g=a.child,g.childLanes=0,g.pendingProps=D,a.deletions=null):(g=Os(x,D),g.subtreeFlags=x.subtreeFlags&14680064),j!==null?S=Os(j,S):(S=bi(S,C,h,null),S.flags|=2),S.return=a,g.return=a,g.sibling=S,a.child=g,g=S,S=a.child,C=o.child.memoizedState,C=C===null?pf(h):{baseLanes:C.baseLanes|h,cachePool:null,transitions:C.transitions},S.memoizedState=C,S.childLanes=o.childLanes&~h,a.memoizedState=hf,g}return S=o.child,o=S.sibling,g=Os(S,{mode:"visible",children:g.children}),(a.mode&1)===0&&(g.lanes=h),g.return=a,g.sibling=null,o!==null&&(h=a.deletions,h===null?(a.deletions=[o],a.flags|=16):h.push(o)),a.child=g,a.memoizedState=null,g}function mf(o,a){return a=Xa({mode:"visible",children:a},o.mode,0,null),a.return=o,o.child=a}function za(o,a,h,g){return g!==null&&Fd(g),to(a,o.child,null,h),o=mf(a,a.pendingProps.children),o.flags|=2,a.memoizedState=null,o}function WS(o,a,h,g,x,S,C){if(h)return a.flags&256?(a.flags&=-257,g=cf(Error(n(422))),za(o,a,C,g)):a.memoizedState!==null?(a.child=o.child,a.flags|=128,null):(S=g.fallback,x=a.mode,g=Xa({mode:"visible",children:g.children},x,0,null),S=bi(S,x,C,null),S.flags|=2,g.return=a,S.return=a,g.sibling=S,a.child=g,(a.mode&1)!==0&&to(a,o.child,null,C),a.child.memoizedState=pf(C),a.memoizedState=hf,S);if((a.mode&1)===0)return za(o,a,C,null);if(x.data==="$!"){if(g=x.nextSibling&&x.nextSibling.dataset,g)var j=g.dgst;return g=j,S=Error(n(419)),g=cf(S,g,void 0),za(o,a,C,g)}if(j=(C&o.childLanes)!==0,Gn||j){if(g=hn,g!==null){switch(C&-C){case 4:x=2;break;case 16:x=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(g.suspendedLanes|C))!==0?0:x,x!==0&&x!==S.retryLane&&(S.retryLane=x,Qr(o,x),Nr(g,o,x,-1))}return Of(),g=cf(Error(n(421))),za(o,a,C,g)}return x.data==="$?"?(a.flags|=128,a.child=o.child,a=rE.bind(null,o),x._reactRetry=a,null):(o=S.treeContext,tr=xs(x.nextSibling),er=a,$t=!0,wr=null,o!==null&&(lr[ar++]=Jr,lr[ar++]=Yr,lr[ar++]=ci,Jr=o.id,Yr=o.overflow,ci=a),a=mf(a,g.children),a.flags|=4096,a)}function cy(o,a,h){o.lanes|=a;var g=o.alternate;g!==null&&(g.lanes|=a),Vd(o.return,a,h)}function gf(o,a,h,g,x){var S=o.memoizedState;S===null?o.memoizedState={isBackwards:a,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:x}:(S.isBackwards=a,S.rendering=null,S.renderingStartTime=0,S.last=g,S.tail=h,S.tailMode=x)}function uy(o,a,h){var g=a.pendingProps,x=g.revealOrder,S=g.tail;if(zn(o,a,g.children,h),g=Ht.current,(g&2)!==0)g=g&1|2,a.flags|=128;else{if(o!==null&&(o.flags&128)!==0)e:for(o=a.child;o!==null;){if(o.tag===13)o.memoizedState!==null&&cy(o,h,a);else if(o.tag===19)cy(o,h,a);else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===a)break e;for(;o.sibling===null;){if(o.return===null||o.return===a)break e;o=o.return}o.sibling.return=o.return,o=o.sibling}g&=1}if(It(Ht,g),(a.mode&1)===0)a.memoizedState=null;else switch(x){case"forwards":for(h=a.child,x=null;h!==null;)o=h.alternate,o!==null&&Ra(o)===null&&(x=h),h=h.sibling;h=x,h===null?(x=a.child,a.child=null):(x=h.sibling,h.sibling=null),gf(a,!1,x,h,S);break;case"backwards":for(h=null,x=a.child,a.child=null;x!==null;){if(o=x.alternate,o!==null&&Ra(o)===null){a.child=x;break}o=x.sibling,x.sibling=h,h=x,x=o}gf(a,!0,h,null,S);break;case"together":gf(a,!1,null,null,void 0);break;default:a.memoizedState=null}return a.child}function $a(o,a){(a.mode&1)===0&&o!==null&&(o.alternate=null,a.alternate=null,a.flags|=2)}function Zr(o,a,h){if(o!==null&&(a.dependencies=o.dependencies),pi|=a.lanes,(h&a.childLanes)===0)return null;if(o!==null&&a.child!==o.child)throw Error(n(153));if(a.child!==null){for(o=a.child,h=Os(o,o.pendingProps),a.child=h,h.return=a;o.sibling!==null;)o=o.sibling,h=h.sibling=Os(o,o.pendingProps),h.return=a;h.sibling=null}return a.child}function VS(o,a,h){switch(a.tag){case 3:oy(a),eo();break;case 5:Eg(a);break;case 1:Kn(a.type)&&ka(a);break;case 4:qd(a,a.stateNode.containerInfo);break;case 10:var g=a.type._context,x=a.memoizedProps.value;It(Ta,g._currentValue),g._currentValue=x;break;case 13:if(g=a.memoizedState,g!==null)return g.dehydrated!==null?(It(Ht,Ht.current&1),a.flags|=128,null):(h&a.child.childLanes)!==0?ay(o,a,h):(It(Ht,Ht.current&1),o=Zr(o,a,h),o!==null?o.sibling:null);It(Ht,Ht.current&1);break;case 19:if(g=(h&a.childLanes)!==0,(o.flags&128)!==0){if(g)return uy(o,a,h);a.flags|=128}if(x=a.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),It(Ht,Ht.current),g)break;return null;case 22:case 23:return a.lanes=0,ry(o,a,h)}return Zr(o,a,h)}var dy,yf,fy,hy;dy=function(o,a){for(var h=a.child;h!==null;){if(h.tag===5||h.tag===6)o.appendChild(h.stateNode);else if(h.tag!==4&&h.child!==null){h.child.return=h,h=h.child;continue}if(h===a)break;for(;h.sibling===null;){if(h.return===null||h.return===a)return;h=h.return}h.sibling.return=h.return,h=h.sibling}},yf=function(){},fy=function(o,a,h,g){var x=o.memoizedProps;if(x!==g){o=a.stateNode,fi(Dr.current);var S=null;switch(h){case"input":x=Te(o,x),g=Te(o,g),S=[];break;case"select":x=K({},x,{value:void 0}),g=K({},g,{value:void 0}),S=[];break;case"textarea":x=at(o,x),g=at(o,g),S=[];break;default:typeof x.onClick!="function"&&typeof g.onClick=="function"&&(o.onclick=va)}qe(h,g);var C;h=null;for(Q in x)if(!g.hasOwnProperty(Q)&&x.hasOwnProperty(Q)&&x[Q]!=null)if(Q==="style"){var j=x[Q];for(C in j)j.hasOwnProperty(C)&&(h||(h={}),h[C]="")}else Q!=="dangerouslySetInnerHTML"&&Q!=="children"&&Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&Q!=="autoFocus"&&(s.hasOwnProperty(Q)?S||(S=[]):(S=S||[]).push(Q,null));for(Q in g){var D=g[Q];if(j=x!=null?x[Q]:void 0,g.hasOwnProperty(Q)&&D!==j&&(D!=null||j!=null))if(Q==="style")if(j){for(C in j)!j.hasOwnProperty(C)||D&&D.hasOwnProperty(C)||(h||(h={}),h[C]="");for(C in D)D.hasOwnProperty(C)&&j[C]!==D[C]&&(h||(h={}),h[C]=D[C])}else h||(S||(S=[]),S.push(Q,h)),h=D;else Q==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,j=j?j.__html:void 0,D!=null&&j!==D&&(S=S||[]).push(Q,D)):Q==="children"?typeof D!="string"&&typeof D!="number"||(S=S||[]).push(Q,""+D):Q!=="suppressContentEditableWarning"&&Q!=="suppressHydrationWarning"&&(s.hasOwnProperty(Q)?(D!=null&&Q==="onScroll"&&Dt("scroll",o),S||j===D||(S=[])):(S=S||[]).push(Q,D))}h&&(S=S||[]).push("style",h);var Q=S;(a.updateQueue=Q)&&(a.flags|=4)}},hy=function(o,a,h,g){h!==g&&(a.flags|=4)};function ll(o,a){if(!$t)switch(o.tailMode){case"hidden":a=o.tail;for(var h=null;a!==null;)a.alternate!==null&&(h=a),a=a.sibling;h===null?o.tail=null:h.sibling=null;break;case"collapsed":h=o.tail;for(var g=null;h!==null;)h.alternate!==null&&(g=h),h=h.sibling;g===null?a||o.tail===null?o.tail=null:o.tail.sibling=null:g.sibling=null}}function On(o){var a=o.alternate!==null&&o.alternate.child===o.child,h=0,g=0;if(a)for(var x=o.child;x!==null;)h|=x.lanes|x.childLanes,g|=x.subtreeFlags&14680064,g|=x.flags&14680064,x.return=o,x=x.sibling;else for(x=o.child;x!==null;)h|=x.lanes|x.childLanes,g|=x.subtreeFlags,g|=x.flags,x.return=o,x=x.sibling;return o.subtreeFlags|=g,o.childLanes=h,a}function KS(o,a,h){var g=a.pendingProps;switch(Bd(a),a.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return On(a),null;case 1:return Kn(a.type)&&wa(),On(a),null;case 3:return g=a.stateNode,so(),Pt(Vn),Pt(Mn),Qd(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(o===null||o.child===null)&&(Ca(a)?a.flags|=4:o===null||o.memoizedState.isDehydrated&&(a.flags&256)===0||(a.flags|=1024,wr!==null&&(Tf(wr),wr=null))),yf(o,a),On(a),null;case 5:Jd(a);var x=fi(nl.current);if(h=a.type,o!==null&&a.stateNode!=null)fy(o,a,h,g,x),o.ref!==a.ref&&(a.flags|=512,a.flags|=2097152);else{if(!g){if(a.stateNode===null)throw Error(n(166));return On(a),null}if(o=fi(Dr.current),Ca(a)){g=a.stateNode,h=a.type;var S=a.memoizedProps;switch(g[Lr]=a,g[Qo]=S,o=(a.mode&1)!==0,h){case"dialog":Dt("cancel",g),Dt("close",g);break;case"iframe":case"object":case"embed":Dt("load",g);break;case"video":case"audio":for(x=0;x<qo.length;x++)Dt(qo[x],g);break;case"source":Dt("error",g);break;case"img":case"image":case"link":Dt("error",g),Dt("load",g);break;case"details":Dt("toggle",g);break;case"input":Ue(g,S),Dt("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!S.multiple},Dt("invalid",g);break;case"textarea":ft(g,S),Dt("invalid",g)}qe(h,S),x=null;for(var C in S)if(S.hasOwnProperty(C)){var j=S[C];C==="children"?typeof j=="string"?g.textContent!==j&&(S.suppressHydrationWarning!==!0&&ba(g.textContent,j,o),x=["children",j]):typeof j=="number"&&g.textContent!==""+j&&(S.suppressHydrationWarning!==!0&&ba(g.textContent,j,o),x=["children",""+j]):s.hasOwnProperty(C)&&j!=null&&C==="onScroll"&&Dt("scroll",g)}switch(h){case"input":ve(g),tt(g,S,!0);break;case"textarea":ve(g),ht(g);break;case"select":case"option":break;default:typeof S.onClick=="function"&&(g.onclick=va)}g=x,a.updateQueue=g,g!==null&&(a.flags|=4)}else{C=x.nodeType===9?x:x.ownerDocument,o==="http://www.w3.org/1999/xhtml"&&(o=zt(h)),o==="http://www.w3.org/1999/xhtml"?h==="script"?(o=C.createElement("div"),o.innerHTML="<script><\/script>",o=o.removeChild(o.firstChild)):typeof g.is=="string"?o=C.createElement(h,{is:g.is}):(o=C.createElement(h),h==="select"&&(C=o,g.multiple?C.multiple=!0:g.size&&(C.size=g.size))):o=C.createElementNS(o,h),o[Lr]=a,o[Qo]=g,dy(o,a,!1,!1),a.stateNode=o;e:{switch(C=Wn(h,g),h){case"dialog":Dt("cancel",o),Dt("close",o),x=g;break;case"iframe":case"object":case"embed":Dt("load",o),x=g;break;case"video":case"audio":for(x=0;x<qo.length;x++)Dt(qo[x],o);x=g;break;case"source":Dt("error",o),x=g;break;case"img":case"image":case"link":Dt("error",o),Dt("load",o),x=g;break;case"details":Dt("toggle",o),x=g;break;case"input":Ue(o,g),x=Te(o,g),Dt("invalid",o);break;case"option":x=g;break;case"select":o._wrapperState={wasMultiple:!!g.multiple},x=K({},g,{value:void 0}),Dt("invalid",o);break;case"textarea":ft(o,g),x=at(o,g),Dt("invalid",o);break;default:x=g}qe(h,x),j=x;for(S in j)if(j.hasOwnProperty(S)){var D=j[S];S==="style"?nt(o,D):S==="dangerouslySetInnerHTML"?(D=D?D.__html:void 0,D!=null&&xn(o,D)):S==="children"?typeof D=="string"?(h!=="textarea"||D!=="")&&ee(o,D):typeof D=="number"&&ee(o,""+D):S!=="suppressContentEditableWarning"&&S!=="suppressHydrationWarning"&&S!=="autoFocus"&&(s.hasOwnProperty(S)?D!=null&&S==="onScroll"&&Dt("scroll",o):D!=null&&I(o,S,D,C))}switch(h){case"input":ve(o),tt(o,g,!1);break;case"textarea":ve(o),ht(o);break;case"option":g.value!=null&&o.setAttribute("value",""+Le(g.value));break;case"select":o.multiple=!!g.multiple,S=g.value,S!=null?ke(o,!!g.multiple,S,!1):g.defaultValue!=null&&ke(o,!!g.multiple,g.defaultValue,!0);break;default:typeof x.onClick=="function"&&(o.onclick=va)}switch(h){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(a.flags|=4)}a.ref!==null&&(a.flags|=512,a.flags|=2097152)}return On(a),null;case 6:if(o&&a.stateNode!=null)hy(o,a,o.memoizedProps,g);else{if(typeof g!="string"&&a.stateNode===null)throw Error(n(166));if(h=fi(nl.current),fi(Dr.current),Ca(a)){if(g=a.stateNode,h=a.memoizedProps,g[Lr]=a,(S=g.nodeValue!==h)&&(o=er,o!==null))switch(o.tag){case 3:ba(g.nodeValue,h,(o.mode&1)!==0);break;case 5:o.memoizedProps.suppressHydrationWarning!==!0&&ba(g.nodeValue,h,(o.mode&1)!==0)}S&&(a.flags|=4)}else g=(h.nodeType===9?h:h.ownerDocument).createTextNode(g),g[Lr]=a,a.stateNode=g}return On(a),null;case 13:if(Pt(Ht),g=a.memoizedState,o===null||o.memoizedState!==null&&o.memoizedState.dehydrated!==null){if($t&&tr!==null&&(a.mode&1)!==0&&(a.flags&128)===0)gg(),eo(),a.flags|=98560,S=!1;else if(S=Ca(a),g!==null&&g.dehydrated!==null){if(o===null){if(!S)throw Error(n(318));if(S=a.memoizedState,S=S!==null?S.dehydrated:null,!S)throw Error(n(317));S[Lr]=a}else eo(),(a.flags&128)===0&&(a.memoizedState=null),a.flags|=4;On(a),S=!1}else wr!==null&&(Tf(wr),wr=null),S=!0;if(!S)return a.flags&65536?a:null}return(a.flags&128)!==0?(a.lanes=h,a):(g=g!==null,g!==(o!==null&&o.memoizedState!==null)&&g&&(a.child.flags|=8192,(a.mode&1)!==0&&(o===null||(Ht.current&1)!==0?cn===0&&(cn=3):Of())),a.updateQueue!==null&&(a.flags|=4),On(a),null);case 4:return so(),yf(o,a),o===null&&Jo(a.stateNode.containerInfo),On(a),null;case 10:return Wd(a.type._context),On(a),null;case 17:return Kn(a.type)&&wa(),On(a),null;case 19:if(Pt(Ht),S=a.memoizedState,S===null)return On(a),null;if(g=(a.flags&128)!==0,C=S.rendering,C===null)if(g)ll(S,!1);else{if(cn!==0||o!==null&&(o.flags&128)!==0)for(o=a.child;o!==null;){if(C=Ra(o),C!==null){for(a.flags|=128,ll(S,!1),g=C.updateQueue,g!==null&&(a.updateQueue=g,a.flags|=4),a.subtreeFlags=0,g=h,h=a.child;h!==null;)S=h,o=g,S.flags&=14680066,C=S.alternate,C===null?(S.childLanes=0,S.lanes=o,S.child=null,S.subtreeFlags=0,S.memoizedProps=null,S.memoizedState=null,S.updateQueue=null,S.dependencies=null,S.stateNode=null):(S.childLanes=C.childLanes,S.lanes=C.lanes,S.child=C.child,S.subtreeFlags=0,S.deletions=null,S.memoizedProps=C.memoizedProps,S.memoizedState=C.memoizedState,S.updateQueue=C.updateQueue,S.type=C.type,o=C.dependencies,S.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),h=h.sibling;return It(Ht,Ht.current&1|2),a.child}o=o.sibling}S.tail!==null&&Ft()>ao&&(a.flags|=128,g=!0,ll(S,!1),a.lanes=4194304)}else{if(!g)if(o=Ra(C),o!==null){if(a.flags|=128,g=!0,h=o.updateQueue,h!==null&&(a.updateQueue=h,a.flags|=4),ll(S,!0),S.tail===null&&S.tailMode==="hidden"&&!C.alternate&&!$t)return On(a),null}else 2*Ft()-S.renderingStartTime>ao&&h!==1073741824&&(a.flags|=128,g=!0,ll(S,!1),a.lanes=4194304);S.isBackwards?(C.sibling=a.child,a.child=C):(h=S.last,h!==null?h.sibling=C:a.child=C,S.last=C)}return S.tail!==null?(a=S.tail,S.rendering=a,S.tail=a.sibling,S.renderingStartTime=Ft(),a.sibling=null,h=Ht.current,It(Ht,g?h&1|2:h&1),a):(On(a),null);case 22:case 23:return Af(),g=a.memoizedState!==null,o!==null&&o.memoizedState!==null!==g&&(a.flags|=8192),g&&(a.mode&1)!==0?(nr&1073741824)!==0&&(On(a),a.subtreeFlags&6&&(a.flags|=8192)):On(a),null;case 24:return null;case 25:return null}throw Error(n(156,a.tag))}function GS(o,a){switch(Bd(a),a.tag){case 1:return Kn(a.type)&&wa(),o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 3:return so(),Pt(Vn),Pt(Mn),Qd(),o=a.flags,(o&65536)!==0&&(o&128)===0?(a.flags=o&-65537|128,a):null;case 5:return Jd(a),null;case 13:if(Pt(Ht),o=a.memoizedState,o!==null&&o.dehydrated!==null){if(a.alternate===null)throw Error(n(340));eo()}return o=a.flags,o&65536?(a.flags=o&-65537|128,a):null;case 19:return Pt(Ht),null;case 4:return so(),null;case 10:return Wd(a.type._context),null;case 22:case 23:return Af(),null;case 24:return null;default:return null}}var Fa=!1,Rn=!1,qS=typeof WeakSet=="function"?WeakSet:Set,Oe=null;function oo(o,a){var h=o.ref;if(h!==null)if(typeof h=="function")try{h(null)}catch(g){qt(o,a,g)}else h.current=null}function bf(o,a,h){try{h()}catch(g){qt(o,a,g)}}var py=!1;function JS(o,a){if(Md=la,o=Km(),wd(o)){if("selectionStart"in o)var h={start:o.selectionStart,end:o.selectionEnd};else e:{h=(h=o.ownerDocument)&&h.defaultView||window;var g=h.getSelection&&h.getSelection();if(g&&g.rangeCount!==0){h=g.anchorNode;var x=g.anchorOffset,S=g.focusNode;g=g.focusOffset;try{h.nodeType,S.nodeType}catch{h=null;break e}var C=0,j=-1,D=-1,Q=0,de=0,he=o,ue=null;t:for(;;){for(var Ne;he!==h||x!==0&&he.nodeType!==3||(j=C+x),he!==S||g!==0&&he.nodeType!==3||(D=C+g),he.nodeType===3&&(C+=he.nodeValue.length),(Ne=he.firstChild)!==null;)ue=he,he=Ne;for(;;){if(he===o)break t;if(ue===h&&++Q===x&&(j=C),ue===S&&++de===g&&(D=C),(Ne=he.nextSibling)!==null)break;he=ue,ue=he.parentNode}he=Ne}h=j===-1||D===-1?null:{start:j,end:D}}else h=null}h=h||{start:0,end:0}}else h=null;for(Ad={focusedElem:o,selectionRange:h},la=!1,Oe=a;Oe!==null;)if(a=Oe,o=a.child,(a.subtreeFlags&1028)!==0&&o!==null)o.return=a,Oe=o;else for(;Oe!==null;){a=Oe;try{var Re=a.alternate;if((a.flags&1024)!==0)switch(a.tag){case 0:case 11:case 15:break;case 1:if(Re!==null){var Ie=Re.memoizedProps,tn=Re.memoizedState,V=a.stateNode,z=V.getSnapshotBeforeUpdate(a.elementType===a.type?Ie:kr(a.type,Ie),tn);V.__reactInternalSnapshotBeforeUpdate=z}break;case 3:var q=a.stateNode.containerInfo;q.nodeType===1?q.textContent="":q.nodeType===9&&q.documentElement&&q.removeChild(q.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ye){qt(a,a.return,ye)}if(o=a.sibling,o!==null){o.return=a.return,Oe=o;break}Oe=a.return}return Re=py,py=!1,Re}function al(o,a,h){var g=a.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var x=g=g.next;do{if((x.tag&o)===o){var S=x.destroy;x.destroy=void 0,S!==void 0&&bf(a,h,S)}x=x.next}while(x!==g)}}function Ua(o,a){if(a=a.updateQueue,a=a!==null?a.lastEffect:null,a!==null){var h=a=a.next;do{if((h.tag&o)===o){var g=h.create;h.destroy=g()}h=h.next}while(h!==a)}}function vf(o){var a=o.ref;if(a!==null){var h=o.stateNode;switch(o.tag){case 5:o=h;break;default:o=h}typeof a=="function"?a(o):a.current=o}}function my(o){var a=o.alternate;a!==null&&(o.alternate=null,my(a)),o.child=null,o.deletions=null,o.sibling=null,o.tag===5&&(a=o.stateNode,a!==null&&(delete a[Lr],delete a[Qo],delete a[jd],delete a[OS],delete a[RS])),o.stateNode=null,o.return=null,o.dependencies=null,o.memoizedProps=null,o.memoizedState=null,o.pendingProps=null,o.stateNode=null,o.updateQueue=null}function gy(o){return o.tag===5||o.tag===3||o.tag===4}function yy(o){e:for(;;){for(;o.sibling===null;){if(o.return===null||gy(o.return))return null;o=o.return}for(o.sibling.return=o.return,o=o.sibling;o.tag!==5&&o.tag!==6&&o.tag!==18;){if(o.flags&2||o.child===null||o.tag===4)continue e;o.child.return=o,o=o.child}if(!(o.flags&2))return o.stateNode}}function xf(o,a,h){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?h.nodeType===8?h.parentNode.insertBefore(o,a):h.insertBefore(o,a):(h.nodeType===8?(a=h.parentNode,a.insertBefore(o,h)):(a=h,a.appendChild(o)),h=h._reactRootContainer,h!=null||a.onclick!==null||(a.onclick=va));else if(g!==4&&(o=o.child,o!==null))for(xf(o,a,h),o=o.sibling;o!==null;)xf(o,a,h),o=o.sibling}function wf(o,a,h){var g=o.tag;if(g===5||g===6)o=o.stateNode,a?h.insertBefore(o,a):h.appendChild(o);else if(g!==4&&(o=o.child,o!==null))for(wf(o,a,h),o=o.sibling;o!==null;)wf(o,a,h),o=o.sibling}var wn=null,Sr=!1;function Cs(o,a,h){for(h=h.child;h!==null;)by(o,a,h),h=h.sibling}function by(o,a,h){if(ut&&typeof ut.onCommitFiberUnmount=="function")try{ut.onCommitFiberUnmount(ot,h)}catch{}switch(h.tag){case 5:Rn||oo(h,a);case 6:var g=wn,x=Sr;wn=null,Cs(o,a,h),wn=g,Sr=x,wn!==null&&(Sr?(o=wn,h=h.stateNode,o.nodeType===8?o.parentNode.removeChild(h):o.removeChild(h)):wn.removeChild(h.stateNode));break;case 18:wn!==null&&(Sr?(o=wn,h=h.stateNode,o.nodeType===8?Id(o.parentNode,h):o.nodeType===1&&Id(o,h),$o(o)):Id(wn,h.stateNode));break;case 4:g=wn,x=Sr,wn=h.stateNode.containerInfo,Sr=!0,Cs(o,a,h),wn=g,Sr=x;break;case 0:case 11:case 14:case 15:if(!Rn&&(g=h.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){x=g=g.next;do{var S=x,C=S.destroy;S=S.tag,C!==void 0&&((S&2)!==0||(S&4)!==0)&&bf(h,a,C),x=x.next}while(x!==g)}Cs(o,a,h);break;case 1:if(!Rn&&(oo(h,a),g=h.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=h.memoizedProps,g.state=h.memoizedState,g.componentWillUnmount()}catch(j){qt(h,a,j)}Cs(o,a,h);break;case 21:Cs(o,a,h);break;case 22:h.mode&1?(Rn=(g=Rn)||h.memoizedState!==null,Cs(o,a,h),Rn=g):Cs(o,a,h);break;default:Cs(o,a,h)}}function vy(o){var a=o.updateQueue;if(a!==null){o.updateQueue=null;var h=o.stateNode;h===null&&(h=o.stateNode=new qS),a.forEach(function(g){var x=sE.bind(null,o,g);h.has(g)||(h.add(g),g.then(x,x))})}}function Er(o,a){var h=a.deletions;if(h!==null)for(var g=0;g<h.length;g++){var x=h[g];try{var S=o,C=a,j=C;e:for(;j!==null;){switch(j.tag){case 5:wn=j.stateNode,Sr=!1;break e;case 3:wn=j.stateNode.containerInfo,Sr=!0;break e;case 4:wn=j.stateNode.containerInfo,Sr=!0;break e}j=j.return}if(wn===null)throw Error(n(160));by(S,C,x),wn=null,Sr=!1;var D=x.alternate;D!==null&&(D.return=null),x.return=null}catch(Q){qt(x,a,Q)}}if(a.subtreeFlags&12854)for(a=a.child;a!==null;)xy(a,o),a=a.sibling}function xy(o,a){var h=o.alternate,g=o.flags;switch(o.tag){case 0:case 11:case 14:case 15:if(Er(a,o),Br(o),g&4){try{al(3,o,o.return),Ua(3,o)}catch(Ie){qt(o,o.return,Ie)}try{al(5,o,o.return)}catch(Ie){qt(o,o.return,Ie)}}break;case 1:Er(a,o),Br(o),g&512&&h!==null&&oo(h,h.return);break;case 5:if(Er(a,o),Br(o),g&512&&h!==null&&oo(h,h.return),o.flags&32){var x=o.stateNode;try{ee(x,"")}catch(Ie){qt(o,o.return,Ie)}}if(g&4&&(x=o.stateNode,x!=null)){var S=o.memoizedProps,C=h!==null?h.memoizedProps:S,j=o.type,D=o.updateQueue;if(o.updateQueue=null,D!==null)try{j==="input"&&S.type==="radio"&&S.name!=null&&Ee(x,S),Wn(j,C);var Q=Wn(j,S);for(C=0;C<D.length;C+=2){var de=D[C],he=D[C+1];de==="style"?nt(x,he):de==="dangerouslySetInnerHTML"?xn(x,he):de==="children"?ee(x,he):I(x,de,he,Q)}switch(j){case"input":Qe(x,S);break;case"textarea":st(x,S);break;case"select":var ue=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!S.multiple;var Ne=S.value;Ne!=null?ke(x,!!S.multiple,Ne,!1):ue!==!!S.multiple&&(S.defaultValue!=null?ke(x,!!S.multiple,S.defaultValue,!0):ke(x,!!S.multiple,S.multiple?[]:"",!1))}x[Qo]=S}catch(Ie){qt(o,o.return,Ie)}}break;case 6:if(Er(a,o),Br(o),g&4){if(o.stateNode===null)throw Error(n(162));x=o.stateNode,S=o.memoizedProps;try{x.nodeValue=S}catch(Ie){qt(o,o.return,Ie)}}break;case 3:if(Er(a,o),Br(o),g&4&&h!==null&&h.memoizedState.isDehydrated)try{$o(a.containerInfo)}catch(Ie){qt(o,o.return,Ie)}break;case 4:Er(a,o),Br(o);break;case 13:Er(a,o),Br(o),x=o.child,x.flags&8192&&(S=x.memoizedState!==null,x.stateNode.isHidden=S,!S||x.alternate!==null&&x.alternate.memoizedState!==null||(Ef=Ft())),g&4&&vy(o);break;case 22:if(de=h!==null&&h.memoizedState!==null,o.mode&1?(Rn=(Q=Rn)||de,Er(a,o),Rn=Q):Er(a,o),Br(o),g&8192){if(Q=o.memoizedState!==null,(o.stateNode.isHidden=Q)&&!de&&(o.mode&1)!==0)for(Oe=o,de=o.child;de!==null;){for(he=Oe=de;Oe!==null;){switch(ue=Oe,Ne=ue.child,ue.tag){case 0:case 11:case 14:case 15:al(4,ue,ue.return);break;case 1:oo(ue,ue.return);var Re=ue.stateNode;if(typeof Re.componentWillUnmount=="function"){g=ue,h=ue.return;try{a=g,Re.props=a.memoizedProps,Re.state=a.memoizedState,Re.componentWillUnmount()}catch(Ie){qt(g,h,Ie)}}break;case 5:oo(ue,ue.return);break;case 22:if(ue.memoizedState!==null){Sy(he);continue}}Ne!==null?(Ne.return=ue,Oe=Ne):Sy(he)}de=de.sibling}e:for(de=null,he=o;;){if(he.tag===5){if(de===null){de=he;try{x=he.stateNode,Q?(S=x.style,typeof S.setProperty=="function"?S.setProperty("display","none","important"):S.display="none"):(j=he.stateNode,D=he.memoizedProps.style,C=D!=null&&D.hasOwnProperty("display")?D.display:null,j.style.display=_t("display",C))}catch(Ie){qt(o,o.return,Ie)}}}else if(he.tag===6){if(de===null)try{he.stateNode.nodeValue=Q?"":he.memoizedProps}catch(Ie){qt(o,o.return,Ie)}}else if((he.tag!==22&&he.tag!==23||he.memoizedState===null||he===o)&&he.child!==null){he.child.return=he,he=he.child;continue}if(he===o)break e;for(;he.sibling===null;){if(he.return===null||he.return===o)break e;de===he&&(de=null),he=he.return}de===he&&(de=null),he.sibling.return=he.return,he=he.sibling}}break;case 19:Er(a,o),Br(o),g&4&&vy(o);break;case 21:break;default:Er(a,o),Br(o)}}function Br(o){var a=o.flags;if(a&2){try{e:{for(var h=o.return;h!==null;){if(gy(h)){var g=h;break e}h=h.return}throw Error(n(160))}switch(g.tag){case 5:var x=g.stateNode;g.flags&32&&(ee(x,""),g.flags&=-33);var S=yy(o);wf(o,S,x);break;case 3:case 4:var C=g.stateNode.containerInfo,j=yy(o);xf(o,j,C);break;default:throw Error(n(161))}}catch(D){qt(o,o.return,D)}o.flags&=-3}a&4096&&(o.flags&=-4097)}function YS(o,a,h){Oe=o,wy(o)}function wy(o,a,h){for(var g=(o.mode&1)!==0;Oe!==null;){var x=Oe,S=x.child;if(x.tag===22&&g){var C=x.memoizedState!==null||Fa;if(!C){var j=x.alternate,D=j!==null&&j.memoizedState!==null||Rn;j=Fa;var Q=Rn;if(Fa=C,(Rn=D)&&!Q)for(Oe=x;Oe!==null;)C=Oe,D=C.child,C.tag===22&&C.memoizedState!==null?Ey(x):D!==null?(D.return=C,Oe=D):Ey(x);for(;S!==null;)Oe=S,wy(S),S=S.sibling;Oe=x,Fa=j,Rn=Q}ky(o)}else(x.subtreeFlags&8772)!==0&&S!==null?(S.return=x,Oe=S):ky(o)}}function ky(o){for(;Oe!==null;){var a=Oe;if((a.flags&8772)!==0){var h=a.alternate;try{if((a.flags&8772)!==0)switch(a.tag){case 0:case 11:case 15:Rn||Ua(5,a);break;case 1:var g=a.stateNode;if(a.flags&4&&!Rn)if(h===null)g.componentDidMount();else{var x=a.elementType===a.type?h.memoizedProps:kr(a.type,h.memoizedProps);g.componentDidUpdate(x,h.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var S=a.updateQueue;S!==null&&Sg(a,S,g);break;case 3:var C=a.updateQueue;if(C!==null){if(h=null,a.child!==null)switch(a.child.tag){case 5:h=a.child.stateNode;break;case 1:h=a.child.stateNode}Sg(a,C,h)}break;case 5:var j=a.stateNode;if(h===null&&a.flags&4){h=j;var D=a.memoizedProps;switch(a.type){case"button":case"input":case"select":case"textarea":D.autoFocus&&h.focus();break;case"img":D.src&&(h.src=D.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(a.memoizedState===null){var Q=a.alternate;if(Q!==null){var de=Q.memoizedState;if(de!==null){var he=de.dehydrated;he!==null&&$o(he)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Rn||a.flags&512&&vf(a)}catch(ue){qt(a,a.return,ue)}}if(a===o){Oe=null;break}if(h=a.sibling,h!==null){h.return=a.return,Oe=h;break}Oe=a.return}}function Sy(o){for(;Oe!==null;){var a=Oe;if(a===o){Oe=null;break}var h=a.sibling;if(h!==null){h.return=a.return,Oe=h;break}Oe=a.return}}function Ey(o){for(;Oe!==null;){var a=Oe;try{switch(a.tag){case 0:case 11:case 15:var h=a.return;try{Ua(4,a)}catch(D){qt(a,h,D)}break;case 1:var g=a.stateNode;if(typeof g.componentDidMount=="function"){var x=a.return;try{g.componentDidMount()}catch(D){qt(a,x,D)}}var S=a.return;try{vf(a)}catch(D){qt(a,S,D)}break;case 5:var C=a.return;try{vf(a)}catch(D){qt(a,C,D)}}}catch(D){qt(a,a.return,D)}if(a===o){Oe=null;break}var j=a.sibling;if(j!==null){j.return=a.return,Oe=j;break}Oe=a.return}}var QS=Math.ceil,Ha=_.ReactCurrentDispatcher,kf=_.ReactCurrentOwner,dr=_.ReactCurrentBatchConfig,mt=0,hn=null,sn=null,kn=0,nr=0,lo=ws(0),cn=0,cl=null,pi=0,Wa=0,Sf=0,ul=null,qn=null,Ef=0,ao=1/0,es=null,Va=!1,Nf=null,_s=null,Ka=!1,Ts=null,Ga=0,dl=0,Cf=null,qa=-1,Ja=0;function $n(){return(mt&6)!==0?Ft():qa!==-1?qa:qa=Ft()}function Ms(o){return(o.mode&1)===0?1:(mt&2)!==0&&kn!==0?kn&-kn:jS.transition!==null?(Ja===0&&(Ja=sa()),Ja):(o=pt,o!==0||(o=window.event,o=o===void 0?16:Cm(o.type)),o)}function Nr(o,a,h,g){if(50<dl)throw dl=0,Cf=null,Error(n(185));gs(o,h,g),((mt&2)===0||o!==hn)&&(o===hn&&((mt&2)===0&&(Wa|=h),cn===4&&As(o,kn)),Jn(o,g),h===1&&mt===0&&(a.mode&1)===0&&(ao=Ft()+500,Sa&&Ss()))}function Jn(o,a){var h=o.callbackNode;ad(o,a);var g=si(o,o===hn?kn:0);if(g===0)h!==null&&vr(h),o.callbackNode=null,o.callbackPriority=0;else if(a=g&-g,o.callbackPriority!==a){if(h!=null&&vr(h),a===1)o.tag===0?IS(Cy.bind(null,o)):dg(Cy.bind(null,o)),MS(function(){(mt&6)===0&&Ss()}),h=null;else{switch(rt(g)){case 1:h=jo;break;case 4:h=ni;break;case 16:h=$i;break;case 536870912:h=De;break;default:h=$i}h=jy(h,Ny.bind(null,o))}o.callbackPriority=a,o.callbackNode=h}}function Ny(o,a){if(qa=-1,Ja=0,(mt&6)!==0)throw Error(n(327));var h=o.callbackNode;if(co()&&o.callbackNode!==h)return null;var g=si(o,o===hn?kn:0);if(g===0)return null;if((g&30)!==0||(g&o.expiredLanes)!==0||a)a=Ya(o,g);else{a=g;var x=mt;mt|=2;var S=Ty();(hn!==o||kn!==a)&&(es=null,ao=Ft()+500,gi(o,a));do try{eE();break}catch(j){_y(o,j)}while(!0);Hd(),Ha.current=S,mt=x,sn!==null?a=0:(hn=null,kn=0,a=cn)}if(a!==0){if(a===2&&(x=Lo(o),x!==0&&(g=x,a=_f(o,x))),a===1)throw h=cl,gi(o,0),As(o,g),Jn(o,Ft()),h;if(a===6)As(o,g);else{if(x=o.current.alternate,(g&30)===0&&!XS(x)&&(a=Ya(o,g),a===2&&(S=Lo(o),S!==0&&(g=S,a=_f(o,S))),a===1))throw h=cl,gi(o,0),As(o,g),Jn(o,Ft()),h;switch(o.finishedWork=x,o.finishedLanes=g,a){case 0:case 1:throw Error(n(345));case 2:yi(o,qn,es);break;case 3:if(As(o,g),(g&130023424)===g&&(a=Ef+500-Ft(),10<a)){if(si(o,0)!==0)break;if(x=o.suspendedLanes,(x&g)!==g){$n(),o.pingedLanes|=o.suspendedLanes&x;break}o.timeoutHandle=Rd(yi.bind(null,o,qn,es),a);break}yi(o,qn,es);break;case 4:if(As(o,g),(g&4194240)===g)break;for(a=o.eventTimes,x=-1;0<g;){var C=31-Ut(g);S=1<<C,C=a[C],C>x&&(x=C),g&=~S}if(g=x,g=Ft()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*QS(g/1960))-g,10<g){o.timeoutHandle=Rd(yi.bind(null,o,qn,es),g);break}yi(o,qn,es);break;case 5:yi(o,qn,es);break;default:throw Error(n(329))}}}return Jn(o,Ft()),o.callbackNode===h?Ny.bind(null,o):null}function _f(o,a){var h=ul;return o.current.memoizedState.isDehydrated&&(gi(o,a).flags|=256),o=Ya(o,a),o!==2&&(a=qn,qn=h,a!==null&&Tf(a)),o}function Tf(o){qn===null?qn=o:qn.push.apply(qn,o)}function XS(o){for(var a=o;;){if(a.flags&16384){var h=a.updateQueue;if(h!==null&&(h=h.stores,h!==null))for(var g=0;g<h.length;g++){var x=h[g],S=x.getSnapshot;x=x.value;try{if(!xr(S(),x))return!1}catch{return!1}}}if(h=a.child,a.subtreeFlags&16384&&h!==null)h.return=a,a=h;else{if(a===o)break;for(;a.sibling===null;){if(a.return===null||a.return===o)return!0;a=a.return}a.sibling.return=a.return,a=a.sibling}}return!0}function As(o,a){for(a&=~Sf,a&=~Wa,o.suspendedLanes|=a,o.pingedLanes&=~a,o=o.expirationTimes;0<a;){var h=31-Ut(a),g=1<<h;o[h]=-1,a&=~g}}function Cy(o){if((mt&6)!==0)throw Error(n(327));co();var a=si(o,0);if((a&1)===0)return Jn(o,Ft()),null;var h=Ya(o,a);if(o.tag!==0&&h===2){var g=Lo(o);g!==0&&(a=g,h=_f(o,g))}if(h===1)throw h=cl,gi(o,0),As(o,a),Jn(o,Ft()),h;if(h===6)throw Error(n(345));return o.finishedWork=o.current.alternate,o.finishedLanes=a,yi(o,qn,es),Jn(o,Ft()),null}function Mf(o,a){var h=mt;mt|=1;try{return o(a)}finally{mt=h,mt===0&&(ao=Ft()+500,Sa&&Ss())}}function mi(o){Ts!==null&&Ts.tag===0&&(mt&6)===0&&co();var a=mt;mt|=1;var h=dr.transition,g=pt;try{if(dr.transition=null,pt=1,o)return o()}finally{pt=g,dr.transition=h,mt=a,(mt&6)===0&&Ss()}}function Af(){nr=lo.current,Pt(lo)}function gi(o,a){o.finishedWork=null,o.finishedLanes=0;var h=o.timeoutHandle;if(h!==-1&&(o.timeoutHandle=-1,TS(h)),sn!==null)for(h=sn.return;h!==null;){var g=h;switch(Bd(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&wa();break;case 3:so(),Pt(Vn),Pt(Mn),Qd();break;case 5:Jd(g);break;case 4:so();break;case 13:Pt(Ht);break;case 19:Pt(Ht);break;case 10:Wd(g.type._context);break;case 22:case 23:Af()}h=h.return}if(hn=o,sn=o=Os(o.current,null),kn=nr=a,cn=0,cl=null,Sf=Wa=pi=0,qn=ul=null,di!==null){for(a=0;a<di.length;a++)if(h=di[a],g=h.interleaved,g!==null){h.interleaved=null;var x=g.next,S=h.pending;if(S!==null){var C=S.next;S.next=x,g.next=C}h.pending=g}di=null}return o}function _y(o,a){do{var h=sn;try{if(Hd(),Ia.current=Pa,ja){for(var g=Wt.memoizedState;g!==null;){var x=g.queue;x!==null&&(x.pending=null),g=g.next}ja=!1}if(hi=0,fn=an=Wt=null,rl=!1,sl=0,kf.current=null,h===null||h.return===null){cn=1,cl=a,sn=null;break}e:{var S=o,C=h.return,j=h,D=a;if(a=kn,j.flags|=32768,D!==null&&typeof D=="object"&&typeof D.then=="function"){var Q=D,de=j,he=de.tag;if((de.mode&1)===0&&(he===0||he===11||he===15)){var ue=de.alternate;ue?(de.updateQueue=ue.updateQueue,de.memoizedState=ue.memoizedState,de.lanes=ue.lanes):(de.updateQueue=null,de.memoizedState=null)}var Ne=Xg(C);if(Ne!==null){Ne.flags&=-257,Zg(Ne,C,j,S,a),Ne.mode&1&&Qg(S,Q,a),a=Ne,D=Q;var Re=a.updateQueue;if(Re===null){var Ie=new Set;Ie.add(D),a.updateQueue=Ie}else Re.add(D);break e}else{if((a&1)===0){Qg(S,Q,a),Of();break e}D=Error(n(426))}}else if($t&&j.mode&1){var tn=Xg(C);if(tn!==null){(tn.flags&65536)===0&&(tn.flags|=256),Zg(tn,C,j,S,a),Fd(io(D,j));break e}}S=D=io(D,j),cn!==4&&(cn=2),ul===null?ul=[S]:ul.push(S),S=C;do{switch(S.tag){case 3:S.flags|=65536,a&=-a,S.lanes|=a;var V=Jg(S,D,a);kg(S,V);break e;case 1:j=D;var z=S.type,q=S.stateNode;if((S.flags&128)===0&&(typeof z.getDerivedStateFromError=="function"||q!==null&&typeof q.componentDidCatch=="function"&&(_s===null||!_s.has(q)))){S.flags|=65536,a&=-a,S.lanes|=a;var ye=Yg(S,j,a);kg(S,ye);break e}}S=S.return}while(S!==null)}Ay(h)}catch(je){a=je,sn===h&&h!==null&&(sn=h=h.return);continue}break}while(!0)}function Ty(){var o=Ha.current;return Ha.current=Pa,o===null?Pa:o}function Of(){(cn===0||cn===3||cn===2)&&(cn=4),hn===null||(pi&268435455)===0&&(Wa&268435455)===0||As(hn,kn)}function Ya(o,a){var h=mt;mt|=2;var g=Ty();(hn!==o||kn!==a)&&(es=null,gi(o,a));do try{ZS();break}catch(x){_y(o,x)}while(!0);if(Hd(),mt=h,Ha.current=g,sn!==null)throw Error(n(261));return hn=null,kn=0,cn}function ZS(){for(;sn!==null;)My(sn)}function eE(){for(;sn!==null&&!na();)My(sn)}function My(o){var a=Iy(o.alternate,o,nr);o.memoizedProps=o.pendingProps,a===null?Ay(o):sn=a,kf.current=null}function Ay(o){var a=o;do{var h=a.alternate;if(o=a.return,(a.flags&32768)===0){if(h=KS(h,a,nr),h!==null){sn=h;return}}else{if(h=GS(h,a),h!==null){h.flags&=32767,sn=h;return}if(o!==null)o.flags|=32768,o.subtreeFlags=0,o.deletions=null;else{cn=6,sn=null;return}}if(a=a.sibling,a!==null){sn=a;return}sn=a=o}while(a!==null);cn===0&&(cn=5)}function yi(o,a,h){var g=pt,x=dr.transition;try{dr.transition=null,pt=1,tE(o,a,h,g)}finally{dr.transition=x,pt=g}return null}function tE(o,a,h,g){do co();while(Ts!==null);if((mt&6)!==0)throw Error(n(327));h=o.finishedWork;var x=o.finishedLanes;if(h===null)return null;if(o.finishedWork=null,o.finishedLanes=0,h===o.current)throw Error(n(177));o.callbackNode=null,o.callbackPriority=0;var S=h.lanes|h.childLanes;if(or(o,S),o===hn&&(sn=hn=null,kn=0),(h.subtreeFlags&2064)===0&&(h.flags&2064)===0||Ka||(Ka=!0,jy($i,function(){return co(),null})),S=(h.flags&15990)!==0,(h.subtreeFlags&15990)!==0||S){S=dr.transition,dr.transition=null;var C=pt;pt=1;var j=mt;mt|=4,kf.current=null,JS(o,h),xy(h,o),wS(Ad),la=!!Md,Ad=Md=null,o.current=h,YS(h),ra(),mt=j,pt=C,dr.transition=S}else o.current=h;if(Ka&&(Ka=!1,Ts=o,Ga=x),S=o.pendingLanes,S===0&&(_s=null),Zt(h.stateNode),Jn(o,Ft()),a!==null)for(g=o.onRecoverableError,h=0;h<a.length;h++)x=a[h],g(x.value,{componentStack:x.stack,digest:x.digest});if(Va)throw Va=!1,o=Nf,Nf=null,o;return(Ga&1)!==0&&o.tag!==0&&co(),S=o.pendingLanes,(S&1)!==0?o===Cf?dl++:(dl=0,Cf=o):dl=0,Ss(),null}function co(){if(Ts!==null){var o=rt(Ga),a=dr.transition,h=pt;try{if(dr.transition=null,pt=16>o?16:o,Ts===null)var g=!1;else{if(o=Ts,Ts=null,Ga=0,(mt&6)!==0)throw Error(n(331));var x=mt;for(mt|=4,Oe=o.current;Oe!==null;){var S=Oe,C=S.child;if((Oe.flags&16)!==0){var j=S.deletions;if(j!==null){for(var D=0;D<j.length;D++){var Q=j[D];for(Oe=Q;Oe!==null;){var de=Oe;switch(de.tag){case 0:case 11:case 15:al(8,de,S)}var he=de.child;if(he!==null)he.return=de,Oe=he;else for(;Oe!==null;){de=Oe;var ue=de.sibling,Ne=de.return;if(my(de),de===Q){Oe=null;break}if(ue!==null){ue.return=Ne,Oe=ue;break}Oe=Ne}}}var Re=S.alternate;if(Re!==null){var Ie=Re.child;if(Ie!==null){Re.child=null;do{var tn=Ie.sibling;Ie.sibling=null,Ie=tn}while(Ie!==null)}}Oe=S}}if((S.subtreeFlags&2064)!==0&&C!==null)C.return=S,Oe=C;else e:for(;Oe!==null;){if(S=Oe,(S.flags&2048)!==0)switch(S.tag){case 0:case 11:case 15:al(9,S,S.return)}var V=S.sibling;if(V!==null){V.return=S.return,Oe=V;break e}Oe=S.return}}var z=o.current;for(Oe=z;Oe!==null;){C=Oe;var q=C.child;if((C.subtreeFlags&2064)!==0&&q!==null)q.return=C,Oe=q;else e:for(C=z;Oe!==null;){if(j=Oe,(j.flags&2048)!==0)try{switch(j.tag){case 0:case 11:case 15:Ua(9,j)}}catch(je){qt(j,j.return,je)}if(j===C){Oe=null;break e}var ye=j.sibling;if(ye!==null){ye.return=j.return,Oe=ye;break e}Oe=j.return}}if(mt=x,Ss(),ut&&typeof ut.onPostCommitFiberRoot=="function")try{ut.onPostCommitFiberRoot(ot,o)}catch{}g=!0}return g}finally{pt=h,dr.transition=a}}return!1}function Oy(o,a,h){a=io(h,a),a=Jg(o,a,1),o=Ns(o,a,1),a=$n(),o!==null&&(gs(o,1,a),Jn(o,a))}function qt(o,a,h){if(o.tag===3)Oy(o,o,h);else for(;a!==null;){if(a.tag===3){Oy(a,o,h);break}else if(a.tag===1){var g=a.stateNode;if(typeof a.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(_s===null||!_s.has(g))){o=io(h,o),o=Yg(a,o,1),a=Ns(a,o,1),o=$n(),a!==null&&(gs(a,1,o),Jn(a,o));break}}a=a.return}}function nE(o,a,h){var g=o.pingCache;g!==null&&g.delete(a),a=$n(),o.pingedLanes|=o.suspendedLanes&h,hn===o&&(kn&h)===h&&(cn===4||cn===3&&(kn&130023424)===kn&&500>Ft()-Ef?gi(o,0):Sf|=h),Jn(o,a)}function Ry(o,a){a===0&&((o.mode&1)===0?a=1:(a=ri,ri<<=1,(ri&130023424)===0&&(ri=4194304)));var h=$n();o=Qr(o,a),o!==null&&(gs(o,a,h),Jn(o,h))}function rE(o){var a=o.memoizedState,h=0;a!==null&&(h=a.retryLane),Ry(o,h)}function sE(o,a){var h=0;switch(o.tag){case 13:var g=o.stateNode,x=o.memoizedState;x!==null&&(h=x.retryLane);break;case 19:g=o.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(a),Ry(o,h)}var Iy;Iy=function(o,a,h){if(o!==null)if(o.memoizedProps!==a.pendingProps||Vn.current)Gn=!0;else{if((o.lanes&h)===0&&(a.flags&128)===0)return Gn=!1,VS(o,a,h);Gn=(o.flags&131072)!==0}else Gn=!1,$t&&(a.flags&1048576)!==0&&fg(a,Na,a.index);switch(a.lanes=0,a.tag){case 2:var g=a.type;$a(o,a),o=a.pendingProps;var x=Qi(a,Mn.current);ro(a,h),x=ef(null,a,g,o,x,h);var S=tf();return a.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(a.tag=1,a.memoizedState=null,a.updateQueue=null,Kn(g)?(S=!0,ka(a)):S=!1,a.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,Gd(a),x.updater=Ba,a.stateNode=x,x._reactInternals=a,af(a,g,o,h),a=ff(null,a,g,!0,S,h)):(a.tag=0,$t&&S&&Pd(a),zn(null,a,x,h),a=a.child),a;case 16:g=a.elementType;e:{switch($a(o,a),o=a.pendingProps,x=g._init,g=x(g._payload),a.type=g,x=a.tag=oE(g),o=kr(g,o),x){case 0:a=df(null,a,g,o,h);break e;case 1:a=iy(null,a,g,o,h);break e;case 11:a=ey(null,a,g,o,h);break e;case 14:a=ty(null,a,g,kr(g.type,o),h);break e}throw Error(n(306,g,""))}return a;case 0:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),df(o,a,g,x,h);case 1:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),iy(o,a,g,x,h);case 3:e:{if(oy(a),o===null)throw Error(n(387));g=a.pendingProps,S=a.memoizedState,x=S.element,wg(o,a),Oa(a,g,null,h);var C=a.memoizedState;if(g=C.element,S.isDehydrated)if(S={element:g,isDehydrated:!1,cache:C.cache,pendingSuspenseBoundaries:C.pendingSuspenseBoundaries,transitions:C.transitions},a.updateQueue.baseState=S,a.memoizedState=S,a.flags&256){x=io(Error(n(423)),a),a=ly(o,a,g,h,x);break e}else if(g!==x){x=io(Error(n(424)),a),a=ly(o,a,g,h,x);break e}else for(tr=xs(a.stateNode.containerInfo.firstChild),er=a,$t=!0,wr=null,h=vg(a,null,g,h),a.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling;else{if(eo(),g===x){a=Zr(o,a,h);break e}zn(o,a,g,h)}a=a.child}return a;case 5:return Eg(a),o===null&&$d(a),g=a.type,x=a.pendingProps,S=o!==null?o.memoizedProps:null,C=x.children,Od(g,x)?C=null:S!==null&&Od(g,S)&&(a.flags|=32),sy(o,a),zn(o,a,C,h),a.child;case 6:return o===null&&$d(a),null;case 13:return ay(o,a,h);case 4:return qd(a,a.stateNode.containerInfo),g=a.pendingProps,o===null?a.child=to(a,null,g,h):zn(o,a,g,h),a.child;case 11:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),ey(o,a,g,x,h);case 7:return zn(o,a,a.pendingProps,h),a.child;case 8:return zn(o,a,a.pendingProps.children,h),a.child;case 12:return zn(o,a,a.pendingProps.children,h),a.child;case 10:e:{if(g=a.type._context,x=a.pendingProps,S=a.memoizedProps,C=x.value,It(Ta,g._currentValue),g._currentValue=C,S!==null)if(xr(S.value,C)){if(S.children===x.children&&!Vn.current){a=Zr(o,a,h);break e}}else for(S=a.child,S!==null&&(S.return=a);S!==null;){var j=S.dependencies;if(j!==null){C=S.child;for(var D=j.firstContext;D!==null;){if(D.context===g){if(S.tag===1){D=Xr(-1,h&-h),D.tag=2;var Q=S.updateQueue;if(Q!==null){Q=Q.shared;var de=Q.pending;de===null?D.next=D:(D.next=de.next,de.next=D),Q.pending=D}}S.lanes|=h,D=S.alternate,D!==null&&(D.lanes|=h),Vd(S.return,h,a),j.lanes|=h;break}D=D.next}}else if(S.tag===10)C=S.type===a.type?null:S.child;else if(S.tag===18){if(C=S.return,C===null)throw Error(n(341));C.lanes|=h,j=C.alternate,j!==null&&(j.lanes|=h),Vd(C,h,a),C=S.sibling}else C=S.child;if(C!==null)C.return=S;else for(C=S;C!==null;){if(C===a){C=null;break}if(S=C.sibling,S!==null){S.return=C.return,C=S;break}C=C.return}S=C}zn(o,a,x.children,h),a=a.child}return a;case 9:return x=a.type,g=a.pendingProps.children,ro(a,h),x=cr(x),g=g(x),a.flags|=1,zn(o,a,g,h),a.child;case 14:return g=a.type,x=kr(g,a.pendingProps),x=kr(g.type,x),ty(o,a,g,x,h);case 15:return ny(o,a,a.type,a.pendingProps,h);case 17:return g=a.type,x=a.pendingProps,x=a.elementType===g?x:kr(g,x),$a(o,a),a.tag=1,Kn(g)?(o=!0,ka(a)):o=!1,ro(a,h),Gg(a,g,x),af(a,g,x,h),ff(null,a,g,!0,o,h);case 19:return uy(o,a,h);case 22:return ry(o,a,h)}throw Error(n(156,a.tag))};function jy(o,a){return ta(o,a)}function iE(o,a,h,g){this.tag=o,this.key=h,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=a,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fr(o,a,h,g){return new iE(o,a,h,g)}function Rf(o){return o=o.prototype,!(!o||!o.isReactComponent)}function oE(o){if(typeof o=="function")return Rf(o)?1:0;if(o!=null){if(o=o.$$typeof,o===F)return 11;if(o===te)return 14}return 2}function Os(o,a){var h=o.alternate;return h===null?(h=fr(o.tag,a,o.key,o.mode),h.elementType=o.elementType,h.type=o.type,h.stateNode=o.stateNode,h.alternate=o,o.alternate=h):(h.pendingProps=a,h.type=o.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=o.flags&14680064,h.childLanes=o.childLanes,h.lanes=o.lanes,h.child=o.child,h.memoizedProps=o.memoizedProps,h.memoizedState=o.memoizedState,h.updateQueue=o.updateQueue,a=o.dependencies,h.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext},h.sibling=o.sibling,h.index=o.index,h.ref=o.ref,h}function Qa(o,a,h,g,x,S){var C=2;if(g=o,typeof o=="function")Rf(o)&&(C=1);else if(typeof o=="string")C=5;else e:switch(o){case P:return bi(h.children,x,S,a);case $:C=8,x|=8;break;case B:return o=fr(12,h,a,x|2),o.elementType=B,o.lanes=S,o;case re:return o=fr(13,h,a,x),o.elementType=re,o.lanes=S,o;case G:return o=fr(19,h,a,x),o.elementType=G,o.lanes=S,o;case ne:return Xa(h,x,S,a);default:if(typeof o=="object"&&o!==null)switch(o.$$typeof){case W:C=10;break e;case J:C=9;break e;case F:C=11;break e;case te:C=14;break e;case U:C=16,g=null;break e}throw Error(n(130,o==null?o:typeof o,""))}return a=fr(C,h,a,x),a.elementType=o,a.type=g,a.lanes=S,a}function bi(o,a,h,g){return o=fr(7,o,g,a),o.lanes=h,o}function Xa(o,a,h,g){return o=fr(22,o,g,a),o.elementType=ne,o.lanes=h,o.stateNode={isHidden:!1},o}function If(o,a,h){return o=fr(6,o,null,a),o.lanes=h,o}function jf(o,a,h){return a=fr(4,o.children!==null?o.children:[],o.key,a),a.lanes=h,a.stateNode={containerInfo:o.containerInfo,pendingChildren:null,implementation:o.implementation},a}function lE(o,a,h,g,x){this.tag=a,this.containerInfo=o,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=ms(0),this.expirationTimes=ms(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ms(0),this.identifierPrefix=g,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function Lf(o,a,h,g,x,S,C,j,D){return o=new lE(o,a,h,j,D),a===1?(a=1,S===!0&&(a|=8)):a=0,S=fr(3,null,null,a),o.current=S,S.stateNode=o,S.memoizedState={element:g,isDehydrated:h,cache:null,transitions:null,pendingSuspenseBoundaries:null},Gd(S),o}function aE(o,a,h){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:g==null?null:""+g,children:o,containerInfo:a,implementation:h}}function Ly(o){if(!o)return ks;o=o._reactInternals;e:{if(Kr(o)!==o||o.tag!==1)throw Error(n(170));var a=o;do{switch(a.tag){case 3:a=a.stateNode.context;break e;case 1:if(Kn(a.type)){a=a.stateNode.__reactInternalMemoizedMergedChildContext;break e}}a=a.return}while(a!==null);throw Error(n(171))}if(o.tag===1){var h=o.type;if(Kn(h))return cg(o,h,a)}return a}function Dy(o,a,h,g,x,S,C,j,D){return o=Lf(h,g,!0,o,x,S,C,j,D),o.context=Ly(null),h=o.current,g=$n(),x=Ms(h),S=Xr(g,x),S.callback=a??null,Ns(h,S,x),o.current.lanes=x,gs(o,x,g),Jn(o,g),o}function Za(o,a,h,g){var x=a.current,S=$n(),C=Ms(x);return h=Ly(h),a.context===null?a.context=h:a.pendingContext=h,a=Xr(S,C),a.payload={element:o},g=g===void 0?null:g,g!==null&&(a.callback=g),o=Ns(x,a,C),o!==null&&(Nr(o,x,C,S),Aa(o,x,C)),C}function ec(o){if(o=o.current,!o.child)return null;switch(o.child.tag){case 5:return o.child.stateNode;default:return o.child.stateNode}}function Py(o,a){if(o=o.memoizedState,o!==null&&o.dehydrated!==null){var h=o.retryLane;o.retryLane=h!==0&&h<a?h:a}}function Df(o,a){Py(o,a),(o=o.alternate)&&Py(o,a)}function cE(){return null}var By=typeof reportError=="function"?reportError:function(o){console.error(o)};function Pf(o){this._internalRoot=o}tc.prototype.render=Pf.prototype.render=function(o){var a=this._internalRoot;if(a===null)throw Error(n(409));Za(o,a,null,null)},tc.prototype.unmount=Pf.prototype.unmount=function(){var o=this._internalRoot;if(o!==null){this._internalRoot=null;var a=o.containerInfo;mi(function(){Za(null,o,null,null)}),a[Gr]=null}};function tc(o){this._internalRoot=o}tc.prototype.unstable_scheduleHydration=function(o){if(o){var a=ii();o={blockedOn:null,target:o,priority:a};for(var h=0;h<dn.length&&a!==0&&a<dn[h].priority;h++);dn.splice(h,0,o),h===0&&Em(o)}};function Bf(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11)}function nc(o){return!(!o||o.nodeType!==1&&o.nodeType!==9&&o.nodeType!==11&&(o.nodeType!==8||o.nodeValue!==" react-mount-point-unstable "))}function zy(){}function uE(o,a,h,g,x){if(x){if(typeof g=="function"){var S=g;g=function(){var Q=ec(C);S.call(Q)}}var C=Dy(a,g,o,0,null,!1,!1,"",zy);return o._reactRootContainer=C,o[Gr]=C.current,Jo(o.nodeType===8?o.parentNode:o),mi(),C}for(;x=o.lastChild;)o.removeChild(x);if(typeof g=="function"){var j=g;g=function(){var Q=ec(D);j.call(Q)}}var D=Lf(o,0,!1,null,null,!1,!1,"",zy);return o._reactRootContainer=D,o[Gr]=D.current,Jo(o.nodeType===8?o.parentNode:o),mi(function(){Za(a,D,h,g)}),D}function rc(o,a,h,g,x){var S=h._reactRootContainer;if(S){var C=S;if(typeof x=="function"){var j=x;x=function(){var D=ec(C);j.call(D)}}Za(a,C,o,x)}else C=uE(h,a,o,x,g);return ec(C)}Po=function(o){switch(o.tag){case 3:var a=o.stateNode;if(a.current.memoizedState.isDehydrated){var h=ps(a.pendingLanes);h!==0&&(Do(a,h|1),Jn(a,Ft()),(mt&6)===0&&(ao=Ft()+500,Ss()))}break;case 13:mi(function(){var g=Qr(o,1);if(g!==null){var x=$n();Nr(g,o,1,x)}}),Df(o,1)}},en=function(o){if(o.tag===13){var a=Qr(o,134217728);if(a!==null){var h=$n();Nr(a,o,134217728,h)}Df(o,134217728)}},St=function(o){if(o.tag===13){var a=Ms(o),h=Qr(o,a);if(h!==null){var g=$n();Nr(h,o,a,g)}Df(o,a)}},ii=function(){return pt},jr=function(o,a){var h=pt;try{return pt=o,a()}finally{pt=h}},be=function(o,a,h){switch(a){case"input":if(Qe(o,h),a=h.name,h.type==="radio"&&a!=null){for(h=o;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll("input[name="+JSON.stringify(""+a)+'][type="radio"]'),a=0;a<h.length;a++){var g=h[a];if(g!==o&&g.form===o.form){var x=xa(g);if(!x)throw Error(n(90));ie(g),Qe(g,x)}}}break;case"textarea":st(o,h);break;case"select":a=h.value,a!=null&&ke(o,!!h.multiple,a,!1)}},xe=Mf,Je=mi;var dE={usingClientEntryPoint:!1,Events:[Xo,Ji,xa,L,oe,Mf]},fl={findFiberByHostInstance:li,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},fE={bundleType:fl.bundleType,version:fl.version,rendererPackageName:fl.rendererPackageName,rendererConfig:fl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(o){return o=Zl(o),o===null?null:o.stateNode},findFiberByHostInstance:fl.findFiberByHostInstance||cE,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var sc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!sc.isDisabled&&sc.supportsFiber)try{ot=sc.inject(fE),ut=sc}catch{}}return Yn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=dE,Yn.createPortal=function(o,a){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Bf(a))throw Error(n(200));return aE(o,a,null,h)},Yn.createRoot=function(o,a){if(!Bf(o))throw Error(n(299));var h=!1,g="",x=By;return a!=null&&(a.unstable_strictMode===!0&&(h=!0),a.identifierPrefix!==void 0&&(g=a.identifierPrefix),a.onRecoverableError!==void 0&&(x=a.onRecoverableError)),a=Lf(o,1,!1,null,null,h,!1,g,x),o[Gr]=a.current,Jo(o.nodeType===8?o.parentNode:o),new Pf(a)},Yn.findDOMNode=function(o){if(o==null)return null;if(o.nodeType===1)return o;var a=o._reactInternals;if(a===void 0)throw typeof o.render=="function"?Error(n(188)):(o=Object.keys(o).join(","),Error(n(268,o)));return o=Zl(a),o=o===null?null:o.stateNode,o},Yn.flushSync=function(o){return mi(o)},Yn.hydrate=function(o,a,h){if(!nc(a))throw Error(n(200));return rc(null,o,a,!0,h)},Yn.hydrateRoot=function(o,a,h){if(!Bf(o))throw Error(n(405));var g=h!=null&&h.hydratedSources||null,x=!1,S="",C=By;if(h!=null&&(h.unstable_strictMode===!0&&(x=!0),h.identifierPrefix!==void 0&&(S=h.identifierPrefix),h.onRecoverableError!==void 0&&(C=h.onRecoverableError)),a=Dy(a,null,o,1,h??null,x,!1,S,C),o[Gr]=a.current,Jo(o),g)for(o=0;o<g.length;o++)h=g[o],x=h._getVersion,x=x(h._source),a.mutableSourceEagerHydrationData==null?a.mutableSourceEagerHydrationData=[h,x]:a.mutableSourceEagerHydrationData.push(h,x);return new tc(a)},Yn.render=function(o,a,h){if(!nc(a))throw Error(n(200));return rc(null,o,a,!1,h)},Yn.unmountComponentAtNode=function(o){if(!nc(o))throw Error(n(40));return o._reactRootContainer?(mi(function(){rc(null,null,o,!1,function(){o._reactRootContainer=null,o[Gr]=null})}),!0):!1},Yn.unstable_batchedUpdates=Mf,Yn.unstable_renderSubtreeIntoContainer=function(o,a,h,g){if(!nc(h))throw Error(n(200));if(o==null||o._reactInternals===void 0)throw Error(n(38));return rc(o,a,h,!1,g)},Yn.version="18.3.1-next-f1338f8080-20240426",Yn}var Gy;function D0(){if(Gy)return Ff.exports;Gy=1;function t(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),Ff.exports=vE(),Ff.exports}var qy;function xE(){if(qy)return ic;qy=1;var t=D0();return ic.createRoot=t.createRoot,ic.hydrateRoot=t.hydrateRoot,ic}var wE=xE();const kE=Bu(wE),P0=[{id:"charter",label:"Charter",description:"Charter serif"},{id:"source-serif",label:"Source Serif",description:"Source Serif 4"},{id:"plex-mono",label:"Plex Mono",description:"IBM Plex Mono"},{id:"crimson",label:"Crimson",description:"Crimson Pro"},{id:"inter",label:"Inter",description:"Inter sans-serif"},{id:"baskerville",label:"Baskerville",description:"Libre Baskerville"},{id:"grotesk",label:"Grotesk",description:"Space Grotesk"},{id:"literata",label:"Literata",description:"Literata serif"},{id:"dm-sans",label:"DM Sans",description:"DM Sans + Serif"}],B0=[{id:"default",label:"Tree",icon:"tree"},{id:"timeline",label:"Timeline",icon:"timeline"},{id:"board",label:"Board",icon:"board"},{id:"shelf",label:"Shelf",icon:"shelf"}],z0=[{id:"seamless",label:"Seamless"},{id:"outline",label:"Outline"},{id:"page",label:"Page"},{id:"paper",label:"Paper"}],$0=[{id:"default",label:"Default"},{id:"web",label:"Web"},{id:"blog",label:"Blog"},{id:"butterick",label:"Butterick"}],SE=["full","compact","minimal"],Nn={typeface:"ow-typeface",mode:"ow-theme-mode",sidebarMode:"ow-sidebar-mode",sidebarStyle:"ow-sidebar-style",sidebarDensity:"ow-sidebar-density",spacing:"ow-spacing",canvas:"ow-canvas"},EE={ink:"charter",novel:"source-serif",mono:"plex-mono",editorial:"crimson",studio:"inter",prose:"baskerville"};function NE(){const t=localStorage.getItem("ow-theme");if(t&&!localStorage.getItem(Nn.typeface)){const n=EE[t];n&&localStorage.setItem(Nn.typeface,n),localStorage.removeItem("ow-theme")}localStorage.removeItem("ow-color");const e=localStorage.getItem("ow-typography");e&&!localStorage.getItem(Nn.spacing)&&(localStorage.setItem(Nn.spacing,e),localStorage.removeItem("ow-typography"))}function F0(){const t=localStorage.getItem(Nn.typeface);return t&&P0.some(e=>e.id===t)?t:"charter"}function U0(){const t=localStorage.getItem(Nn.mode);return t==="light"||t==="dark"?t:window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function zu(){const t=localStorage.getItem(Nn.sidebarMode);return t&&B0.some(e=>e.id===t)?t:"default"}function H0(){return"cards"}function W0(){const t=localStorage.getItem(Nn.sidebarDensity);return t&&SE.includes(t)?t:"full"}function CE(t){localStorage.setItem(Nn.sidebarDensity,t),document.documentElement.setAttribute("data-sidebar-density",t)}function V0(){const t=localStorage.getItem(Nn.spacing);return t&&$0.some(e=>e.id===t)?t:"default"}function K0(){const t=localStorage.getItem(Nn.canvas);return t&&z0.some(e=>e.id===t)?t:"seamless"}function G0(t,e,n,r,s="default",i="seamless"){const l=document.documentElement;l.setAttribute("data-typeface",t),l.setAttribute("data-mode",e),l.setAttribute("data-sidebar-mode",n),l.setAttribute("data-sidebar-style",r),s==="default"?l.removeAttribute("data-spacing"):l.setAttribute("data-spacing",s),i==="seamless"?l.removeAttribute("data-canvas"):l.setAttribute("data-canvas",i),l.removeAttribute("data-color"),localStorage.setItem(Nn.typeface,t),localStorage.setItem(Nn.mode,e),localStorage.setItem(Nn.sidebarMode,n),localStorage.setItem(Nn.sidebarStyle,r),localStorage.setItem(Nn.spacing,s),localStorage.setItem(Nn.canvas,i)}function _E(){NE(),G0(F0(),U0(),zu(),H0(),V0(),K0()),document.documentElement.setAttribute("data-sidebar-density",W0())}var TE=D0();const ME=Bu(TE);var Wf={exports:{}},Vf={};/**
41
+ * @license React
42
+ * use-sync-external-store-shim.production.js
43
+ *
44
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
45
+ *
46
+ * This source code is licensed under the MIT license found in the
47
+ * LICENSE file in the root directory of this source tree.
48
+ */var Jy;function AE(){if(Jy)return Vf;Jy=1;var t=Kl();function e(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,s=t.useEffect,i=t.useLayoutEffect,l=t.useDebugValue;function c(m,y){var b=y(),v=r({inst:{value:b,getSnapshot:y}}),w=v[0].inst,k=v[1];return i(function(){w.value=b,w.getSnapshot=y,u(w)&&k({inst:w})},[m,b,y]),s(function(){return u(w)&&k({inst:w}),m(function(){u(w)&&k({inst:w})})},[m]),l(b),b}function u(m){var y=m.getSnapshot;m=m.value;try{var b=y();return!n(m,b)}catch{return!0}}function f(m,y){return y()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Vf.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:p,Vf}var Yy;function q0(){return Yy||(Yy=1,Wf.exports=AE()),Wf.exports}var J0=q0();function En(t){this.content=t}En.prototype={constructor:En,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),i=r.content.slice();return s==-1?i.push(n||t,e):(i[s+1]=e,n&&(i[s]=n)),new En(i)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new En(n)},addToStart:function(t,e){return new En([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new En(n)},addBefore:function(t,e,n){var r=this.remove(e),s=r.content.slice(),i=r.find(t);return s.splice(i==-1?s.length:i,0,e,n),new En(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=En.from(t),t.size?new En(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=En.from(t),t.size?new En(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=En.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}};En.from=function(t){if(t instanceof En)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new En(e)};function Y0(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),i=e.child(r);if(s==i){n+=s.nodeSize;continue}if(!s.sameMarkup(i))return n;if(s.isText&&s.text!=i.text){for(let l=0;s.text[l]==i.text[l];l++)n++;return n}if(s.content.size||i.content.size){let l=Y0(s.content,i.content,n+1);if(l!=null)return l}n+=s.nodeSize}}function Q0(t,e,n,r){for(let s=t.childCount,i=e.childCount;;){if(s==0||i==0)return s==i?null:{a:n,b:r};let l=t.child(--s),c=e.child(--i),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let f=0,p=Math.min(l.text.length,c.text.length);for(;f<p&&l.text[l.text.length-f-1]==c.text[c.text.length-f-1];)f++,n--,r--;return{a:n,b:r}}if(l.content.size||c.content.size){let f=Q0(l.content,c.content,n-1,r-1);if(f)return f}n-=u,r-=u}}class ae{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,i){for(let l=0,c=0;c<n;l++){let u=this.content[l],f=c+u.nodeSize;if(f>e&&r(u,s+c,i||null,l)!==!1&&u.content.size){let p=c+1;u.nodesBetween(Math.max(0,e-p),Math.min(u.content.size,n-p),r,s+p)}c=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,s){let i="",l=!0;return this.nodesBetween(e,n,(c,u)=>{let f=c.isText?c.text.slice(Math.max(e,u)-u,n-u):c.isLeaf?s?typeof s=="function"?s(c):s:c.type.spec.leafText?c.type.spec.leafText(c):"":"";c.isBlock&&(c.isLeaf&&f||c.isTextblock)&&r&&(l?l=!1:i+=r),i+=f},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,s=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(s[s.length-1]=n.withText(n.text+r.text),i=1);i<e.content.length;i++)s.push(e.content[i]);return new ae(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 i=0,l=0;l<n;i++){let c=this.content[i],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),s+=c.nodeSize),l=u}return new ae(r,s)}cutByIndex(e,n){return e==n?ae.empty:e==0&&n==this.content.length?this:new ae(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let s=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return s[e]=n,new ae(s,i)}addToStart(e){return new ae([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new ae(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 Y0(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Q0(this,e,n,r)}findIndex(e){if(e==0)return oc(0,e);if(e==this.size)return oc(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),i=r+s.nodeSize;if(i>=e)return i==e?oc(n+1,i):oc(n,r);r=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return ae.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ae(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return ae.empty;let n,r=0;for(let s=0;s<e.length;s++){let i=e[s];r+=i.nodeSize,s&&i.isText&&e[s-1].sameMarkup(i)?(n||(n=e.slice(0,s)),n[n.length-1]=i.withText(n[n.length-1].text+i.text)):n&&n.push(i)}return new ae(n||e,r)}static from(e){if(!e)return ae.empty;if(e instanceof ae)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new ae([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ae.empty=new ae([],0);const Kf={index:0,offset:0};function oc(t,e){return Kf.index=t,Kf.offset=e,Kf}function Uc(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(!Uc(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Uc(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let At=class Ih{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let s=0;s<e.length;s++){let i=e[s];if(this.eq(i))return e;if(this.type.excludes(i.type))n||(n=e.slice(0,s));else{if(i.type.excludes(this.type))return e;!r&&i.type.rank>this.type.rank&&(n||(n=e.slice(0,s)),n.push(this),r=!0),n&&n.push(i)}}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&&Uc(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 Ih.none;if(e instanceof Ih)return[e];let n=e.slice();return n.sort((r,s)=>r.type.rank-s.type.rank),n}};At.none=[];class Hc extends Error{}class Se{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=Z0(this.content,e+this.openStart,n);return r&&new Se(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Se(X0(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 Se.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 Se(ae.fromJSON(e,n.content),r,s)}static maxOpen(e,n=!0){let r=0,s=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)s++;return new Se(e,r,s)}}Se.empty=new Se(ae.empty,0,0);function X0(t,e,n){let{index:r,offset:s}=t.findIndex(e),i=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(s==e||i.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(X0(i.content,e-s-1,n-s-1)))}function Z0(t,e,n,r){let{index:s,offset:i}=t.findIndex(e),l=t.maybeChild(s);if(i==e||l.isText)return r&&!r.canReplace(s,s,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=Z0(l.content,e-i-1,n,l);return c&&t.replaceChild(s,l.copy(c))}function OE(t,e,n){if(n.openStart>t.depth)throw new Hc("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Hc("Inconsistent open depths");return ex(t,e,n,0)}function ex(t,e,n,r){let s=t.index(r),i=t.node(r);if(s==e.index(r)&&r<t.depth-n.openStart){let l=ex(t,e,n,r+1);return i.copy(i.content.replaceChild(s,l))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let l=t.parent,c=l.content;return Ci(l,c.cut(0,t.parentOffset).append(n.content).append(c.cut(e.parentOffset)))}else{let{start:l,end:c}=RE(n,t);return Ci(i,nx(t,l,c,e,r))}else return Ci(i,Wc(t,e,r))}function tx(t,e){if(!e.type.compatibleContent(t.type))throw new Hc("Cannot join "+e.type.name+" onto "+t.type.name)}function jh(t,e,n){let r=t.node(n);return tx(r,e.node(n)),r}function Ni(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 El(t,e,n,r){let s=(e||t).node(n),i=0,l=e?e.index(n):s.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ni(t.nodeAfter,r),i++));for(let c=i;c<l;c++)Ni(s.child(c),r);e&&e.depth==n&&e.textOffset&&Ni(e.nodeBefore,r)}function Ci(t,e){return t.type.checkContent(e),t.copy(e)}function nx(t,e,n,r,s){let i=t.depth>s&&jh(t,e,s+1),l=r.depth>s&&jh(n,r,s+1),c=[];return El(null,t,s,c),i&&l&&e.index(s)==n.index(s)?(tx(i,l),Ni(Ci(i,nx(t,e,n,r,s+1)),c)):(i&&Ni(Ci(i,Wc(t,e,s+1)),c),El(e,n,s,c),l&&Ni(Ci(l,Wc(n,r,s+1)),c)),El(r,null,s,c),new ae(c)}function Wc(t,e,n){let r=[];if(El(null,t,n,r),t.depth>n){let s=jh(t,e,n+1);Ni(Ci(s,Wc(t,e,n+1)),r)}return El(e,null,n,r),new ae(r)}function RE(t,e){let n=e.depth-t.openStart,s=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)s=e.node(i).copy(ae.from(s));return{start:s.resolveNoCache(t.openStart+n),end:s.resolveNoCache(s.content.size-t.openEnd-n)}}class jl{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 i=0;i<e;i++)s+=r.child(i).nodeSize;return s}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return At.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),s=e.maybeChild(n);if(!r){let c=r;r=s,s=c}let i=r.marks;for(var l=0;l<i.length;l++)i[l].type.spec.inclusive===!1&&(!s||!i[l].isInSet(s.marks))&&(i=i[l--].removeFromSet(i));return i}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 i=0;i<r.length;i++)r[i].type.spec.inclusive===!1&&(!s||!r[i].isInSet(s.marks))&&(r=r[i--].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 Vc(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,i=n;for(let l=e;;){let{index:c,offset:u}=l.content.findIndex(i),f=i-u;if(r.push(l,c,s+u),!f||(l=l.child(c),l.isText))break;i=f-1,s+=u+1}return new jl(n,r,i)}static resolveCached(e,n){let r=Qy.get(e);if(r)for(let i=0;i<r.elts.length;i++){let l=r.elts[i];if(l.pos==n)return l}else Qy.set(e,r=new IE);let s=r.elts[r.i]=jl.resolve(e,n);return r.i=(r.i+1)%jE,s}}class IE{constructor(){this.elts=[],this.i=0}}const jE=12,Qy=new WeakMap;class Vc{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 LE=Object.create(null);class Mr{constructor(e,n,r,s=At.none){this.type=e,this.attrs=n,this.marks=s,this.content=r||ae.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&&Uc(this.attrs,n||e.defaultAttrs||LE)&&At.sameSet(this.marks,r||At.none)}copy(e=null){return e==this.content?this:new Mr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Mr(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 Se.empty;let s=this.resolve(e),i=this.resolve(n),l=r?0:s.sharedDepth(n),c=s.start(l),f=s.node(l).content.cut(s.pos-c,i.pos-c);return new Se(f,s.depth-l,i.depth-l)}replace(e,n,r){return OE(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 jl.resolveCached(this,e)}resolveNoCache(e){return jl.resolve(this,e)}rangeHasMark(e,n,r){let s=!1;return n>e&&this.nodesBetween(e,n,i=>(r.isInSet(i.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()+")"),rx(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=ae.empty,s=0,i=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,s,i),c=l&&l.matchFragment(this.content,n);if(!c||!c.validEnd)return!1;for(let u=s;u<i;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,s){if(s&&!this.type.allowsMarks(s))return!1;let i=this.contentMatchAt(e).matchType(r),l=i&&i.matchFragment(this.content,n);return l?l.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=At.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(!At.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=ae.fromJSON(e,n.content),i=e.nodeType(n.type).create(n.attrs,s,r);return i.type.checkAttrs(i.attrs),i}}Mr.prototype.text=void 0;class Kc extends Mr{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):rx(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 Kc(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Kc(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 rx(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ai{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new DE(e,n);if(r.next==null)return Ai.empty;let s=sx(r);r.next&&r.err("Unexpected trailing text");let i=HE(UE(s));return WE(i,r),i}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 i=n;s&&i<r;i++)s=s.matchType(e.child(i).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 i(l,c){let u=l.matchFragment(e,r);if(u&&(!n||u.validEnd))return ae.from(c.map(f=>f.createAndFill()));for(let f=0;f<l.next.length;f++){let{type:p,next:m}=l.next[f];if(!(p.isText||p.hasRequiredAttrs())&&s.indexOf(m)==-1){s.push(m);let y=i(m,c.concat(p));if(y)return y}}return null}return i(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let 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(),i=s.match;if(i.matchType(e)){let l=[];for(let c=s;c.type;c=c.via)l.push(c.type);return l.reverse()}for(let l=0;l<i.next.length;l++){let{type:c,next:u}=i.next[l];!c.isLeaf&&!c.hasRequiredAttrs()&&!(c.name in n)&&(!s.type||u.validEnd)&&(r.push({match:c.contentMatch,type:c,via:s}),n[c.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 i=s+(r.validEnd?"*":" ")+" ";for(let l=0;l<r.next.length;l++)i+=(l?", ":"")+r.next[l].type.name+"->"+e.indexOf(r.next[l].next);return i}).join(`
49
+ `)}}Ai.empty=new Ai(!0);class DE{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 sx(t){let e=[];do e.push(PE(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function PE(t){let e=[];do e.push(BE(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function BE(t){let e=FE(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=zE(t,e);else break;return e}function Xy(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function zE(t,e){let n=Xy(t),r=n;return t.eat(",")&&(t.next!="}"?r=Xy(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function $E(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let s=[];for(let i in n){let l=n[i];l.isInGroup(e)&&s.push(l)}return s.length==0&&t.err("No node type or group '"+e+"' found"),s}function FE(t){if(t.eat("(")){let e=sx(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=$E(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 UE(t){let e=[[]];return s(i(t,0),n()),e;function n(){return e.push([])-1}function r(l,c,u){let f={term:u,to:c};return e[l].push(f),f}function s(l,c){l.forEach(u=>u.to=c)}function i(l,c){if(l.type=="choice")return l.exprs.reduce((u,f)=>u.concat(i(f,c)),[]);if(l.type=="seq")for(let u=0;;u++){let f=i(l.exprs[u],c);if(u==l.exprs.length-1)return f;s(f,c=n())}else if(l.type=="star"){let u=n();return r(c,u),s(i(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=n();return s(i(l.expr,c),u),s(i(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(c)].concat(i(l.expr,c));if(l.type=="range"){let u=c;for(let f=0;f<l.min;f++){let p=n();s(i(l.expr,u),p),u=p}if(l.max==-1)s(i(l.expr,u),u);else for(let f=l.min;f<l.max;f++){let p=n();r(u,p),s(i(l.expr,u),p),u=p}return[r(u)]}else{if(l.type=="name")return[r(c,void 0,l.value)];throw new Error("Unknown expr type")}}}}function ix(t,e){return e-t}function Zy(t,e){let n=[];return r(e),n.sort(ix);function r(s){let i=t[s];if(i.length==1&&!i[0].term)return r(i[0].to);n.push(s);for(let l=0;l<i.length;l++){let{term:c,to:u}=i[l];!c&&n.indexOf(u)==-1&&r(u)}}}function HE(t){let e=Object.create(null);return n(Zy(t,0));function n(r){let s=[];r.forEach(l=>{t[l].forEach(({term:c,to:u})=>{if(!c)return;let f;for(let p=0;p<s.length;p++)s[p][0]==c&&(f=s[p][1]);Zy(t,u).forEach(p=>{f||s.push([c,f=[]]),f.indexOf(p)==-1&&f.push(p)})})});let i=e[r.join(",")]=new Ai(r.indexOf(t.length-1)>-1);for(let l=0;l<s.length;l++){let c=s[l][1].sort(ix);i.next.push({type:s[l][0],next:e[c.join(",")]||n(c)})}return i}}function WE(t,e){for(let n=0,r=[t];n<r.length;n++){let s=r[n],i=!s.validEnd,l=[];for(let c=0;c<s.next.length;c++){let{type:u,next:f}=s.next[c];l.push(u.name),i&&!(u.isText||u.hasRequiredAttrs())&&(i=!1),r.indexOf(f)==-1&&r.push(f)}i&&e.err("Only non-generatable nodes ("+l.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ox(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 lx(t,e){let n=Object.create(null);for(let r in t){let s=e&&e[r];if(s===void 0){let i=t[r];if(i.hasDefault)s=i.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=s}return n}function ax(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 i=t[s];i.validate&&i.validate(e[s])}}function cx(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new KE(t,r,e[r]);return n}let eb=class ux{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=cx(e,r.attrs),this.defaultAttrs=ox(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==Ai.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:lx(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new Mr(this,this.computeAttrs(e),ae.from(n),At.setFrom(r))}createChecked(e=null,n,r){return n=ae.from(n),this.checkContent(n),new Mr(this,this.computeAttrs(e),n,At.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=ae.from(n),n.size){let l=this.contentMatch.fillBefore(n);if(!l)return null;n=l.append(n)}let s=this.contentMatch.matchFragment(n),i=s&&s.fillBefore(ae.empty,!0);return i?new Mr(this,e,n.append(i),At.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){ax(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:At.none:e}static compile(e,n){let r=Object.create(null);e.forEach((i,l)=>r[i]=new ux(i,n,l));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 i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function VE(t,e,n){let r=n.split("|");return s=>{let i=s===null?"null":typeof s;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${i}`)}}class KE{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?VE(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class $u{constructor(e,n,r,s){this.name=e,this.rank=n,this.schema=r,this.spec=s,this.attrs=cx(e,s.attrs),this.excluded=null;let i=ox(this.attrs);this.instance=i?new At(this,i):null}create(e=null){return!e&&this.instance?this.instance:new At(this,lx(this.attrs,e))}static compile(e,n){let r=Object.create(null),s=0;return e.forEach((i,l)=>r[i]=new $u(i,s++,n,l)),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){ax(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class dx{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=En.from(e.nodes),n.marks=En.from(e.marks||{}),this.nodes=eb.compile(this.spec.nodes,this),this.marks=$u.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 i=this.nodes[s],l=i.spec.content||"",c=i.spec.marks;if(i.contentMatch=r[l]||(r[l]=Ai.parse(l,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=c=="_"?null:c?tb(this,c.split(" ")):c==""||!i.inlineContent?[]:null}for(let s in this.marks){let i=this.marks[s],l=i.spec.excludes;i.excluded=l==null?[i]:l==""?[]:tb(this,l.split(" "))}this.nodeFromJSON=s=>Mr.fromJSON(this,s),this.markFromJSON=s=>At.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 eb){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 Kc(r,r.defaultAttrs,e,At.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 tb(t,e){let n=[];for(let r=0;r<e.length;r++){let s=e[r],i=t.marks[s],l=i;if(i)n.push(i);else for(let c in t.marks){let u=t.marks[c];(s=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(s)>-1)&&n.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function GE(t){return t.tag!=null}function qE(t){return t.style!=null}class Ws{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(s=>{if(GE(s))this.tags.push(s);else if(qE(s)){let i=/[^=]*/.exec(s.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(s)}}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=e.nodes[s.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new rb(this,n,!1);return r.addAll(e,At.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new rb(this,n,!0);return r.addAll(e,At.none,n.from,n.to),Se.maxOpen(r.finish())}matchTag(e,n,r){for(let s=r?this.tags.indexOf(r)+1:0;s<this.tags.length;s++){let i=this.tags[s];if(QE(e,i.tag)&&(i.namespace===void 0||e.namespaceURI==i.namespace)&&(!i.context||n.matchesContext(i.context))){if(i.getAttrs){let l=i.getAttrs(e);if(l===!1)continue;i.attrs=l||void 0}return i}}}matchStyle(e,n,r,s){for(let i=s?this.styles.indexOf(s)+1:0;i<this.styles.length;i++){let l=this.styles[i],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(s){let i=s.priority==null?50:s.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<i)break}n.splice(l,0,s)}for(let s in e.marks){let i=e.marks[s].spec.parseDOM;i&&i.forEach(l=>{r(l=sb(l)),l.mark||l.ignore||l.clearMark||(l.mark=s)})}for(let s in e.nodes){let i=e.nodes[s].spec.parseDOM;i&&i.forEach(l=>{r(l=sb(l)),l.node||l.ignore||l.mark||(l.node=s)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Ws(e,Ws.schemaRules(e)))}}const fx={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},JE={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},hx={ol:!0,ul:!0},Ll=1,Lh=2,Nl=4;function nb(t,e,n){return e!=null?(e?Ll:0)|(e==="full"?Lh:0):t&&t.whitespace=="pre"?Ll|Lh:n&~Nl}class lc{constructor(e,n,r,s,i,l){this.type=e,this.attrs=n,this.marks=r,this.solid=s,this.options=l,this.content=[],this.activeMarks=At.none,this.match=i||(l&Nl?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ae.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&Ll)){let r=this.content[this.content.length-1],s;if(r&&r.isText&&(s=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==s[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-s[0].length))}}let n=ae.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(ae.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&&!fx.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class rb{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let s=n.topNode,i,l=nb(null,n.preserveWhitespace,0)|(r?Nl:0);s?i=new lc(s.type,s.attrs,At.none,!0,n.topMatch||s.type.contentMatch,l):r?i=new lc(null,null,At.none,!0,null,l):i=new lc(e.schema.topNodeType,null,At.none,!0,null,l),this.nodes=[i],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,i=s.options&Lh?"full":this.localPreserveWS||(s.options&Ll)>0,{schema:l}=this.parser;if(i==="full"||s.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)if(i==="full")r=r.replace(/\r\n?/g,`
50
+ `);else if(l.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(l.linebreakReplacement.create())){let c=r.split(/\r?\n|\r/);for(let u=0;u<c.length;u++)u&&this.insertNode(l.linebreakReplacement.create(),n,!0),c[u]&&this.insertNode(l.text(c[u]),n,!/\S/.test(c[u]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let c=s.content[s.content.length-1],u=e.previousSibling;(!c||u&&u.nodeName=="BR"||c.isText&&/[ \t\r\n\u000c]$/.test(c.text))&&(r=r.slice(1))}r&&this.insertNode(l.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let s=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let l=e.nodeName.toLowerCase(),c;hx.hasOwnProperty(l)&&this.parser.normalizeLists&&YE(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(c=this.parser.matchTag(e,this,r));e:if(u?u.ignore:JE.hasOwnProperty(l))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let f,p=this.needsBlock;if(fx.hasOwnProperty(l))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),f=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let m=u&&u.skip?n:this.readStyles(e,n);m&&this.addAll(e,m),f&&this.sync(i),this.needsBlock=p}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,u,f,u.consuming===!1?c:void 0)}this.localPreserveWS=s}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
51
+ `),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 i=this.parser.matchedStyles[s],l=r.getPropertyValue(i);if(l)for(let c=void 0;;){let u=this.parser.matchStyle(i,l,this,c);if(!u)break;if(u.ignore)return null;if(u.clearMark?n=n.filter(f=>!u.clearMark(f)):n=n.concat(this.parser.schema.marks[u.mark].create(u.attrs)),u.consuming===!1)c=u;else break}}return n}addElementByRule(e,n,r,s){let i,l;if(n.node)if(l=this.parser.schema.nodes[n.node],l.isLeaf)this.insertNode(l.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(l,n.attrs||null,r,n.preserveWhitespace);u&&(i=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let c=this.top;if(l&&l.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(u=>this.insertNode(u,r,!1));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u,r),this.findAround(e,u,!1)}i&&this.sync(c)&&this.open--}addAll(e,n,r,s){let i=r||0;for(let l=r?e.childNodes[r]:e.firstChild,c=s==null?null:e.childNodes[s];l!=c;l=l.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(l,n);this.findAtPoint(e,i)}findPlace(e,n,r){let s,i;for(let l=this.open,c=0;l>=0;l--){let u=this.nodes[l],f=u.findWrapping(e);if(f&&(!s||s.length>f.length+c)&&(s=f,i=u,!f.length))break;if(u.solid){if(r)break;c+=2}}if(!s)return null;this.sync(i);for(let l=0;l<s.length;l++)n=this.enterInner(s[l],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let i=this.textblockFromContext();i&&(n=this.enterInner(i,null,n))}let s=this.findPlace(e,n,r);if(s){this.closeExtra();let i=this.top;i.match&&(i.match=i.match.matchType(e.type));let l=At.none;for(let c of s.concat(e.marks))(i.type?i.type.allowsMarkType(c.type):ib(c.type,e.type))&&(l=c.addToSet(l));return i.content.push(e.mark(l)),!0}return!1}enter(e,n,r,s){let i=this.findPlace(e.create(n),r,!1);return i&&(i=this.enterInner(e,n,r,!0,s)),i}enterInner(e,n,r,s=!1,i){this.closeExtra();let l=this.top;l.match=l.match&&l.match.matchType(e);let c=nb(e,i,l.options);l.options&Nl&&l.content.length==0&&(c|=Nl);let u=At.none;return r=r.filter(f=>(l.type?l.type.allowsMarkType(f.type):ib(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new lc(e,n,u,s,null,c)),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|=Ll)}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),i=-(r?r.depth+1:0)+(s?0:1),l=(c,u)=>{for(;c>=0;c--){let f=n[c];if(f==""){if(c==n.length-1||c==0)continue;for(;u>=i;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&s?this.nodes[u].type:r&&u>=i?r.node(u-i).type:null;if(!p||p.name!=f&&!p.isInGroup(f))return!1;u--}}return!0};return l(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 YE(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&hx.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function QE(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function sb(t){let e={};for(let n in t)e[n]=t[n];return e}function ib(t,e){let n=e.schema.nodes;for(let r in n){let s=n[r];if(!s.allowsMarkType(t))continue;let i=[],l=c=>{i.push(c);for(let u=0;u<c.edgeCount;u++){let{type:f,next:p}=c.edge(u);if(f==e||i.indexOf(p)<0&&l(p))return!0}};if(l(s.contentMatch))return!0}}class Pi{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=Gf(n).createDocumentFragment());let s=r,i=[];return e.forEach(l=>{if(i.length||l.marks.length){let c=0,u=0;for(;c<i.length&&u<l.marks.length;){let f=l.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(i[c][0])||f.type.spec.spanning===!1)break;c++,u++}for(;c<i.length;)s=i.pop()[1];for(;u<l.marks.length;){let f=l.marks[u++],p=this.serializeMark(f,l.isInline,n);p&&(i.push([f,s]),s.appendChild(p.dom),s=p.contentDOM||p.dom)}}s.appendChild(this.serializeNodeInner(l,n))}),r}serializeNodeInner(e,n){let{dom:r,contentDOM:s}=jc(Gf(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 i=this.serializeMark(e.marks[s],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let s=this.marks[e.type.name];return s&&jc(Gf(r),s(e,n),null,e.attrs)}static renderSpec(e,n,r=null,s){return jc(e,n,r,s)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Pi(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ob(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ob(e.marks)}}function ob(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Gf(t){return t.document||window.document}const lb=new WeakMap;function XE(t){let e=lb.get(t);return e===void 0&&lb.set(t,e=ZE(t)),e}function ZE(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 jc(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],i;if(typeof s!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(i=XE(r))&&i.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let l=s.indexOf(" ");l>0&&(n=s.slice(0,l),s=s.slice(l+1));let c,u=n?t.createElementNS(n,s):t.createElement(s),f=e[1],p=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){p=2;for(let m in f)if(f[m]!=null){let y=m.indexOf(" ");y>0?u.setAttributeNS(m.slice(0,y),m.slice(y+1),f[m]):m=="style"&&u.style?u.style.cssText=f[m]:u.setAttribute(m,f[m])}}for(let m=p;m<e.length;m++){let y=e[m];if(y===0){if(m<e.length-1||m>p)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else{let{dom:b,contentDOM:v}=jc(t,y,n,r);if(u.appendChild(b),v){if(c)throw new RangeError("Multiple content holes");c=v}}}return{dom:u,contentDOM:c}}const px=65535,mx=Math.pow(2,16);function eN(t,e){return t+e*mx}function ab(t){return t&px}function tN(t){return(t-(t&px))/mx}const gx=1,yx=2,Lc=4,bx=8;class Dh{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&bx)>0}get deletedBefore(){return(this.delInfo&(gx|Lc))>0}get deletedAfter(){return(this.delInfo&(yx|Lc))>0}get deletedAcross(){return(this.delInfo&Lc)>0}}class rr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&rr.empty)return rr.empty}recover(e){let n=0,r=ab(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+tN(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,i=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>e)break;let f=this.ranges[c+i],p=this.ranges[c+l],m=u+f;if(e<=m){let y=f?e==u?-1:e==m?1:n:n,b=u+s+(y<0?0:p);if(r)return b;let v=e==(n<0?u:m)?null:eN(c/3,e-u),w=e==u?yx:e==m?gx:Lc;return(n<0?e!=u:e!=m)&&(w|=bx),new Dh(b,w,v)}s+=p-f}return r?e+s:new Dh(e+s,0,null)}touches(e,n){let r=0,s=ab(n),i=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[c+i],p=u+f;if(e<=p&&c==s*3)return!0;r+=this.ranges[c+l]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let s=0,i=0;s<this.ranges.length;s+=3){let l=this.ranges[s],c=l-(this.inverted?i:0),u=l+(this.inverted?0:i),f=this.ranges[s+n],p=this.ranges[s+r];e(c,c+f,u,u+p),i+=p-f}}invert(){return new rr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?rr.empty:new rr(e<0?[0,-e,0]:[0,0,e])}}rr.empty=new rr([]);class Dl{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 Dl(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 Dl;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 i=this.from;i<this.to;i++){let l=this._maps[i],c=l.mapResult(e,n);if(c.recover!=null){let u=this.getMirror(i);if(u!=null&&u>i&&u<this.to){i=u,e=this._maps[u].recover(c.recover);continue}}s|=c.delInfo,e=c.pos}return r?e:new Dh(e,s,null)}}const qf=Object.create(null);class Dn{getMap(){return rr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=qf[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 qf)throw new RangeError("Duplicate use of step JSON ID "+e);return qf[e]=n,n.prototype.jsonID=e,n}}class on{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new on(e,null)}static fail(e){return new on(null,e)}static fromReplace(e,n,r,s){try{return on.ok(e.replace(n,r,s))}catch(i){if(i instanceof Hc)return on.fail(i.message);throw i}}}function bp(t,e,n){let r=[];for(let s=0;s<t.childCount;s++){let i=t.child(s);i.content.size&&(i=i.copy(bp(i.content,e,i))),i.isInline&&(i=e(i,n,s)),r.push(i)}return ae.fromArray(r)}class Fs extends Dn{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)),i=new Se(bp(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),s),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,i)}invert(){return new Tr(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 Fs(n.pos,r.pos,this.mark)}merge(e){return e instanceof Fs&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fs(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 Fs(n.from,n.to,e.markFromJSON(n.mark))}}Dn.jsonID("addMark",Fs);class Tr extends Dn{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 Se(bp(n.content,s=>s.mark(this.mark.removeFromSet(s.marks)),e),n.openStart,n.openEnd);return on.fromReplace(e,this.from,this.to,r)}invert(){return new Fs(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 Tr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Tr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tr(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 Tr(n.from,n.to,e.markFromJSON(n.mark))}}Dn.jsonID("removeMark",Tr);class Us extends Dn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Se(ae.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 Us(this.pos,n.marks[s]);return new Us(this.pos,this.mark)}}return new Oi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Us(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 Us(n.pos,e.markFromJSON(n.mark))}}Dn.jsonID("addNodeMark",Us);class Oi extends Dn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return on.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return on.fromReplace(e,this.pos,this.pos+1,new Se(ae.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Us(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Oi(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 Oi(n.pos,e.markFromJSON(n.mark))}}Dn.jsonID("removeNodeMark",Oi);class mn extends Dn{constructor(e,n,r,s=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=s}apply(e){return this.structure&&Ph(e,this.from,this.to)?on.fail("Structure replace would overwrite content"):on.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new rr([this.from,this.to-this.from,this.slice.size])}invert(e){return new mn(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 mn(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof mn)||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?Se.empty:new Se(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new mn(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?Se.empty:new Se(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new mn(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 mn(n.from,n.to,Se.fromJSON(e,n.slice),!!n.structure)}}Dn.jsonID("replace",mn);class gn extends Dn{constructor(e,n,r,s,i,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=s,this.slice=i,this.insert=l,this.structure=c}apply(e){if(this.structure&&(Ph(e,this.from,this.gapFrom)||Ph(e,this.gapTo,this.to)))return on.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return on.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?on.fromReplace(e,this.from,this.to,r):on.fail("Content does not fit in gap")}getMap(){return new rr([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 gn(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),i=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||s<n.pos||i>r.pos?null:new gn(n.pos,r.pos,s,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 gn(n.from,n.to,n.gapFrom,n.gapTo,Se.fromJSON(e,n.slice),n.insert,!!n.structure)}}Dn.jsonID("replaceAround",gn);function Ph(t,e,n){let r=t.resolve(e),s=n-e,i=r.depth;for(;s>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,s--;if(s>0){let l=r.node(i).maybeChild(r.indexAfter(i));for(;s>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,s--}}return!1}function nN(t,e,n,r){let s=[],i=[],l,c;t.doc.nodesBetween(e,n,(u,f,p)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&p.type.allowsMarkType(r.type)){let y=Math.max(f,e),b=Math.min(f+u.nodeSize,n),v=r.addToSet(m);for(let w=0;w<m.length;w++)m[w].isInSet(v)||(l&&l.to==y&&l.mark.eq(m[w])?l.to=b:s.push(l=new Tr(y,b,m[w])));c&&c.to==y?c.to=b:i.push(c=new Fs(y,b,r))}}),s.forEach(u=>t.step(u)),i.forEach(u=>t.step(u))}function rN(t,e,n,r){let s=[],i=0;t.doc.nodesBetween(e,n,(l,c)=>{if(!l.isInline)return;i++;let u=null;if(r instanceof $u){let f=l.marks,p;for(;p=r.isInSet(f);)(u||(u=[])).push(p),f=p.removeFromSet(f)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let f=Math.min(c+l.nodeSize,n);for(let p=0;p<u.length;p++){let m=u[p],y;for(let b=0;b<s.length;b++){let v=s[b];v.step==i-1&&m.eq(s[b].style)&&(y=v)}y?(y.to=f,y.step=i):s.push({style:m,from:Math.max(c,e),to:f,step:i})}}}),s.forEach(l=>t.step(new Tr(l.from,l.to,l.style)))}function vp(t,e,n,r=n.contentMatch,s=!0){let i=t.doc.nodeAt(e),l=[],c=e+1;for(let u=0;u<i.childCount;u++){let f=i.child(u),p=c+f.nodeSize,m=r.matchType(f.type);if(!m)l.push(new mn(c,p,Se.empty));else{r=m;for(let y=0;y<f.marks.length;y++)n.allowsMarkType(f.marks[y].type)||t.step(new Tr(c,p,f.marks[y]));if(s&&f.isText&&n.whitespace!="pre"){let y,b=/\r?\n|\r/g,v;for(;y=b.exec(f.text);)v||(v=new Se(ae.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),l.push(new mn(c+y.index,c+y.index+y[0].length,v))}}c=p}if(!r.validEnd){let u=r.fillBefore(ae.empty,!0);t.replace(c,c,new Se(u,0,0))}for(let u=l.length-1;u>=0;u--)t.step(l[u])}function sN(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ao(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,s=0,i=0;;--r){let l=t.$from.node(r),c=t.$from.index(r)+s,u=t.$to.indexAfter(r)-i;if(r<t.depth&&l.canReplace(c,u,n))return r;if(r==0||l.type.spec.isolating||!sN(l,c,u))break;c&&(s=1),u<l.childCount&&(i=1)}return null}function iN(t,e,n){let{$from:r,$to:s,depth:i}=e,l=r.before(i+1),c=s.after(i+1),u=l,f=c,p=ae.empty,m=0;for(let v=i,w=!1;v>n;v--)w||r.index(v)>0?(w=!0,p=ae.from(r.node(v).copy(p)),m++):u--;let y=ae.empty,b=0;for(let v=i,w=!1;v>n;v--)w||s.after(v+1)<s.end(v)?(w=!0,y=ae.from(s.node(v).copy(y)),b++):f++;t.step(new gn(u,f,l,c,new Se(p.append(y),m,b),p.size-m,!0))}function xp(t,e,n=null,r=t){let s=oN(t,e),i=s&&lN(r,e);return i?s.map(cb).concat({type:e,attrs:n}).concat(i.map(cb)):null}function cb(t){return{type:t,attrs:null}}function oN(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let l=i.length?i[0]:e;return n.canReplaceWith(r,s,l)?i:null}function lN(t,e){let{parent:n,startIndex:r,endIndex:s}=t,i=n.child(r),l=e.contentMatch.findWrapping(i.type);if(!l)return null;let u=(l.length?l[l.length-1]:e).contentMatch;for(let f=r;u&&f<s;f++)u=u.matchType(n.child(f).type);return!u||!u.validEnd?null:l}function aN(t,e,n){let r=ae.empty;for(let l=n.length-1;l>=0;l--){if(r.size){let c=n[l].type.contentMatch.matchFragment(r);if(!c||!c.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=ae.from(n[l].type.create(n[l].attrs,r))}let s=e.start,i=e.end;t.step(new gn(s,i,s,i,new Se(r,0,0),n.length,!0))}function cN(t,e,n,r,s){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(l,c)=>{let u=typeof s=="function"?s(l):s;if(l.isTextblock&&!l.hasMarkup(r,u)&&uN(t.doc,t.mapping.slice(i).map(c),r)){let f=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",v=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!v?f=!1:!b&&v&&(f=!0)}f===!1&&xx(t,l,c,i),vp(t,t.mapping.slice(i).map(c,1),r,void 0,f===null);let p=t.mapping.slice(i),m=p.map(c,1),y=p.map(c+l.nodeSize,1);return t.step(new gn(m,y,m+1,y-1,new Se(ae.from(r.create(u,null,l.marks)),0,0),1,!0)),f===!0&&vx(t,l,c,i),!1}})}function vx(t,e,n,r){e.forEach((s,i)=>{if(s.isText){let l,c=/\r?\n|\r/g;for(;l=c.exec(s.text);){let u=t.mapping.slice(r).map(n+1+i+l.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function xx(t,e,n,r){e.forEach((s,i)=>{if(s.type==s.type.schema.linebreakReplacement){let l=t.mapping.slice(r).map(n+1+i);t.replaceWith(l,l+1,e.type.schema.text(`
52
+ `))}})}function uN(t,e,n){let r=t.resolve(e),s=r.index();return r.parent.canReplaceWith(s,s+1,n)}function dN(t,e,n,r,s){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let l=n.create(r,null,s||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,l);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new gn(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new Se(ae.from(l),0,0),1,!0))}function us(t,e,n=1,r){let s=t.resolve(e),i=s.depth-n,l=r&&r[r.length-1]||s.parent;if(i<0||s.parent.type.spec.isolating||!s.parent.canReplace(s.index(),s.parent.childCount)||!l.type.validContent(s.parent.content.cutByIndex(s.index(),s.parent.childCount)))return!1;for(let f=s.depth-1,p=n-2;f>i;f--,p--){let m=s.node(f),y=s.index(f);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(y,m.childCount),v=r&&r[p+1];v&&(b=b.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[p]||m;if(!m.canReplace(y+1,m.childCount)||!w.type.validContent(b))return!1}let c=s.indexAfter(i),u=r&&r[0];return s.node(i).canReplaceWith(c,c,u?u.type:s.node(i+1).type)}function fN(t,e,n=1,r){let s=t.doc.resolve(e),i=ae.empty,l=ae.empty;for(let c=s.depth,u=s.depth-n,f=n-1;c>u;c--,f--){i=ae.from(s.node(c).copy(i));let p=r&&r[f];l=ae.from(p?p.type.create(p.attrs,l):s.node(c).copy(l))}t.step(new mn(e,e,new Se(i.append(l),n,n),!0))}function Xs(t,e){let n=t.resolve(e),r=n.index();return wx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function hN(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 i=e.child(s),l=i.type==r?t.type.schema.nodes.text:i.type;if(n=n.matchType(l),!n||!t.type.allowsMarks(i.marks))return!1}return n.validEnd}function wx(t,e){return!!(t&&e&&!t.isLeaf&&hN(t,e))}function Fu(t,e,n=-1){let r=t.resolve(e);for(let s=r.depth;;s--){let i,l,c=r.index(s);if(s==r.depth?(i=r.nodeBefore,l=r.nodeAfter):n>0?(i=r.node(s+1),c++,l=r.node(s).maybeChild(c)):(i=r.node(s).maybeChild(c-1),l=r.node(s+1)),i&&!i.isTextblock&&wx(i,l)&&r.node(s).canReplace(c,c+1))return e;if(s==0)break;e=n<0?r.before(s):r.after(s)}}function pN(t,e,n){let r=null,{linebreakReplacement:s}=t.doc.type.schema,i=t.doc.resolve(e-n),l=i.node().type;if(s&&l.inlineContent){let p=l.whitespace=="pre",m=!!l.contentMatch.matchType(s);p&&!m?r=!1:!p&&m&&(r=!0)}let c=t.steps.length;if(r===!1){let p=t.doc.resolve(e+n);xx(t,p.node(),p.before(),c)}l.inlineContent&&vp(t,e+n-1,l,i.node().contentMatchAt(i.index()),r==null);let u=t.mapping.slice(c),f=u.map(e-n);if(t.step(new mn(f,u.map(e+n,-1),Se.empty,!0)),r===!0){let p=t.doc.resolve(f);vx(t,p.node(),p.before(),t.steps.length)}return t}function mN(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 i=r.index(s);if(r.node(s).canReplaceWith(i,i,n))return r.before(s+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let s=r.depth-1;s>=0;s--){let i=r.indexAfter(s);if(r.node(s).canReplaceWith(i,i,n))return r.after(s+1);if(i<r.node(s).childCount)return null}return null}function kx(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let s=n.content;for(let i=0;i<n.openStart;i++)s=s.firstChild.content;for(let i=1;i<=(n.openStart==0&&n.size?2:1);i++)for(let l=r.depth;l>=0;l--){let c=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(c>0?1:0),f=r.node(l),p=!1;if(i==1)p=f.canReplace(u,u,s);else{let m=f.contentMatchAt(u).findWrapping(s.firstChild.type);p=m&&f.canReplaceWith(u,u,m[0])}if(p)return c==0?r.pos:c<0?r.before(l+1):r.after(l+1)}return null}function Uu(t,e,n=e,r=Se.empty){if(e==n&&!r.size)return null;let s=t.resolve(e),i=t.resolve(n);return Sx(s,i,r)?new mn(e,n,r):new gN(s,i,r).fit()}function Sx(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class gN{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=ae.empty;for(let s=0;s<=e.depth;s++){let i=e.node(s);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(s))})}for(let s=e.depth;s>0;s--)this.placed=ae.from(e.node(s).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let f=this.findFittable();f?this.placeNodes(f):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 i=this.placed,l=r.depth,c=s.depth;for(;l&&c&&i.childCount==1;)i=i.firstChild.content,l--,c--;let u=new Se(i,l,c);return e>-1?new gn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new mn(r.pos,s.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,s=this.unplaced.openEnd;r<e;r++){let i=n.firstChild;if(n.childCount>1&&(s=0),i.type.spec.isolating&&s<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let s,i=null;r?(i=Jf(this.unplaced.content,r-1).firstChild,s=i.content):s=this.unplaced.content;let l=s.firstChild;for(let c=this.depth;c>=0;c--){let{type:u,match:f}=this.frontier[c],p,m=null;if(n==1&&(l?f.matchType(l.type)||(m=f.fillBefore(ae.from(l),!1)):i&&u.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:c,parent:i,inject:m};if(n==2&&l&&(p=f.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:c,parent:i,wrap:p};if(i&&f.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,s=Jf(e,n);return!s.childCount||s.firstChild.isLeaf?!1:(this.unplaced=new Se(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=Jf(e,n);if(s.childCount<=1&&n>0){let i=e.size-n<=n+s.size;this.unplaced=new Se(vl(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new Se(vl(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:s,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let w=0;w<i.length;w++)this.openFrontierNode(i[w]);let l=this.unplaced,c=r?r.content:l.content,u=l.openStart-e,f=0,p=[],{match:m,type:y}=this.frontier[n];if(s){for(let w=0;w<s.childCount;w++)p.push(s.child(w));m=m.matchFragment(s)}let b=c.size+e-(l.content.size-l.openEnd);for(;f<c.childCount;){let w=c.child(f),k=m.matchType(w.type);if(!k)break;f++,(f>1||u==0||w.content.size)&&(m=k,p.push(Ex(w.mark(y.allowedMarks(w.marks)),f==1?u:0,f==c.childCount?b:-1)))}let v=f==c.childCount;v||(b=-1),this.placed=xl(this.placed,n,ae.from(p)),this.frontier[n].match=m,v&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let w=0,k=c;w<b;w++){let N=k.lastChild;this.frontier.push({type:N.type,match:N.contentMatchAt(N.childCount)}),k=N.content}this.unplaced=v?e==0?Se.empty:new Se(vl(l.content,e-1,1),e-1,b<0?l.openEnd:e-1):new Se(vl(l.content,e,f),l.openStart,l.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!Yf(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],i=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),l=Yf(e,n,s,r,i);if(l){for(let c=n-1;c>=0;c--){let{match:u,type:f}=this.frontier[c],p=Yf(e,c,f,u,!0);if(!p||p.childCount)continue e}return{depth:n,fit:l,move:i?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=xl(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let s=e.node(r),i=s.type.contentMatch.fillBefore(s.content,!0,e.index(r));this.openFrontierNode(s.type,s.attrs,i)}return e}openFrontierNode(e,n=null,r){let s=this.frontier[this.depth];s.match=s.match.matchType(e),this.placed=xl(this.placed,this.depth,ae.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(ae.empty,!0);n.childCount&&(this.placed=xl(this.placed,this.frontier.length,n))}}function vl(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(vl(t.firstChild.content,e-1,n)))}function xl(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(xl(t.lastChild.content,e-1,n)))}function Jf(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function Ex(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,Ex(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(ae.empty,!0)))),t.copy(r)}function Yf(t,e,n,r,s){let i=t.node(e),l=s?t.indexAfter(e):t.index(e);if(l==i.childCount&&!n.compatibleContent(i.type))return null;let c=r.fillBefore(i.content,!0,l);return c&&!yN(n,i.content,l)?c:null}function yN(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function bN(t){return t.spec.defining||t.spec.definingForContent}function vN(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let s=t.doc.resolve(e),i=t.doc.resolve(n);if(Sx(s,i,r))return t.step(new mn(e,n,r));let l=Cx(s,i);l[l.length-1]==0&&l.pop();let c=-(s.depth+1);l.unshift(c);for(let y=s.depth,b=s.pos-1;y>0;y--,b--){let v=s.node(y).type.spec;if(v.defining||v.definingAsContext||v.isolating)break;l.indexOf(y)>-1?c=y:s.before(y)==b&&l.splice(1,0,-y)}let u=l.indexOf(c),f=[],p=r.openStart;for(let y=r.content,b=0;;b++){let v=y.firstChild;if(f.push(v),b==r.openStart)break;y=v.content}for(let y=p-1;y>=0;y--){let b=f[y],v=bN(b.type);if(v&&!b.sameMarkup(s.node(Math.abs(c)-1)))p=y;else if(v||!b.type.isTextblock)break}for(let y=r.openStart;y>=0;y--){let b=(y+p+1)%(r.openStart+1),v=f[b];if(v)for(let w=0;w<l.length;w++){let k=l[(w+u)%l.length],N=!0;k<0&&(N=!1,k=-k);let T=s.node(k-1),I=s.index(k-1);if(T.canReplaceWith(I,I,v.type,v.marks))return t.replace(s.before(k),N?i.after(k):n,new Se(Nx(r.content,0,r.openStart,b),b,r.openEnd))}}let m=t.steps.length;for(let y=l.length-1;y>=0&&(t.replace(e,n,r),!(t.steps.length>m));y--){let b=l[y];b<0||(e=s.before(b),n=i.after(b))}}function Nx(t,e,n,r,s){if(e<n){let i=t.firstChild;t=t.replaceChild(0,i.copy(Nx(i.content,e+1,n,r,i)))}if(e>r){let i=s.contentMatchAt(0),l=i.fillBefore(t).append(t);t=l.append(i.matchFragment(l).fillBefore(ae.empty,!0))}return t}function xN(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let s=mN(t.doc,e,r.type);s!=null&&(e=n=s)}t.replaceRange(e,n,new Se(ae.from(r),0,0))}function wN(t,e,n){let r=t.doc.resolve(e),s=t.doc.resolve(n),i=Cx(r,s);for(let l=0;l<i.length;l++){let c=i[l],u=l==i.length-1;if(u&&c==0||r.node(c).type.contentMatch.validEnd)return t.delete(r.start(c),s.end(c));if(c>0&&(u||r.node(c-1).canReplace(r.index(c-1),s.indexAfter(c-1))))return t.delete(r.before(c),s.after(c))}for(let l=1;l<=r.depth&&l<=s.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&s.end(l)-n!=s.depth-l&&r.start(l-1)==s.start(l-1)&&r.node(l-1).canReplace(r.index(l-1),s.index(l-1)))return t.delete(r.before(l),n);t.delete(e,n)}function Cx(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let s=r;s>=0;s--){let i=t.start(s);if(i<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;(i==e.start(s)||s==t.depth&&s==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&s&&e.start(s-1)==i-1)&&n.push(s)}return n}class xo extends Dn{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 on.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let s=n.type.create(r,null,n.marks);return on.fromReplace(e,this.pos,this.pos+1,new Se(ae.from(s),0,n.isLeaf?0:1))}getMap(){return rr.empty}invert(e){return new xo(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 xo(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 xo(n.pos,n.attr,n.value)}}Dn.jsonID("attr",xo);class Pl extends Dn{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 on.ok(r)}getMap(){return rr.empty}invert(e){return new Pl(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 Pl(n.attr,n.value)}}Dn.jsonID("docAttr",Pl);let So=class extends Error{};So=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};So.prototype=Object.create(Error.prototype);So.prototype.constructor=So;So.prototype.name="TransformError";class wp{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dl}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new So(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}changedRange(){let e=1e9,n=-1e9;for(let r=0;r<this.mapping.maps.length;r++){let s=this.mapping.maps[r];r&&(e=s.map(e,1),n=s.map(n,-1)),s.forEach((i,l,c,u)=>{e=Math.min(e,c),n=Math.max(n,u)})}return e==1e9?null:{from:e,to:n}}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=Se.empty){let s=Uu(this.doc,e,n,r);return s&&this.step(s),this}replaceWith(e,n,r){return this.replace(e,n,new Se(ae.from(r),0,0))}delete(e,n){return this.replace(e,n,Se.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return vN(this,e,n,r),this}replaceRangeWith(e,n,r){return xN(this,e,n,r),this}deleteRange(e,n){return wN(this,e,n),this}lift(e,n){return iN(this,e,n),this}join(e,n=1){return pN(this,e,n),this}wrap(e,n){return aN(this,e,n),this}setBlockType(e,n=e,r,s=null){return cN(this,e,n,r,s),this}setNodeMarkup(e,n,r=null,s){return dN(this,e,n,r,s),this}setNodeAttribute(e,n,r){return this.step(new xo(e,n,r)),this}setDocAttribute(e,n){return this.step(new Pl(e,n)),this}addNodeMark(e,n){return this.step(new Us(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 At)n.isInSet(r.marks)&&this.step(new Oi(e,n));else{let s=r.marks,i,l=[];for(;i=n.isInSet(s);)l.push(new Oi(e,i)),s=i.removeFromSet(s);for(let c=l.length-1;c>=0;c--)this.step(l[c])}return this}split(e,n=1,r){return fN(this,e,n,r),this}addMark(e,n,r){return nN(this,e,n,r),this}removeMark(e,n,r){return rN(this,e,n,r),this}clearIncompatible(e,n,r){return vp(this,e,n,r),this}}const Qf=Object.create(null);class Ye{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new _x(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=Se.empty){let r=n.content.lastChild,s=null;for(let c=0;c<n.openEnd;c++)s=r,r=r.lastChild;let i=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:f}=l[c],p=e.mapping.slice(i);e.replaceRange(p.map(u.pos),p.map(f.pos),c?Se.empty:n),c==0&&fb(e,i,(r?r.isInline:s&&s.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,s=this.ranges;for(let i=0;i<s.length;i++){let{$from:l,$to:c}=s[i],u=e.mapping.slice(r),f=u.map(l.pos),p=u.map(c.pos);i?e.deleteRange(f,p):(e.replaceRangeWith(f,p,n),fb(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let s=e.parent.inlineContent?new Fe(e):po(e.node(0),e.parent,e.pos,e.index(),n,r);if(s)return s;for(let i=e.depth-1;i>=0;i--){let l=n<0?po(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):po(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ir(e.node(0))}static atStart(e){return po(e,e,0,0,1)||new ir(e)}static atEnd(e){return po(e,e,e.content.size,e.childCount,-1)||new ir(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Qf[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 Qf)throw new RangeError("Duplicate use of selection JSON ID "+e);return Qf[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Fe.between(this.$anchor,this.$head).getBookmark()}}Ye.prototype.visible=!0;class _x{constructor(e,n){this.$from=e,this.$to=n}}let ub=!1;function db(t){!ub&&!t.parent.inlineContent&&(ub=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Fe extends Ye{constructor(e,n=e){db(e),db(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 Ye.near(r);let s=e.resolve(n.map(this.anchor));return new Fe(s.parent.inlineContent?s:r,r)}replace(e,n=Se.empty){if(super.replace(e,n),n==Se.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Fe&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Hu(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 Fe(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 i=Ye.findFrom(n,r,!0)||Ye.findFrom(n,-r,!0);if(i)n=i.$head;else return Ye.near(n,r)}return e.parent.inlineContent||(s==0?e=n:(e=(Ye.findFrom(e,-r,!0)||Ye.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=s<0&&(e=n))),new Fe(e,n)}}Ye.jsonID("text",Fe);class Hu{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Hu(e.map(this.anchor),e.map(this.head))}resolve(e){return Fe.between(e.resolve(this.anchor),e.resolve(this.head))}}class ze extends Ye{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),i=e.resolve(s);return r?Ye.near(i):new ze(i)}content(){return new Se(ae.from(this.node),0,0)}eq(e){return e instanceof ze&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new kp(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new ze(e.resolve(n.anchor))}static create(e,n){return new ze(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}ze.prototype.visible=!1;Ye.jsonID("node",ze);class kp{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Hu(r,r):new kp(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&ze.isSelectable(r)?new ze(n):Ye.near(n)}}class ir extends Ye{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Se.empty){if(n==Se.empty){e.delete(0,e.doc.content.size);let r=Ye.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new ir(e)}map(e){return new ir(e)}eq(e){return e instanceof ir}getBookmark(){return kN}}Ye.jsonID("all",ir);const kN={map(){return this},resolve(t){return new ir(t)}};function po(t,e,n,r,s,i=!1){if(e.inlineContent)return Fe.create(t,n);for(let l=r-(s>0?0:1);s>0?l<e.childCount:l>=0;l+=s){let c=e.child(l);if(c.isAtom){if(!i&&ze.isSelectable(c))return ze.create(t,n-(s<0?c.nodeSize:0))}else{let u=po(t,c,n+s,s<0?c.childCount:0,s,i);if(u)return u}n+=c.nodeSize*s}return null}function fb(t,e,n){let r=t.steps.length-1;if(r<e)return;let s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;let i=t.mapping.maps[r],l;i.forEach((c,u,f,p)=>{l==null&&(l=p)}),t.setSelection(Ye.near(t.doc.resolve(l),n))}const hb=1,ac=2,pb=4;class SN extends wp{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|hb)&~ac,this.storedMarks=null,this}get selectionSet(){return(this.updated&hb)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ac,this}ensureMarks(e){return At.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&ac)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~ac,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)||At.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),!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let l=this.doc.resolve(n);i=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,s.text(e,i)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ye.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|=pb,this}get scrolledIntoView(){return(this.updated&pb)>0}}function mb(t,e){return!e||!t?t:t.bind(e)}class wl{constructor(e,n,r){this.name=e,this.init=mb(n.init,r),this.apply=mb(n.apply,r)}}const EN=[new wl("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new wl("selection",{init(t,e){return t.selection||Ye.atStart(e.doc)},apply(t){return t.selection}}),new wl("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new wl("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Xf{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=EN.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 wl(r.key,r.spec.state,r))})}}class vo{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 i=!1;for(let l=0;l<this.config.plugins.length;l++){let c=this.config.plugins[l];if(c.spec.appendTransaction){let u=s?s[l].n:0,f=s?s[l].state:this,p=u<n.length&&c.spec.appendTransaction.call(c,u?n.slice(u):n,f,r);if(p&&r.filterTransaction(p,l)){if(p.setMeta("appendedTransaction",e),!s){s=[];for(let m=0;m<this.config.plugins.length;m++)s.push(m<l?{state:r,n:n.length}:{state:this,n:0})}n.push(p),r=r.applyInner(p),i=!0}s&&(s[l]={state:r,n:n.length})}}if(!i)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new vo(this.config),r=this.config.fields;for(let s=0;s<r.length;s++){let i=r[s];n[i.name]=i.apply(e,this[i.name],this,n)}return n}get tr(){return new SN(this)}static create(e){let n=new Xf(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new vo(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 Xf(this.schema,e.plugins),r=n.fields,s=new vo(n);for(let i=0;i<r.length;i++){let l=r[i].name;s[l]=this.hasOwnProperty(l)?this[l]:r[i].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],i=s.spec.state;i&&i.toJSON&&(n[r]=i.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 Xf(e.schema,e.plugins),i=new vo(s);return s.fields.forEach(l=>{if(l.name=="doc")i.doc=Mr.fromJSON(e.schema,n.doc);else if(l.name=="selection")i.selection=Ye.fromJSON(i.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let c in r){let u=r[c],f=u.spec.state;if(u.key==l.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,c)){i[l.name]=f.fromJSON.call(u,e,n[c],i);return}}i[l.name]=l.init(e,i)}}),i}}function Tx(t,e,n){for(let r in t){let s=t[r];s instanceof Function?s=s.bind(e):r=="handleDOMEvents"&&(s=Tx(s,e,{})),n[r]=s}return n}class kt{constructor(e){this.spec=e,this.props={},e.props&&Tx(e.props,this,this.props),this.key=e.key?e.key.key:Mx("plugin")}getState(e){return e[this.key]}}const Zf=Object.create(null);function Mx(t){return t in Zf?t+"$"+ ++Zf[t]:(Zf[t]=0,t+"$")}class Ot{constructor(e="key"){this.key=Mx(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Sp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ax(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ox=(t,e,n)=>{let r=Ax(t,n);if(!r)return!1;let s=Ep(r);if(!s){let l=r.blockRange(),c=l&&Ao(l);return c==null?!1:(e&&e(t.tr.lift(l,c).scrollIntoView()),!0)}let i=s.nodeBefore;if($x(t,s,e,-1))return!0;if(r.parent.content.size==0&&(Eo(i,"end")||ze.isSelectable(i)))for(let l=r.depth;;l--){let c=Uu(t.doc,r.before(l),r.after(l),Se.empty);if(c&&c.slice.size<c.to-c.from){if(e){let u=t.tr.step(c);u.setSelection(Eo(i,"end")?Ye.findFrom(u.doc.resolve(u.mapping.map(s.pos,-1)),-1):ze.create(u.doc,s.pos-i.nodeSize)),e(u.scrollIntoView())}return!0}if(l==1||r.node(l-1).childCount>1)break}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos-i.nodeSize,s.pos).scrollIntoView()),!0):!1},NN=(t,e,n)=>{let r=Ax(t,n);if(!r)return!1;let s=Ep(r);return s?Rx(t,s,e):!1},CN=(t,e,n)=>{let r=jx(t,n);if(!r)return!1;let s=Np(r);return s?Rx(t,s,e):!1};function Rx(t,e,n){let r=e.nodeBefore,s=r,i=e.pos-1;for(;!s.isTextblock;i--){if(s.type.spec.isolating)return!1;let p=s.lastChild;if(!p)return!1;s=p}let l=e.nodeAfter,c=l,u=e.pos+1;for(;!c.isTextblock;u++){if(c.type.spec.isolating)return!1;let p=c.firstChild;if(!p)return!1;c=p}let f=Uu(t.doc,i,u,Se.empty);if(!f||f.from!=i||f instanceof mn&&f.slice.size>=u-i)return!1;if(n){let p=t.tr.step(f);p.setSelection(Fe.create(p.doc,i)),n(p.scrollIntoView())}return!0}function Eo(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 Ix=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ep(r)}let l=i&&i.nodeBefore;return!l||!ze.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ze.create(t.doc,i.pos-l.nodeSize)).scrollIntoView()),!0)};function Ep(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 jx(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const Lx=(t,e,n)=>{let r=jx(t,n);if(!r)return!1;let s=Np(r);if(!s)return!1;let i=s.nodeAfter;if($x(t,s,e,1))return!0;if(r.parent.content.size==0&&(Eo(i,"start")||ze.isSelectable(i))){let l=Uu(t.doc,r.before(),r.after(),Se.empty);if(l&&l.slice.size<l.to-l.from){if(e){let c=t.tr.step(l);c.setSelection(Eo(i,"start")?Ye.findFrom(c.doc.resolve(c.mapping.map(s.pos)),1):ze.create(c.doc,c.mapping.map(s.pos))),e(c.scrollIntoView())}return!0}}return i.isAtom&&s.depth==r.depth-1?(e&&e(t.tr.delete(s.pos,s.pos+i.nodeSize).scrollIntoView()),!0):!1},Dx=(t,e,n)=>{let{$head:r,empty:s}=t.selection,i=r;if(!s)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Np(r)}let l=i&&i.nodeAfter;return!l||!ze.isSelectable(l)?!1:(e&&e(t.tr.setSelection(ze.create(t.doc,i.pos)).scrollIntoView()),!0)};function Np(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 _N=(t,e)=>{let n=t.selection,r=n instanceof ze,s;if(r){if(n.node.isTextblock||!Xs(t.doc,n.from))return!1;s=n.from}else if(s=Fu(t.doc,n.from,-1),s==null)return!1;if(e){let i=t.tr.join(s);r&&i.setSelection(ze.create(i.doc,s-t.doc.resolve(s).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},TN=(t,e)=>{let n=t.selection,r;if(n instanceof ze){if(n.node.isTextblock||!Xs(t.doc,n.to))return!1;r=n.to}else if(r=Fu(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},MN=(t,e)=>{let{$from:n,$to:r}=t.selection,s=n.blockRange(r),i=s&&Ao(s);return i==null?!1:(e&&e(t.tr.lift(s,i).scrollIntoView()),!0)},Px=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
53
+ `).scrollIntoView()),!0)};function Cp(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 AN=(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),i=n.indexAfter(-1),l=Cp(s.contentMatchAt(i));if(!l||!s.canReplaceWith(i,i,l))return!1;if(e){let c=n.after(),u=t.tr.replaceWith(c,c,l.createAndFill());u.setSelection(Ye.near(u.doc.resolve(c),1)),e(u.scrollIntoView())}return!0},Bx=(t,e)=>{let n=t.selection,{$from:r,$to:s}=n;if(n instanceof ir||r.parent.inlineContent||s.parent.inlineContent)return!1;let i=Cp(s.parent.contentMatchAt(s.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let l=(!r.parentOffset&&s.index()<s.parent.childCount?r:s).pos,c=t.tr.insert(l,i.createAndFill());c.setSelection(Fe.create(c.doc,l+1)),e(c.scrollIntoView())}return!0},zx=(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 i=n.before();if(us(t.doc,i))return e&&e(t.tr.split(i).scrollIntoView()),!0}let r=n.blockRange(),s=r&&Ao(r);return s==null?!1:(e&&e(t.tr.lift(r,s).scrollIntoView()),!0)};function ON(t){return(e,n)=>{let{$from:r,$to:s}=e.selection;if(e.selection instanceof ze&&e.selection.node.isBlock)return!r.parentOffset||!us(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],l,c,u=!1,f=!1;for(let b=r.depth;;b--)if(r.node(b).isBlock){u=r.end(b)==r.pos+(r.depth-b),f=r.start(b)==r.pos-(r.depth-b),c=Cp(r.node(b-1).contentMatchAt(r.indexAfter(b-1))),i.unshift(u&&c?{type:c}:null),l=b;break}else{if(b==1)return!1;i.unshift(null)}let p=e.tr;(e.selection instanceof Fe||e.selection instanceof ir)&&p.deleteSelection();let m=p.mapping.map(r.pos),y=us(p.doc,m,i.length,i);if(y||(i[0]=c?{type:c}:null,y=us(p.doc,m,i.length,i)),!y)return!1;if(p.split(m,i.length,i),!u&&f&&r.node(l).type!=c){let b=p.mapping.map(r.before(l)),v=p.doc.resolve(b);c&&r.node(l-1).canReplaceWith(v.index(),v.index()+1,c)&&p.setNodeMarkup(p.mapping.map(r.before(l)),c)}return n&&n(p.scrollIntoView()),!0}}const RN=ON(),IN=(t,e)=>{let{$from:n,to:r}=t.selection,s,i=n.sharedDepth(r);return i==0?!1:(s=n.before(i),e&&e(t.tr.setSelection(ze.create(t.doc,s))),!0)};function jN(t,e,n){let r=e.nodeBefore,s=e.nodeAfter,i=e.index();return!r||!s||!r.type.compatibleContent(s.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(s.isTextblock||Xs(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function $x(t,e,n,r){let s=e.nodeBefore,i=e.nodeAfter,l,c,u=s.type.spec.isolating||i.type.spec.isolating;if(!u&&jN(t,e,n))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(l=(c=s.contentMatchAt(s.childCount)).findWrapping(i.type))&&c.matchType(l[0]||i.type).validEnd){if(n){let b=e.pos+i.nodeSize,v=ae.empty;for(let N=l.length-1;N>=0;N--)v=ae.from(l[N].create(null,v));v=ae.from(s.copy(v));let w=t.tr.step(new gn(e.pos-1,b,e.pos,b,new Se(v,1,0),l.length,!0)),k=w.doc.resolve(b+2*l.length);k.nodeAfter&&k.nodeAfter.type==s.type&&Xs(w.doc,k.pos)&&w.join(k.pos),n(w.scrollIntoView())}return!0}let p=i.type.spec.isolating||r>0&&u?null:Ye.findFrom(e,1),m=p&&p.$from.blockRange(p.$to),y=m&&Ao(m);if(y!=null&&y>=e.depth)return n&&n(t.tr.lift(m,y).scrollIntoView()),!0;if(f&&Eo(i,"start",!0)&&Eo(s,"end")){let b=s,v=[];for(;v.push(b),!b.isTextblock;)b=b.lastChild;let w=i,k=1;for(;!w.isTextblock;w=w.firstChild)k++;if(b.canReplace(b.childCount,b.childCount,w.content)){if(n){let N=ae.empty;for(let I=v.length-1;I>=0;I--)N=ae.from(v[I].copy(N));let T=t.tr.step(new gn(e.pos-v.length,e.pos+i.nodeSize,e.pos+k,e.pos+i.nodeSize-k,new Se(N,v.length,0),0,!0));n(T.scrollIntoView())}return!0}}return!1}function Fx(t){return function(e,n){let r=e.selection,s=t<0?r.$from:r.$to,i=s.depth;for(;s.node(i).isInline;){if(!i)return!1;i--}return s.node(i).isTextblock?(n&&n(e.tr.setSelection(Fe.create(e.doc,t<0?s.start(i):s.end(i)))),!0):!1}}const LN=Fx(-1),DN=Fx(1);function PN(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,l=s.blockRange(i),c=l&&xp(l,t,e);return c?(r&&r(n.tr.wrap(l,c).scrollIntoView()),!0):!1}}function gb(t,e=null){return function(n,r){let s=!1;for(let i=0;i<n.selection.ranges.length&&!s;i++){let{$from:{pos:l},$to:{pos:c}}=n.selection.ranges[i];n.doc.nodesBetween(l,c,(u,f)=>{if(s)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)s=!0;else{let p=n.doc.resolve(f),m=p.index();s=p.parent.canReplaceWith(m,m+1,t)}})}if(!s)return!1;if(r){let i=n.tr;for(let l=0;l<n.selection.ranges.length;l++){let{$from:{pos:c},$to:{pos:u}}=n.selection.ranges[l];i.setBlockType(c,u,t,e)}r(i.scrollIntoView())}return!0}}function _p(...t){return function(e,n,r){for(let s=0;s<t.length;s++)if(t[s](e,n,r))return!0;return!1}}_p(Sp,Ox,Ix);_p(Sp,Lx,Dx);_p(Px,Bx,zx,RN);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function BN(t,e=null){return function(n,r){let{$from:s,$to:i}=n.selection,l=s.blockRange(i);if(!l)return!1;let c=r?n.tr:null;return zN(c,l,t,e)?(r&&r(c.scrollIntoView()),!0):!1}}function zN(t,e,n,r=null){let s=!1,i=e,l=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 u=l.resolve(e.start-2);i=new Vc(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Vc(e.$from,l.resolve(e.$to.end(e.depth)),e.depth)),s=!0}let c=xp(i,n,r,e);return c?(t&&$N(t,e,c,s,n),!0):!1}function $N(t,e,n,r,s){let i=ae.empty;for(let p=n.length-1;p>=0;p--)i=ae.from(n[p].type.create(n[p].attrs,i));t.step(new gn(e.start-(r?2:0),e.end,e.start,e.end,new Se(i,0,0),n.length,!0));let l=0;for(let p=0;p<n.length;p++)n[p].type==s&&(l=p+1);let c=n.length-l,u=e.start+n.length-(r?2:0),f=e.parent;for(let p=e.startIndex,m=e.endIndex,y=!0;p<m;p++,y=!1)!y&&us(t.doc,u,c)&&(t.split(u,c),u+=2*c),u+=f.child(p).nodeSize;return t}function FN(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,l=>l.childCount>0&&l.firstChild.type==t);return i?n?r.node(i.depth-1).type==t?UN(e,n,t,i):HN(e,n,i):!0:!1}}function UN(t,e,n,r){let s=t.tr,i=r.end,l=r.$to.end(r.depth);i<l&&(s.step(new gn(i-1,l,i,l,new Se(ae.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Vc(s.doc.resolve(r.$from.pos),s.doc.resolve(l),r.depth));const c=Ao(r);if(c==null)return!1;s.lift(r,c);let u=s.doc.resolve(s.mapping.map(i,-1)-1);return Xs(s.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&s.join(u.pos),e(s.scrollIntoView()),!0}function HN(t,e,n){let r=t.tr,s=n.parent;for(let b=n.end,v=n.endIndex-1,w=n.startIndex;v>w;v--)b-=s.child(v).nodeSize,r.delete(b-1,b+1);let i=r.doc.resolve(n.start),l=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let c=n.startIndex==0,u=n.endIndex==s.childCount,f=i.node(-1),p=i.index(-1);if(!f.canReplace(p+(c?0:1),p+1,l.content.append(u?ae.empty:ae.from(s))))return!1;let m=i.pos,y=m+l.nodeSize;return r.step(new gn(m-(c?1:0),y+(u?1:0),m+1,y-1,new Se((c?ae.empty:ae.from(s.copy(ae.empty))).append(u?ae.empty:ae.from(s.copy(ae.empty))),c?0:1,u?0:1),c?0:1)),e(r.scrollIntoView()),!0}function WN(t){return function(e,n){let{$from:r,$to:s}=e.selection,i=r.blockRange(s,f=>f.childCount>0&&f.firstChild.type==t);if(!i)return!1;let l=i.startIndex;if(l==0)return!1;let c=i.parent,u=c.child(l-1);if(u.type!=t)return!1;if(n){let f=u.lastChild&&u.lastChild.type==c.type,p=ae.from(f?t.create():null),m=new Se(ae.from(t.create(null,ae.from(c.type.create(null,p)))),f?3:1,0),y=i.start,b=i.end;n(e.tr.step(new gn(y-(f?3:1),b,y,b,m,1,!0)).scrollIntoView())}return!0}}const Cn=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},No=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bh=null;const ls=function(t,e,n){let r=Bh||(Bh=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},VN=function(){Bh=null},Ri=function(t,e,n,r){return n&&(yb(t,e,n,r,-1)||yb(t,e,n,r,1))},KN=/^(img|br|input|textarea|hr)$/i;function yb(t,e,n,r,s){for(var i;;){if(t==n&&e==r)return!0;if(e==(s<0?0:gr(t))){let l=t.parentNode;if(!l||l.nodeType!=1||Gl(t)||KN.test(t.nodeName)||t.contentEditable=="false")return!1;e=Cn(t)+(s<0?0:1),t=l}else if(t.nodeType==1){let l=t.childNodes[e+(s<0?-1:0)];if(l.nodeType==1&&l.contentEditable=="false")if(!((i=l.pmViewDesc)===null||i===void 0)&&i.ignoreForSelection)e+=s;else return!1;else t=l,e=s<0?gr(t):0}else return!1}}function gr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function GN(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=gr(t)}else if(t.parentNode&&!Gl(t))e=Cn(t),t=t.parentNode;else return null}}function qN(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&&!Gl(t))e=Cn(t)+1,t=t.parentNode;else return null}}function JN(t,e,n){for(let r=e==0,s=e==gr(t);r||s;){if(t==n)return!0;let i=Cn(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,s=s&&i==gr(t)}}function Gl(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 Wu=function(t){return t.focusNode&&Ri(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function xi(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function YN(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function QN(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(gr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(gr(r.startContainer),r.startOffset)}}}const Hr=typeof navigator<"u"?navigator:null,bb=typeof document<"u"?document:null,Zs=Hr&&Hr.userAgent||"",zh=/Edge\/(\d+)/.exec(Zs),Ux=/MSIE \d/.exec(Zs),$h=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zs),Xn=!!(Ux||$h||zh),Vs=Ux?document.documentMode:$h?+$h[1]:zh?+zh[1]:0,yr=!Xn&&/gecko\/(\d+)/i.test(Zs);yr&&+(/Firefox\/(\d+)/.exec(Zs)||[0,0])[1];const Fh=!Xn&&/Chrome\/(\d+)/.exec(Zs),Tn=!!Fh,Hx=Fh?+Fh[1]:0,jn=!Xn&&!!Hr&&/Apple Computer/.test(Hr.vendor),Co=jn&&(/Mobile\/\w+/.test(Zs)||!!Hr&&Hr.maxTouchPoints>2),mr=Co||(Hr?/Mac/.test(Hr.platform):!1),Wx=Hr?/Win/.test(Hr.platform):!1,cs=/Android \d/.test(Zs),ql=!!bb&&"webkitFontSmoothing"in bb.documentElement.style,XN=ql?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ZN(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 ts(t,e){return typeof t=="number"?t:t[e]}function eC(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 vb(t,e,n){let r=t.someProp("scrollThreshold")||0,s=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let l=n||t.dom;l;){if(l.nodeType!=1){l=No(l);continue}let c=l,u=c==i.body,f=u?ZN(i):eC(c),p=0,m=0;if(e.top<f.top+ts(r,"top")?m=-(f.top-e.top+ts(s,"top")):e.bottom>f.bottom-ts(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+ts(s,"top")-f.top:e.bottom-f.bottom+ts(s,"bottom")),e.left<f.left+ts(r,"left")?p=-(f.left-e.left+ts(s,"left")):e.right>f.right-ts(r,"right")&&(p=e.right-f.right+ts(s,"right")),p||m)if(u)i.defaultView.scrollBy(p,m);else{let b=c.scrollLeft,v=c.scrollTop;m&&(c.scrollTop+=m),p&&(c.scrollLeft+=p);let w=c.scrollLeft-b,k=c.scrollTop-v;e={left:e.left-w,top:e.top-k,right:e.right-w,bottom:e.bottom-k}}let y=u?"fixed":getComputedStyle(l).position;if(/^(fixed|sticky)$/.test(y))break;l=y=="absolute"?l.offsetParent:No(l)}}function tC(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,s;for(let i=(e.left+e.right)/2,l=n+1;l<Math.min(innerHeight,e.bottom);l+=5){let c=t.root.elementFromPoint(i,l);if(!c||c==t.dom||!t.dom.contains(c))continue;let u=c.getBoundingClientRect();if(u.top>=n-20){r=c,s=u.top;break}}return{refDOM:r,refTop:s,stack:Vx(t.dom)}}function Vx(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=No(r));return e}function nC({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Kx(n,r==0?0:r-e)}function Kx(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:s,left:i}=t[n];r.scrollTop!=s+e&&(r.scrollTop=s+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let uo=null;function rC(t){if(t.setActive)return t.setActive();if(uo)return t.focus(uo);let e=Vx(t);t.focus(uo==null?{get preventScroll(){return uo={preventScroll:!0},!0}}:void 0),uo||(uo=!1,Kx(e,0))}function Gx(t,e){let n,r=2e8,s,i=0,l=e.top,c=e.top,u,f;for(let p=t.firstChild,m=0;p;p=p.nextSibling,m++){let y;if(p.nodeType==1)y=p.getClientRects();else if(p.nodeType==3)y=ls(p).getClientRects();else continue;for(let b=0;b<y.length;b++){let v=y[b];if(v.top<=l&&v.bottom>=c){l=Math.max(v.bottom,l),c=Math.min(v.top,c);let w=v.left>e.left?v.left-e.left:v.right<e.left?e.left-v.right:0;if(w<r){n=p,r=w,s=w&&n.nodeType==3?{left:v.right<e.left?v.right:v.left,top:e.top}:e,p.nodeType==1&&w&&(i=m+(e.left>=(v.left+v.right)/2?1:0));continue}}else v.top>e.top&&!u&&v.left<=e.left&&v.right>=e.left&&(u=p,f={left:Math.max(v.left,Math.min(v.right,e.left)),top:v.top});!n&&(e.left>=v.right&&e.top>=v.top||e.left>=v.left&&e.top>=v.bottom)&&(i=m+1)}}return!n&&u&&(n=u,s=f,r=0),n&&n.nodeType==3?sC(n,s):!n||r&&n.nodeType==1?{node:t,offset:i}:Gx(n,s)}function sC(t,e){let n=t.nodeValue.length,r=document.createRange(),s;for(let i=0;i<n;i++){r.setEnd(t,i+1),r.setStart(t,i);let l=js(r,1);if(l.top!=l.bottom&&Tp(e,l)){s={node:t,offset:i+(e.left>=(l.left+l.right)/2?1:0)};break}}return r.detach(),s||{node:t,offset:0}}function Tp(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function iC(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function oC(t,e,n){let{node:r,offset:s}=Gx(e,n),i=-1;if(r.nodeType==1&&!r.firstChild){let l=r.getBoundingClientRect();i=l.left!=l.right&&n.left>(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,s,i)}function lC(t,e,n,r){let s=-1;for(let i=e,l=!1;i!=t.dom;){let c=t.docView.nearestDesc(i,!0),u;if(!c)return null;if(c.dom.nodeType==1&&(c.node.isBlock&&c.parent||!c.contentDOM)&&((u=c.dom.getBoundingClientRect()).width||u.height)&&(c.node.isBlock&&c.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(c.dom.nodeName)&&(!l&&u.left>r.left||u.top>r.top?s=c.posBefore:(!l&&u.right<r.left||u.bottom<r.top)&&(s=c.posAfter),l=!0),!c.contentDOM&&s<0&&!c.node.isText))return(c.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?c.posBefore:c.posAfter;i=c.dom.parentNode}return s>-1?s:t.docView.posFromDOM(e,n,-1)}function qx(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)),i=s;;){let l=t.childNodes[i];if(l.nodeType==1){let c=l.getClientRects();for(let u=0;u<c.length;u++){let f=c[u];if(Tp(e,f))return qx(l,e,f)}}if((i=(i+1)%r)==s)break}return t}function aC(t,e){let n=t.dom.ownerDocument,r,s=0,i=QN(n,e.left,e.top);i&&({node:r,offset:s}=i);let l=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),c;if(!l||!t.dom.contains(l.nodeType!=1?l.parentNode:l)){let f=t.dom.getBoundingClientRect();if(!Tp(e,f)||(l=qx(t.dom,e,f),!l))return null}if(jn)for(let f=l;r&&f;f=No(f))f.draggable&&(r=void 0);if(l=iC(l,e),r){if(yr&&r.nodeType==1&&(s=Math.min(s,r.childNodes.length),s<r.childNodes.length)){let p=r.childNodes[s],m;p.nodeName=="IMG"&&(m=p.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&s++}let f;ql&&s&&r.nodeType==1&&(f=r.childNodes[s-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&s--,r==t.dom&&s==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?c=t.state.doc.content.size:(s==0||r.nodeType!=1||r.childNodes[s-1].nodeName!="BR")&&(c=lC(t,r,s,e))}c==null&&(c=oC(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:c,inside:u?u.posAtStart-u.border:-1}}function xb(t){return t.top<t.bottom||t.left<t.right}function js(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(xb(r))return r}return Array.prototype.find.call(n,xb)||t.getBoundingClientRect()}const cC=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Jx(t,e,n){let{node:r,offset:s,atom:i}=t.docView.domFromPos(e,n<0?-1:1),l=ql||yr;if(r.nodeType==3)if(l&&(cC.test(r.nodeValue)||(n<0?!s:s==r.nodeValue.length))){let u=js(ls(r,s,s),n);if(yr&&s&&/\s/.test(r.nodeValue[s-1])&&s<r.nodeValue.length){let f=js(ls(r,s-1,s-1),-1);if(f.top==u.top){let p=js(ls(r,s,s+1),-1);if(p.top!=u.top)return pl(p,p.left<f.left)}}return u}else{let u=s,f=s,p=n<0?1:-1;return n<0&&!s?(f++,p=-1):n>=0&&s==r.nodeValue.length?(u--,p=1):n<0?u--:f++,pl(js(ls(r,u,f),p),p<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&s&&(n<0||s==gr(r))){let u=r.childNodes[s-1];if(u.nodeType==1)return eh(u.getBoundingClientRect(),!1)}if(i==null&&s<gr(r)){let u=r.childNodes[s];if(u.nodeType==1)return eh(u.getBoundingClientRect(),!0)}return eh(r.getBoundingClientRect(),n>=0)}if(i==null&&s&&(n<0||s==gr(r))){let u=r.childNodes[s-1],f=u.nodeType==3?ls(u,gr(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return pl(js(f,1),!1)}if(i==null&&s<gr(r)){let u=r.childNodes[s];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?ls(u,0,l?0:1):u.nodeType==1?u:null:null;if(f)return pl(js(f,-1),!0)}return pl(js(r.nodeType==3?ls(r):r,-n),n>=0)}function pl(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 eh(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 Yx(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 uC(t,e,n){let r=e.selection,s=n=="up"?r.$from:r.$to;return Yx(t,e,()=>{let{node:i}=t.docView.domFromPos(s.pos,n=="up"?-1:1);for(;;){let c=t.docView.nearestDesc(i,!0);if(!c)break;if(c.node.isBlock){i=c.contentDOM||c.dom;break}i=c.dom.parentNode}let l=Jx(t,s.pos,1);for(let c=i.firstChild;c;c=c.nextSibling){let u;if(c.nodeType==1)u=c.getClientRects();else if(c.nodeType==3)u=ls(c,0,c.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let p=u[f];if(p.bottom>p.top+1&&(n=="up"?l.top-p.top>(p.bottom-l.top)*2:p.bottom-l.bottom>(l.bottom-p.top)*2))return!1}}return!0})}const dC=/[\u0590-\u08ac]/;function fC(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let s=r.parentOffset,i=!s,l=s==r.parent.content.size,c=t.domSelection();return c?!dC.test(r.parent.textContent)||!c.modify?n=="left"||n=="backward"?i:l:Yx(t,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:p,anchorOffset:m}=t.domSelectionRange(),y=c.caretBidiLevel;c.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:v,focusOffset:w}=t.domSelectionRange(),k=v&&!b.contains(v.nodeType==1?v:v.parentNode)||u==v&&f==w;try{c.collapse(p,m),u&&(u!=p||f!=m)&&c.extend&&c.extend(u,f)}catch{}return y!=null&&(c.caretBidiLevel=y),k}):r.pos==r.start()||r.pos==r.end()}let wb=null,kb=null,Sb=!1;function hC(t,e,n){return wb==e&&kb==n?Sb:(wb=e,kb=n,Sb=n=="up"||n=="down"?uC(t,e,n):fC(t,e,n))}const br=0,Eb=1,wi=2,Wr=3;class Jl{constructor(e,n,r,s){this.parent=e,this.children=n,this.dom=r,this.contentDOM=s,this.dirty=br,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 i,l;if(e==this.contentDOM)i=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.previousSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.previousSibling;return i?this.posBeforeChild(l)+l.size:this.posAtStart}else{let i,l;if(e==this.contentDOM)i=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;i=e.nextSibling}for(;i&&!((l=i.pmViewDesc)&&l.parent==this);)i=i.nextSibling;return i?this.posBeforeChild(l):this.posAtEnd}let s;if(e==this.dom&&this.contentDOM)s=n>Cn(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 i=e;;i=i.parentNode){if(i==this.dom){s=!1;break}if(i.previousSibling)break}if(s==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){s=!0;break}if(i.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 i=this.getDesc(s),l;if(i&&(!n||i.node))if(r&&(l=i.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==e))r=!1;else return i}}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 i=this.getDesc(s);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let s=this.children[n],i=r+s.size;if(r==e&&i!=r){for(;!s.border&&s.children.length;)for(let l=0;l<s.children.length;l++){let c=s.children[l];if(c.size){s=c;break}}return s}if(e<i)return s.descAt(e-r-s.border);r=i}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,s=0;for(let i=0;r<this.children.length;r++){let l=this.children[r],c=i+l.size;if(c>e||l instanceof Xx){s=e-i;break}i=c}if(s)return this.children[r].domFromPos(s-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof Qx&&i.side>=0;r--);if(n<=0){let i,l=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,l=!1);return i&&n&&l&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?Cn(i.dom)+1:0}}else{let i,l=!0;for(;i=r<this.children.length?this.children[r]:null,!(!i||i.dom.parentNode==this.contentDOM);r++,l=!1);return i&&l&&!i.border&&!i.domAtom?i.domFromPos(0,n):{node:this.contentDOM,offset:i?Cn(i.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,i=-1;for(let l=r,c=0;;c++){let u=this.children[c],f=l+u.size;if(s==-1&&e<=f){let p=l+u.border;if(e>=p&&n<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,p);e=l;for(let m=c;m>0;m--){let y=this.children[m-1];if(y.size&&y.dom.parentNode==this.contentDOM&&!y.emptyChildAt(1)){s=Cn(y.dom)+1;break}e-=y.size}s==-1&&(s=0)}if(s>-1&&(f>n||c==this.children.length-1)){n=f;for(let p=c+1;p<this.children.length;p++){let m=this.children[p];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){i=Cn(m.dom);break}n+=m.size}i==-1&&(i=this.contentDOM.childNodes.length);break}l=f}return{node:this.contentDOM,from:e,to:n,fromOffset:s,toOffset:i}}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 i=Math.min(e,n),l=Math.max(e,n);for(let b=0,v=0;b<this.children.length;b++){let w=this.children[b],k=v+w.size;if(i>v&&l<k)return w.setSelection(e-v-w.border,n-v-w.border,r,s);v=k}let c=this.domFromPos(e,e?-1:1),u=n==e?c:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),p=r.domSelectionRange(),m=!1;if((yr||jn)&&e==n){let{node:b,offset:v}=c;if(b.nodeType==3){if(m=!!(v&&b.nodeValue[v-1]==`
54
+ `),m&&v==b.nodeValue.length)for(let w=b,k;w;w=w.parentNode){if(k=w.nextSibling){k.nodeName=="BR"&&(c=u={node:k.parentNode,offset:Cn(k)+1});break}let N=w.pmViewDesc;if(N&&N.node&&N.node.isBlock)break}}else{let w=b.childNodes[v-1];m=w&&(w.nodeName=="BR"||w.contentEditable=="false")}}if(yr&&p.focusNode&&p.focusNode!=u.node&&p.focusNode.nodeType==1){let b=p.focusNode.childNodes[p.focusOffset];b&&b.contentEditable=="false"&&(s=!0)}if(!(s||m&&jn)&&Ri(c.node,c.offset,p.anchorNode,p.anchorOffset)&&Ri(u.node,u.offset,p.focusNode,p.focusOffset))return;let y=!1;if((f.extend||e==n)&&!(m&&yr)){f.collapse(c.node,c.offset);try{e!=n&&f.extend(u.node,u.offset),y=!0}catch{}}if(!y){if(e>n){let v=c;c=u,u=v}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(c.node,c.offset),f.removeAllRanges(),f.addRange(b)}}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 i=this.children[s],l=r+i.size;if(r==l?e<=l&&n>=r:e<l&&n>r){let c=r+i.border,u=l-i.border;if(e>=c&&n<=u){this.dirty=e==r||n==l?wi:Eb,e==c&&n==u&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Wr:i.markDirty(e-c,n-c);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?wi:Wr}r=l}this.dirty=wi}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?wi:Eb;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class Qx extends Jl{constructor(e,n,r,s){let i,l=n.type.toDOM;if(typeof l=="function"&&(l=l(r,()=>{if(!i)return s;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(l.nodeType!=1){let c=document.createElement("span");c.appendChild(l),l=c}l.contentEditable="false",l.classList.add("ProseMirror-widget")}super(e,[],l,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==br&&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 pC extends Jl{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 Ii extends Jl{constructor(e,n,r,s,i){super(e,[],r,s),this.mark=n,this.spec=i}static create(e,n,r,s){let i=s.nodeViews[n.type.name],l=i&&i(n,s,r);return(!l||!l.dom)&&(l=Pi.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Ii(e,n,l.dom,l.contentDOM||l.dom,l)}parseRule(){return this.dirty&Wr||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Wr&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=br){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=br}}slice(e,n,r){let s=Ii.create(this.parent,this.mark,!0,r),i=this.children,l=this.size;n<l&&(i=Hh(i,n,l,r)),e>0&&(i=Hh(i,0,e,r));for(let c=0;c<i.length;c++)i[c].parent=s;return s.children=i,s}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ks extends Jl{constructor(e,n,r,s,i,l,c,u,f){super(e,[],i,l),this.node=n,this.outerDeco=r,this.innerDeco=s,this.nodeDOM=c}static create(e,n,r,s,i,l){let c=i.nodeViews[n.type.name],u,f=c&&c(n,i,()=>{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,s),p=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!p)p=document.createTextNode(n.text);else if(p.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else p||({dom:p,contentDOM:m}=Pi.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&p.nodeName!="BR"&&(p.hasAttribute("contenteditable")||(p.contentEditable="false"),n.type.spec.draggable&&(p.draggable=!0));let y=p;return p=tw(p,r,n),f?u=new mC(e,n,r,s,p,m||null,y,f,i,l+1):n.isText?new Vu(e,n,r,s,p,y,i):new Ks(e,n,r,s,p,m||null,y,i,l+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=()=>ae.empty)}return e}matchesNode(e,n,r){return this.dirty==br&&e.eq(this.node)&&Gc(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,i=e.composing?this.localCompositionInfo(e,n):null,l=i&&i.pos>-1?i:null,c=i&&i.pos<0,u=new yC(this,l&&l.node,e);xC(this.node,this.innerDeco,(f,p,m)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,p):f.type.side>=0&&!m&&u.syncToMarks(p==this.node.childCount?At.none:this.node.child(p).marks,r,e,p),u.placeWidget(f,e,s)},(f,p,m,y)=>{u.syncToMarks(f.marks,r,e,y);let b;u.findNodeMatch(f,p,m,y)||c&&e.state.selection.from>s&&e.state.selection.to<s+f.nodeSize&&(b=u.findIndexWithChild(i.node))>-1&&u.updateNodeAt(f,p,m,b,e)||u.updateNextNode(f,p,m,e,y,s)||u.addNode(f,p,m,e,s),s+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==wi)&&(l&&this.protectLocalComposition(e,l),Zx(this.contentDOM,this.children,e),Co&&wC(this.dom))}localCompositionInfo(e,n){let{from:r,to:s}=e.state.selection;if(!(e.state.selection instanceof Fe)||r<n||s>n+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let l=i.nodeValue,c=kC(this.node.content,l,r-n,s-n);return c<0?null:{node:i,pos:c,text:l}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:s}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let l=new pC(this,i,n,s);e.input.compositionNodes.push(l),this.children=Hh(this.children,r,r+s.length,e,l)}update(e,n,r,s){return this.dirty==Wr||!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=br}updateOuterDeco(e){if(Gc(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=ew(this.dom,this.nodeDOM,Uh(this.outerDeco,this.node,n),Uh(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.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Nb(t,e,n,r,s){tw(r,e,t);let i=new Ks(void 0,t,e,n,r,r,r,s,0);return i.contentDOM&&i.updateChildren(s,0),i}class Vu extends Ks{constructor(e,n,r,s,i,l,c){super(e,n,r,s,i,null,l,c,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==Wr||this.dirty!=br&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=br||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=br,!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),i=document.createTextNode(s.text);return new Vu(this.parent,s,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Wr)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Xx extends Jl{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==br&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class mC extends Ks{constructor(e,n,r,s,i,l,c,u,f,p){super(e,n,r,s,i,l,c,f,p),this.spec=u}update(e,n,r,s){if(this.dirty==Wr)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,s),i}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 Zx(t,e,n){let r=t.firstChild,s=!1;for(let i=0;i<e.length;i++){let l=e[i],c=l.dom;if(c.parentNode==t){for(;c!=r;)r=Cb(r),s=!0;r=r.nextSibling}else s=!0,t.insertBefore(c,r);if(l instanceof Ii){let u=r?r.previousSibling:t.lastChild;Zx(l.contentDOM,l.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=Cb(r),s=!0;s&&n.trackWrites==t&&(n.trackWrites=null)}const Cl=function(t){t&&(this.nodeName=t)};Cl.prototype=Object.create(null);const ki=[new Cl];function Uh(t,e,n){if(t.length==0)return ki;let r=n?ki[0]:new Cl,s=[r];for(let i=0;i<t.length;i++){let l=t[i].type.attrs;if(l){l.nodeName&&s.push(r=new Cl(l.nodeName));for(let c in l){let u=l[c];u!=null&&(n&&s.length==1&&s.push(r=new Cl(e.isInline?"span":"div")),c=="class"?r.class=(r.class?r.class+" ":"")+u:c=="style"?r.style=(r.style?r.style+";":"")+u:c!="nodeName"&&(r[c]=u))}}}return s}function ew(t,e,n,r){if(n==ki&&r==ki)return e;let s=e;for(let i=0;i<r.length;i++){let l=r[i],c=n[i];if(i){let u;c&&c.nodeName==l.nodeName&&s!=t&&(u=s.parentNode)&&u.nodeName.toLowerCase()==l.nodeName||(u=document.createElement(l.nodeName),u.pmIsDeco=!0,u.appendChild(s),c=ki[0]),s=u}gC(s,c||ki[0],l)}return s}function gC(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 i=0;i<r.length;i++)s.indexOf(r[i])==-1&&t.classList.remove(r[i]);for(let i=0;i<s.length;i++)r.indexOf(s[i])==-1&&t.classList.add(s[i]);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 tw(t,e,n){return ew(t,t,ki,Uh(e,n,t.nodeType!=1))}function Gc(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 Cb(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class yC{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=bC(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,s){let i=0,l=this.stack.length>>1,c=Math.min(l,e.length);for(;i<c&&(i==l-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<l;)this.destroyRest(),this.top.dirty=br,this.index=this.stack.pop(),this.top=this.stack.pop(),l--;for(;l<e.length;){this.stack.push(this.top,this.index+1);let u=-1,f=this.top.children.length;s<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let p=this.index;p<f;p++){let m=this.top.children[p];if(m.matchesMark(e[l])&&!this.isLocked(m.dom)){u=p;break}}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let p=Ii.create(this.top,e[l],n,r);this.top.children.splice(this.index,0,p),this.top=p,this.changed=!0}this.index=0,l++}}findNodeMatch(e,n,r,s){let i=-1,l;if(s>=this.preMatch.index&&(l=this.preMatch.matches[s-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))i=this.top.children.indexOf(l,this.index);else for(let c=this.index,u=Math.min(this.top.children.length,c+5);c<u;c++){let f=this.top.children[c];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){i=c;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,n,r,s,i){let l=this.top.children[s];return l.dirty==Wr&&l.dom==l.contentDOM&&(l.dirty=wi),l.update(e,n,r,i)?(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,i,l){for(let c=this.index;c<this.top.children.length;c++){let u=this.top.children[c];if(u instanceof Ks){let f=this.preMatch.matched.get(u);if(f!=null&&f!=i)return!1;let p=u.dom,m,y=this.isLocked(p)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=Wr&&Gc(n,u.outerDeco));if(!y&&u.update(e,n,r,s))return this.destroyBetween(this.index,c),u.dom!=p&&(this.changed=!0),this.index++,!0;if(!y&&(m=this.recreateWrapper(u,e,n,r,s,l)))return this.destroyBetween(this.index,c),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=wi,m.updateChildren(s,l+1),m.dirty=br),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,s,i,l){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Gc(r,e.outerDeco)||!s.eq(e.innerDeco))return null;let c=Ks.create(this.top,n,r,s,i,l);if(c.contentDOM){c.children=e.children,e.children=[];for(let u of c.children)u.parent=c}return e.destroy(),c}addNode(e,n,r,s,i){let l=Ks.create(this.top,e,n,r,s,i);l.contentDOM&&l.updateChildren(s,i+1),this.top.children.splice(this.index++,0,l),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 i=new Qx(this.top,e,n,r);this.top.children.splice(this.index++,0,i),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ii;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof Vu)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((jn||Tn)&&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 Xx(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 bC(t,e){let n=e,r=n.children.length,s=t.childCount,i=new Map,l=[];e:for(;s>0;){let c;for(;;)if(r){let f=n.children[r-1];if(f instanceof Ii)n=f,r=f.children.length;else{c=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=c.node;if(u){if(u!=t.child(s-1))break;--s,i.set(c,s),l.push(c)}}return{index:s,matched:i,matches:l.reverse()}}function vC(t,e){return t.type.side-e.type.side}function xC(t,e,n,r){let s=e.locals(t),i=0;if(s.length==0){for(let f=0;f<t.childCount;f++){let p=t.child(f);r(p,s,e.forChild(i,p),f),i+=p.nodeSize}return}let l=0,c=[],u=null;for(let f=0;;){let p,m;for(;l<s.length&&s[l].to==i;){let k=s[l++];k.widget&&(p?(m||(m=[p])).push(k):p=k)}if(p)if(m){m.sort(vC);for(let k=0;k<m.length;k++)n(m[k],f,!!u)}else n(p,f,!!u);let y,b;if(u)b=-1,y=u,u=null;else if(f<t.childCount)b=f,y=t.child(f++);else break;for(let k=0;k<c.length;k++)c[k].to<=i&&c.splice(k--,1);for(;l<s.length&&s[l].from<=i&&s[l].to>i;)c.push(s[l++]);let v=i+y.nodeSize;if(y.isText){let k=v;l<s.length&&s[l].from<k&&(k=s[l].from);for(let N=0;N<c.length;N++)c[N].to<k&&(k=c[N].to);k<v&&(u=y.cut(k-i),y=y.cut(0,k-i),v=k,b=-1)}else for(;l<s.length&&s[l].to<v;)l++;let w=y.isInline&&!y.isLeaf?c.filter(k=>!k.inline):c.slice();r(y,w,e.forChild(i,y),b),i=v}}function wC(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 kC(t,e,n,r){for(let s=0,i=0;s<t.childCount&&i<=r;){let l=t.child(s++),c=i;if(i+=l.nodeSize,!l.isText)continue;let u=l.text;for(;s<t.childCount;){let f=t.child(s++);if(i+=f.nodeSize,!f.isText)break;u+=f.text}if(i>=n){if(i>=r&&u.slice(r-e.length-c,r-c)==e)return r-e.length;let f=c<r?u.lastIndexOf(e,r-c-1):-1;if(f>=0&&f+e.length+c>=n)return c+f;if(n==r&&u.length>=r+e.length-c&&u.slice(r-c,r-c+e.length)==e)return r}}return-1}function Hh(t,e,n,r,s){let i=[];for(let l=0,c=0;l<t.length;l++){let u=t[l],f=c,p=c+=u.size;f>=n||p<=e?i.push(u):(f<e&&i.push(u.slice(0,e-f,r)),s&&(i.push(s),s=void 0),p>n&&i.push(u.slice(n-f,u.size,r)))}return i}function Mp(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let s=t.docView.nearestDesc(n.focusNode),i=s&&s.size==0,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let c=r.resolve(l),u,f;if(Wu(n)){for(u=l;s&&!s.node;)s=s.parent;let m=s.node;if(s&&m.isAtom&&ze.isSelectable(m)&&s.parent&&!(m.isInline&&JN(n.focusNode,n.focusOffset,s.dom))){let y=s.posBefore;f=new ze(l==y?c:r.resolve(y))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=l,y=l;for(let b=0;b<n.rangeCount;b++){let v=n.getRangeAt(b);m=Math.min(m,t.docView.posFromDOM(v.startContainer,v.startOffset,1)),y=Math.max(y,t.docView.posFromDOM(v.endContainer,v.endOffset,-1))}if(m<0)return null;[u,l]=y==t.state.selection.anchor?[y,m]:[m,y],c=r.resolve(l)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let p=r.resolve(u);if(!f){let m=e=="pointer"||t.state.selection.head<c.pos&&!i?1:-1;f=Ap(t,p,c,m)}return f}function nw(t){return t.editable?t.hasFocus():sw(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function ds(t,e=!1){let n=t.state.selection;if(rw(t,n),!!nw(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Tn){let r=t.domSelectionRange(),s=t.domObserver.currentSelection;if(r.anchorNode&&s.anchorNode&&Ri(r.anchorNode,r.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)EC(t);else{let{anchor:r,head:s}=n,i,l;_b&&!(n instanceof Fe)&&(n.$from.parent.inlineContent||(i=Tb(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=Tb(t,n.to))),t.docView.setSelection(r,s,t,e),_b&&(i&&Mb(i),l&&Mb(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&SC(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const _b=jn||Tn&&Hx<63;function Tb(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),s=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(jn&&s&&s.contentEditable=="false")return th(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return th(s);if(i)return th(i)}}function th(t){return t.contentEditable="true",jn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Mb(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function SC(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(()=>{(!nw(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function EC(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Cn(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&Xn&&Vs<=11&&(n.disabled=!0,n.disabled=!1)}function rw(t,e){if(e instanceof ze){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Ab(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Ab(t)}function Ab(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ap(t,e,n,r){return t.someProp("createSelectionBetween",s=>s(t,e,n))||Fe.between(e,n,r)}function Ob(t){return t.editable&&!t.hasFocus()?!1:sw(t)}function sw(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 NC(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ri(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Wh(t,e){let{$anchor:n,$head:r}=t.selection,s=e>0?n.max(r):n.min(r),i=s.parent.inlineContent?s.depth?t.doc.resolve(e>0?s.after():s.before()):null:s;return i&&Ye.findFrom(i,e)}function Ls(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Rb(t,e,n){let r=t.state.selection;if(r instanceof Fe)if(n.indexOf("s")>-1){let{$head:s}=r,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let l=t.state.doc.resolve(s.pos+i.nodeSize*(e<0?-1:1));return Ls(t,new Fe(r.$anchor,l))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let s=Wh(t.state,e);return s&&s instanceof ze?Ls(t,s):!1}else if(!(mr&&n.indexOf("m")>-1)){let s=r.$head,i=s.textOffset?null:e<0?s.nodeBefore:s.nodeAfter,l;if(!i||i.isText)return!1;let c=e<0?s.pos-i.nodeSize:s.pos;return i.isAtom||(l=t.docView.descAt(c))&&!l.contentDOM?ze.isSelectable(i)?Ls(t,new ze(e<0?t.state.doc.resolve(s.pos-i.nodeSize):s)):ql?Ls(t,new Fe(t.state.doc.resolve(e<0?c:c+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof ze&&r.node.isInline)return Ls(t,new Fe(e>0?r.$to:r.$from));{let s=Wh(t.state,e);return s?Ls(t,s):!1}}}function qc(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function _l(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function fo(t,e){return e<0?CC(t):_C(t)}function CC(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s,i,l=!1;for(yr&&n.nodeType==1&&r<qc(n)&&_l(n.childNodes[r],-1)&&(l=!0);;)if(r>0){if(n.nodeType!=1)break;{let c=n.childNodes[r-1];if(_l(c,-1))s=n,i=--r;else if(c.nodeType==3)n=c,r=n.nodeValue.length;else break}}else{if(iw(n))break;{let c=n.previousSibling;for(;c&&_l(c,-1);)s=n.parentNode,i=Cn(c),c=c.previousSibling;if(c)n=c,r=qc(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?Vh(t,n,r):s&&Vh(t,s,i)}function _C(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let s=qc(n),i,l;for(;;)if(r<s){if(n.nodeType!=1)break;let c=n.childNodes[r];if(_l(c,1))i=n,l=++r;else break}else{if(iw(n))break;{let c=n.nextSibling;for(;c&&_l(c,1);)i=c.parentNode,l=Cn(c)+1,c=c.nextSibling;if(c)n=c,r=0,s=qc(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}i&&Vh(t,i,l)}function iw(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function TC(t,e){for(;t&&e==t.childNodes.length&&!Gl(t);)e=Cn(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 MC(t,e){for(;t&&!e&&!Gl(t);)e=Cn(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 Vh(t,e,n){if(e.nodeType!=3){let i,l;(l=TC(e,n))?(e=l,n=0):(i=MC(e,n))&&(e=i,n=i.nodeValue.length)}let r=t.domSelection();if(!r)return;if(Wu(r)){let i=document.createRange();i.setEnd(e,n),i.setStart(e,n),r.removeAllRanges(),r.addRange(i)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:s}=t;setTimeout(()=>{t.state==s&&ds(t)},50)}function Ib(t,e){let n=t.state.doc.resolve(e);if(!(Tn||Wx)&&n.parent.inlineContent){let s=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),l=(i.top+i.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(i.left-s.left)>1)return i.left<s.left?"ltr":"rtl"}if(e<n.end()){let i=t.coordsAtPos(e+1),l=(i.top+i.bottom)/2;if(l>s.top&&l<s.bottom&&Math.abs(i.left-s.left)>1)return i.left>s.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function jb(t,e,n){let r=t.state.selection;if(r instanceof Fe&&!r.empty||n.indexOf("s")>-1||mr&&n.indexOf("m")>-1)return!1;let{$from:s,$to:i}=r;if(!s.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=Wh(t.state,e);if(l&&l instanceof ze)return Ls(t,l)}if(!s.parent.inlineContent){let l=e<0?s:i,c=r instanceof ir?Ye.near(l,e):Ye.findFrom(l,e);return c?Ls(t,c):!1}return!1}function Lb(t,e){if(!(t.state.selection instanceof Fe))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 i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let l=t.state.tr;return e<0?l.delete(n.pos-i.nodeSize,n.pos):l.delete(n.pos,n.pos+i.nodeSize),t.dispatch(l),!0}return!1}function Db(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function AC(t){if(!jn||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;Db(t,r,"true"),setTimeout(()=>Db(t,r,"false"),20)}return!1}function OC(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function RC(t,e){let n=e.keyCode,r=OC(e);if(n==8||mr&&n==72&&r=="c")return Lb(t,-1)||fo(t,-1);if(n==46&&!e.shiftKey||mr&&n==68&&r=="c")return Lb(t,1)||fo(t,1);if(n==13||n==27)return!0;if(n==37||mr&&n==66&&r=="c"){let s=n==37?Ib(t,t.state.selection.from)=="ltr"?-1:1:-1;return Rb(t,s,r)||fo(t,s)}else if(n==39||mr&&n==70&&r=="c"){let s=n==39?Ib(t,t.state.selection.from)=="ltr"?1:-1:1;return Rb(t,s,r)||fo(t,s)}else{if(n==38||mr&&n==80&&r=="c")return jb(t,-1,r)||fo(t,-1);if(n==40||mr&&n==78&&r=="c")return AC(t)||jb(t,1,r)||fo(t,1);if(r==(mr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Op(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:s,openEnd:i}=e;for(;s>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){s--,i--;let b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let l=t.someProp("clipboardSerializer")||Pi.fromSchema(t.state.schema),c=dw(),u=c.createElement("div");u.appendChild(l.serializeFragment(r,{document:c}));let f=u.firstChild,p,m=0;for(;f&&f.nodeType==1&&(p=uw[f.nodeName.toLowerCase()]);){for(let b=p.length-1;b>=0;b--){let v=c.createElement(p[b]);for(;u.firstChild;)v.appendChild(u.firstChild);u.appendChild(v),m++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${s} ${i}${m?` -${m}`:""} ${JSON.stringify(n)}`);let y=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
55
+
56
+ `);return{dom:u,text:y,slice:e}}function ow(t,e,n,r,s){let i=s.parent.type.spec.code,l,c;if(!n&&!e)return null;let u=!!e&&(r||i||!n);if(u){if(t.someProp("transformPastedText",y=>{e=y(e,i||r,t)}),i)return c=new Se(ae.from(t.state.schema.text(e.replace(/\r\n?/g,`
57
+ `))),0,0),t.someProp("transformPasted",y=>{c=y(c,t,!0)}),c;let m=t.someProp("clipboardTextParser",y=>y(e,s,r,t));if(m)c=m;else{let y=s.marks(),{schema:b}=t.state,v=Pi.fromSchema(b);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(w=>{let k=l.appendChild(document.createElement("p"));w&&k.appendChild(v.serializeNode(b.text(w,y)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),l=DC(n),ql&&PC(l);let f=l&&l.querySelector("[data-pm-slice]"),p=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let m=+p[3];m>0;m--){let y=l.firstChild;for(;y&&y.nodeType!=1;)y=y.nextSibling;if(!y)break;l=y}if(c||(c=(t.someProp("clipboardParser")||t.someProp("domParser")||Ws.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||p),context:s,ruleFromNode(y){return y.nodeName=="BR"&&!y.nextSibling&&y.parentNode&&!IC.test(y.parentNode.nodeName)?{ignore:!0}:null}})),p)c=BC(Pb(c,+p[1],+p[2]),p[4]);else if(c=Se.maxOpen(jC(c.content,s),!0),c.openStart||c.openEnd){let m=0,y=0;for(let b=c.content.firstChild;m<c.openStart&&!b.type.spec.isolating;m++,b=b.firstChild);for(let b=c.content.lastChild;y<c.openEnd&&!b.type.spec.isolating;y++,b=b.lastChild);c=Pb(c,m,y)}return t.someProp("transformPasted",m=>{c=m(c,t,u)}),c}const IC=/^(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 jC(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)),i,l=[];if(t.forEach(c=>{if(!l)return;let u=s.findWrapping(c.type),f;if(!u)return l=null;if(f=l.length&&i.length&&aw(u,i,c,l[l.length-1],0))l[l.length-1]=f;else{l.length&&(l[l.length-1]=cw(l[l.length-1],i.length));let p=lw(c,u);l.push(p),s=s.matchType(p.type),i=u}}),l)return ae.from(l)}return t}function lw(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,ae.from(t));return t}function aw(t,e,n,r,s){if(s<t.length&&s<e.length&&t[s]==e[s]){let i=aw(t,e,n,r.lastChild,s+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(s==t.length-1?n.type:t[s+1]))return r.copy(r.content.append(ae.from(lw(n,t,s+1))))}}function cw(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,cw(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(ae.empty,!0);return t.copy(n.append(r))}function Kh(t,e,n,r,s,i){let l=e<0?t.firstChild:t.lastChild,c=l.content;return t.childCount>1&&(i=0),s<r-1&&(c=Kh(c,e,n,r,s+1,i)),s>=n&&(c=e<0?l.contentMatchAt(0).fillBefore(c,i<=s).append(c):c.append(l.contentMatchAt(l.childCount).fillBefore(ae.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(c))}function Pb(t,e,n){return e<t.openStart&&(t=new Se(Kh(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Se(Kh(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const uw={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 Bb=null;function dw(){return Bb||(Bb=document.implementation.createHTMLDocument("title"))}let nh=null;function LC(t){let e=window.trustedTypes;return e?(nh||(nh=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),nh.createHTML(t)):t}function DC(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=dw().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),s;if((s=r&&uw[r[1].toLowerCase()])&&(t=s.map(i=>"<"+i+">").join("")+t+s.map(i=>"</"+i+">").reverse().join("")),n.innerHTML=LC(t),s)for(let i=0;i<s.length;i++)n=n.querySelector(s[i])||n;return n}function PC(t){let e=t.querySelectorAll(Tn?"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 BC(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:i,openEnd:l}=t;for(let c=r.length-2;c>=0;c-=2){let u=n.nodes[r[c]];if(!u||u.hasRequiredAttrs())break;s=ae.from(u.create(r[c+1],s)),i++,l++}return new Se(s,i,l)}const Un={},Hn={},zC={touchstart:!0,touchmove:!0};class $C{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.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function FC(t){for(let e in Un){let n=Un[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{HC(t,r)&&!Rp(t,r)&&(t.editable||!(r.type in Hn))&&n(t,r)},zC[e]?{passive:!0}:void 0)}jn&&t.dom.addEventListener("input",()=>null),Gh(t)}function Hs(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function UC(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 Gh(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Rp(t,r))})}function Rp(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function HC(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 WC(t,e){!Rp(t,e)&&Un[e.type]&&(t.editable||!(e.type in Hn))&&Un[e.type](t,e)}Hn.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!hw(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(cs&&Tn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Co&&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,xi(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||RC(t,n)?n.preventDefault():Hs(t,"key")};Hn.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Hn.keypress=(t,e)=>{let n=e;if(hw(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||mr&&n.metaKey)return;if(t.someProp("handleKeyPress",s=>s(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof Fe)||!r.$from.sameParent(r.$to)){let s=String.fromCharCode(n.charCode),i=()=>t.state.tr.insertText(s).scrollIntoView();!/[\r\n]/.test(s)&&!t.someProp("handleTextInput",l=>l(t,r.$from.pos,r.$to.pos,s,i))&&t.dispatch(i()),n.preventDefault()}};function Ku(t){return{left:t.clientX,top:t.clientY}}function VC(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Ip(t,e,n,r,s){if(r==-1)return!1;let i=t.state.doc.resolve(r);for(let l=i.depth+1;l>0;l--)if(t.someProp(e,c=>l>i.depth?c(t,n,i.nodeAfter,i.before(l),s,!0):c(t,n,i.node(l),i.before(l),s,!1)))return!0;return!1}function wo(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 KC(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&ze.isSelectable(r)?(wo(t,new ze(n)),!0):!1}function GC(t,e){if(e==-1)return!1;let n=t.state.selection,r,s;n instanceof ze&&(r=n.node);let i=t.state.doc.resolve(e);for(let l=i.depth+1;l>0;l--){let c=l>i.depth?i.nodeAfter:i.node(l);if(ze.isSelectable(c)){r&&n.$from.depth>0&&l>=n.$from.depth&&i.before(n.$from.depth+1)==n.$from.pos?s=i.before(n.$from.depth):s=i.before(l);break}}return s!=null?(wo(t,ze.create(t.state.doc,s)),!0):!1}function qC(t,e,n,r,s){return Ip(t,"handleClickOn",e,n,r)||t.someProp("handleClick",i=>i(t,e,r))||(s?GC(t,n):KC(t,n))}function JC(t,e,n,r){return Ip(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",s=>s(t,e,r))}function YC(t,e,n,r){return Ip(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",s=>s(t,e,r))||QC(t,n,r)}function QC(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(wo(t,Fe.create(r,0,r.content.size)),!0):!1;let s=r.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i),c=s.before(i);if(l.inlineContent)wo(t,Fe.create(r,c+1,c+1+l.content.size));else if(ze.isSelectable(l))wo(t,ze.create(r,c));else continue;return!0}}function jp(t){return Jc(t)}const fw=mr?"metaKey":"ctrlKey";Un.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=jp(t),s=Date.now(),i="singleClick";s-t.input.lastClick.time<500&&VC(n,t.input.lastClick)&&!n[fw]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?i="doubleClick":t.input.lastClick.type=="doubleClick"&&(i="tripleClick")),t.input.lastClick={time:s,x:n.clientX,y:n.clientY,type:i,button:n.button};let l=t.posAtCoords(Ku(n));l&&(i=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new XC(t,l,n,!!r)):(i=="doubleClick"?JC:YC)(t,l.pos,l.inside,n)?n.preventDefault():Hs(t,"pointer"))};class XC{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[fw],this.allowDefault=r.shiftKey;let i,l;if(n.inside>-1)i=e.state.doc.nodeAt(n.inside),l=n.inside;else{let p=e.state.doc.resolve(n.pos);i=p.parent,l=p.depth?p.before():0}const c=s?null:r.target,u=c?e.docView.nearestDesc(c,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:f}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||f instanceof ze&&f.from<=l&&f.to>l)&&(this.mightDrag={node:i,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&yr&&!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)),Hs(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(()=>ds(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(Ku(e))),this.updateAllowDefault(e),this.allowDefault||!n?Hs(this.view,"pointer"):qC(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||jn&&this.mightDrag&&!this.mightDrag.node.isAtom||Tn&&!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)?(wo(this.view,Ye.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):Hs(this.view,"pointer")}move(e){this.updateAllowDefault(e),Hs(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)}}Un.touchstart=t=>{t.input.lastTouch=Date.now(),jp(t),Hs(t,"pointer")};Un.touchmove=t=>{t.input.lastTouch=Date.now(),Hs(t,"pointer")};Un.contextmenu=t=>jp(t);function hw(t,e){return t.composing?!0:jn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const ZC=cs?5e3:-1;Hn.compositionstart=Hn.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Fe&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||Tn&&Wx&&e_(t)))t.markCursor=t.state.storedMarks||n.marks(),Jc(t,!0),t.markCursor=null;else if(Jc(t,!e.selection.empty),yr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let s=r.focusNode,i=r.focusOffset;s&&s.nodeType==1&&i!=0;){let l=i<0?s.lastChild:s.childNodes[i-1];if(!l)break;if(l.nodeType==3){let c=t.domSelection();c&&c.collapse(l,l.nodeValue.length);break}else s=l,i=-1}}t.input.composing=!0}pw(t,ZC)};function e_(t){let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(!e||e.nodeType!=1||n>=e.childNodes.length)return!1;let r=e.childNodes[n];return r.nodeType==1&&r.contentEditable=="false"}Hn.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.badSafariComposition?t.domObserver.forceFlush():t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,pw(t,20))};function pw(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Jc(t),e))}function mw(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=n_());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function t_(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=GN(e.focusNode,e.focusOffset),r=qN(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let s=r.pmViewDesc,i=t.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!s||!s.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let l=n.pmViewDesc;if(!(!l||!l.isText(n.nodeValue)))return r}}return n||r}function n_(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Jc(t,e=!1){if(!(cs&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),mw(t),e||t.docView&&t.docView.dirty){let n=Mp(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 r_(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 Bl=Xn&&Vs<15||Co&&XN<604;Un.copy=Hn.cut=(t,e)=>{let n=e,r=t.state.selection,s=n.type=="cut";if(r.empty)return;let i=Bl?null:n.clipboardData,l=r.content(),{dom:c,text:u}=Op(t,l);i?(n.preventDefault(),i.clearData(),i.setData("text/html",c.innerHTML),i.setData("text/plain",u)):r_(t,c),s&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function s_(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function i_(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?zl(t,r.value,null,s,e):zl(t,r.textContent,r.innerHTML,s,e)},50)}function zl(t,e,n,r,s){let i=ow(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,s,i||Se.empty)))return!0;if(!i)return!1;let l=s_(i),c=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(i);return t.dispatch(c.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gw(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," "):""}Hn.paste=(t,e)=>{let n=e;if(t.composing&&!cs)return;let r=Bl?null:n.clipboardData,s=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&zl(t,gw(r),r.getData("text/html"),s,n)?n.preventDefault():i_(t,n)};class yw{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const o_=mr?"altKey":"ctrlKey";function bw(t,e){let n=t.someProp("dragCopies",r=>!r(e));return n??!e[o_]}Un.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let s=t.state.selection,i=s.empty?null:t.posAtCoords(Ku(n)),l;if(!(i&&i.pos>=s.from&&i.pos<=(s instanceof ze?s.to-1:s.to))){if(r&&r.mightDrag)l=ze.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let m=t.docView.nearestDesc(n.target,!0);m&&m.node.type.spec.draggable&&m!=t.docView&&(l=ze.create(t.state.doc,m.posBefore))}}let c=(l||t.state.selection).content(),{dom:u,text:f,slice:p}=Op(t,c);(!n.dataTransfer.files.length||!Tn||Hx>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Bl?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Bl||n.dataTransfer.setData("text/plain",f),t.dragging=new yw(p,bw(t,n),l)};Un.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Hn.dragover=Hn.dragenter=(t,e)=>e.preventDefault();Hn.drop=(t,e)=>{try{l_(t,e,t.dragging)}finally{t.dragging=null}};function l_(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(Ku(e));if(!r)return;let s=t.state.doc.resolve(r.pos),i=n&&n.slice;i?t.someProp("transformPasted",b=>{i=b(i,t,!1)}):i=ow(t,gw(e.dataTransfer),Bl?null:e.dataTransfer.getData("text/html"),!1,s);let l=!!(n&&bw(t,e));if(t.someProp("handleDrop",b=>b(t,e,i||Se.empty,l))){e.preventDefault();return}if(!i)return;e.preventDefault();let c=i?kx(t.state.doc,s.pos,i):s.pos;c==null&&(c=s.pos);let u=t.state.tr;if(l){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let f=u.mapping.map(c),p=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,m=u.doc;if(p?u.replaceRangeWith(f,f,i.content.firstChild):u.replaceRange(f,f,i),u.doc.eq(m))return;let y=u.doc.resolve(f);if(p&&ze.isSelectable(i.content.firstChild)&&y.nodeAfter&&y.nodeAfter.sameMarkup(i.content.firstChild))u.setSelection(new ze(y));else{let b=u.mapping.map(c);u.mapping.maps[u.mapping.maps.length-1].forEach((v,w,k,N)=>b=N),u.setSelection(Ap(t,y,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}Un.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())&&ds(t)},20))};Un.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)};Un.beforeinput=(t,e)=>{if(Tn&&cs&&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",i=>i(t,xi(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 Hn)Un[t]=Hn[t];function $l(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 Yc{constructor(e,n){this.toDOM=e,this.spec=n||_i,this.side=this.spec.side||0}map(e,n,r,s){let{pos:i,deleted:l}=e.mapResult(n.from+s,this.side<0?-1:1);return l?null:new jt(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Yc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&$l(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Gs{constructor(e,n){this.attrs=e,this.spec=n||_i}map(e,n,r,s){let i=e.map(n.from+s,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+s,this.spec.inclusiveEnd?1:-1)-r;return i>=l?null:new jt(i,l,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof Gs&&$l(this.attrs,e.attrs)&&$l(this.spec,e.spec)}static is(e){return e.type instanceof Gs}destroy(){}}class Lp{constructor(e,n){this.attrs=e,this.spec=n||_i}map(e,n,r,s){let i=e.mapResult(n.from+s,1);if(i.deleted)return null;let l=e.mapResult(n.to+s,-1);return l.deleted||l.pos<=i.pos?null:new jt(i.pos-r,l.pos-r,this)}valid(e,n){let{index:r,offset:s}=e.content.findIndex(n.from),i;return s==n.from&&!(i=e.child(r)).isText&&s+i.nodeSize==n.to}eq(e){return this==e||e instanceof Lp&&$l(this.attrs,e.attrs)&&$l(this.spec,e.spec)}destroy(){}}class jt{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new jt(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 jt(e,e,new Yc(n,r))}static inline(e,n,r,s){return new jt(e,n,new Gs(r,s))}static node(e,n,r,s){return new jt(e,n,new Lp(r,s))}get spec(){return this.type.spec}get inline(){return this.type instanceof Gs}get widget(){return this.type instanceof Yc}}const mo=[],_i={};class bt{constructor(e,n){this.local=e.length?e:mo,this.children=n.length?n:mo}static create(e,n){return n.length?Qc(n,e,0,_i):In}find(e,n,r){let s=[];return this.findInner(e??0,n??1e9,s,0,r),s}findInner(e,n,r,s,i){for(let l=0;l<this.local.length;l++){let c=this.local[l];c.from<=n&&c.to>=e&&(!i||i(c.spec))&&r.push(c.copy(c.from+s,c.to+s))}for(let l=0;l<this.children.length;l+=3)if(this.children[l]<n&&this.children[l+1]>e){let c=this.children[l]+1;this.children[l+2].findInner(e-c,n-c,r,s+c,i)}}map(e,n,r){return this==In||e.maps.length==0?this:this.mapInner(e,n,0,0,r||_i)}mapInner(e,n,r,s,i){let l;for(let c=0;c<this.local.length;c++){let u=this.local[c].map(e,r,s);u&&u.type.valid(n,u)?(l||(l=[])).push(u):i.onRemove&&i.onRemove(this.local[c].spec)}return this.children.length?a_(this.children,l||[],e,n,r,s,i):l?new bt(l.sort(Ti),mo):In}add(e,n){return n.length?this==In?bt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let s,i=0;e.forEach((c,u)=>{let f=u+r,p;if(p=xw(n,c,f)){for(s||(s=this.children.slice());i<s.length&&s[i]<u;)i+=3;s[i]==u?s[i+2]=s[i+2].addInner(c,p,f+1):s.splice(i,0,u,u+c.nodeSize,Qc(p,c,f+1,_i)),i+=3}});let l=vw(i?ww(n):n,-r);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||l.splice(c--,1);return new bt(l.length?this.local.concat(l).sort(Ti):this.local,s||this.children)}remove(e){return e.length==0||this==In?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,s=this.local;for(let i=0;i<r.length;i+=3){let l,c=r[i]+n,u=r[i+1]+n;for(let p=0,m;p<e.length;p++)(m=e[p])&&m.from>c&&m.to<u&&(e[p]=null,(l||(l=[])).push(m));if(!l)continue;r==this.children&&(r=this.children.slice());let f=r[i+2].removeInner(l,c+1);f!=In?r[i+2]=f:(r.splice(i,3),i-=3)}if(s.length){for(let i=0,l;i<e.length;i++)if(l=e[i])for(let c=0;c<s.length;c++)s[c].eq(l,n)&&(s==this.local&&(s=this.local.slice()),s.splice(c--,1))}return r==this.children&&s==this.local?this:s.length||r.length?new bt(s,r):In}forChild(e,n){if(this==In)return this;if(n.isLeaf)return bt.empty;let r,s;for(let c=0;c<this.children.length;c+=3)if(this.children[c]>=e){this.children[c]==e&&(r=this.children[c+2]);break}let i=e+1,l=i+n.content.size;for(let c=0;c<this.local.length;c++){let u=this.local[c];if(u.from<l&&u.to>i&&u.type instanceof Gs){let f=Math.max(i,u.from)-i,p=Math.min(l,u.to)-i;f<p&&(s||(s=[])).push(u.copy(f,p))}}if(s){let c=new bt(s.sort(Ti),mo);return r?new Bs([c,r]):c}return r||In}eq(e){if(this==e)return!0;if(!(e instanceof bt)||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 Dp(this.localsInner(e))}localsInner(e){if(this==In)return mo;if(e.inlineContent||!this.local.some(Gs.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Gs||n.push(this.local[r]);return n}forEachSet(e){e(this)}}bt.empty=new bt([],[]);bt.removeOverlap=Dp;const In=bt.empty;class Bs{constructor(e){this.members=e}map(e,n){const r=this.members.map(s=>s.map(e,n,_i));return Bs.from(r)}forChild(e,n){if(n.isLeaf)return bt.empty;let r=[];for(let s=0;s<this.members.length;s++){let i=this.members[s].forChild(e,n);i!=In&&(i instanceof Bs?r=r.concat(i.members):r.push(i))}return Bs.from(r)}eq(e){if(!(e instanceof Bs)||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 i=this.members[s].localsInner(e);if(i.length)if(!n)n=i;else{r&&(n=n.slice(),r=!1);for(let l=0;l<i.length;l++)n.push(i[l])}}return n?Dp(r?n:n.sort(Ti)):mo}static from(e){switch(e.length){case 0:return In;case 1:return e[0];default:return new Bs(e.every(n=>n instanceof bt)?e:e.reduce((n,r)=>n.concat(r instanceof bt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function a_(t,e,n,r,s,i,l){let c=t.slice();for(let f=0,p=i;f<n.maps.length;f++){let m=0;n.maps[f].forEach((y,b,v,w)=>{let k=w-v-(b-y);for(let N=0;N<c.length;N+=3){let T=c[N+1];if(T<0||y>T+p-m)continue;let I=c[N]+p-m;b>=I?c[N+1]=y<=I?-2:-1:y>=p&&k&&(c[N]+=k,c[N+1]+=k)}m+=k}),p=n.maps[f].map(p,-1)}let u=!1;for(let f=0;f<c.length;f+=3)if(c[f+1]<0){if(c[f+1]==-2){u=!0,c[f+1]=-1;continue}let p=n.map(t[f]+i),m=p-s;if(m<0||m>=r.content.size){u=!0;continue}let y=n.map(t[f+1]+i,-1),b=y-s,{index:v,offset:w}=r.content.findIndex(m),k=r.maybeChild(v);if(k&&w==m&&w+k.nodeSize==b){let N=c[f+2].mapInner(n,k,p+1,t[f]+i+1,l);N!=In?(c[f]=m,c[f+1]=b,c[f+2]=N):(c[f+1]=-2,u=!0)}else u=!0}if(u){let f=c_(c,t,e,n,s,i,l),p=Qc(f,r,0,l);e=p.local;for(let m=0;m<c.length;m+=3)c[m+1]<0&&(c.splice(m,3),m-=3);for(let m=0,y=0;m<p.children.length;m+=3){let b=p.children[m];for(;y<c.length&&c[y]<b;)y+=3;c.splice(y,0,p.children[m],p.children[m+1],p.children[m+2])}}return new bt(e.sort(Ti),c)}function vw(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 jt(s.from+e,s.to+e,s.type))}return n}function c_(t,e,n,r,s,i,l){function c(u,f){for(let p=0;p<u.local.length;p++){let m=u.local[p].map(r,s,f);m?n.push(m):l.onRemove&&l.onRemove(u.local[p].spec)}for(let p=0;p<u.children.length;p+=3)c(u.children[p+2],u.children[p]+f+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&c(t[u+2],e[u]+i+1);return n}function xw(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,s=null;for(let i=0,l;i<t.length;i++)(l=t[i])&&l.from>n&&l.to<r&&((s||(s=[])).push(l),t[i]=null);return s}function ww(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Qc(t,e,n,r){let s=[],i=!1;e.forEach((c,u)=>{let f=xw(t,c,u+n);if(f){i=!0;let p=Qc(f,c,n+u+1,r);p!=In&&s.push(u,u+c.nodeSize,p)}});let l=vw(i?ww(t):t,-n).sort(Ti);for(let c=0;c<l.length;c++)l[c].type.valid(e,l[c])||(r.onRemove&&r.onRemove(l[c].spec),l.splice(c--,1));return l.length||s.length?new bt(l,s):In}function Ti(t,e){return t.from-e.from||t.to-e.to}function Dp(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 i=e[s];if(i.from==r.from){i.to!=r.to&&(e==t&&(e=t.slice()),e[s]=i.copy(i.from,r.to),zb(e,s+1,i.copy(r.to,i.to)));continue}else{i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),zb(e,s,r.copy(i.from,r.to)));break}}}return e}function zb(t,e,n){for(;e<t.length&&Ti(n,t[e])>0;)e++;t.splice(e,0,n)}function rh(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=In&&e.push(r)}),t.cursorWrapper&&e.push(bt.create(t.state.doc,[t.cursorWrapper.deco])),Bs.from(e)}const u_={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},d_=Xn&&Vs<=11;class f_{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 h_{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new f_,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]);Xn&&Vs<=11&&r.some(s=>s.type=="childList"&&s.removedNodes.length||s.type=="characterData"&&s.oldValue.length>s.target.nodeValue.length)?this.flushSoon():jn&&e.composing&&r.some(s=>s.type=="childList"&&s.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),d_&&(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,u_)),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(Ob(this.view)){if(this.suppressingSelectionUpdates)return ds(this.view);if(Xn&&Vs<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ri(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 i=e.focusNode;i;i=No(i))n.add(i);for(let i=e.anchorNode;i;i=No(i))if(n.has(i)){r=i;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)&&Ob(e)&&!this.ignoreSelectionChange(r),i=-1,l=-1,c=!1,u=[];if(e.editable)for(let p=0;p<n.length;p++){let m=this.registerMutation(n[p],u);m&&(i=i<0?m.from:Math.min(m.from,i),l=l<0?m.to:Math.max(m.to,l),m.typeOver&&(c=!0))}if(u.some(p=>p.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let p of u)if(p.nodeName=="BR"&&p.parentNode){let m=p.nextSibling;m&&m.nodeType==1&&m.contentEditable=="false"&&p.parentNode.removeChild(p)}}else if(yr&&u.length){let p=u.filter(m=>m.nodeName=="BR");if(p.length==2){let[m,y]=p;m.parentNode&&m.parentNode.parentNode==y.parentNode?y.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let y of p){let b=y.parentNode;b&&b.nodeName=="LI"&&(!m||g_(e,m)!=b)&&y.remove()}}}let f=null;i<0&&s&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Wu(r)&&(f=Mp(e))&&f.eq(Ye.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,ds(e),this.currentSelection.set(r),e.scrollToSelection()):(i>-1||s)&&(i>-1&&(e.docView.markDirty(i,l),p_(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,y_(e,u)),this.handleDOMChange(i,l,c,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||ds(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 p=0;p<e.addedNodes.length;p++){let m=e.addedNodes[p];n.push(m),m.nodeType==3&&(this.lastChangedTextNode=m)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let s=e.previousSibling,i=e.nextSibling;if(Xn&&Vs<=11&&e.addedNodes.length)for(let p=0;p<e.addedNodes.length;p++){let{previousSibling:m,nextSibling:y}=e.addedNodes[p];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(s=m),(!y||Array.prototype.indexOf.call(e.addedNodes,y)<0)&&(i=y)}let l=s&&s.parentNode==e.target?Cn(s)+1:0,c=r.localPosFromDOM(e.target,l,-1),u=i&&i.parentNode==e.target?Cn(i):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:c,to:f}}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 $b=new WeakMap,Fb=!1;function p_(t){if(!$b.has(t)&&($b.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=yr,Fb)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."),Fb=!0}}function Ub(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,i=e.endOffset,l=t.domAtPos(t.state.selection.anchor);return Ri(l.node,l.offset,s,i)&&([n,r,s,i]=[s,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:i}}function m_(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return Ub(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?Ub(t,n):null}function g_(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 y_(t,e){var n;let{focusNode:r,focusOffset:s}=t.domSelectionRange();for(let i of e)if(((n=i.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let l=i.nextSibling;for(;l&&l.nodeName!="TD"&&l.nodeName!="TH";)l=l.nextSibling;if(l){let c=l;for(;;){let u=c.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;c=u}c.insertBefore(i,c.firstChild),r==i&&t.domSelection().collapse(i,s)}else i.parentNode.removeChild(i)}}function b_(t,e,n){let{node:r,fromOffset:s,toOffset:i,from:l,to:c}=t.docView.parseRange(e,n),u=t.domSelectionRange(),f,p=u.anchorNode;if(p&&t.dom.contains(p.nodeType==1?p:p.parentNode)&&(f=[{node:p,offset:u.anchorOffset}],Wu(u)||f.push({node:u.focusNode,offset:u.focusOffset})),Tn&&t.input.lastKeyCode===8)for(let k=i;k>s;k--){let N=r.childNodes[k-1],T=N.pmViewDesc;if(N.nodeName=="BR"&&!T){i=k;break}if(!T||T.size)break}let m=t.state.doc,y=t.someProp("domParser")||Ws.fromSchema(t.state.schema),b=m.resolve(l),v=null,w=y.parse(r,{topNode:b.parent,topMatch:b.parent.contentMatchAt(b.index()),topOpen:!0,from:s,to:i,preserveWhitespace:b.parent.type.whitespace=="pre"?"full":!0,findPositions:f,ruleFromNode:v_,context:b});if(f&&f[0].pos!=null){let k=f[0].pos,N=f[1]&&f[1].pos;N==null&&(N=k),v={anchor:k+l,head:N+l}}return{doc:w,sel:v,from:l,to:c}}function v_(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(jn&&/^(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||jn&&/^(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 x_=/^(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 w_(t,e,n,r,s){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let P=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,$=Mp(t,P);if($&&!t.state.selection.eq($)){if(Tn&&cs&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",W=>W(t,xi(13,"Enter"))))return;let B=t.state.tr.setSelection($);P=="pointer"?B.setMeta("pointer",!0):P=="key"&&B.scrollIntoView(),i&&B.setMeta("composition",i),t.dispatch(B)}return}let l=t.state.doc.resolve(e),c=l.sharedDepth(n);e=l.before(c+1),n=t.state.doc.resolve(n).after(c+1);let u=t.state.selection,f=b_(t,e,n),p=t.state.doc,m=p.slice(f.from,f.to),y,b;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(y=t.state.selection.to,b="end"):(y=t.state.selection.from,b="start"),t.input.lastKeyCode=null;let v=E_(m.content,f.doc.content,f.from,y,b);if(v&&t.input.domChangeCount++,(Co&&t.input.lastIOSEnter>Date.now()-225||cs)&&s.some(P=>P.nodeType==1&&!x_.test(P.nodeName))&&(!v||v.endA>=v.endB)&&t.someProp("handleKeyDown",P=>P(t,xi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!v)if(r&&u instanceof Fe&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))v={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let P=Hb(t,t.state.doc,f.sel);if(P&&!P.eq(t.state.selection)){let $=t.state.tr.setSelection(P);i&&$.setMeta("composition",i),t.dispatch($)}}return}t.state.selection.from<t.state.selection.to&&v.start==v.endB&&t.state.selection instanceof Fe&&(v.start>t.state.selection.from&&v.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?v.start=t.state.selection.from:v.endA<t.state.selection.to&&v.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(v.endB+=t.state.selection.to-v.endA,v.endA=t.state.selection.to)),Xn&&Vs<=11&&v.endB==v.start+1&&v.endA==v.start&&v.start>f.from&&f.doc.textBetween(v.start-f.from-1,v.start-f.from+1)=="  "&&(v.start--,v.endA--,v.endB--);let w=f.doc.resolveNoCache(v.start-f.from),k=f.doc.resolveNoCache(v.endB-f.from),N=p.resolve(v.start),T=w.sameParent(k)&&w.parent.inlineContent&&N.end()>=v.endA;if((Co&&t.input.lastIOSEnter>Date.now()-225&&(!T||s.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!T&&w.pos<f.doc.content.size&&(!w.sameParent(k)||!w.parent.inlineContent)&&w.pos<k.pos&&!/\S/.test(f.doc.textBetween(w.pos,k.pos,"","")))&&t.someProp("handleKeyDown",P=>P(t,xi(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>v.start&&S_(p,v.start,v.endA,w,k)&&t.someProp("handleKeyDown",P=>P(t,xi(8,"Backspace")))){cs&&Tn&&t.domObserver.suppressSelectionUpdates();return}Tn&&v.endB==v.start&&(t.input.lastChromeDelete=Date.now()),cs&&!T&&w.start()!=k.start()&&k.parentOffset==0&&w.depth==k.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==v.endA&&(v.endB-=2,k=f.doc.resolveNoCache(v.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,xi(13,"Enter"))})},20));let I=v.start,_=v.endA,M=P=>{let $=P||t.state.tr.replace(I,_,f.doc.slice(v.start-f.from,v.endB-f.from));if(f.sel){let B=Hb(t,$.doc,f.sel);B&&!(Tn&&t.composing&&B.empty&&(v.start!=v.endB||t.input.lastChromeDelete<Date.now()-100)&&(B.head==I||B.head==$.mapping.map(_)-1)||Xn&&B.empty&&B.head==I)&&$.setSelection(B)}return i&&$.setMeta("composition",i),$.scrollIntoView()},O;if(T)if(w.pos==k.pos){Xn&&Vs<=11&&w.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>ds(t),20));let P=M(t.state.tr.delete(I,_)),$=p.resolve(v.start).marksAcross(p.resolve(v.endA));$&&P.ensureMarks($),t.dispatch(P)}else if(v.endA==v.endB&&(O=k_(w.parent.content.cut(w.parentOffset,k.parentOffset),N.parent.content.cut(N.parentOffset,v.endA-N.start())))){let P=M(t.state.tr);O.type=="add"?P.addMark(I,_,O.mark):P.removeMark(I,_,O.mark),t.dispatch(P)}else if(w.parent.child(w.index()).isText&&w.index()==k.index()-(k.textOffset?0:1)){let P=w.parent.textBetween(w.parentOffset,k.parentOffset),$=()=>M(t.state.tr.insertText(P,I,_));t.someProp("handleTextInput",B=>B(t,I,_,P,$))||t.dispatch($())}else t.dispatch(M());else t.dispatch(M())}function Hb(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ap(t,e.resolve(n.anchor),e.resolve(n.head))}function k_(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,s=n,i=r,l,c,u;for(let p=0;p<r.length;p++)s=r[p].removeFromSet(s);for(let p=0;p<n.length;p++)i=n[p].removeFromSet(i);if(s.length==1&&i.length==0)c=s[0],l="add",u=p=>p.mark(c.addToSet(p.marks));else if(s.length==0&&i.length==1)c=i[0],l="remove",u=p=>p.mark(c.removeFromSet(p.marks));else return null;let f=[];for(let p=0;p<e.childCount;p++)f.push(u(e.child(p)));if(ae.from(f).eq(t))return{mark:c,type:l}}function S_(t,e,n,r,s){if(n-e<=s.pos-r.pos||sh(r,!0,!1)<s.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let c=i.nodeAfter;return c!=null&&n==e+c.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let l=t.resolve(sh(i,!0,!0));return!l.parent.isTextblock||l.pos>n||sh(l,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(l.parent.content)}function sh(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 i=t.node(r).maybeChild(t.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,s++}return s}function E_(t,e,n,r,s){let i=t.findDiffStart(e,n);if(i==null)return null;let{a:l,b:c}=t.findDiffEnd(e,n+t.size,n+e.size);if(s=="end"){let u=Math.max(0,i-Math.min(l,c));r-=l+u-i}if(l<i&&t.size<e.size){let u=r<=i&&r>=l?i-r:0;i-=u,i&&i<e.size&&Wb(e.textBetween(i-1,i+1))&&(i+=u?1:-1),c=i+(c-l),l=i}else if(c<i){let u=r<=i&&r>=c?i-r:0;i-=u,i&&i<t.size&&Wb(t.textBetween(i-1,i+1))&&(i+=u?1:-1),l=i+(l-c),c=i}return{start:i,endA:l,endB:c}}function Wb(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 kw{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 $C,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(Jb),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=Gb(this),Kb(this),this.nodeViews=qb(this),this.docView=Nb(this.state.doc,Vb(this),rh(this),this.dom,this),this.domObserver=new h_(this,(r,s,i,l)=>w_(this,r,s,i,l)),this.domObserver.start(),FC(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&&Gh(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Jb),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,i=!1,l=!1;e.storedMarks&&this.composing&&(mw(this),l=!0),this.state=e;let c=s.plugins!=e.plugins||this._props.plugins!=n.plugins;if(c||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=qb(this);C_(b,this.nodeViews)&&(this.nodeViews=b,i=!0)}(c||n.handleDOMEvents!=this._props.handleDOMEvents)&&Gh(this),this.editable=Gb(this),Kb(this);let u=rh(this),f=Vb(this),p=s.plugins!=e.plugins&&!s.doc.eq(e.doc)?"reset":e.scrollToSelection>s.scrollToSelection?"to selection":"preserve",m=i||!this.docView.matchesNode(e.doc,f,u);(m||!e.selection.eq(s.selection))&&(l=!0);let y=p=="preserve"&&l&&this.dom.style.overflowAnchor==null&&tC(this);if(l){this.domObserver.stop();let b=m&&(Xn||Tn)&&!this.composing&&!s.selection.empty&&!e.selection.empty&&N_(s.selection,e.selection);if(m){let v=Tn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=t_(this)),(i||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=Nb(e.doc,f,u,this.dom,this)),v&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}b||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&NC(this))?ds(this,b):(rw(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),p=="reset"?this.dom.scrollTop=0:p=="to selection"?this.scrollToSelection():y&&nC(y)}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 ze){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&vb(this,n.getBoundingClientRect(),e)}else vb(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 i=r.from+(this.state.doc.content.size-n.doc.content.size);(i>0&&this.state.doc.nodeAt(i))==r.node&&(s=i)}this.dragging=new yw(e.slice,e.move,s<0?void 0:ze.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 l=0;l<this.directPlugins.length;l++){let c=this.directPlugins[l].props[e];if(c!=null&&(s=n?n(c):c))return s}let i=this.state.plugins;if(i)for(let l=0;l<i.length;l++){let c=i[l].props[e];if(c!=null&&(s=n?n(c):c))return s}}hasFocus(){if(Xn){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&&rC(this.dom),ds(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 aC(this,e)}coordsAtPos(e,n=1){return Jx(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 hC(this,n||this.state,e)}pasteHTML(e,n){return zl(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return zl(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Op(this,e)}destroy(){this.docView&&(UC(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],rh(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,VN())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return WC(this,e)}domSelectionRange(){let e=this.domSelection();return e?jn&&this.root.nodeType===11&&YN(this.dom.ownerDocument)==this.dom&&m_(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}kw.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function Vb(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"),[jt.node(0,t.state.doc.content.size,e)]}function Kb(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:jt.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function Gb(t){return!t.someProp("editable",e=>e(t.state)===!1)}function N_(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 qb(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 C_(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 Jb(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 Js={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:"'"},Xc={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},__=typeof navigator<"u"&&/Mac/.test(navigator.platform),T_=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var _n=0;_n<10;_n++)Js[48+_n]=Js[96+_n]=String(_n);for(var _n=1;_n<=24;_n++)Js[_n+111]="F"+_n;for(var _n=65;_n<=90;_n++)Js[_n]=String.fromCharCode(_n+32),Xc[_n]=String.fromCharCode(_n);for(var ih in Js)Xc.hasOwnProperty(ih)||(Xc[ih]=Js[ih]);function M_(t){var e=__&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||T_&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Xc:Js)[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 A_=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),O_=typeof navigator<"u"&&/Win/.test(navigator.platform);function R_(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,s,i,l;for(let c=0;c<e.length-1;c++){let u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))A_?l=!0:s=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),s&&(n="Ctrl-"+n),l&&(n="Meta-"+n),i&&(n="Shift-"+n),n}function I_(t){let e=Object.create(null);for(let n in t)e[R_(n)]=t[n];return e}function oh(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 j_(t){return new kt({props:{handleKeyDown:Pp(t)}})}function Pp(t){let e=I_(t);return function(n,r){let s=M_(r),i,l=e[oh(s,r)];if(l&&l(n.state,n.dispatch,n))return!0;if(s.length==1&&s!=" "){if(r.shiftKey){let c=e[oh(s,r,!1)];if(c&&c(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(O_&&r.ctrlKey&&r.altKey)&&(i=Js[r.keyCode])&&i!=s){let c=e[oh(i,r)];if(c&&c(n.state,n.dispatch,n))return!0}}return!1}}var L_=Object.defineProperty,Bp=(t,e)=>{for(var n in e)L_(t,n,{get:e[n],enumerable:!0})};function Gu(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:s}=n,{storedMarks:i}=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 i},get selection(){return r},get doc(){return s},get tr(){return r=n.selection,s=n.doc,i=n.storedMarks,n}}}var qu=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,i=this.buildProps(s);return Object.fromEntries(Object.entries(t).map(([l,c])=>[l,(...f)=>{const p=c(...f)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(s),p}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,l=[],c=!!t,u=t||s.tr,f=()=>(!c&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(u),l.every(m=>m===!0)),p={...Object.fromEntries(Object.entries(n).map(([m,y])=>[m,(...v)=>{const w=this.buildProps(u,e),k=y(...v)(w);return l.push(k),p}])),run:f};return p}createCan(t){const{rawCommands:e,state:n}=this,r=!1,s=t||n.tr,i=this.buildProps(s,r);return{...Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...f)=>u(...f)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:s}=this,{view:i}=r,l={tr:t,editor:r,view:i,state:Gu({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(([c,u])=>[c,(...f)=>u(...f)(l)]))}};return l}},Sw={};Bp(Sw,{blur:()=>D_,clearContent:()=>P_,clearNodes:()=>B_,command:()=>z_,createParagraphNear:()=>$_,cut:()=>F_,deleteCurrentNode:()=>U_,deleteNode:()=>H_,deleteRange:()=>W_,deleteSelection:()=>V_,enter:()=>K_,exitCode:()=>G_,extendMarkRange:()=>q_,first:()=>J_,focus:()=>Q_,forEach:()=>X_,insertContent:()=>Z_,insertContentAt:()=>nT,joinBackward:()=>iT,joinDown:()=>sT,joinForward:()=>oT,joinItemBackward:()=>lT,joinItemForward:()=>aT,joinTextblockBackward:()=>cT,joinTextblockForward:()=>uT,joinUp:()=>rT,keyboardShortcut:()=>fT,lift:()=>hT,liftEmptyBlock:()=>pT,liftListItem:()=>mT,newlineInCode:()=>gT,resetAttributes:()=>yT,scrollIntoView:()=>bT,selectAll:()=>vT,selectNodeBackward:()=>xT,selectNodeForward:()=>wT,selectParentNode:()=>kT,selectTextblockEnd:()=>ST,selectTextblockStart:()=>ET,setContent:()=>NT,setMark:()=>HT,setMeta:()=>WT,setNode:()=>VT,setNodeSelection:()=>KT,setTextDirection:()=>GT,setTextSelection:()=>qT,sinkListItem:()=>JT,splitBlock:()=>YT,splitListItem:()=>QT,toggleList:()=>XT,toggleMark:()=>ZT,toggleNode:()=>eM,toggleWrap:()=>tM,undoInputRule:()=>nM,unsetAllMarks:()=>rM,unsetMark:()=>sM,unsetTextDirection:()=>iM,updateAttributes:()=>oM,wrapIn:()=>lM,wrapInList:()=>aM});var D_=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())==null||n.removeAllRanges())}),!0),P_=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),B_=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:s}=r;return n&&s.forEach(({$from:i,$to:l})=>{t.doc.nodesBetween(i.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:f,mapping:p}=e,m=f.resolve(p.map(u)),y=f.resolve(p.map(u+c.nodeSize)),b=m.blockRange(y);if(!b)return;const v=Ao(b);if(c.type.isTextblock){const{defaultType:w}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,w)}(v||v===0)&&e.lift(b,v)})}),!0},z_=t=>e=>t(e),$_=()=>({state:t,dispatch:e})=>Bx(t,e),F_=(t,e)=>({editor:n,tr:r})=>{const{state:s}=n,i=s.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const l=r.mapping.map(e);return r.insert(l,i.content),r.setSelection(new Fe(r.doc.resolve(Math.max(l-1,0)))),!0},U_=()=>({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 i=s.depth;i>0;i-=1)if(s.node(i).type===r.type){if(e){const c=s.before(i),u=s.after(i);t.delete(c,u).scrollIntoView()}return!0}return!1};function ln(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}var H_=t=>({tr:e,state:n,dispatch:r})=>{const s=ln(t,n.schema),i=e.selection.$anchor;for(let l=i.depth;l>0;l-=1)if(i.node(l).type===s){if(r){const u=i.before(l),f=i.after(l);e.delete(u,f).scrollIntoView()}return!0}return!1},W_=t=>({tr:e,dispatch:n})=>{const{from:r,to:s}=t;return n&&e.delete(r,s),!0},V_=()=>({state:t,dispatch:e})=>Sp(t,e),K_=()=>({commands:t})=>t.keyboardShortcut("Enter"),G_=()=>({state:t,dispatch:e})=>AN(t,e);function zp(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Zc(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(s=>n.strict?e[s]===t[s]:zp(e[s])?e[s].test(t[s]):e[s]===t[s]):!0}function Ew(t,e,n={}){return t.find(r=>r.type===e&&Zc(Object.fromEntries(Object.keys(n).map(s=>[s,r.attrs[s]])),n))}function Yb(t,e,n={}){return!!Ew(t,e,n)}function $p(t,e,n){var r;if(!t||!e)return;let s=t.parent.childAfter(t.parentOffset);if((!s.node||!s.node.marks.some(p=>p.type===e))&&(s=t.parent.childBefore(t.parentOffset)),!s.node||!s.node.marks.some(p=>p.type===e)||(n=n||((r=s.node.marks[0])==null?void 0:r.attrs),!Ew([...s.node.marks],e,n)))return;let l=s.index,c=t.start()+s.offset,u=l+1,f=c+s.node.nodeSize;for(;l>0&&Yb([...t.parent.child(l-1).marks],e,n);)l-=1,c-=t.parent.child(l).nodeSize;for(;u<t.parent.childCount&&Yb([...t.parent.child(u).marks],e,n);)f+=t.parent.child(u).nodeSize,u+=1;return{from:c,to:f}}function fs(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}var q_=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const i=fs(t,r.schema),{doc:l,selection:c}=n,{$from:u,from:f,to:p}=c;if(s){const m=$p(u,i,e);if(m&&m.from<=f&&m.to>=p){const y=Fe.create(l,m.from,m.to);n.setSelection(y)}}return!0},J_=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 Nw(t){return t instanceof Fe}function Si(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Cw(t,e=null){if(!e)return null;const n=Ye.atStart(t),r=Ye.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const s=n.from,i=r.to;return e==="all"?Fe.create(t,Si(0,s,i),Si(t.content.size,s,i)):Fe.create(t,Si(e,s,i),Si(e,s,i))}function Qb(){return navigator.platform==="Android"||/android/i.test(navigator.userAgent)}function eu(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function Y_(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var Q_=(t=null,e={})=>({editor:n,view:r,tr:s,dispatch:i})=>{e={scrollIntoView:!0,...e};const l=()=>{(eu()||Qb())&&r.dom.focus(),Y_()&&!eu()&&!Qb()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(i&&t===null&&!Nw(n.state.selection))return l(),!0;const c=Cw(s.doc,t)||n.state.selection,u=n.state.selection.eq(c);return i&&(u||s.setSelection(c),u&&s.storedMarks&&s.setStoredMarks(s.storedMarks),l()),!0},X_=(t,e)=>n=>t.every((r,s)=>e(r,{...n,index:s})),Z_=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),_w=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&&_w(r)}return t};function cc(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 _w(n)}function Fl(t,e,n){if(t instanceof Mr||t instanceof ae)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 ae.fromArray(t.map(c=>e.nodeFromJSON(c)));const l=e.nodeFromJSON(t);return n.errorOnInvalidContent&&l.check(),l}catch(i){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",i),Fl("",e,n)}if(s){if(n.errorOnInvalidContent){let l=!1,c="";const u=new dx({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:f=>(l=!0,c=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?Ws.fromSchema(u).parseSlice(cc(t),n.parseOptions):Ws.fromSchema(u).parse(cc(t),n.parseOptions),n.errorOnInvalidContent&&l)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${c}`)})}const i=Ws.fromSchema(e);return n.slice?i.parseSlice(cc(t),n.parseOptions).content:i.parse(cc(t),n.parseOptions)}return Fl("",e,n)}function eT(t,e,n){const r=t.steps.length-1;if(r<e)return;const s=t.steps[r];if(!(s instanceof mn||s instanceof gn))return;const i=t.mapping.maps[r];let l=0;i.forEach((c,u,f,p)=>{l===0&&(l=p)}),t.setSelection(Ye.near(t.doc.resolve(l),n))}var tT=t=>!("type"in t),nT=(t,e,n)=>({tr:r,dispatch:s,editor:i})=>{var l;if(s){n={parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let c;const u=k=>{i.emit("contentError",{editor:i,error:k,disableCollaboration:()=>{"collaboration"in i.storage&&typeof i.storage.collaboration=="object"&&i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!i.options.enableContentCheck&&i.options.emitContentError)try{Fl(e,i.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(k){u(k)}try{c=Fl(e,i.schema,{parseOptions:f,errorOnInvalidContent:(l=n.errorOnInvalidContent)!=null?l:i.options.enableContentCheck})}catch(k){return u(k),!1}let{from:p,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},y=!0,b=!0;if((tT(c)?c:[c]).forEach(k=>{k.check(),y=y?k.isText&&k.marks.length===0:!1,b=b?k.isBlock:!1}),p===m&&b){const{parent:k}=r.doc.resolve(p);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(p-=1,m+=1)}let w;if(y){if(Array.isArray(e))w=e.map(k=>k.text||"").join("");else if(e instanceof ae){let k="";e.forEach(N=>{N.text&&(k+=N.text)}),w=k}else typeof e=="object"&&e&&e.text?w=e.text:w=e;r.insertText(w,p,m)}else{w=c;const k=r.doc.resolve(p),N=k.node(),T=k.parentOffset===0,I=N.isText||N.isTextblock,_=N.content.size>0;T&&I&&_&&(p=Math.max(0,p-1)),r.replaceWith(p,m,w)}n.updateSelection&&eT(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:p,text:w}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:p,text:w})}return!0},rT=()=>({state:t,dispatch:e})=>_N(t,e),sT=()=>({state:t,dispatch:e})=>TN(t,e),iT=()=>({state:t,dispatch:e})=>Ox(t,e),oT=()=>({state:t,dispatch:e})=>Lx(t,e),lT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Fu(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},aT=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Fu(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},cT=()=>({state:t,dispatch:e})=>NN(t,e),uT=()=>({state:t,dispatch:e})=>CN(t,e);function Tw(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function dT(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,s,i,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))s=!0;else if(/^s(hift)?$/i.test(u))i=!0;else if(/^mod$/i.test(u))eu()||Tw()?l=!0:s=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),s&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),i&&(n=`Shift-${n}`),n}var fT=t=>({editor:e,view:n,tr:r,dispatch:s})=>{const i=dT(t).split(/-(?!$)/),l=i.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,c))});return u==null||u.steps.forEach(f=>{const p=f.map(r.mapping);p&&s&&r.maybeStep(p)}),!0};function Ys(t,e,n={}){const{from:r,to:s,empty:i}=t.selection,l=e?ln(e,t.schema):null,c=[];t.doc.nodesBetween(r,s,(m,y)=>{if(m.isText)return;const b=Math.max(r,y),v=Math.min(s,y+m.nodeSize);c.push({node:m,from:b,to:v})});const u=s-r,f=c.filter(m=>l?l.name===m.node.type.name:!0).filter(m=>Zc(m.node.attrs,n,{strict:!1}));return i?!!f.length:f.reduce((m,y)=>m+y.to-y.from,0)>=u}var hT=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return Ys(n,s,e)?MN(n,r):!1},pT=()=>({state:t,dispatch:e})=>zx(t,e),mT=t=>({state:e,dispatch:n})=>{const r=ln(t,e.schema);return FN(r)(e,n)},gT=()=>({state:t,dispatch:e})=>Px(t,e);function Ju(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Xb(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 yT=(t,e)=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Ju(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=ln(t,r.schema)),c==="mark"&&(l=fs(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(p,m)=>{i&&i===p.type&&(u=!0,s&&n.setNodeMarkup(m,void 0,Xb(p.attrs,e))),l&&p.marks.length&&p.marks.forEach(y=>{l===y.type&&(u=!0,s&&n.addMark(m,m+p.nodeSize,l.create(Xb(y.attrs,e))))})})}),u},bT=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),vT=()=>({tr:t,dispatch:e})=>{if(e){const n=new ir(t.doc);t.setSelection(n)}return!0},xT=()=>({state:t,dispatch:e})=>Ix(t,e),wT=()=>({state:t,dispatch:e})=>Dx(t,e),kT=()=>({state:t,dispatch:e})=>IN(t,e),ST=()=>({state:t,dispatch:e})=>DN(t,e),ET=()=>({state:t,dispatch:e})=>LN(t,e);function qh(t,e,n={},r={}){return Fl(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var NT=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:s,tr:i,dispatch:l,commands:c})=>{const{doc:u}=i;if(r.preserveWhitespace!=="full"){const f=qh(t,s.schema,r,{errorOnInvalidContent:e??s.options.enableContentCheck});return l&&i.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!n),!0}return l&&i.setMeta("preventUpdate",!n),c.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??s.options.enableContentCheck})};function Mw(t,e){const n=fs(e,t.schema),{from:r,to:s,empty:i}=t.selection,l=[];i?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,s,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function Fp(t,e){const n=new wp(t);return e.forEach(r=>{r.steps.forEach(s=>{n.step(s)})}),n}function CT(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 tu(t,e){const n=[];return t.descendants((r,s)=>{e(r)&&n.push({node:r,pos:s})}),n}function Aw(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(s,i)=>{n(s)&&r.push({node:s,pos:i})}),r}function Ow(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 Yu(t){return e=>Ow(e.$from,t)}function Pe(t,e,n){return t.config[e]===void 0&&t.parent?Pe(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Pe(t.parent,e,n):null}):t.config[e]}function Up(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=Pe(e,"addExtensions",n);return r?[e,...Up(r())]:e}).flat(10)}function Hp(t,e){const n=Pi.fromSchema(e).serializeFragment(t),s=document.implementation.createHTMLDocument().createElement("div");return s.appendChild(n),s.innerHTML}function Rw(t){return typeof t=="function"}function xt(t,e=void 0,...n){return Rw(t)?e?t.bind(e)(...n):t(...n):t}function _T(t={}){return Object.keys(t).length===0&&t.constructor===Object}function _o(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 Iw(t){const e=[],{nodeExtensions:n,markExtensions:r}=_o(t),s=[...n,...r],i={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage,extensions:s},u=Pe(l,"addGlobalAttributes",c);if(!u)return;u().forEach(p=>{p.types.forEach(m=>{Object.entries(p.attributes).forEach(([y,b])=>{e.push({type:m,name:y,attribute:{...i,...b}})})})})}),s.forEach(l=>{const c={name:l.name,options:l.options,storage:l.storage},u=Pe(l,"addAttributes",c);if(!u)return;const f=u();Object.entries(f).forEach(([p,m])=>{const y={...i,...m};typeof(y==null?void 0:y.default)=="function"&&(y.default=y.default()),y!=null&&y.isRequired&&(y==null?void 0:y.default)===void 0&&delete y.default,e.push({type:l.name,name:p,attribute:y})})}),e}function wt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([s,i])=>{if(!r[s]){r[s]=i;return}if(s==="class"){const c=i?String(i).split(" "):[],u=r[s]?r[s].split(" "):[],f=c.filter(p=>!u.includes(p));r[s]=[...u,...f].join(" ")}else if(s==="style"){const c=i?i.split(";").map(p=>p.trim()).filter(Boolean):[],u=r[s]?r[s].split(";").map(p=>p.trim()).filter(Boolean):[],f=new Map;u.forEach(p=>{const[m,y]=p.split(":").map(b=>b.trim());f.set(m,y)}),c.forEach(p=>{const[m,y]=p.split(":").map(b=>b.trim());f.set(m,y)}),r[s]=Array.from(f.entries()).map(([p,m])=>`${p}: ${m}`).join("; ")}else r[s]=i}),r},{})}function Ul(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)=>wt(n,r),{})}function TT(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function Zb(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((i,l)=>{const c=l.attribute.parseHTML?l.attribute.parseHTML(n):TT(n.getAttribute(l.name));return c==null?i:{...i,[l.name]:c}},{});return{...r,...s}}}}function ev(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&_T(n)?!1:n!=null))}function tv(t){var e,n;const r={};return!((e=t==null?void 0:t.attribute)!=null&&e.isRequired)&&"default"in((t==null?void 0:t.attribute)||{})&&(r.default=t.attribute.default),((n=t==null?void 0:t.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function MT(t,e){var n;const r=Iw(t),{nodeExtensions:s,markExtensions:i}=_o(t),l=(n=s.find(f=>Pe(f,"topNode")))==null?void 0:n.name,c=Object.fromEntries(s.map(f=>{const p=r.filter(N=>N.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((N,T)=>{const I=Pe(T,"extendNodeSchema",m);return{...N,...I?I(f):{}}},{}),b=ev({...y,content:xt(Pe(f,"content",m)),marks:xt(Pe(f,"marks",m)),group:xt(Pe(f,"group",m)),inline:xt(Pe(f,"inline",m)),atom:xt(Pe(f,"atom",m)),selectable:xt(Pe(f,"selectable",m)),draggable:xt(Pe(f,"draggable",m)),code:xt(Pe(f,"code",m)),whitespace:xt(Pe(f,"whitespace",m)),linebreakReplacement:xt(Pe(f,"linebreakReplacement",m)),defining:xt(Pe(f,"defining",m)),isolating:xt(Pe(f,"isolating",m)),attrs:Object.fromEntries(p.map(tv))}),v=xt(Pe(f,"parseHTML",m));v&&(b.parseDOM=v.map(N=>Zb(N,p)));const w=Pe(f,"renderHTML",m);w&&(b.toDOM=N=>w({node:N,HTMLAttributes:Ul(N,p)}));const k=Pe(f,"renderText",m);return k&&(b.toText=k),[f.name,b]})),u=Object.fromEntries(i.map(f=>{const p=r.filter(k=>k.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},y=t.reduce((k,N)=>{const T=Pe(N,"extendMarkSchema",m);return{...k,...T?T(f):{}}},{}),b=ev({...y,inclusive:xt(Pe(f,"inclusive",m)),excludes:xt(Pe(f,"excludes",m)),group:xt(Pe(f,"group",m)),spanning:xt(Pe(f,"spanning",m)),code:xt(Pe(f,"code",m)),attrs:Object.fromEntries(p.map(tv))}),v=xt(Pe(f,"parseHTML",m));v&&(b.parseDOM=v.map(k=>Zb(k,p)));const w=Pe(f,"renderHTML",m);return w&&(b.toDOM=k=>w({mark:k,HTMLAttributes:Ul(k,p)})),[f.name,b]}));return new dx({topNode:l,nodes:c,marks:u})}function AT(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function nu(t){return t.sort((n,r)=>{const s=Pe(n,"priority")||100,i=Pe(r,"priority")||100;return s>i?-1:s<i?1:0})}function jw(t){const e=nu(Up(t)),n=AT(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 Lw(t,e,n){const{from:r,to:s}=e,{blockSeparator:i=`
58
+
59
+ `,textSerializers:l={}}=n||{};let c="";return t.nodesBetween(r,s,(u,f,p,m)=>{var y;u.isBlock&&f>r&&(c+=i);const b=l==null?void 0:l[u.type.name];if(b)return p&&(c+=b({node:u,pos:f,parent:p,index:m,range:e})),!1;u.isText&&(c+=(y=u==null?void 0:u.text)==null?void 0:y.slice(Math.max(r,f)-f,s-f))}),c}function OT(t,e){const n={from:0,to:t.content.size};return Lw(t,n,e)}function Dw(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function RT(t,e){const n=ln(e,t.schema),{from:r,to:s}=t.selection,i=[];t.doc.nodesBetween(r,s,c=>{i.push(c)});const l=i.reverse().find(c=>c.type.name===n.name);return l?{...l.attrs}:{}}function Pw(t,e){const n=Ju(typeof e=="string"?e:e.name,t.schema);return n==="node"?RT(t,e):n==="mark"?Mw(t,e):{}}function IT(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 jT(t){const e=IT(t);return e.length===1?e:e.filter((n,r)=>!e.filter((i,l)=>l!==r).some(i=>n.oldRange.from>=i.oldRange.from&&n.oldRange.to<=i.oldRange.to&&n.newRange.from>=i.newRange.from&&n.newRange.to<=i.newRange.to))}function Wp(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((s,i)=>{const l=[];if(s.ranges.length)s.forEach((c,u)=>{l.push({from:c,to:u})});else{const{from:c,to:u}=n[i];if(c===void 0||u===void 0)return;l.push({from:c,to:u})}l.forEach(({from:c,to:u})=>{const f=e.slice(i).map(c,-1),p=e.slice(i).map(u),m=e.invert().map(f,-1),y=e.invert().map(p);r.push({oldRange:{from:m,to:y},newRange:{from:f,to:p}})})}),jT(r)}function Vp(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(s=>{const i=n.resolve(t),l=$p(i,s.type);l&&r.push({mark:s,...l})}):n.nodesBetween(t,e,(s,i)=>{!s||(s==null?void 0:s.nodeSize)===void 0||r.push(...s.marks.map(l=>({from:i,to:i+s.nodeSize,mark:l})))}),r}var LT=(t,e,n,r=20)=>{const s=t.doc.resolve(n);let i=r,l=null;for(;i>0&&l===null;){const c=s.node(i);(c==null?void 0:c.type.name)===e?l=c:i-=1}return[l,i]};function uc(t,e){return e.nodes[t]||e.marks[t]||null}function Dc(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const s=t.find(i=>i.type===e&&i.name===r);return s?s.attribute.keepOnSplit:!1}))}var DT=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(s,i,l,c)=>{var u,f;const p=((f=(u=s.type.spec).toText)==null?void 0:f.call(u,{node:s,pos:i,parent:l,index:c}))||s.textContent||"%leaf%";n+=s.isAtom&&!s.isText?p:p.slice(0,Math.max(0,r-i))}),n};function Jh(t,e,n={}){const{empty:r,ranges:s}=t.selection,i=e?fs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>i?i.name===m.type.name:!0).find(m=>Zc(m.attrs,n,{strict:!1}));let l=0;const c=[];if(s.forEach(({$from:m,$to:y})=>{const b=m.pos,v=y.pos;t.doc.nodesBetween(b,v,(w,k)=>{if(!w.isText&&!w.marks.length)return;const N=Math.max(b,k),T=Math.min(v,k+w.nodeSize),I=T-N;l+=I,c.push(...w.marks.map(_=>({mark:_,from:N,to:T})))})}),l===0)return!1;const u=c.filter(m=>i?i.name===m.mark.type.name:!0).filter(m=>Zc(m.mark.attrs,n,{strict:!1})).reduce((m,y)=>m+y.to-y.from,0),f=c.filter(m=>i?m.mark.type!==i&&m.mark.type.excludes(i):!0).reduce((m,y)=>m+y.to-y.from,0);return(u>0?u+f:u)>=l}function PT(t,e,n={}){if(!e)return Ys(t,null,n)||Jh(t,null,n);const r=Ju(e,t.schema);return r==="node"?Ys(t,e,n):r==="mark"?Jh(t,e,n):!1}var BT=(t,e)=>{const{$from:n,$to:r,$anchor:s}=t.selection;if(e){const i=Yu(c=>c.type.name===e)(t.selection);if(!i)return!1;const l=t.doc.resolve(i.pos+1);return s.pos+1===l.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},zT=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function nv(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function rv(t,e){const{nodeExtensions:n}=_o(e),r=n.find(l=>l.name===t);if(!r)return!1;const s={name:r.name,options:r.options,storage:r.storage},i=xt(Pe(r,"group",s));return typeof i!="string"?!1:i.split(" ").includes("list")}function Qu(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(i=>{s!==!1&&(Qu(i,{ignoreWhitespace:n,checkChildren:e})||(s=!1))}),s}return!1}function Bw(t){return t instanceof ze}var zw=class $w{constructor(e){this.position=e}static fromJSON(e){return new $w(e.position)}toJSON(){return{position:this.position}}};function $T(t,e){const n=e.mapping.mapResult(t.position);return{position:new zw(n.pos),mapResult:n}}function FT(t){return new zw(t)}function UT(t,e,n){var r;const{selection:s}=e;let i=null;if(Nw(s)&&(i=s.$cursor),i){const c=(r=t.storedMarks)!=null?r:i.marks();return i.parent.type.allowsMarkType(n)&&(!!n.isInSet(c)||!c.some(f=>f.type.excludes(n)))}const{ranges:l}=s;return l.some(({$from:c,$to:u})=>{let f=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(p,m,y)=>{if(f)return!1;if(p.isInline){const b=!y||y.type.allowsMarkType(n),v=!!n.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(n));f=b&&v}return!f}),f})}var HT=(t,e={})=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=n,{empty:l,ranges:c}=i,u=fs(t,r.schema);if(s)if(l){const f=Mw(r,u);n.addStoredMark(u.create({...f,...e}))}else c.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(p,m,(y,b)=>{const v=Math.max(b,p),w=Math.min(b+y.nodeSize,m);y.marks.find(N=>N.type===u)?y.marks.forEach(N=>{u===N.type&&n.addMark(v,w,u.create({...N.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return UT(r,n,u)},WT=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),VT=(t,e={})=>({state:n,dispatch:r,chain:s})=>{const i=ln(t,n.schema);let l;return n.selection.$anchor.sameParent(n.selection.$head)&&(l=n.selection.$anchor.parent.attrs),i.isTextblock?s().command(({commands:c})=>gb(i,{...l,...e})(n)?!0:c.clearNodes()).command(({state:c})=>gb(i,{...l,...e})(c,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},KT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,s=Si(t,0,r.content.size),i=ze.create(r,s);e.setSelection(i)}return!0},GT=(t,e)=>({tr:n,state:r,dispatch:s})=>{const{selection:i}=r;let l,c;return typeof e=="number"?(l=e,c=e):e&&"from"in e&&"to"in e?(l=e.from,c=e.to):(l=i.from,c=i.to),s&&n.doc.nodesBetween(l,c,(u,f)=>{u.isText||n.setNodeMarkup(f,void 0,{...u.attrs,dir:t})}),!0},qT=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:s,to:i}=typeof t=="number"?{from:t,to:t}:t,l=Fe.atStart(r).from,c=Fe.atEnd(r).to,u=Si(s,l,c),f=Si(i,l,c),p=Fe.create(r,u,f);e.setSelection(p)}return!0},JT=t=>({state:e,dispatch:n})=>{const r=ln(t,e.schema);return WN(r)(e,n)};function sv(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 YT=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:s})=>{const{selection:i,doc:l}=e,{$from:c,$to:u}=i,f=s.extensionManager.attributes,p=Dc(f,c.node().type.name,c.node().attrs);if(i instanceof ze&&i.node.isBlock)return!c.parentOffset||!us(l,c.pos)?!1:(r&&(t&&sv(n,s.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,y=c.depth===0?void 0:CT(c.node(-1).contentMatchAt(c.indexAfter(-1)));let b=m&&y?[{type:y,attrs:p}]:void 0,v=us(e.doc,e.mapping.map(c.pos),1,b);if(!b&&!v&&us(e.doc,e.mapping.map(c.pos),1,y?[{type:y}]:void 0)&&(v=!0,b=y?[{type:y,attrs:p}]:void 0),r){if(v&&(i instanceof Fe&&e.deleteSelection(),e.split(e.mapping.map(c.pos),1,b),y&&!m&&!c.parentOffset&&c.parent.type!==y)){const w=e.mapping.map(c.before()),k=e.doc.resolve(w);c.node(-1).canReplaceWith(k.index(),k.index()+1,y)&&e.setNodeMarkup(e.mapping.map(c.before()),y)}t&&sv(n,s.extensionManager.splittableMarks),e.scrollIntoView()}return v},QT=(t,e={})=>({tr:n,state:r,dispatch:s,editor:i})=>{var l;const c=ln(t,r.schema),{$from:u,$to:f}=r.selection,p=r.selection.node;if(p&&p.isBlock||u.depth<2||!u.sameParent(f))return!1;const m=u.node(-1);if(m.type!==c)return!1;const y=i.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==c||u.index(-2)!==u.node(-2).childCount-1)return!1;if(s){let N=ae.empty;const T=u.index(-1)?1:u.index(-2)?2:3;for(let $=u.depth-T;$>=u.depth-3;$-=1)N=ae.from(u.node($).copy(N));const I=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,_={...Dc(y,u.node().type.name,u.node().attrs),...e},M=((l=c.contentMatch.defaultType)==null?void 0:l.createAndFill(_))||void 0;N=N.append(ae.from(c.createAndFill(null,M)||void 0));const O=u.before(u.depth-(T-1));n.replace(O,u.after(-I),new Se(N,4-T,0));let P=-1;n.doc.nodesBetween(O,n.doc.content.size,($,B)=>{if(P>-1)return!1;$.isTextblock&&$.content.size===0&&(P=B+1)}),P>-1&&n.setSelection(Fe.near(n.doc.resolve(P))),n.scrollIntoView()}return!0}const b=f.pos===u.end()?m.contentMatchAt(0).defaultType:null,v={...Dc(y,m.type.name,m.attrs),...e},w={...Dc(y,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,f.pos);const k=b?[{type:c,attrs:v},{type:b,attrs:w}]:[{type:c,attrs:v}];if(!us(n.doc,u.pos,2))return!1;if(s){const{selection:N,storedMarks:T}=r,{splittableMarks:I}=i.extensionManager,_=T||N.$to.parentOffset&&N.$from.marks();if(n.split(u.pos,2,k).scrollIntoView(),!_||!s)return!0;const M=_.filter(O=>I.includes(O.type.name));n.ensureMarks(M)}return!0},lh=(t,e)=>{const n=Yu(l=>l.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)&&Xs(t.doc,n.pos)&&t.join(n.pos),!0},ah=(t,e)=>{const n=Yu(l=>l.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)&&Xs(t.doc,r)&&t.join(r),!0},XT=(t,e,n,r={})=>({editor:s,tr:i,state:l,dispatch:c,chain:u,commands:f,can:p})=>{const{extensions:m,splittableMarks:y}=s.extensionManager,b=ln(t,l.schema),v=ln(e,l.schema),{selection:w,storedMarks:k}=l,{$from:N,$to:T}=w,I=N.blockRange(T),_=k||w.$to.parentOffset&&w.$from.marks();if(!I)return!1;const M=Yu(O=>rv(O.type.name,m))(w);if(I.depth>=1&&M&&I.depth-M.depth<=1){if(M.node.type===b)return f.liftListItem(v);if(rv(M.node.type.name,m)&&b.validContent(M.node.content)&&c)return u().command(()=>(i.setNodeMarkup(M.pos,b),!0)).command(()=>lh(i,b)).command(()=>ah(i,b)).run()}return!n||!_||!c?u().command(()=>p().wrapInList(b,r)?!0:f.clearNodes()).wrapInList(b,r).command(()=>lh(i,b)).command(()=>ah(i,b)).run():u().command(()=>{const O=p().wrapInList(b,r),P=_.filter($=>y.includes($.type.name));return i.ensureMarks(P),O?!0:f.clearNodes()}).wrapInList(b,r).command(()=>lh(i,b)).command(()=>ah(i,b)).run()},ZT=(t,e={},n={})=>({state:r,commands:s})=>{const{extendEmptyMarkRange:i=!1}=n,l=fs(t,r.schema);return Jh(r,l,e)?s.unsetMark(l,{extendEmptyMarkRange:i}):s.setMark(l,e)},eM=(t,e,n={})=>({state:r,commands:s})=>{const i=ln(t,r.schema),l=ln(e,r.schema),c=Ys(r,i,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),c?s.setNode(l,u):s.setNode(i,{...u,...n})},tM=(t,e={})=>({state:n,commands:r})=>{const s=ln(t,n.schema);return Ys(n,s,e)?r.lift(s):r.wrapIn(s,e)},nM=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const s=n[r];let i;if(s.spec.isInputRules&&(i=s.getState(t))){if(e){const l=t.tr,c=i.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(i.text){const u=l.doc.resolve(i.from).marks();l.replaceWith(i.from,i.to,t.schema.text(i.text,u))}else l.delete(i.from,i.to)}return!0}}return!1},rM=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:s}=n;return r||e&&s.forEach(i=>{t.removeMark(i.$from.pos,i.$to.pos)}),!0},sM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{var i;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,u=fs(t,r.schema),{$from:f,empty:p,ranges:m}=c;if(!s)return!0;if(p&&l){let{from:y,to:b}=c;const v=(i=f.marks().find(k=>k.type===u))==null?void 0:i.attrs,w=$p(f,u,v);w&&(y=w.from,b=w.to),n.removeMark(y,b,u)}else m.forEach(y=>{n.removeMark(y.$from.pos,y.$to.pos,u)});return n.removeStoredMark(u),!0},iM=t=>({tr:e,state:n,dispatch:r})=>{const{selection:s}=n;let i,l;return typeof t=="number"?(i=t,l=t):t&&"from"in t&&"to"in t?(i=t.from,l=t.to):(i=s.from,l=s.to),r&&e.doc.nodesBetween(i,l,(c,u)=>{if(c.isText)return;const f={...c.attrs};delete f.dir,e.setNodeMarkup(u,void 0,f)}),!0},oM=(t,e={})=>({tr:n,state:r,dispatch:s})=>{let i=null,l=null;const c=Ju(typeof t=="string"?t:t.name,r.schema);if(!c)return!1;c==="node"&&(i=ln(t,r.schema)),c==="mark"&&(l=fs(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{const p=f.$from.pos,m=f.$to.pos;let y,b,v,w;n.selection.empty?r.doc.nodesBetween(p,m,(k,N)=>{i&&i===k.type&&(u=!0,v=Math.max(N,p),w=Math.min(N+k.nodeSize,m),y=N,b=k)}):r.doc.nodesBetween(p,m,(k,N)=>{N<p&&i&&i===k.type&&(u=!0,v=Math.max(N,p),w=Math.min(N+k.nodeSize,m),y=N,b=k),N>=p&&N<=m&&(i&&i===k.type&&(u=!0,s&&n.setNodeMarkup(N,void 0,{...k.attrs,...e})),l&&k.marks.length&&k.marks.forEach(T=>{if(l===T.type&&(u=!0,s)){const I=Math.max(N,p),_=Math.min(N+k.nodeSize,m);n.addMark(I,_,l.create({...T.attrs,...e}))}}))}),b&&(y!==void 0&&s&&n.setNodeMarkup(y,void 0,{...b.attrs,...e}),l&&b.marks.length&&b.marks.forEach(k=>{l===k.type&&s&&n.addMark(v,w,l.create({...k.attrs,...e}))}))}),u},lM=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return PN(s,e)(n,r)},aM=(t,e={})=>({state:n,dispatch:r})=>{const s=ln(t,n.schema);return BN(s,e)(n,r)},cM=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={}}},Yl=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},uM=(t,e)=>{if(zp(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 dc(t){var e;const{editor:n,from:r,to:s,text:i,rules:l,plugin:c}=t,{view:u}=n;if(u.composing)return!1;const f=u.state.doc.resolve(r);if(f.parent.type.spec.code||(e=f.nodeBefore||f.nodeAfter)!=null&&e.marks.find(y=>y.type.spec.code))return!1;let p=!1;const m=DT(f)+i;return l.forEach(y=>{if(p)return;const b=uM(m,y.find);if(!b)return;const v=u.state.tr,w=Gu({state:u.state,transaction:v}),k={from:r-(b[0].length-i.length),to:s},{commands:N,chain:T,can:I}=new qu({editor:n,state:w});y.handler({state:w,range:k,match:b,commands:N,chain:T,can:I})===null||!v.steps.length||(y.undoable&&v.setMeta(c,{transform:v,from:r,to:s,text:i}),u.dispatch(v),p=!0)}),p}function dM(t){const{editor:e,rules:n}=t,r=new kt({state:{init(){return null},apply(s,i,l){const c=s.getMeta(r);if(c)return c;const u=s.getMeta("applyInputRules");return!!u&&setTimeout(()=>{let{text:p}=u;typeof p=="string"?p=p:p=Hp(ae.from(p),l.schema);const{from:m}=u,y=m+p.length;dc({editor:e,from:m,to:y,text:p,rules:n,plugin:r})}),s.selectionSet||s.docChanged?null:i}},props:{handleTextInput(s,i,l,c){return dc({editor:e,from:i,to:l,text:c,rules:n,plugin:r})},handleDOMEvents:{compositionend:s=>(setTimeout(()=>{const{$cursor:i}=s.state.selection;i&&dc({editor:e,from:i.pos,to:i.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(s,i){if(i.key!=="Enter")return!1;const{$cursor:l}=s.state.selection;return l?dc({editor:e,from:l.pos,to:l.pos,text:`
60
+ `,rules:n,plugin:r}):!1}},isInputRules:!0});return r}function fM(t){return Object.prototype.toString.call(t).slice(8,-1)}function fc(t){return fM(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function Fw(t,e){const n={...t};return fc(t)&&fc(e)&&Object.keys(e).forEach(r=>{fc(e[r])&&fc(t[r])?n[r]=Fw(t[r],e[r]):n[r]=e[r]}),n}var Kp=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{...xt(Pe(this,"addOptions",{name:this.name}))||{}}}get storage(){return{...xt(Pe(this,"addStorage",{name:this.name,options:this.options}))||{}}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>Fw(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}},Ar=class Uw extends Kp{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new Uw(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,s=e.state.selection.$from;if(s.pos===s.end()){const l=s.marks();if(!!!l.find(f=>(f==null?void 0:f.type.name)===n.name))return!1;const u=l.find(f=>(f==null?void 0:f.type.name)===n.name);return u&&r.removeStoredMark(u),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 hM(t){return typeof t=="number"}var pM=class{constructor(t){this.find=t.find,this.handler=t.handler}},mM=(t,e,n)=>{if(zp(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(s=>{const i=[s.text];return i.index=s.index,i.input=t,i.data=s.data,s.replaceWith&&(s.text.includes(s.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(s.replaceWith)),i}):[]};function gM(t){const{editor:e,state:n,from:r,to:s,rule:i,pasteEvent:l,dropEvent:c}=t,{commands:u,chain:f,can:p}=new qu({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,s,(b,v)=>{var w,k,N,T,I;if((k=(w=b.type)==null?void 0:w.spec)!=null&&k.code||!(b.isText||b.isTextblock||b.isInline))return;const _=(I=(T=(N=b.content)==null?void 0:N.size)!=null?T:b.nodeSize)!=null?I:0,M=Math.max(r,v),O=Math.min(s,v+_);if(M>=O)return;const P=b.isText?b.text||"":b.textBetween(M-v,O-v,void 0,"");mM(P,i.find,l).forEach(B=>{if(B.index===void 0)return;const W=M+B.index+1,J=W+B[0].length,F={from:n.tr.mapping.map(W),to:n.tr.mapping.map(J)},re=i.handler({state:n,range:F,match:B,commands:u,chain:f,can:p,pasteEvent:l,dropEvent:c});m.push(re)})}),m.every(b=>b!==null)}var hc=null,yM=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function bM(t){const{editor:e,rules:n}=t;let r=null,s=!1,i=!1,l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,c;try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}const u=({state:p,from:m,to:y,rule:b,pasteEvt:v})=>{const w=p.tr,k=Gu({state:p,transaction:w});if(!(!gM({editor:e,state:k,from:Math.max(m-1,0),to:y.b-1,rule:b,pasteEvent:v,dropEvent:c})||!w.steps.length)){try{c=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{c=null}return l=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,w}};return n.map(p=>new kt({view(m){const y=v=>{var w;r=(w=m.dom.parentElement)!=null&&w.contains(v.target)?m.dom.parentElement:null,r&&(hc=e)},b=()=>{hc&&(hc=null)};return window.addEventListener("dragstart",y),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",y),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,y)=>{if(i=r===m.dom.parentElement,c=y,!i){const b=hc;b!=null&&b.isEditable&&setTimeout(()=>{const v=b.state.selection;v&&b.commands.deleteRange({from:v.from,to:v.to})},10)}return!1},paste:(m,y)=>{var b;const v=(b=y.clipboardData)==null?void 0:b.getData("text/html");return l=y,s=!!(v!=null&&v.includes("data-pm-slice")),!1}}},appendTransaction:(m,y,b)=>{const v=m[0],w=v.getMeta("uiEvent")==="paste"&&!s,k=v.getMeta("uiEvent")==="drop"&&!i,N=v.getMeta("applyPasteRules"),T=!!N;if(!w&&!k&&!T)return;if(T){let{text:M}=N;typeof M=="string"?M=M:M=Hp(ae.from(M),b.schema);const{from:O}=N,P=O+M.length,$=yM(M);return u({rule:p,state:b,from:O,to:{b:P},pasteEvt:$})}const I=y.doc.content.findDiffStart(b.doc.content),_=y.doc.content.findDiffEnd(b.doc.content);if(!(!hM(I)||!_||I===_.b))return u({rule:p,state:b,from:I,to:_,pasteEvt:l})}}))}var Xu=class{constructor(t,e){this.splittableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=jw(t),this.schema=MT(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:uc(e.name,this.schema)},r=Pe(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return nu([...this.extensions].reverse()).flatMap(r=>{const s={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:uc(r.name,this.schema)},i=[],l=Pe(r,"addKeyboardShortcuts",s);let c={};if(r.type==="mark"&&Pe(r,"exitable",s)&&(c.ArrowRight=()=>Ar.handleExit({editor:t,mark:r})),l){const y=Object.fromEntries(Object.entries(l()).map(([b,v])=>[b,()=>v({editor:t})]));c={...c,...y}}const u=j_(c);i.push(u);const f=Pe(r,"addInputRules",s);if(nv(r,t.options.enableInputRules)&&f){const y=f();if(y&&y.length){const b=dM({editor:t,rules:y}),v=Array.isArray(b)?b:[b];i.push(...v)}}const p=Pe(r,"addPasteRules",s);if(nv(r,t.options.enablePasteRules)&&p){const y=p();if(y&&y.length){const b=bM({editor:t,rules:y});i.push(...b)}}const m=Pe(r,"addProseMirrorPlugins",s);if(m){const y=m();i.push(...y)}return i})}get attributes(){return Iw(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=_o(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:ln(n.name,this.schema)},i=Pe(n,"addNodeView",s);if(!i)return[];const l=i();if(!l)return[];const c=(u,f,p,m,y)=>{const b=Ul(u,r);return l({node:u,view:f,getPos:p,decorations:m,innerDecorations:y,editor:t,extension:n,HTMLAttributes:b})};return[n.name,c]}))}dispatchTransaction(t){const{editor:e}=this;return nu([...this.extensions].reverse()).reduceRight((r,s)=>{const i={name:s.name,options:s.options,storage:this.editor.extensionStorage[s.name],editor:e,type:uc(s.name,this.schema)},l=Pe(s,"dispatchTransaction",i);return l?c=>{l.call(i,{transaction:c,next:r})}:r},t)}get markViews(){const{editor:t}=this,{markExtensions:e}=_o(this.extensions);return Object.fromEntries(e.filter(n=>!!Pe(n,"addMarkView")).map(n=>{const r=this.attributes.filter(c=>c.type===n.name),s={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:fs(n.name,this.schema)},i=Pe(n,"addMarkView",s);if(!i)return[];const l=(c,u,f)=>{const p=Ul(c,r);return i()({mark:c,view:u,inline:f,editor:t,extension:n,HTMLAttributes:p,updateAttributes:m=>{IM(c,t,m)}})};return[n.name,l]}))}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:uc(e.name,this.schema)};e.type==="mark"&&((n=xt(Pe(e,"keepOnSplit",r)))==null||n)&&this.splittableMarks.push(e.name);const s=Pe(e,"onBeforeCreate",r),i=Pe(e,"onCreate",r),l=Pe(e,"onUpdate",r),c=Pe(e,"onSelectionUpdate",r),u=Pe(e,"onTransaction",r),f=Pe(e,"onFocus",r),p=Pe(e,"onBlur",r),m=Pe(e,"onDestroy",r);s&&this.editor.on("beforeCreate",s),i&&this.editor.on("create",i),l&&this.editor.on("update",l),c&&this.editor.on("selectionUpdate",c),u&&this.editor.on("transaction",u),f&&this.editor.on("focus",f),p&&this.editor.on("blur",p),m&&this.editor.on("destroy",m)})}};Xu.resolve=jw;Xu.sort=nu;Xu.flatten=Up;var vM={};Bp(vM,{ClipboardTextSerializer:()=>Ww,Commands:()=>Vw,Delete:()=>Kw,Drop:()=>Gw,Editable:()=>qw,FocusEvents:()=>Yw,Keymap:()=>Qw,Paste:()=>Xw,Tabindex:()=>Zw,TextDirection:()=>ek,focusEventsPluginKey:()=>Jw});var gt=class Hw extends Kp{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new Hw(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},Ww=gt.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new kt({key:new Ot("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:s}=e,{ranges:i}=s,l=Math.min(...i.map(p=>p.$from.pos)),c=Math.max(...i.map(p=>p.$to.pos)),u=Dw(n);return Lw(r,{from:l,to:c},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:u})}}})]}}),Vw=gt.create({name:"commands",addCommands(){return{...Sw}}}),Kw=gt.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,s;const i=()=>{var l,c,u,f;if((f=(u=(c=(l=this.editor.options.coreExtensionOptions)==null?void 0:l.delete)==null?void 0:c.filterTransaction)==null?void 0:u.call(c,t))!=null?f:t.getMeta("y-sync$"))return;const p=Fp(t.before,[t,...e]);Wp(p).forEach(b=>{p.mapping.mapResult(b.oldRange.from).deletedAfter&&p.mapping.mapResult(b.oldRange.to).deletedBefore&&p.before.nodesBetween(b.oldRange.from,b.oldRange.to,(v,w)=>{const k=w+v.nodeSize-2,N=b.oldRange.from<=w&&k<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:v,from:w,to:k,newFrom:p.mapping.map(w),newTo:p.mapping.map(k),deletedRange:b.oldRange,newRange:b.newRange,partial:!N,editor:this.editor,transaction:t,combinedTransform:p})})});const y=p.mapping;p.steps.forEach((b,v)=>{var w,k;if(b instanceof Tr){const N=y.slice(v).map(b.from,-1),T=y.slice(v).map(b.to),I=y.invert().map(N,-1),_=y.invert().map(T),M=(w=p.doc.nodeAt(N-1))==null?void 0:w.marks.some(P=>P.eq(b.mark)),O=(k=p.doc.nodeAt(T))==null?void 0:k.marks.some(P=>P.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:I,to:_},newRange:{from:N,to:T},partial:!!(O||M),editor:this.editor,transaction:t,combinedTransform:p})}})};(s=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||s?setTimeout(i,0):i()}}),Gw=gt.create({name:"drop",addProseMirrorPlugins(){return[new kt({key:new Ot("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),qw=gt.create({name:"editable",addProseMirrorPlugins(){return[new kt({key:new Ot("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Jw=new Ot("focusEvents"),Yw=gt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new kt({key:Jw,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}}}})]}}),Qw=gt.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:f}=c,{empty:p,$anchor:m}=u,{pos:y,parent:b}=m,v=m.parent.isTextblock&&y>0?c.doc.resolve(y-1):m,w=v.parent.type.spec.isolating,k=m.pos-m.parentOffset,N=w&&v.parent.childCount===1?k===m.pos:Ye.atStart(f).from===y;return!p||!b.type.isTextblock||b.textContent.length||!N||N&&m.parent.type.name==="paragraph"?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.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},i={...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 eu()||Tw()?i:s},addProseMirrorPlugins(){return[new kt({key:new Ot("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(w=>w.getMeta("composition")))return;const r=t.some(w=>w.docChanged)&&!e.doc.eq(n.doc),s=t.some(w=>w.getMeta("preventClearDocument"));if(!r||s)return;const{empty:i,from:l,to:c}=e.selection,u=Ye.atStart(e.doc).from,f=Ye.atEnd(e.doc).to;if(i||!(l===u&&c===f)||!Qu(n.doc))return;const y=n.tr,b=Gu({state:n,transaction:y}),{commands:v}=new qu({editor:this.editor,state:b});if(v.clearNodes(),!!y.steps.length)return y}})]}}),Xw=gt.create({name:"paste",addProseMirrorPlugins(){return[new kt({key:new Ot("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Zw=gt.create({name:"tabindex",addProseMirrorPlugins(){return[new kt({key:new Ot("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),ek=gt.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=_o(this.extensions);return[{types:t.filter(e=>e.name!=="text").map(e=>e.name),attributes:{dir:{default:this.options.direction,parseHTML:e=>{const n=e.getAttribute("dir");return n&&(n==="ltr"||n==="rtl"||n==="auto")?n:this.options.direction},renderHTML:e=>e.dir?{dir:e.dir}:{}}}}]},addProseMirrorPlugins(){return[new kt({key:new Ot("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),xM=class kl{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 kl(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 kl(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 kl(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const s=n.isBlock&&!n.isTextblock,i=n.isAtom&&!n.isText,l=n.isInline,c=this.pos+r+(i?0:1);if(c<0||c>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(c);if(!s&&!l&&u.depth<=this.depth)return;const f=new kl(u,this.editor,s,s||l?n:null);s&&(f.actualDepth=this.depth+1),e.push(f)}),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 i=s.node.attrs,l=Object.keys(n);for(let c=0;c<l.length;c+=1){const u=l[c];if(i[u]!==n[u])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 i=Object.keys(n);return this.children.forEach(l=>{r&&s.length>0||(l.node.type.name===e&&i.every(u=>n[u]===l.node.attrs[u])&&s.push(l),!(r&&s.length>0)&&(s=s.concat(l.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)}},wM=`.ProseMirror {
61
+ position: relative;
62
+ }
63
+
64
+ .ProseMirror {
65
+ word-wrap: break-word;
66
+ white-space: pre-wrap;
67
+ white-space: break-spaces;
68
+ -webkit-font-variant-ligatures: none;
69
+ font-variant-ligatures: none;
70
+ font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
71
+ }
72
+
73
+ .ProseMirror [contenteditable="false"] {
74
+ white-space: normal;
75
+ }
76
+
77
+ .ProseMirror [contenteditable="false"] [contenteditable="true"] {
78
+ white-space: pre-wrap;
79
+ }
80
+
81
+ .ProseMirror pre {
82
+ white-space: pre-wrap;
83
+ }
84
+
85
+ img.ProseMirror-separator {
86
+ display: inline !important;
87
+ border: none !important;
88
+ margin: 0 !important;
89
+ width: 0 !important;
90
+ height: 0 !important;
91
+ }
92
+
93
+ .ProseMirror-gapcursor {
94
+ display: none;
95
+ pointer-events: none;
96
+ position: absolute;
97
+ margin: 0;
98
+ }
99
+
100
+ .ProseMirror-gapcursor:after {
101
+ content: "";
102
+ display: block;
103
+ position: absolute;
104
+ top: -2px;
105
+ width: 20px;
106
+ border-top: 1px solid black;
107
+ animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
108
+ }
109
+
110
+ @keyframes ProseMirror-cursor-blink {
111
+ to {
112
+ visibility: hidden;
113
+ }
114
+ }
115
+
116
+ .ProseMirror-hideselection *::selection {
117
+ background: transparent;
118
+ }
119
+
120
+ .ProseMirror-hideselection *::-moz-selection {
121
+ background: transparent;
122
+ }
123
+
124
+ .ProseMirror-hideselection * {
125
+ caret-color: transparent;
126
+ }
127
+
128
+ .ProseMirror-focused .ProseMirror-gapcursor {
129
+ display: block;
130
+ }`;function kM(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 SM=class extends cM{constructor(t={}){super(),this.css=null,this.className="tiptap",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,textDirection:void 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:r})=>{throw r},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:$T,createMappablePosition:FT},this.setOptions(t),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:r,slice:s,moved:i})=>this.options.onDrop(r,s,i)),this.on("paste",({event:r,slice:s})=>this.options.onPaste(r,s)),this.on("delete",this.options.onDelete);const e=this.createDoc(),n=Cw(e,this.options.autofocus);this.editorState=vo.create({doc:e,schema:this.schema,selection:n||void 0}),this.options.element&&this.mount(this.options.element)}mount(t){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(t),this.emit("mount",{editor:this}),this.css&&!document.head.contains(this.css)&&document.head.appendChild(this.css),window.setTimeout(()=>{this.isDestroyed||(this.options.autofocus!==!1&&this.options.autofocus!==null&&this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}unmount(){if(this.editorView){const t=this.editorView.dom;t!=null&&t.editor&&delete t.editor,this.editorView.destroy()}if(this.editorView=null,this.isInitialized=!1,this.css&&!document.querySelectorAll(`.${this.className}`).length)try{typeof this.css.remove=="function"?this.css.remove():this.css.parentNode&&this.css.parentNode.removeChild(this.css)}catch(t){console.warn("Failed to remove CSS element:",t)}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=kM(wM,this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},!(!this.editorView||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&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:t=>{this.editorState=t},dispatch:t=>{this.dispatchTransaction(t)},composing:!1,dragging:null,editable:!0,isDestroyed:!1},{get:(t,e)=>{if(this.editorView)return this.editorView[e];if(e==="state")return this.editorState;if(e in t)return Reflect.get(t,e);throw new Error(`[tiptap error]: The editor view is not available. Cannot access view['${e}']. The editor may not be mounted yet.`)}})}get state(){return this.editorView&&(this.editorState=this.view.state),this.editorState}registerPlugin(t,e){const n=Rw(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e=this.state.plugins;let n=e;if([].concat(t).forEach(s=>{const i=typeof s=="string"?`${s}$`:s.key;n=n.filter(l=>!l.key.startsWith(i))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e;const r=[...this.options.enableCoreExtensions?[qw,Ww.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),Vw,Yw,Qw,Zw,Gw,Xw,Kw,ek.configure({direction:this.options.textDirection})].filter(s=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[s.name]!==!1:!0):[],...this.options.extensions].filter(s=>["extension","node","mark"].includes(s==null?void 0:s.type));this.extensionManager=new Xu(r,this)}createCommandManager(){this.commandManager=new qu({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=qh(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message))throw e;this.emit("contentError",{editor:this,error:e,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(n=>n.name!=="collaboration"),this.createExtensionManager()}}),t=qh(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),s=n?this.extensionManager.dispatchTransaction(r):r;this.editorView=new kw(t,{...e,attributes:{role:"textbox",...e==null?void 0:e.attributes},dispatchTransaction:s,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const i=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(i),this.prependClass(),this.injectCSS();const l=this.view.dom;l.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`${this.className} ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=t;return}t.steps.forEach(f=>{var p;return(p=this.capturedTransaction)==null?void 0:p.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),s=n.includes(t),i=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!s)return;this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t,appendedTransactions:n.slice(1)}),r&&this.emit("selectionUpdate",{editor:this,transaction:t});const l=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),c=l==null?void 0:l.getMeta("focus"),u=l==null?void 0:l.getMeta("blur");c&&this.emit("focus",{editor:this,event:c.event,transaction:l}),u&&this.emit("blur",{editor:this,event:u.event,transaction:l}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||i.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return Pw(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return PT(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Hp(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
131
+
132
+ `,textSerializers:n={}}=t||{};return OT(this.state.doc,{blockSeparator:e,textSerializers:{...Dw(this.schema),...n}})}get isEmpty(){return Qu(this.state.doc)}destroy(){this.emit("destroy"),this.unmount(),this.removeAllListeners()}get isDestroyed(){var t,e;return(e=(t=this.editorView)==null?void 0:t.isDestroyed)!=null?e:!0}$node(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return((n=this.$doc)==null?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new xM(e,this)}get $doc(){return this.$pos(0)}};function ji(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=xt(t.getAttributes,void 0,r);if(s===!1||s===null)return null;const{tr:i}=e,l=r[r.length-1],c=r[0];if(l){const u=c.search(/\S/),f=n.from+c.indexOf(l),p=f+l.length;if(Vp(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(w=>w===t.type&&w!==b.mark.type)).filter(b=>b.to>f).length)return null;p<n.to&&i.delete(p,n.to),f>n.from&&i.delete(n.from+u,f);const y=n.from+u+l.length;i.addMark(n.from+u,y,t.type.create(s||{})),i.removeStoredMark(t.type)}},undoable:t.undoable})}function tk(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=xt(t.getAttributes,void 0,r)||{},{tr:i}=e,l=n.from;let c=n.to;const u=t.type.create(s);if(r[1]){const f=r[0].lastIndexOf(r[1]);let p=l+f;p>c?p=c:c=p+r[1].length;const m=r[0][r[0].length-1];i.insertText(m,l+r[0].length-1),i.replaceWith(p,c,u)}else if(r[0]){const f=t.type.isInline?l:l-1;i.insert(f,t.type.create(s)).delete(i.mapping.map(l),i.mapping.map(c))}i.scrollIntoView()},undoable:t.undoable})}function Yh(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{const s=e.doc.resolve(n.from),i=xt(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,i)},undoable:t.undoable})}function Xt(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r})=>{let s=t.replace,i=n.from;const l=n.to;if(r[1]){const c=r[0].lastIndexOf(r[1]);s+=r[0].slice(c+r[1].length),i+=c;const u=i-l;u>0&&(s=r[0].slice(c-u,c)+s,i=l)}e.tr.insertText(s,i,l)},undoable:t.undoable})}function To(t){return new Yl({find:t.find,handler:({state:e,range:n,match:r,chain:s})=>{const i=xt(t.getAttributes,void 0,r)||{},l=e.tr.delete(n.from,n.to),u=l.doc.resolve(n.from).blockRange(),f=u&&xp(u,t.type,i);if(!f)return null;if(l.wrap(u,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:y}=e,{splittableMarks:b}=t.editor.extensionManager,v=y||m.$to.parentOffset&&m.$from.marks();if(v){const w=v.filter(k=>b.includes(k.type.name));l.ensureMarks(w)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";s().updateAttributes(m,i).run()}const p=l.doc.resolve(n.from-1).nodeBefore;p&&p.type===t.type&&Xs(l.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,p))&&l.join(n.from-1)},undoable:t.undoable})}var EM=t=>"touches"in t,NM=class{constructor(t){this.directions=["bottom-left","bottom-right","top-left","top-right"],this.minSize={height:8,width:8},this.preserveAspectRatio=!1,this.classNames={container:"",wrapper:"",handle:"",resizing:""},this.initialWidth=0,this.initialHeight=0,this.aspectRatio=1,this.isResizing=!1,this.activeHandle=null,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.isShiftKeyPressed=!1,this.lastEditableState=void 0,this.handleMap=new Map,this.handleMouseMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.clientX-this.startX,f=c.clientY-this.startY;this.handleResize(u,f)},this.handleTouchMove=c=>{if(!this.isResizing||!this.activeHandle)return;const u=c.touches[0];if(!u)return;const f=u.clientX-this.startX,p=u.clientY-this.startY;this.handleResize(f,p)},this.handleMouseUp=()=>{if(!this.isResizing)return;const c=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(c,u),this.isResizing=!1,this.activeHandle=null,this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp)},this.handleKeyDown=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=c=>{c.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,s,i,l;this.node=t.node,this.editor=t.editor,this.element=t.element,this.contentElement=t.contentElement,this.getPos=t.getPos,this.onResize=t.onResize,this.onCommit=t.onCommit,this.onUpdate=t.onUpdate,(e=t.options)!=null&&e.min&&(this.minSize={...this.minSize,...t.options.min}),(n=t.options)!=null&&n.max&&(this.maxSize=t.options.max),(r=t==null?void 0:t.options)!=null&&r.directions&&(this.directions=t.options.directions),(s=t.options)!=null&&s.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(i=t.options)!=null&&i.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(l=t.options)!=null&&l.createCustomHandle&&(this.createCustomHandle=t.options.createCustomHandle),this.wrapper=this.createWrapper(),this.container=this.createContainer(),this.applyInitialSize(),this.attachHandles(),this.editor.on("update",this.handleEditorUpdate.bind(this))}get dom(){return this.container}get contentDOM(){var t;return(t=this.contentElement)!=null?t:null}handleEditorUpdate(){const t=this.editor.isEditable;t!==this.lastEditableState&&(this.lastEditableState=t,t?t&&this.handleMap.size===0&&this.attachHandles():this.removeHandles())}update(t,e,n){return t.type!==this.node.type?!1:(this.node=t,this.onUpdate?this.onUpdate(t,e,n):!0)}destroy(){this.isResizing&&(this.container.dataset.resizeState="false",this.classNames.resizing&&this.container.classList.remove(this.classNames.resizing),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("keyup",this.handleKeyUp),this.isResizing=!1,this.activeHandle=null),this.editor.off("update",this.handleEditorUpdate.bind(this)),this.container.remove()}createContainer(){const t=document.createElement("div");return t.dataset.resizeContainer="",t.dataset.node=this.node.type.name,t.style.display="flex",this.classNames.container&&(t.className=this.classNames.container),t.appendChild(this.wrapper),t}createWrapper(){const t=document.createElement("div");return t.style.position="relative",t.style.display="block",t.dataset.resizeWrapper="",this.classNames.wrapper&&(t.className=this.classNames.wrapper),t.appendChild(this.element),t}createHandle(t){const e=document.createElement("div");return e.dataset.resizeHandle=t,e.style.position="absolute",this.classNames.handle&&(e.className=this.classNames.handle),e}positionHandle(t,e){const n=e.includes("top"),r=e.includes("bottom"),s=e.includes("left"),i=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),s&&(t.style.left="0"),i&&(t.style.right="0"),(e==="top"||e==="bottom")&&(t.style.left="0",t.style.right="0"),(e==="left"||e==="right")&&(t.style.top="0",t.style.bottom="0")}attachHandles(){this.directions.forEach(t=>{let e;this.createCustomHandle?e=this.createCustomHandle(t):e=this.createHandle(t),e instanceof HTMLElement||(console.warn(`[ResizableNodeView] createCustomHandle("${t}") did not return an HTMLElement. Falling back to default handle.`),e=this.createHandle(t)),this.createCustomHandle||this.positionHandle(e,t),e.addEventListener("mousedown",n=>this.handleResizeStart(n,t)),e.addEventListener("touchstart",n=>this.handleResizeStart(n,t)),this.handleMap.set(t,e),this.wrapper.appendChild(e)})}removeHandles(){this.handleMap.forEach(t=>t.remove()),this.handleMap.clear()}applyInitialSize(){const t=this.node.attrs.width,e=this.node.attrs.height;t?(this.element.style.width=`${t}px`,this.initialWidth=t):this.initialWidth=this.element.offsetWidth,e?(this.element.style.height=`${e}px`,this.initialHeight=e):this.initialHeight=this.element.offsetHeight,this.initialWidth>0&&this.initialHeight>0&&(this.aspectRatio=this.initialWidth/this.initialHeight)}handleResizeStart(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.activeHandle=e,EM(t)?(this.startX=t.touches[0].clientX,this.startY=t.touches[0].clientY):(this.startX=t.clientX,this.startY=t.clientY),this.startWidth=this.element.offsetWidth,this.startHeight=this.element.offsetHeight,this.startWidth>0&&this.startHeight>0&&(this.aspectRatio=this.startWidth/this.startHeight),this.getPos(),this.container.dataset.resizeState="true",this.classNames.resizing&&this.container.classList.add(this.classNames.resizing),document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("touchmove",this.handleTouchMove),document.addEventListener("mouseup",this.handleMouseUp),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("keyup",this.handleKeyUp)}handleResize(t,e){if(!this.activeHandle)return;const n=this.preserveAspectRatio||this.isShiftKeyPressed,{width:r,height:s}=this.calculateNewDimensions(this.activeHandle,t,e),i=this.applyConstraints(r,s,n);this.element.style.width=`${i.width}px`,this.element.style.height=`${i.height}px`,this.onResize&&this.onResize(i.width,i.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,s=this.startHeight;const i=t.includes("right"),l=t.includes("left"),c=t.includes("bottom"),u=t.includes("top");return i?r=this.startWidth+e:l&&(r=this.startWidth-e),c?s=this.startHeight+n:u&&(s=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(i?e:-e)),(t==="top"||t==="bottom")&&(s=this.startHeight+(c?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,s,t):{width:r,height:s}}applyConstraints(t,e,n){var r,s,i,l;if(!n){let f=Math.max(this.minSize.width,t),p=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(s=this.maxSize)!=null&&s.height&&(p=Math.min(this.maxSize.height,p)),{width:f,height:p}}let c=t,u=e;return c<this.minSize.width&&(c=this.minSize.width,u=c/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,c=u*this.aspectRatio),(i=this.maxSize)!=null&&i.width&&c>this.maxSize.width&&(c=this.maxSize.width,u=c/this.aspectRatio),(l=this.maxSize)!=null&&l.height&&u>this.maxSize.height&&(u=this.maxSize.height,c=u*this.aspectRatio),{width:c,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",s=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:s?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}};function CM(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof ze){const i=r.index();return r.parent.canReplaceWith(i,i+1,e)}let s=r.depth;for(;s>=0;){const i=r.index(s);if(r.node(s).contentMatchAt(i).matchType(e))return!0;s-=1}return!1}var _M={};Bp(_M,{createAtomBlockMarkdownSpec:()=>TM,createBlockMarkdownSpec:()=>MM,createInlineMarkdownSpec:()=>RM,parseAttributes:()=>Gp,parseIndentedBlocks:()=>Qh,renderNestedMarkdownContent:()=>Jp,serializeAttributes:()=>qp});function Gp(t){if(!(t!=null&&t.trim()))return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),s=r.match(/(?:^|\s)\.([a-zA-Z][\w-]*)/g);if(s){const f=s.map(p=>p.trim().slice(1));e.class=f.join(" ")}const i=r.match(/(?:^|\s)#([a-zA-Z][\w-]*)/);i&&(e.id=i[1]);const l=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(l)).forEach(([,f,p])=>{var m;const y=parseInt(((m=p.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[y];b&&(e[f]=b.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([a-zA-Z][\w-]*)/g,"").replace(/(?:^|\s)#([a-zA-Z][\w-]*)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(p=>{p.match(/^[a-zA-Z][\w-]*$/)&&(e[p]=!0)}),e}function qp(t){if(!t||Object.keys(t).length===0)return"";const e=[];return t.class&&String(t.class).split(/\s+/).filter(Boolean).forEach(r=>e.push(`.${r}`)),t.id&&e.push(`#${t.id}`),Object.entries(t).forEach(([n,r])=>{n==="class"||n==="id"||(r===!0?e.push(n):r!==!1&&r!=null&&e.push(`${n}="${String(r)}"`))}),e.join(" ")}function TM(t){const{nodeName:e,name:n,parseAttributes:r=Gp,serializeAttributes:s=qp,defaultAttributes:i={},requiredAttributes:l=[],allowedAttributes:c}=t,u=n||e,f=p=>{if(!c)return p;const m={};return c.forEach(y=>{y in p&&(m[y]=p[y])}),m};return{parseMarkdown:(p,m)=>{const y={...i,...p.attributes};return m.createNode(e,y,[])},markdownTokenizer:{name:e,level:"block",start(p){var m;const y=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=p.match(y))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(p,m,y){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),v=p.match(b);if(!v)return;const w=v[1]||"",k=r(w);if(!l.find(T=>!(T in k)))return{type:e,raw:v[0],attributes:k}}},renderMarkdown:p=>{const m=f(p.attrs||{}),y=s(m),b=y?` {${y}}`:"";return`:::${u}${b} :::`}}}function MM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=Gp,serializeAttributes:i=qp,defaultAttributes:l={},content:c="block",allowedAttributes:u}=t,f=n||e,p=m=>{if(!u)return m;const y={};return u.forEach(b=>{b in m&&(y[b]=m[b])}),y};return{parseMarkdown:(m,y)=>{let b;if(r){const w=r(m);b=typeof w=="string"?[{type:"text",text:w}]:w}else c==="block"?b=y.parseChildren(m.tokens||[]):b=y.parseInline(m.tokens||[]);const v={...l,...m.attributes};return y.createNode(e,v,b)},markdownTokenizer:{name:e,level:"block",start(m){var y;const b=new RegExp(`^:::${f}`,"m"),v=(y=m.match(b))==null?void 0:y.index;return v!==void 0?v:-1},tokenize(m,y,b){var v;const w=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),k=m.match(w);if(!k)return;const[N,T=""]=k,I=s(T);let _=1;const M=N.length;let O="";const P=/^:::([\w-]*)(\s.*)?/gm,$=m.slice(M);for(P.lastIndex=0;;){const B=P.exec($);if(B===null)break;const W=B.index,J=B[1];if(!((v=B[2])!=null&&v.endsWith(":::"))){if(J)_+=1;else if(_-=1,_===0){const F=$.slice(0,W);O=F.trim();const re=m.slice(0,M+W+B[0].length);let G=[];if(O)if(c==="block")for(G=b.blockTokens(F),G.forEach(te=>{te.text&&(!te.tokens||te.tokens.length===0)&&(te.tokens=b.inlineTokens(te.text))});G.length>0;){const te=G[G.length-1];if(te.type==="paragraph"&&(!te.text||te.text.trim()===""))G.pop();else break}else G=b.inlineTokens(O);return{type:e,raw:re,attributes:I,content:O,tokens:G}}}}}},renderMarkdown:(m,y)=>{const b=p(m.attrs||{}),v=i(b),w=v?` {${v}}`:"",k=y.renderChildren(m.content||[],`
133
+
134
+ `);return`:::${f}${w}
135
+
136
+ ${k}
137
+
138
+ :::`}}}function AM(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,s,i,l]=r;e[s]=i||l,r=n.exec(t)}return e}function OM(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function RM(t){const{nodeName:e,name:n,getContent:r,parseAttributes:s=AM,serializeAttributes:i=OM,defaultAttributes:l={},selfClosing:c=!1,allowedAttributes:u}=t,f=n||e,p=y=>{if(!u)return y;const b={};return u.forEach(v=>{const w=typeof v=="string"?v:v.name,k=typeof v=="string"?void 0:v.skipIfDefault;if(w in y){const N=y[w];if(k!==void 0&&N===k)return;b[w]=N}}),b},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(y,b)=>{const v={...l,...y.attributes};if(c)return b.createNode(e,v);const w=r?r(y):y.content||"";return w?b.createNode(e,v,[b.createTextNode(w)]):b.createNode(e,v,[])},markdownTokenizer:{name:e,level:"inline",start(y){const b=c?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),v=y.match(b),w=v==null?void 0:v.index;return w!==void 0?w:-1},tokenize(y,b,v){const w=c?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),k=y.match(w);if(!k)return;let N="",T="";if(c){const[,_]=k;T=_}else{const[,_,M]=k;T=_,N=M||""}const I=s(T.trim());return{type:e,raw:k[0],content:N.trim(),attributes:I}}},renderMarkdown:y=>{let b="";r?b=r(y):y.content&&y.content.length>0&&(b=y.content.filter(N=>N.type==="text").map(N=>N.text).join(""));const v=p(y.attrs||{}),w=i(v),k=w?` ${w}`:"";return c?`[${f}${k}]`:`[${f}${k}]${b}[/${f}]`}}}function Qh(t,e,n){var r,s,i,l;const c=t.split(`
139
+ `),u=[];let f="",p=0;const m=e.baseIndentSize||2;for(;p<c.length;){const y=c[p],b=y.match(e.itemPattern);if(!b){if(u.length>0)break;if(y.trim()===""){p+=1,f=`${f}${y}
140
+ `;continue}else return}const v=e.extractItemData(b),{indentLevel:w,mainContent:k}=v;f=`${f}${y}
141
+ `;const N=[k];for(p+=1;p<c.length;){const M=c[p];if(M.trim()===""){const P=c.slice(p+1).findIndex(W=>W.trim()!=="");if(P===-1)break;if((((s=(r=c[p+1+P].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:s.length)||0)>w){N.push(M),f=`${f}${M}
142
+ `,p+=1;continue}else break}if((((l=(i=M.match(/^(\s*)/))==null?void 0:i[1])==null?void 0:l.length)||0)>w)N.push(M),f=`${f}${M}
143
+ `,p+=1;else break}let T;const I=N.slice(1);if(I.length>0){const M=I.map(O=>O.slice(w+m)).join(`
144
+ `);M.trim()&&(e.customNestedParser?T=e.customNestedParser(M):T=n.blockTokens(M))}const _=e.createToken(v,T);u.push(_)}if(u.length!==0)return{items:u,raw:f}}function Jp(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const s=typeof n=="function"?n(r):n,[i,...l]=t.content,c=e.renderChildren([i]),u=[`${s}${c}`];return l&&l.length>0&&l.forEach(f=>{const p=e.renderChildren([f]);if(p){const m=p.split(`
145
+ `).map(y=>y?e.indent(y):"").join(`
146
+ `);u.push(m)}}),u.join(`
147
+ `)}function IM(t,e,n={}){const{state:r}=e,{doc:s,tr:i}=r,l=t;s.descendants((c,u)=>{const f=i.mapping.map(u),p=i.mapping.map(u)+c.nodeSize;let m=null;if(c.marks.forEach(b=>{if(b!==l)return!1;m=b}),!m)return;let y=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(y=!0)}),y){const b=t.type.create({...t.attrs,...n});i.removeMark(f,p,t.type),i.addMark(f,p,b)}}),i.docChanged&&e.view.dispatch(i)}var vn=class nk extends Kp{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new nk(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Qs(t){return new pM({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:s})=>{const i=xt(t.getAttributes,void 0,r,s);if(i===!1||i===null)return null;const{tr:l}=e,c=r[r.length-1],u=r[0];let f=n.to;if(c){const p=u.search(/\S/),m=n.from+u.indexOf(c),y=m+c.length;if(Vp(n.from,n.to,e.doc).filter(v=>v.mark.type.excluded.find(k=>k===t.type&&k!==v.mark.type)).filter(v=>v.to>m).length)return null;y<n.to&&l.delete(y,n.to),m>n.from&&l.delete(n.from+p,m),f=n.from+p+c.length,l.addMark(n.from+p,f,t.type.create(i||{})),l.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:jM,getOwnPropertySymbols:LM}=Object,{hasOwnProperty:DM}=Object.prototype;function ch(t,e){return function(r,s,i){return t(r,s,i)&&e(r,s,i)}}function pc(t){return function(n,r,s){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,s);const{cache:i}=s,l=i.get(n),c=i.get(r);if(l&&c)return l===r&&c===n;i.set(n,r),i.set(r,n);const u=t(n,r,s);return i.delete(n),i.delete(r),u}}function PM(t){return t!=null?t[Symbol.toStringTag]:void 0}function iv(t){return jM(t).concat(LM(t))}const BM=Object.hasOwn||((t,e)=>DM.call(t,e));function Bi(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const zM="__v",$M="__o",FM="_owner",{getOwnPropertyDescriptor:ov,keys:lv}=Object;function UM(t,e){return t.byteLength===e.byteLength&&ru(new Uint8Array(t),new Uint8Array(e))}function HM(t,e,n){let r=t.length;if(e.length!==r)return!1;for(;r-- >0;)if(!n.equals(t[r],e[r],r,r,t,e,n))return!1;return!0}function WM(t,e){return t.byteLength===e.byteLength&&ru(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function VM(t,e){return Bi(t.getTime(),e.getTime())}function KM(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function GM(t,e){return t===e}function av(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.entries();let l,c,u=0;for(;(l=i.next())&&!l.done;){const f=e.entries();let p=!1,m=0;for(;(c=f.next())&&!c.done;){if(s[m]){m++;continue}const y=l.value,b=c.value;if(n.equals(y[0],b[0],u,m,t,e,n)&&n.equals(y[1],b[1],y[0],b[0],t,e,n)){p=s[m]=!0;break}m++}if(!p)return!1;u++}return!0}const qM=Bi;function JM(t,e,n){const r=lv(t);let s=r.length;if(lv(e).length!==s)return!1;for(;s-- >0;)if(!rk(t,e,n,r[s]))return!1;return!0}function ml(t,e,n){const r=iv(t);let s=r.length;if(iv(e).length!==s)return!1;let i,l,c;for(;s-- >0;)if(i=r[s],!rk(t,e,n,i)||(l=ov(t,i),c=ov(e,i),(l||c)&&(!l||!c||l.configurable!==c.configurable||l.enumerable!==c.enumerable||l.writable!==c.writable)))return!1;return!0}function YM(t,e){return Bi(t.valueOf(),e.valueOf())}function QM(t,e){return t.source===e.source&&t.flags===e.flags}function cv(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const s=new Array(r),i=t.values();let l,c;for(;(l=i.next())&&!l.done;){const u=e.values();let f=!1,p=0;for(;(c=u.next())&&!c.done;){if(!s[p]&&n.equals(l.value,c.value,l.value,c.value,t,e,n)){f=s[p]=!0;break}p++}if(!f)return!1}return!0}function ru(t,e){let n=t.byteLength;if(e.byteLength!==n||t.byteOffset!==e.byteOffset)return!1;for(;n-- >0;)if(t[n]!==e[n])return!1;return!0}function XM(t,e){return t.hostname===e.hostname&&t.pathname===e.pathname&&t.protocol===e.protocol&&t.port===e.port&&t.hash===e.hash&&t.username===e.username&&t.password===e.password}function rk(t,e,n,r){return(r===FM||r===$M||r===zM)&&(t.$$typeof||e.$$typeof)?!0:BM(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const ZM="[object ArrayBuffer]",eA="[object Arguments]",tA="[object Boolean]",nA="[object DataView]",rA="[object Date]",sA="[object Error]",iA="[object Map]",oA="[object Number]",lA="[object Object]",aA="[object RegExp]",cA="[object Set]",uA="[object String]",dA={"[object Int8Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Int16Array]":!0,"[object Uint16Array]":!0,"[object Int32Array]":!0,"[object Uint32Array]":!0,"[object Float16Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0,"[object BigInt64Array]":!0,"[object BigUint64Array]":!0},fA="[object URL]",hA=Object.prototype.toString;function pA({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:s,areFunctionsEqual:i,areMapsEqual:l,areNumbersEqual:c,areObjectsEqual:u,arePrimitiveWrappersEqual:f,areRegExpsEqual:p,areSetsEqual:m,areTypedArraysEqual:y,areUrlsEqual:b,unknownTagComparators:v}){return function(k,N,T){if(k===N)return!0;if(k==null||N==null)return!1;const I=typeof k;if(I!==typeof N)return!1;if(I!=="object")return I==="number"?c(k,N,T):I==="function"?i(k,N,T):!1;const _=k.constructor;if(_!==N.constructor)return!1;if(_===Object)return u(k,N,T);if(Array.isArray(k))return e(k,N,T);if(_===Date)return r(k,N,T);if(_===RegExp)return p(k,N,T);if(_===Map)return l(k,N,T);if(_===Set)return m(k,N,T);const M=hA.call(k);if(M===rA)return r(k,N,T);if(M===aA)return p(k,N,T);if(M===iA)return l(k,N,T);if(M===cA)return m(k,N,T);if(M===lA)return typeof k.then!="function"&&typeof N.then!="function"&&u(k,N,T);if(M===fA)return b(k,N,T);if(M===sA)return s(k,N,T);if(M===eA)return u(k,N,T);if(dA[M])return y(k,N,T);if(M===ZM)return t(k,N,T);if(M===nA)return n(k,N,T);if(M===tA||M===oA||M===uA)return f(k,N,T);if(v){let O=v[M];if(!O){const P=PM(k);P&&(O=v[P])}if(O)return O(k,N,T)}return!1}}function mA({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:UM,areArraysEqual:n?ml:HM,areDataViewsEqual:WM,areDatesEqual:VM,areErrorsEqual:KM,areFunctionsEqual:GM,areMapsEqual:n?ch(av,ml):av,areNumbersEqual:qM,areObjectsEqual:n?ml:JM,arePrimitiveWrappersEqual:YM,areRegExpsEqual:QM,areSetsEqual:n?ch(cv,ml):cv,areTypedArraysEqual:n?ch(ru,ml):ru,areUrlsEqual:XM,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const s=pc(r.areArraysEqual),i=pc(r.areMapsEqual),l=pc(r.areObjectsEqual),c=pc(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:s,areMapsEqual:i,areObjectsEqual:l,areSetsEqual:c})}return r}function gA(t){return function(e,n,r,s,i,l,c){return t(e,n,c)}}function yA({circular:t,comparator:e,createState:n,equals:r,strict:s}){if(n)return function(c,u){const{cache:f=t?new WeakMap:void 0,meta:p}=n();return e(c,u,{cache:f,equals:r,meta:p,strict:s})};if(t)return function(c,u){return e(c,u,{cache:new WeakMap,equals:r,meta:void 0,strict:s})};const i={cache:void 0,equals:r,meta:void 0,strict:s};return function(c,u){return e(c,u,i)}}const bA=ei();ei({strict:!0});ei({circular:!0});ei({circular:!0,strict:!0});ei({createInternalComparator:()=>Bi});ei({strict:!0,createInternalComparator:()=>Bi});ei({circular:!0,createInternalComparator:()=>Bi});ei({circular:!0,createInternalComparator:()=>Bi,strict:!0});function ei(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:s=!1}=t,i=mA(t),l=pA(i),c=n?n(l):gA(l);return yA({circular:e,comparator:l,createState:r,equals:c,strict:s})}var uh={exports:{}},dh={};/**
148
+ * @license React
149
+ * use-sync-external-store-shim/with-selector.production.js
150
+ *
151
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
152
+ *
153
+ * This source code is licensed under the MIT license found in the
154
+ * LICENSE file in the root directory of this source tree.
155
+ */var uv;function vA(){if(uv)return dh;uv=1;var t=Kl(),e=q0();function n(f,p){return f===p&&(f!==0||1/f===1/p)||f!==f&&p!==p}var r=typeof Object.is=="function"?Object.is:n,s=e.useSyncExternalStore,i=t.useRef,l=t.useEffect,c=t.useMemo,u=t.useDebugValue;return dh.useSyncExternalStoreWithSelector=function(f,p,m,y,b){var v=i(null);if(v.current===null){var w={hasValue:!1,value:null};v.current=w}else w=v.current;v=c(function(){function N(O){if(!T){if(T=!0,I=O,O=y(O),b!==void 0&&w.hasValue){var P=w.value;if(b(P,O))return _=P}return _=O}if(P=_,r(I,O))return P;var $=y(O);return b!==void 0&&b(P,$)?(I=O,P):(I=O,_=$)}var T=!1,I,_,M=m===void 0?null:m;return[function(){return N(p())},M===null?void 0:function(){return N(M())}]},[p,m,y,b]);var k=s(f,v[0],v[1]);return l(function(){w.hasValue=!0,w.value=k},[k]),u(k),k},dh}var dv;function xA(){return dv||(dv=1,uh.exports=vA()),uh.exports}var wA=xA(),kA=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},SA=({contentComponent:t})=>{const e=J0.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return d.jsx(d.Fragment,{children:Object.values(e)})};function EA(){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]:ME.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 NA=class extends qs.Component{constructor(t){var e;super(t),this.editorContentRef=qs.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!!((e=t.editor)!=null&&e.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){var t;const e=this.props.editor;if(e&&!e.isDestroyed&&((t=e.view.dom)!=null&&t.parentNode)){if(e.contentComponent)return;const n=this.editorContentRef.current;n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n}),e.contentComponent=EA(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=e.contentComponent.subscribe(()=>{this.setState(r=>r.hasContentComponentInitialized?r:{hasContentComponentInitialized:!0}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()})),e.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;try{if(!((t=e.view.dom)!=null&&t.parentNode))return;const n=document.createElement("div");n.append(...e.view.dom.parentNode.childNodes),e.setOptions({element:n})}catch{}}}render(){const{editor:t,innerRef:e,...n}=this.props;return d.jsxs(d.Fragment,{children:[d.jsx("div",{ref:kA(e,this.editorContentRef),...n}),(t==null?void 0:t.contentComponent)&&d.jsx(SA,{contentComponent:t.contentComponent})]})}},CA=E.forwardRef((t,e)=>{const n=qs.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return qs.createElement(NA,{key:n,innerRef:e,...t})}),Yp=qs.memo(CA),_A=typeof window<"u"?E.useLayoutEffect:E.useEffect,TA=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 MA(t){var e;const[n]=E.useState(()=>new TA(t.editor)),r=wA.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:bA);return _A(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var AA=!1,Xh=typeof window>"u",OA=Xh||!!(typeof window<"u"&&window.next),RA=class sk{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(){return this.options.current.immediatelyRender===void 0?Xh||OA?null:this.createEditor():(this.options.current.immediatelyRender,this.options.current.immediatelyRender?this.createEditor():null)}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onBeforeCreate)==null?void 0:i.call(s,...r)},onBlur:(...r)=>{var s,i;return(i=(s=this.options.current).onBlur)==null?void 0:i.call(s,...r)},onCreate:(...r)=>{var s,i;return(i=(s=this.options.current).onCreate)==null?void 0:i.call(s,...r)},onDestroy:(...r)=>{var s,i;return(i=(s=this.options.current).onDestroy)==null?void 0:i.call(s,...r)},onFocus:(...r)=>{var s,i;return(i=(s=this.options.current).onFocus)==null?void 0:i.call(s,...r)},onSelectionUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onSelectionUpdate)==null?void 0:i.call(s,...r)},onTransaction:(...r)=>{var s,i;return(i=(s=this.options.current).onTransaction)==null?void 0:i.call(s,...r)},onUpdate:(...r)=>{var s,i;return(i=(s=this.options.current).onUpdate)==null?void 0:i.call(s,...r)},onContentError:(...r)=>{var s,i;return(i=(s=this.options.current).onContentError)==null?void 0:i.call(s,...r)},onDrop:(...r)=>{var s,i;return(i=(s=this.options.current).onDrop)==null?void 0:i.call(s,...r)},onPaste:(...r)=>{var s,i;return(i=(s=this.options.current).onPaste)==null?void 0:i.call(s,...r)},onDelete:(...r)=>{var s,i;return(i=(s=this.options.current).onDelete)==null?void 0:i.call(s,...r)}};return new SM(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,i)=>{var l;return s===((l=n.extensions)==null?void 0:l[i])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?sk.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 ik(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new RA(n)),s=J0.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(s),E.useEffect(r.onRender(e)),MA({editor:s,selector:({transactionNumber:i})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&i===0?0:i+1}),s}var ok=E.createContext({editor:null});ok.Consumer;var IA=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),jA=()=>E.useContext(IA);qs.forwardRef((t,e)=>{const{onDragStart:n}=jA(),r=t.as||"div";return d.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});qs.createContext({markViewContentRef:()=>{}});var Qp=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});Qp.displayName="TiptapContext";var LA=()=>E.useContext(Qp);function lk({editor:t,instance:e,children:n}){const r=t??e;if(!r)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const s=E.useMemo(()=>({editor:r}),[r]),i=E.useMemo(()=>({editor:r}),[r]);return d.jsx(ok.Provider,{value:i,children:d.jsx(Qp.Provider,{value:s,children:n})})}lk.displayName="Tiptap";function ak({...t}){const{editor:e}=LA();return d.jsx(Yp,{editor:e,...t})}ak.displayName="Tiptap.Content";Object.assign(lk,{Content:ak});var DA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,PA=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,BA=Ar.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",wt(this.options.HTMLAttributes,t),0]},renderMarkdown:(t,e)=>`==${e.renderChildren(t)}==`,parseMarkdown:(t,e)=>e.applyMark("highlight",e.parseInline(t.tokens||[])),markdownTokenizer:{name:"highlight",level:"inline",start:t=>t.indexOf("=="),tokenize(t,e,n){const s=/^(==)([^=]+)(==)/.exec(t);if(s){const i=s[2].trim(),l=n.inlineTokens(i);return{type:"highlight",raw:s[0],text:i,tokens:l}}}},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[ji({find:DA,type:this.type})]},addPasteRules(){return[Qs({find:PA,type:this.type})]}}),zA=BA,$A=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,FA=vn.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{},resize:!1}},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",wt(this.options.HTMLAttributes,t)]},parseMarkdown:(t,e)=>e.createNode("image",{src:t.href,title:t.title,alt:t.text}),renderMarkdown:t=>{var e,n,r,s,i,l;const c=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(s=(r=t.attrs)==null?void 0:r.alt)!=null?s:"",f=(l=(i=t.attrs)==null?void 0:i.title)!=null?l:"";return f?`![${u}](${c} "${f}")`:`![${u}](${c})`},addNodeView(){if(!this.options.resize||!this.options.resize.enabled||typeof document>"u")return null;const{directions:t,minWidth:e,minHeight:n,alwaysPreserveAspectRatio:r}=this.options.resize;return({node:s,getPos:i,HTMLAttributes:l,editor:c})=>{const u=document.createElement("img");Object.entries(l).forEach(([m,y])=>{if(y!=null)switch(m){case"width":case"height":break;default:u.setAttribute(m,y);break}}),u.src=l.src;const f=new NM({element:u,editor:c,node:s,getPos:i,onResize:(m,y)=>{u.style.width=`${m}px`,u.style.height=`${y}px`},onCommit:(m,y)=>{const b=i();b!==void 0&&this.editor.chain().setNodeSelection(b).updateAttributes(this.name,{width:m,height:y}).run()},onUpdate:(m,y,b)=>m.type===s.type,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),p=f.dom;return p.style.visibility="hidden",p.style.pointerEvents="none",u.onload=()=>{p.style.visibility="",p.style.pointerEvents=""},f}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[tk({find:$A,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),Xp=FA;const UA="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",HA="ελ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",Zh="numeric",ep="ascii",tp="alpha",Tl="asciinumeric",Sl="alphanumeric",np="domain",ck="emoji",WA="scheme",VA="slashscheme",fh="whitespace";function KA(t,e){return t in e||(e[t]=[]),e[t]}function Ei(t,e,n){e[Zh]&&(e[Tl]=!0,e[Sl]=!0),e[ep]&&(e[Tl]=!0,e[tp]=!0),e[Tl]&&(e[Sl]=!0),e[tp]&&(e[Sl]=!0),e[Sl]&&(e[np]=!0),e[ck]&&(e[np]=!0);for(const r in e){const s=KA(r,n);s.indexOf(t)<0&&s.push(t)}}function GA(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function Qn(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}Qn.groups={};Qn.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],i=e.jr[r][1];if(i&&s.test(t))return i}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||Qn.groups;let s;return e&&e.j?s=e:(s=new Qn(e),n&&r&&Ei(e,n,r)),this.jr.push([t,s]),s},ts(t,e,n,r){let s=this;const i=t.length;if(!i)return s;for(let l=0;l<i-1;l++)s=s.tt(t[l]);return s.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Qn.groups;const s=this;if(e&&e.j)return s.j[t]=e,e;const i=e;let l,c=s.go(t);if(c?(l=new Qn,Object.assign(l.j,c.j),l.jr.push.apply(l.jr,c.jr),l.jd=c.jd,l.t=c.t):l=new Qn,i){if(r)if(l.t&&typeof l.t=="string"){const u=Object.assign(GA(l.t,r),n);Ei(i,u,r)}else n&&Ei(i,n,r);l.t=i}return s.j[t]=l,l}};const lt=(t,e,n,r,s)=>t.ta(e,n,r,s),Jt=(t,e,n,r,s)=>t.tr(e,n,r,s),fv=(t,e,n,r,s)=>t.ts(e,n,r,s),pe=(t,e,n,r,s)=>t.tt(e,n,r,s),ss="WORD",rp="UWORD",uk="ASCIINUMERICAL",dk="ALPHANUMERICAL",Hl="LOCALHOST",sp="TLD",ip="UTLD",Pc="SCHEME",go="SLASH_SCHEME",Zp="NUM",op="WS",em="NL",Ml="OPENBRACE",Al="CLOSEBRACE",su="OPENBRACKET",iu="CLOSEBRACKET",ou="OPENPAREN",lu="CLOSEPAREN",au="OPENANGLEBRACKET",cu="CLOSEANGLEBRACKET",uu="FULLWIDTHLEFTPAREN",du="FULLWIDTHRIGHTPAREN",fu="LEFTCORNERBRACKET",hu="RIGHTCORNERBRACKET",pu="LEFTWHITECORNERBRACKET",mu="RIGHTWHITECORNERBRACKET",gu="FULLWIDTHLESSTHAN",yu="FULLWIDTHGREATERTHAN",bu="AMPERSAND",vu="APOSTROPHE",xu="ASTERISK",Ds="AT",wu="BACKSLASH",ku="BACKTICK",Su="CARET",zs="COLON",tm="COMMA",Eu="DOLLAR",$r="DOT",Nu="EQUALS",nm="EXCLAMATION",pr="HYPHEN",Ol="PERCENT",Cu="PIPE",_u="PLUS",Tu="POUND",Rl="QUERY",rm="QUOTE",fk="FULLWIDTHMIDDLEDOT",sm="SEMI",Fr="SLASH",Il="TILDE",Mu="UNDERSCORE",hk="EMOJI",Au="SYM";var pk=Object.freeze({__proto__:null,ALPHANUMERICAL:dk,AMPERSAND:bu,APOSTROPHE:vu,ASCIINUMERICAL:uk,ASTERISK:xu,AT:Ds,BACKSLASH:wu,BACKTICK:ku,CARET:Su,CLOSEANGLEBRACKET:cu,CLOSEBRACE:Al,CLOSEBRACKET:iu,CLOSEPAREN:lu,COLON:zs,COMMA:tm,DOLLAR:Eu,DOT:$r,EMOJI:hk,EQUALS:Nu,EXCLAMATION:nm,FULLWIDTHGREATERTHAN:yu,FULLWIDTHLEFTPAREN:uu,FULLWIDTHLESSTHAN:gu,FULLWIDTHMIDDLEDOT:fk,FULLWIDTHRIGHTPAREN:du,HYPHEN:pr,LEFTCORNERBRACKET:fu,LEFTWHITECORNERBRACKET:pu,LOCALHOST:Hl,NL:em,NUM:Zp,OPENANGLEBRACKET:au,OPENBRACE:Ml,OPENBRACKET:su,OPENPAREN:ou,PERCENT:Ol,PIPE:Cu,PLUS:_u,POUND:Tu,QUERY:Rl,QUOTE:rm,RIGHTCORNERBRACKET:hu,RIGHTWHITECORNERBRACKET:mu,SCHEME:Pc,SEMI:sm,SLASH:Fr,SLASH_SCHEME:go,SYM:Au,TILDE:Il,TLD:sp,UNDERSCORE:Mu,UTLD:ip,UWORD:rp,WORD:ss,WS:op});const ns=/[a-z]/,gl=new RegExp("\\p{L}","u"),hh=new RegExp("\\p{Emoji}","u"),rs=/\d/,ph=/\s/,hv="\r",mh=`
156
+ `,qA="️",JA="‍",gh="";let mc=null,gc=null;function YA(t=[]){const e={};Qn.groups=e;const n=new Qn;mc==null&&(mc=pv(UA)),gc==null&&(gc=pv(HA)),pe(n,"'",vu),pe(n,"{",Ml),pe(n,"}",Al),pe(n,"[",su),pe(n,"]",iu),pe(n,"(",ou),pe(n,")",lu),pe(n,"<",au),pe(n,">",cu),pe(n,"(",uu),pe(n,")",du),pe(n,"「",fu),pe(n,"」",hu),pe(n,"『",pu),pe(n,"』",mu),pe(n,"<",gu),pe(n,">",yu),pe(n,"&",bu),pe(n,"*",xu),pe(n,"@",Ds),pe(n,"`",ku),pe(n,"^",Su),pe(n,":",zs),pe(n,",",tm),pe(n,"$",Eu),pe(n,".",$r),pe(n,"=",Nu),pe(n,"!",nm),pe(n,"-",pr),pe(n,"%",Ol),pe(n,"|",Cu),pe(n,"+",_u),pe(n,"#",Tu),pe(n,"?",Rl),pe(n,'"',rm),pe(n,"/",Fr),pe(n,";",sm),pe(n,"~",Il),pe(n,"_",Mu),pe(n,"\\",wu),pe(n,"・",fk);const r=Jt(n,rs,Zp,{[Zh]:!0});Jt(r,rs,r);const s=Jt(r,ns,uk,{[Tl]:!0}),i=Jt(r,gl,dk,{[Sl]:!0}),l=Jt(n,ns,ss,{[ep]:!0});Jt(l,rs,s),Jt(l,ns,l),Jt(s,rs,s),Jt(s,ns,s);const c=Jt(n,gl,rp,{[tp]:!0});Jt(c,ns),Jt(c,rs,i),Jt(c,gl,c),Jt(i,rs,i),Jt(i,ns),Jt(i,gl,i);const u=pe(n,mh,em,{[fh]:!0}),f=pe(n,hv,op,{[fh]:!0}),p=Jt(n,ph,op,{[fh]:!0});pe(n,gh,p),pe(f,mh,u),pe(f,gh,p),Jt(f,ph,p),pe(p,hv),pe(p,mh),Jt(p,ph,p),pe(p,gh,p);const m=Jt(n,hh,hk,{[ck]:!0});pe(m,"#"),Jt(m,hh,m),pe(m,qA,m);const y=pe(m,JA);pe(y,"#"),Jt(y,hh,m);const b=[[ns,l],[rs,s]],v=[[ns,null],[gl,c],[rs,i]];for(let w=0;w<mc.length;w++)Is(n,mc[w],sp,ss,b);for(let w=0;w<gc.length;w++)Is(n,gc[w],ip,rp,v);Ei(sp,{tld:!0,ascii:!0},e),Ei(ip,{utld:!0,alpha:!0},e),Is(n,"file",Pc,ss,b),Is(n,"mailto",Pc,ss,b),Is(n,"http",go,ss,b),Is(n,"https",go,ss,b),Is(n,"ftp",go,ss,b),Is(n,"ftps",go,ss,b),Ei(Pc,{scheme:!0,ascii:!0},e),Ei(go,{slashscheme:!0,ascii:!0},e),t=t.sort((w,k)=>w[0]>k[0]?1:-1);for(let w=0;w<t.length;w++){const k=t[w][0],T=t[w][1]?{[WA]:!0}:{[VA]:!0};k.indexOf("-")>=0?T[np]=!0:ns.test(k)?rs.test(k)?T[Tl]=!0:T[ep]=!0:T[Zh]=!0,fv(n,k,k,T)}return fv(n,"localhost",Hl,{ascii:!0}),n.jd=new Qn(Au),{start:n,tokens:Object.assign({groups:e},pk)}}function mk(t,e){const n=QA(e.replace(/[A-Z]/g,c=>c.toLowerCase())),r=n.length,s=[];let i=0,l=0;for(;l<r;){let c=t,u=null,f=0,p=null,m=-1,y=-1;for(;l<r&&(u=c.go(n[l]));)c=u,c.accepts()?(m=0,y=0,p=c):m>=0&&(m+=n[l].length,y++),f+=n[l].length,i+=n[l].length,l++;i-=m,l-=y,f-=m,s.push({t:p.t,v:e.slice(i-f,i),s:i-f,e:i})}return s}function QA(t){const e=[],n=t.length;let r=0;for(;r<n;){let s=t.charCodeAt(r),i,l=s<55296||s>56319||r+1===n||(i=t.charCodeAt(r+1))<56320||i>57343?t[r]:t.slice(r,r+2);e.push(l),r+=l.length}return e}function Is(t,e,n,r,s){let i;const l=e.length;for(let c=0;c<l-1;c++){const u=e[c];t.j[u]?i=t.j[u]:(i=new Qn(r),i.jr=s.slice(),t.j[u]=i),t=i}return i=new Qn(n),i.jr=s.slice(),t.j[e[l-1]]=i,i}function pv(t){const e=[],n=[];let r=0,s="0123456789";for(;r<t.length;){let i=0;for(;s.indexOf(t[r+i])>=0;)i++;if(i>0){e.push(n.join(""));for(let l=parseInt(t.substring(r,r+i),10);l>0;l--)n.pop();r+=i}else n.push(t[r]),r++}return e}const Wl={defaultProtocol:"http",events:null,format:mv,formatHref:mv,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function im(t,e=null){let n=Object.assign({},Wl);t&&(n=Object.assign(n,t instanceof im?t.o:t));const r=n.ignoreTags,s=[];for(let i=0;i<r.length;i++)s.push(r[i].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=s}im.prototype={o:Wl,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]:Wl[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 mv(t){return t}function gk(t,e){this.t="token",this.v=t,this.tk=e}gk.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=Wl.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),i=this.toFormattedString(t),l={},c=t.get("className",n,e),u=t.get("target",n,e),f=t.get("rel",n,e),p=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return l.href=r,c&&(l.class=c),u&&(l.target=u),f&&(l.rel=f),p&&Object.assign(l,p),{tagName:s,attributes:l,content:i,eventListeners:m}}};function Zu(t,e){class n extends gk{constructor(s,i){super(s,i),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const gv=Zu("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),yv=Zu("text"),XA=Zu("nl"),yc=Zu("url",{isLink:!0,toHref(t=Wl.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Hl&&t[1].t===zs}}),hr=t=>new Qn(t);function ZA({groups:t}){const e=t.domain.concat([bu,xu,Ds,wu,ku,Su,Eu,Nu,pr,Zp,Ol,Cu,_u,Tu,Fr,Au,Il,Mu]),n=[vu,zs,tm,$r,nm,Ol,Rl,rm,sm,au,cu,Ml,Al,iu,su,ou,lu,uu,du,fu,hu,pu,mu,gu,yu],r=[bu,vu,xu,wu,ku,Su,Eu,Nu,pr,Ml,Al,Ol,Cu,_u,Tu,Rl,Fr,Au,Il,Mu],s=hr(),i=pe(s,Il);lt(i,r,i),lt(i,t.domain,i);const l=hr(),c=hr(),u=hr();lt(s,t.domain,l),lt(s,t.scheme,c),lt(s,t.slashscheme,u),lt(l,r,i),lt(l,t.domain,l);const f=pe(l,Ds);pe(i,Ds,f),pe(c,Ds,f),pe(u,Ds,f);const p=pe(i,$r);lt(p,r,i),lt(p,t.domain,i);const m=hr();lt(f,t.domain,m),lt(m,t.domain,m);const y=pe(m,$r);lt(y,t.domain,m);const b=hr(gv);lt(y,t.tld,b),lt(y,t.utld,b),pe(f,Hl,b);const v=pe(m,pr);pe(v,pr,v),lt(v,t.domain,m),lt(b,t.domain,m),pe(b,$r,y),pe(b,pr,v);const w=pe(b,zs);lt(w,t.numeric,gv);const k=pe(l,pr),N=pe(l,$r);pe(k,pr,k),lt(k,t.domain,l),lt(N,r,i),lt(N,t.domain,l);const T=hr(yc);lt(N,t.tld,T),lt(N,t.utld,T),lt(T,t.domain,l),lt(T,r,i),pe(T,$r,N),pe(T,pr,k),pe(T,Ds,f);const I=pe(T,zs),_=hr(yc);lt(I,t.numeric,_);const M=hr(yc),O=hr();lt(M,e,M),lt(M,n,O),lt(O,e,M),lt(O,n,O),pe(T,Fr,M),pe(_,Fr,M);const P=pe(c,zs),$=pe(u,zs),B=pe($,Fr),W=pe(B,Fr);lt(c,t.domain,l),pe(c,$r,N),pe(c,pr,k),lt(u,t.domain,l),pe(u,$r,N),pe(u,pr,k),lt(P,t.domain,M),pe(P,Fr,M),pe(P,Rl,M),lt(W,t.domain,M),lt(W,e,M),pe(W,Fr,M);const J=[[Ml,Al],[su,iu],[ou,lu],[au,cu],[uu,du],[fu,hu],[pu,mu],[gu,yu]];for(let F=0;F<J.length;F++){const[re,G]=J[F],te=pe(M,re);pe(O,re,te),pe(te,G,M);const U=hr(yc);lt(te,e,U);const ne=hr();lt(te,n),lt(U,e,U),lt(U,n,ne),lt(ne,e,U),lt(ne,n,ne),pe(U,G,M),pe(ne,G,M)}return pe(s,Hl,T),pe(s,em,XA),{start:s,tokens:pk}}function e2(t,e,n){let r=n.length,s=0,i=[],l=[];for(;s<r;){let c=t,u=null,f=null,p=0,m=null,y=-1;for(;s<r&&!(u=c.go(n[s].t));)l.push(n[s++]);for(;s<r&&(f=u||c.go(n[s].t));)u=null,c=f,c.accepts()?(y=0,m=c):y>=0&&y++,s++,p++;if(y<0)s-=p,s<r&&(l.push(n[s]),s++);else{l.length>0&&(i.push(yh(yv,e,l)),l=[]),s-=y,p-=y;const b=m.t,v=n.slice(s-p,s);i.push(yh(b,e,v))}}return l.length>0&&i.push(yh(yv,e,l)),i}function yh(t,e,n){const r=n[0].s,s=n[n.length-1].e,i=e.slice(r,s);return new t(i,n)}const t2=typeof console<"u"&&console&&console.warn||(()=>{}),n2="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",Bt={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function r2(){return Qn.groups={},Bt.scanner=null,Bt.parser=null,Bt.tokenQueue=[],Bt.pluginQueue=[],Bt.customSchemes=[],Bt.initialized=!1,Bt}function bv(t,e=!1){if(Bt.initialized&&t2(`linkifyjs: already initialized - will not register custom scheme "${t}" ${n2}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
157
+ 1. Must only contain digits, lowercase ASCII letters or "-"
158
+ 2. Cannot start or end with "-"
159
+ 3. "-" cannot repeat`);Bt.customSchemes.push([t,e])}function s2(){Bt.scanner=YA(Bt.customSchemes);for(let t=0;t<Bt.tokenQueue.length;t++)Bt.tokenQueue[t][1]({scanner:Bt.scanner});Bt.parser=ZA(Bt.scanner.tokens);for(let t=0;t<Bt.pluginQueue.length;t++)Bt.pluginQueue[t][1]({scanner:Bt.scanner,parser:Bt.parser});return Bt.initialized=!0,Bt}function om(t){return Bt.initialized||s2(),e2(Bt.parser.start,t,mk(Bt.scanner.start,t))}om.scan=mk;function yk(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 im(n),s=om(t),i=[];for(let l=0;l<s.length;l++){const c=s[l];c.isLink&&(!e||c.t===e)&&r.check(c)&&i.push(c.toFormattedObject(r))}return i}var lm="[\0-   ᠎ -\u2029  ]",i2=new RegExp(lm),o2=new RegExp(`${lm}$`),l2=new RegExp(lm,"g");function a2(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function c2(t){return new kt({key:new Ot("autolink"),appendTransaction:(e,n,r)=>{const s=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),i=e.some(f=>f.getMeta("preventAutolink"));if(!s||i)return;const{tr:l}=r,c=Fp(n.doc,[...e]);if(Wp(c).forEach(({newRange:f})=>{const p=Aw(r.doc,f,b=>b.isTextblock);let m,y;if(p.length>1)m=p[0],y=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(p.length){const b=r.doc.textBetween(f.from,f.to," "," ");if(!o2.test(b))return;m=p[0],y=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&y){const b=y.split(i2).filter(Boolean);if(b.length<=0)return!1;const v=b[b.length-1],w=m.pos+y.lastIndexOf(v);if(!v)return!1;const k=om(v).map(N=>N.toObject(t.defaultProtocol));if(!a2(k))return!1;k.filter(N=>N.isLink).map(N=>({...N,from:w+N.start+1,to:w+N.end+1})).filter(N=>r.schema.marks.code?!r.doc.rangeHasMark(N.from,N.to,r.schema.marks.code):!0).filter(N=>t.validate(N.value)).filter(N=>t.shouldAutoLink(N.value)).forEach(N=>{Vp(N.from,N.to,r.doc).some(T=>T.mark.type===t.type)||l.addMark(N.from,N.to,t.type.create({href:N.href}))})}}),!!l.steps.length)return l}})}function u2(t){return new kt({key:new Ot("handleClickLink"),props:{handleClick:(e,n,r)=>{var s,i;if(r.button!==0||!e.editable)return!1;let l=null;if(r.target instanceof HTMLAnchorElement)l=r.target;else{const u=r.target;if(!u)return!1;const f=t.editor.view.dom;l=u.closest("a"),l&&!f.contains(l)&&(l=null)}if(!l)return!1;let c=!1;if(t.enableClickSelection&&(c=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=Pw(e.state,t.type.name),f=(s=l.href)!=null?s:u.href,p=(i=l.target)!=null?i:u.target;f&&(window.open(f,p),c=!0)}return c}}})}function d2(t){return new kt({key:new Ot("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:s}=t,{state:i}=e,{selection:l}=i,{empty:c}=l;if(c)return!1;let u="";r.content.forEach(p=>{u+=p.textContent});const f=yk(u,{defaultProtocol:t.defaultProtocol}).find(p=>p.isLink&&p.value===u);return!u||!f||s!==void 0&&!s(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function vi(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(l2,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var bk=Ar.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"){bv(t);return}bv(t.scheme,t.optionalSlashes)})},onDestroy(){r2()},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)=>!!vi(t,e.protocols),validate:t=>!!t,shouldAutoLink:t=>{const e=/^[a-z][a-z0-9+.-]*:\/\//i.test(t),n=/^[a-z][a-z0-9+.-]*:/i.test(t);if(e||n&&!t.includes("@"))return!0;const s=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(s)||!/\./.test(s))}}},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},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!vi(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=>!!vi(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",wt(this.options.HTMLAttributes,t),0]:["a",wt(this.options.HTMLAttributes,{...t,href:""}),0]},markdownTokenName:"link",parseMarkdown:(t,e)=>e.applyMark("link",e.parseInline(t.tokens||[]),{href:t.href,title:t.title||null}),renderMarkdown:(t,e)=>{var n,r,s,i;const l=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",c=(i=(s=t.attrs)==null?void 0:s.title)!=null?i:"",u=e.renderChildren(t);return c?`[${u}](${l} "${c}")`:`[${u}](${l})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!vi(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=>!!vi(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[Qs({find:t=>{const e=[];if(t){const{protocols:n,defaultProtocol:r}=this.options,s=yk(t).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:l=>!!vi(l,n),protocols:n,defaultProtocol:r}));s.length&&s.forEach(i=>{this.options.shouldAutoLink(i.value)&&e.push({text:i.value,data:{href:i.href},index:i.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(c2({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:s=>!!vi(s,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(u2({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(d2({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),f2=bk;function h2(t={}){return new kt({view(e){return new p2(e,t)}})}class p2{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 i=l=>{this[s](l)};return e.dom.addEventListener(s,i),{name:s,handler:i}})}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,i=s.getBoundingClientRect(),l=i.width/s.offsetWidth,c=i.height/s.offsetHeight;if(n){let m=e.nodeBefore,y=e.nodeAfter;if(m||y){let b=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(b){let v=b.getBoundingClientRect(),w=m?v.bottom:v.top;m&&y&&(w=(w+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*c;r={left:v.left,right:v.right,top:w-k,bottom:w+k}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),y=this.width/2*l;r={left:m.left-y,right:m.left+y,top:m.top,bottom:m.bottom}}let u=this.editorView.dom.offsetParent;this.element||(this.element=u.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 f,p;if(!u||u==document.body&&getComputedStyle(u).position=="static")f=-pageXOffset,p=-pageYOffset;else{let m=u.getBoundingClientRect(),y=m.width/u.offsetWidth,b=m.height/u.offsetHeight;f=m.left-u.scrollLeft*y,p=m.top-u.scrollTop*b}this.element.style.left=(r.left-f)/l+"px",this.element.style.top=(r.top-p)/c+"px",this.element.style.width=(r.right-r.left)/l+"px",this.element.style.height=(r.bottom-r.top)/c+"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,i=typeof s=="function"?s(this.editorView,n,e):s;if(n&&!i){let l=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let c=kx(this.editorView.state.doc,l,this.editorView.dragging.slice);c!=null&&(l=c)}this.setCursor(l),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Yt extends Ye{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Yt.valid(r)?new Yt(r):Ye.near(r)}content(){return Se.empty}eq(e){return e instanceof Yt&&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 Yt(e.resolve(n.pos))}getBookmark(){return new am(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!m2(e)||!g2(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&&Yt.valid(e))return e;let s=e.pos,i=null;for(let l=e.depth;;l--){let c=e.node(l);if(n>0?e.indexAfter(l)<c.childCount:e.index(l)>0){i=c.child(n>0?e.indexAfter(l):e.index(l)-1);break}else if(l==0)return null;s+=n;let u=e.doc.resolve(s);if(Yt.valid(u))return u}for(;;){let l=n>0?i.firstChild:i.lastChild;if(!l){if(i.isAtom&&!i.isText&&!ze.isSelectable(i)){e=e.doc.resolve(s+i.nodeSize*n),r=!1;continue e}break}i=l,s+=n;let c=e.doc.resolve(s);if(Yt.valid(c))return c}return null}}}Yt.prototype.visible=!1;Yt.findFrom=Yt.findGapCursorFrom;Ye.jsonID("gapcursor",Yt);class am{constructor(e){this.pos=e}map(e){return new am(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Yt.valid(n)?new Yt(n):Ye.near(n)}}function vk(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function m2(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||vk(s.type))return!0;if(s.inlineContent)return!1}}return!0}function g2(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||vk(s.type))return!0;if(s.inlineContent)return!1}}return!0}function y2(){return new kt({props:{decorations:w2,createSelectionBetween(t,e,n){return e.pos==n.pos&&Yt.valid(n)?new Yt(n):null},handleClick:v2,handleKeyDown:b2,handleDOMEvents:{beforeinput:x2}}})}const b2=Pp({ArrowLeft:bc("horiz",-1),ArrowRight:bc("horiz",1),ArrowUp:bc("vert",-1),ArrowDown:bc("vert",1)});function bc(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,s,i){let l=r.selection,c=e>0?l.$to:l.$from,u=l.empty;if(l instanceof Fe){if(!i.endOfTextblock(n)||c.depth==0)return!1;u=!1,c=r.doc.resolve(e>0?c.after():c.before())}let f=Yt.findGapCursorFrom(c,e,u);return f?(s&&s(r.tr.setSelection(new Yt(f))),!0):!1}}function v2(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Yt.valid(r))return!1;let s=t.posAtCoords({left:n.clientX,top:n.clientY});return s&&s.inside>-1&&ze.isSelectable(t.state.doc.nodeAt(s.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Yt(r))),!0)}function x2(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Yt))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=ae.empty;for(let l=r.length-1;l>=0;l--)s=ae.from(r[l].createAndFill(null,s));let i=t.state.tr.replace(n.pos,n.pos,new Se(s,0,0));return i.setSelection(Fe.near(i.doc.resolve(n.pos+1))),t.dispatch(i),!1}function w2(t){if(!(t.selection instanceof Yt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",bt.create(t.doc,[jt.widget(t.selection.head,e,{key:"gapcursor"})])}var Ou=200,yn=function(){};yn.prototype.append=function(e){return e.length?(e=yn.from(e),!this.length&&e||e.length<Ou&&this.leafAppend(e)||this.length<Ou&&e.leafPrepend(this)||this.appendInner(e)):this};yn.prototype.prepend=function(e){return e.length?yn.from(e).append(this):this};yn.prototype.appendInner=function(e){return new k2(this,e)};yn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?yn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};yn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};yn.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)};yn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var s=[];return this.forEach(function(i,l){return s.push(e(i,l))},n,r),s};yn.from=function(e){return e instanceof yn?e:e&&e.length?new xk(e):yn.empty};var xk=(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,i){return s==0&&i==this.length?this:new e(this.values.slice(s,i))},e.prototype.getInner=function(s){return this.values[s]},e.prototype.forEachInner=function(s,i,l,c){for(var u=i;u<l;u++)if(s(this.values[u],c+u)===!1)return!1},e.prototype.forEachInvertedInner=function(s,i,l,c){for(var u=i-1;u>=l;u--)if(s(this.values[u],c+u)===!1)return!1},e.prototype.leafAppend=function(s){if(this.length+s.length<=Ou)return new e(this.values.concat(s.flatten()))},e.prototype.leafPrepend=function(s){if(this.length+s.length<=Ou)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})(yn);yn.empty=new xk([]);var k2=(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,i,l){var c=this.left.length;if(s<c&&this.left.forEachInner(r,s,Math.min(i,c),l)===!1||i>c&&this.right.forEachInner(r,Math.max(s-c,0),Math.min(this.length,i)-c,l+c)===!1)return!1},e.prototype.forEachInvertedInner=function(r,s,i,l){var c=this.left.length;if(s>c&&this.right.forEachInvertedInner(r,s-c,Math.max(i,c)-c,l+c)===!1||i<c&&this.left.forEachInvertedInner(r,Math.min(s,c),i,l)===!1)return!1},e.prototype.sliceInner=function(r,s){if(r==0&&s==this.length)return this;var i=this.left.length;return s<=i?this.left.slice(r,s):r>=i?this.right.slice(r-i,s-i):this.left.slice(r,i).append(this.right.slice(0,s-i))},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})(yn);const S2=500;class _r{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,i;n&&(s=this.remapping(r,this.items.length),i=s.maps.length);let l=e.tr,c,u,f=[],p=[];return this.items.forEach((m,y)=>{if(!m.step){s||(s=this.remapping(r,y+1),i=s.maps.length),i--,p.push(m);return}if(s){p.push(new Ur(m.map));let b=m.step.map(s.slice(i)),v;b&&l.maybeStep(b).doc&&(v=l.mapping.maps[l.mapping.maps.length-1],f.push(new Ur(v,void 0,void 0,f.length+p.length))),i--,v&&s.appendMap(v,i)}else l.maybeStep(m.step);if(m.selection)return c=s?m.selection.map(s.slice(i)):m.selection,u=new _r(this.items.slice(0,r).append(p.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:l,selection:c}}addTransform(e,n,r,s){let i=[],l=this.eventCount,c=this.items,u=!s&&c.length?c.get(c.length-1):null;for(let p=0;p<e.steps.length;p++){let m=e.steps[p].invert(e.docs[p]),y=new Ur(e.mapping.maps[p],m,n),b;(b=u&&u.merge(y))&&(y=b,p?i.pop():c=c.slice(0,c.length-1)),i.push(y),n&&(l++,n=void 0),s||(u=y)}let f=l-r.depth;return f>N2&&(c=E2(c,f),l-=f),new _r(c.append(i),l)}remapping(e,n){let r=new Dl;return this.items.forEach((s,i)=>{let l=s.mirrorOffset!=null&&i-s.mirrorOffset>=e?r.maps.length-s.mirrorOffset:void 0;r.appendMap(s.map,l)},e,n),r}addMaps(e){return this.eventCount==0?this:new _r(this.items.append(e.map(n=>new Ur(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],s=Math.max(0,this.items.length-n),i=e.mapping,l=e.steps.length,c=this.eventCount;this.items.forEach(y=>{y.selection&&c--},s);let u=n;this.items.forEach(y=>{let b=i.getMirror(--u);if(b==null)return;l=Math.min(l,b);let v=i.maps[b];if(y.step){let w=e.steps[b].invert(e.docs[b]),k=y.selection&&y.selection.map(i.slice(u+1,b));k&&c++,r.push(new Ur(v,w,k))}else r.push(new Ur(v))},s);let f=[];for(let y=n;y<l;y++)f.push(new Ur(i.maps[y]));let p=this.items.slice(0,s).append(f).append(r),m=new _r(p,c);return m.emptyItemCount()>S2&&(m=m.compress(this.items.length-r.length)),m}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=[],i=0;return this.items.forEach((l,c)=>{if(c>=e)s.push(l),l.selection&&i++;else if(l.step){let u=l.step.map(n.slice(r)),f=u&&u.getMap();if(r--,f&&n.appendMap(f,r),u){let p=l.selection&&l.selection.map(n.slice(r));p&&i++;let m=new Ur(f.invert(),u,p),y,b=s.length-1;(y=s.length&&s[b].merge(m))?s[b]=y:s.push(m)}}else l.map&&r--},this.items.length,0),new _r(yn.from(s.reverse()),i)}}_r.empty=new _r(yn.empty,0);function E2(t,e){let n;return t.forEach((r,s)=>{if(r.selection&&e--==0)return n=s,!1}),t.slice(n)}class Ur{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 Ur(n.getMap().invert(),n,this.selection)}}}class Ps{constructor(e,n,r,s,i){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=s,this.prevComposition=i}}const N2=20;function C2(t,e,n,r){let s=n.getMeta(Mi),i;if(s)return s.historyState;n.getMeta(M2)&&(t=new Ps(t.done,t.undone,null,0,-1));let l=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(l&&l.getMeta(Mi))return l.getMeta(Mi).redo?new Ps(t.done.addTransform(n,void 0,r,Bc(e)),t.undone,vv(n.mapping.maps),t.prevTime,t.prevComposition):new Ps(t.done,t.undone.addTransform(n,void 0,r,Bc(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(l&&l.getMeta("addToHistory")===!1)){let c=n.getMeta("composition"),u=t.prevTime==0||!l&&t.prevComposition!=c&&(t.prevTime<(n.time||0)-r.newGroupDelay||!_2(n,t.prevRanges)),f=l?bh(t.prevRanges,n.mapping):vv(n.mapping.maps);return new Ps(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,Bc(e)),_r.empty,f,n.time,c??t.prevComposition)}else return(i=n.getMeta("rebased"))?new Ps(t.done.rebased(n,i),t.undone.rebased(n,i),bh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ps(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),bh(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function _2(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,s)=>{for(let i=0;i<e.length;i+=2)r<=e[i+1]&&s>=e[i]&&(n=!0)}),n}function vv(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,s,i,l)=>e.push(i,l));return e}function bh(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let s=e.map(t[r],1),i=e.map(t[r+1],-1);s<=i&&n.push(s,i)}return n}function T2(t,e,n){let r=Bc(e),s=Mi.get(e).spec.config,i=(n?t.undone:t.done).popEvent(e,r);if(!i)return null;let l=i.selection.resolve(i.transform.doc),c=(n?t.done:t.undone).addTransform(i.transform,e.selection.getBookmark(),s,r),u=new Ps(n?c:i.remaining,n?i.remaining:c,null,0,-1);return i.transform.setSelection(l).setMeta(Mi,{redo:n,historyState:u})}let vh=!1,xv=null;function Bc(t){let e=t.plugins;if(xv!=e){vh=!1,xv=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){vh=!0;break}}return vh}const Mi=new Ot("history"),M2=new Ot("closeHistory");function A2(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new kt({key:Mi,state:{init(){return new Ps(_r.empty,_r.empty,null,0,-1)},apply(e,n,r){return C2(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,s=r=="historyUndo"?kk:r=="historyRedo"?Sk:null;return!s||!e.editable?!1:(n.preventDefault(),s(e.state,e.dispatch))}}}})}function wk(t,e){return(n,r)=>{let s=Mi.getState(n);if(!s||(t?s.undone:s.done).eventCount==0)return!1;if(r){let i=T2(s,n,t);i&&r(e?i.scrollIntoView():i)}return!0}}const kk=wk(!1,!0),Sk=wk(!0,!0);gt.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 kt({key:new Ot("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const s=this.options.limit;if(s==null||s===0){t=!0;return}const i=this.storage.characters({node:r.doc});if(i>s){const l=i-s,c=0,u=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${s} characters. Content was automatically trimmed.`);const f=r.tr.deleteRange(c,u);return t=!0,f}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}),i=this.storage.characters({node:e.doc});if(i<=r||s>r&&i>r&&i<=s)return!0;if(s>r&&i>r&&i>s||!e.getMeta("paste"))return!1;const c=e.selection.$head.pos,u=i-r,f=c-u,p=c;return e.deleteRange(f,p),!(this.storage.characters({node:e.doc})>r)}})]}});var O2=gt.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[h2(this.options)]}});gt.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new kt({key:new Ot("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:s}=e,i=[];if(!n||!r)return bt.create(t,[]);let l=0;this.options.mode==="deepest"&&t.descendants((u,f)=>{if(u.isText)return;if(!(s>=f&&s<=f+u.nodeSize-1))return!1;l+=1});let c=0;return t.descendants((u,f)=>{if(u.isText||!(s>=f&&s<=f+u.nodeSize-1))return!1;if(c+=1,this.options.mode==="deepest"&&l-c>0||this.options.mode==="shallowest"&&c>1)return this.options.mode==="deepest";i.push(jt.node(f,f+u.nodeSize,{class:this.options.className}))}),bt.create(t,i)}}})]}});var R2=gt.create({name:"gapCursor",addProseMirrorPlugins(){return[y2()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=xt(Pe(t,"allowGapCursor",n)))!=null?e:null}}}),wv="placeholder";function I2(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}var j2=gt.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:wv,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){const t=this.options.dataAttribute?`data-${I2(this.options.dataAttribute)}`:`data-${wv}`;return[new kt({key:new Ot("placeholder"),props:{decorations:({doc:e,selection:n})=>{const r=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:s}=n,i=[];if(!r)return null;const l=this.editor.isEmpty;return e.descendants((c,u)=>{const f=s>=u&&s<=u+c.nodeSize,p=!c.isLeaf&&Qu(c);if((f||!this.options.showOnlyCurrent)&&p){const m=[this.options.emptyNodeClass];l&&m.push(this.options.emptyEditorClass);const y=jt.node(u,u+c.nodeSize,{class:m.join(" "),[t]:typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:c,pos:u,hasAnchor:f}):this.options.placeholder});i.push(y)}return this.options.includeChildren}),bt.create(e,i)}}})]}});gt.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new kt({key:new Ot("selection"),props:{decorations(n){return n.selection.empty||t.isFocused||!t.isEditable||Bw(n.selection)||t.view.dragging?null:bt.create(n.doc,[jt.inline(n.selection.from,n.selection.to,{class:e.className})])}}})]}});function kv({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||(e==null?void 0:e.type)===t}var L2=gt.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Ot(this.name),n=this.options.node||((t=this.editor.schema.topNodeType.contentMatch.defaultType)==null?void 0:t.name)||"paragraph",r=Object.entries(this.editor.schema.nodes).map(([,s])=>s).filter(s=>(this.options.notAfter||[]).concat(n).includes(s.name));return[new kt({key:e,appendTransaction:(s,i,l)=>{const{doc:c,tr:u,schema:f}=l,p=e.getState(l),m=c.content.size,y=f.nodes[n];if(p)return u.insert(m,y.create())},state:{init:(s,i)=>{const l=i.tr.doc.lastChild;return!kv({node:l,types:r})},apply:(s,i)=>{if(!s.docChanged||s.getMeta("__uniqueIDTransaction"))return i;const l=s.doc.lastChild;return!kv({node:l,types:r})}}})]}}),D2=gt.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>kk(t,e),redo:()=>({state:t,dispatch:e})=>Sk(t,e)}},addProseMirrorPlugins(){return[A2(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()}}}),ed=j2,P2=Ar.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",wt(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()}}}),B2=P2,z2=Ar.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",wt(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()}}}),$2=z2;let lp,ap;if(typeof WeakMap<"u"){let t=new WeakMap;lp=e=>t.get(e),ap=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;lp=r=>{for(let s=0;s<t.length;s+=2)if(t[s]==r)return t[s+1]},ap=(r,s)=>(n==10&&(n=0),t[n++]=r,t[n++]=s)}var Qt=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 i=r+1,l=s+1;for(let c=1;i<this.width&&this.map[e+c]==n;c++)i++;for(let c=1;l<this.height&&this.map[e+this.width*c]==n;c++)l++;return{left:r,top:s,right:i,bottom:l}}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:i,bottom:l}=this.findCell(t);return e=="horiz"?(n<0?r==0:s==this.width)?null:this.map[i*this.width+(n<0?r-1:s)]:(n<0?i==0:l==this.height)?null:this.map[r+this.width*(n<0?i-1:l)]}rectBetween(t,e){const{left:n,right:r,top:s,bottom:i}=this.findCell(t),{left:l,right:c,top:u,bottom:f}=this.findCell(e);return{left:Math.min(n,l),top:Math.min(s,u),right:Math.max(r,c),bottom:Math.max(i,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let s=t.left;s<t.right;s++){const i=r*this.width+s,l=this.map[i];n[l]||(n[l]=!0,!(s==t.left&&s&&this.map[i-1]==l||r==t.top&&r&&this.map[i-this.width]==l)&&e.push(l))}return e}positionAt(t,e,n){for(let r=0,s=0;;r++){const i=s+n.child(r).nodeSize;if(r==t){let l=e+t*this.width;const c=(t+1)*this.width;for(;l<c&&this.map[l]<s;)l++;return l==c?i-1:this.map[l]}s=i}}static get(t){return lp(t)||ap(t,F2(t))}};function F2(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=U2(t),n=t.childCount,r=[];let s=0,i=null;const l=[];for(let f=0,p=e*n;f<p;f++)r[f]=0;for(let f=0,p=0;f<n;f++){const m=t.child(f);p++;for(let v=0;;v++){for(;s<r.length&&r[s]!=0;)s++;if(v==m.childCount)break;const w=m.child(v),{colspan:k,rowspan:N,colwidth:T}=w.attrs;for(let I=0;I<N;I++){if(I+f>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:p,n:N-I});break}const _=s+I*e;for(let M=0;M<k;M++){r[_+M]==0?r[_+M]=p:(i||(i=[])).push({type:"collision",row:f,pos:p,n:k-M});const O=T&&T[M];if(O){const P=(_+M)%e*2,$=l[P];$==null||$!=O&&l[P+1]==1?(l[P]=O,l[P+1]=1):$==O&&l[P+1]++}}}s+=k,p+=w.nodeSize}const y=(f+1)*e;let b=0;for(;s<y;)r[s++]==0&&b++;b&&(i||(i=[])).push({type:"missing",row:f,n:b}),p++}(e===0||n===0)&&(i||(i=[])).push({type:"zero_sized"});const c=new Qt(e,n,r,i);let u=!1;for(let f=0;!u&&f<l.length;f+=2)l[f]!=null&&l[f+1]<n&&(u=!0);return u&&H2(c,l,t),c}function U2(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const s=t.child(r);let i=0;if(n)for(let l=0;l<r;l++){const c=t.child(l);for(let u=0;u<c.childCount;u++){const f=c.child(u);l+f.attrs.rowspan>r&&(i+=f.attrs.colspan)}}for(let l=0;l<s.childCount;l++){const c=s.child(l);i+=c.attrs.colspan,c.attrs.rowspan>1&&(n=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function H2(t,e,n){t.problems||(t.problems=[]);const r={};for(let s=0;s<t.map.length;s++){const i=t.map[s];if(r[i])continue;r[i]=!0;const l=n.nodeAt(i);if(!l)throw new RangeError(`No cell with offset ${i} found`);let c=null;const u=l.attrs;for(let f=0;f<u.colspan;f++){const p=e[(s+f)%t.width*2];p!=null&&(!u.colwidth||u.colwidth[f]!=p)&&((c||(c=W2(u)))[f]=p)}c&&t.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:c})}}function W2(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Ln(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}const $s=new Ot("selectingCells");function Li(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 V2(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 Or(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 td(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=Li(e.$head)||K2(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function K2(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 cp(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function G2(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function cm(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Ek(t,e,n){const r=t.node(-1),s=Qt.get(r),i=t.start(-1),l=s.nextCell(t.pos-i,e,n);return l==null?null:t.node(0).resolve(i+l)}function Di(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 Nk(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 q2(t,e,n){const r=Ln(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 Lt=class is extends Ye{constructor(e,n=e){const r=e.node(-1),s=Qt.get(r),i=e.start(-1),l=s.rectBetween(e.pos-i,n.pos-i),c=e.node(0),u=s.cellsInRect(l).filter(p=>p!=n.pos-i);u.unshift(n.pos-i);const f=u.map(p=>{const m=r.nodeAt(p);if(!m)throw new RangeError(`No cell with offset ${p} found`);const y=i+p+1;return new _x(c.resolve(y),c.resolve(y+m.content.size))});super(f[0].$from,f[0].$to,f),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(cp(r)&&cp(s)&&cm(r,s)){const i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?is.rowSelection(r,s):i&&this.isColSelection()?is.colSelection(r,s):new is(r,s)}return Fe.between(r,s)}content(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),s=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},l=[];for(let u=s.top;u<s.bottom;u++){const f=[];for(let p=u*n.width+s.left,m=s.left;m<s.right;m++,p++){const y=n.map[p];if(i[y])continue;i[y]=!0;const b=n.findCell(y);let v=e.nodeAt(y);if(!v)throw new RangeError(`No cell with offset ${y} found`);const w=s.left-b.left,k=b.right-s.right;if(w>0||k>0){let N=v.attrs;if(w>0&&(N=Di(N,0,w)),k>0&&(N=Di(N,N.colspan-k,k)),b.left<s.left){if(v=v.type.createAndFill(N),!v)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(N)}`)}else v=v.type.create(N,v.content)}if(b.top<s.top||b.bottom>s.bottom){const N={...v.attrs,rowspan:Math.min(b.bottom,s.bottom)-Math.max(b.top,s.top)};b.top<s.top?v=v.type.createAndFill(N):v=v.type.create(N,v.content)}f.push(v)}l.push(e.child(u).copy(ae.from(f)))}const c=this.isColSelection()&&this.isRowSelection()?e:l;return new Se(ae.from(c),1,1)}replace(e,n=Se.empty){const r=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){const{$from:c,$to:u}=s[l],f=e.mapping.slice(r);e.replace(f.map(c.pos),f.map(u.pos),l?Se.empty:n)}const i=Ye.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,n){this.replace(e,new Se(ae.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Qt.get(n),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let l=0;l<i.length;l++)e(n.nodeAt(i[l]),s+i[l])}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=Qt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),u=e.node(0);return l.top<=c.top?(l.top>0&&(e=u.resolve(i+s.map[l.left])),c.bottom<s.height&&(n=u.resolve(i+s.map[s.width*(s.height-1)+c.right-1]))):(c.top>0&&(n=u.resolve(i+s.map[c.left])),l.bottom<s.height&&(e=u.resolve(i+s.map[s.width*(s.height-1)+l.right-1]))),new is(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Qt.get(e),r=this.$anchorCell.start(-1),s=n.colCount(this.$anchorCell.pos-r),i=n.colCount(this.$headCell.pos-r);if(Math.min(s,i)>0)return!1;const l=s+this.$anchorCell.nodeAfter.attrs.colspan,c=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(l,c)==n.width}eq(e){return e instanceof is&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),s=Qt.get(r),i=e.start(-1),l=s.findCell(e.pos-i),c=s.findCell(n.pos-i),u=e.node(0);return l.left<=c.left?(l.left>0&&(e=u.resolve(i+s.map[l.top*s.width])),c.right<s.width&&(n=u.resolve(i+s.map[s.width*(c.top+1)-1]))):(c.left>0&&(n=u.resolve(i+s.map[c.top*s.width])),l.right<s.width&&(e=u.resolve(i+s.map[s.width*(l.top+1)-1]))),new is(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new is(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new is(e.resolve(n),e.resolve(r))}getBookmark(){return new J2(this.$anchorCell.pos,this.$headCell.pos)}};Lt.prototype.visible=!1;Ye.jsonID("cell",Lt);var J2=class Ck{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Ck(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&&cm(n,r)?new Lt(n,r):Ye.near(r,1)}};function Y2(t){if(!(t.selection instanceof Lt))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(jt.node(r,r+n.nodeSize,{class:"selectedCell"}))}),bt.create(t.doc,e)}function Q2({$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 i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return n==r&&/row|table/.test(t.node(s).type.spec.tableRole)}function X2({$from:t,$to:e}){let n,r;for(let s=t.depth;s>0;s--){const i=t.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){n=i;break}}for(let s=e.depth;s>0;s--){const i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return n!==r&&e.parentOffset===0}function Z2(t,e,n){const r=(e||t).selection,s=(e||t).doc;let i,l;if(r instanceof ze&&(l=r.node.type.spec.tableRole)){if(l=="cell"||l=="header_cell")i=Lt.create(s,r.from);else if(l=="row"){const c=s.resolve(r.from+1);i=Lt.rowSelection(c,c)}else if(!n){const c=Qt.get(r.node),u=r.from+1,f=u+c.map[c.width*c.height-1];i=Lt.create(s,u+1,f)}}else r instanceof Fe&&Q2(r)?i=Fe.create(s,r.from):r instanceof Fe&&X2(r)&&(i=Fe.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=t.tr)).setSelection(i),e}const eO=new Ot("fix-tables");function _k(t,e,n,r){const s=t.childCount,i=e.childCount;e:for(let l=0,c=0;l<i;l++){const u=e.child(l);for(let f=c,p=Math.min(s,l+3);f<p;f++)if(t.child(f)==u){c=f+1,n+=u.nodeSize;continue e}r(u,n),c<s&&t.child(c).sameMarkup(u)?_k(t.child(c),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function Tk(t,e){let n;const r=(s,i)=>{s.type.spec.tableRole=="table"&&(n=tO(t,s,i,n))};return e?e.doc!=t.doc&&_k(e.doc,t.doc,0,r):t.doc.descendants(r),n}function tO(t,e,n,r){const s=Qt.get(e);if(!s.problems)return r;r||(r=t.tr);const i=[];for(let u=0;u<s.height;u++)i.push(0);for(let u=0;u<s.problems.length;u++){const f=s.problems[u];if(f.type=="collision"){const p=e.nodeAt(f.pos);if(!p)continue;const m=p.attrs;for(let y=0;y<m.rowspan;y++)i[f.row+y]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,Di(m,m.colspan-f.n,f.n))}else if(f.type=="missing")i[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,rowspan:p.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const p=e.nodeAt(f.pos);if(!p)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...p.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const p=r.mapping.map(n);r.delete(p,p+e.nodeSize)}}let l,c;for(let u=0;u<i.length;u++)i[u]&&(l==null&&(l=u),c=u);for(let u=0,f=n+1;u<s.height;u++){const p=e.child(u),m=f+p.nodeSize,y=i[u];if(y>0){let b="cell";p.firstChild&&(b=p.firstChild.type.spec.tableRole);const v=[];for(let k=0;k<y;k++){const N=Ln(t.schema)[b].createAndFill();N&&v.push(N)}const w=(u==0||l==u-1)&&c==u?f+1:m-1;r.insert(r.mapping.map(w),v)}f=m}return r.setMeta(eO,{fixTables:!0})}function Vr(t){const e=t.selection,n=td(t),r=n.node(-1),s=n.start(-1),i=Qt.get(r);return{...e instanceof Lt?i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):i.findCell(n.pos-s),tableStart:s,map:i,table:r}}function Mk(t,{map:e,tableStart:n,table:r},s){let i=s>0?-1:0;q2(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let l=0;l<e.height;l++){const c=l*e.width+s;if(s>0&&s<e.width&&e.map[c-1]==e.map[c]){const u=e.map[c],f=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,Nk(f.attrs,s-e.colCount(u))),l+=f.attrs.rowspan-1}else{const u=i==null?Ln(r.type.schema).cell:r.nodeAt(e.map[c+i]).type,f=e.positionAt(l,s,r);t.insert(t.mapping.map(n+f),u.createAndFill())}}return t}function nO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.left))}return!0}function rO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Mk(t.tr,n,n.right))}return!0}function sO(t,{map:e,table:n,tableStart:r},s){const i=t.mapping.maps.length;for(let l=0;l<e.height;){const c=l*e.width+s,u=e.map[c],f=n.nodeAt(u),p=f.attrs;if(s>0&&e.map[c-1]==u||s<e.width-1&&e.map[c+1]==u)t.setNodeMarkup(t.mapping.slice(i).map(r+u),null,Di(p,s-e.colCount(u)));else{const m=t.mapping.slice(i).map(r+u);t.delete(m,m+f.nodeSize)}l+=p.rowspan}}function iO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let s=n.right-1;sO(r,n,s),s!=n.left;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Qt.get(i)}e(r)}return!0}function oO(t,e,n){var r;const s=Ln(e.type.schema).header_cell;for(let i=0;i<t.width;i++)if(((r=e.nodeAt(t.map[i+n*t.width]))===null||r===void 0?void 0:r.type)!=s)return!1;return!0}function Ak(t,{map:e,tableStart:n,table:r},s){let i=n;for(let f=0;f<s;f++)i+=r.child(f).nodeSize;const l=[];let c=s>0?-1:0;oO(e,r,s+c)&&(c=s==0||s==e.height?null:0);for(let f=0,p=e.width*s;f<e.width;f++,p++)if(s>0&&s<e.height&&e.map[p]==e.map[p-e.width]){const m=e.map[p],y=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...y,rowspan:y.rowspan+1}),f+=y.colspan-1}else{var u;const m=c==null?Ln(r.type.schema).cell:(u=r.nodeAt(e.map[p+c*e.width]))===null||u===void 0?void 0:u.type,y=m==null?void 0:m.createAndFill();y&&l.push(y)}return t.insert(i,Ln(r.type.schema).row.create(null,l)),t}function lO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Ak(t.tr,n,n.top))}return!0}function aO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t);e(Ak(t.tr,n,n.bottom))}return!0}function cO(t,{map:e,table:n,tableStart:r},s){let i=0;for(let f=0;f<s;f++)i+=n.child(f).nodeSize;const l=i+n.child(s).nodeSize,c=t.mapping.maps.length;t.delete(i+r,l+r);const u=new Set;for(let f=0,p=s*e.width;f<e.width;f++,p++){const m=e.map[p];if(!u.has(m)){if(u.add(m),s>0&&m==e.map[p-e.width]){const y=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...y,rowspan:y.rowspan-1}),f+=y.colspan-1}else if(s<e.height&&m==e.map[p+e.width]){const y=n.nodeAt(m),b=y.attrs,v=y.type.create({...b,rowspan:y.attrs.rowspan-1},y.content),w=e.positionAt(s+1,f,n);t.insert(t.mapping.slice(c).map(r+w),v),f+=b.colspan-1}}}}function uO(t,e){if(!Or(t))return!1;if(e){const n=Vr(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let s=n.bottom-1;cO(r,n,s),s!=n.top;s--){const i=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!i)throw new RangeError("No table found");n.table=i,n.map=Qt.get(n.table)}e(r)}return!0}function Sv(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function dO({width:t,height:e,map:n},r){let s=r.top*t+r.left,i=s,l=(r.bottom-1)*t+r.left,c=s+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[i]==n[i-1]||r.right<t&&n[c]==n[c+1])return!0;i+=t,c+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[s]==n[s-t]||r.bottom<e&&n[l]==n[l+t])return!0;s++,l++}return!1}function Ev(t,e){const n=t.selection;if(!(n instanceof Lt)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Vr(t),{map:s}=r;if(dO(s,r))return!1;if(e){const i=t.tr,l={};let c=ae.empty,u,f;for(let p=r.top;p<r.bottom;p++)for(let m=r.left;m<r.right;m++){const y=s.map[p*s.width+m],b=r.table.nodeAt(y);if(!(l[y]||!b))if(l[y]=!0,u==null)u=y,f=b;else{Sv(b)||(c=c.append(b.content));const v=i.mapping.map(y+r.tableStart);i.delete(v,v+b.nodeSize)}}if(u==null||f==null)return!0;if(i.setNodeMarkup(u+r.tableStart,null,{...Nk(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const p=u+1+f.content.size,m=Sv(f)?u+1:p;i.replaceWith(m+r.tableStart,p+r.tableStart,c)}i.setSelection(new Lt(i.doc.resolve(u+r.tableStart))),e(i)}return!0}function Nv(t,e){const n=Ln(t.schema);return fO(({node:r})=>n[r.type.spec.tableRole])(t,e)}function fO(t){return(e,n)=>{const r=e.selection;let s,i;if(r instanceof Lt){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{var l;if(s=V2(r.$from),!s)return!1;i=(l=Li(r.$from))===null||l===void 0?void 0:l.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(n){let c=s.attrs;const u=[],f=c.colwidth;c.rowspan>1&&(c={...c,rowspan:1}),c.colspan>1&&(c={...c,colspan:1});const p=Vr(e),m=e.tr;for(let b=0;b<p.right-p.left;b++)u.push(f?{...c,colwidth:f&&f[b]?[f[b]]:null}:c);let y;for(let b=p.top;b<p.bottom;b++){let v=p.map.positionAt(b,p.left,p.table);b==p.top&&(v+=s.nodeSize);for(let w=p.left,k=0;w<p.right;w++,k++)w==p.left&&b==p.top||m.insert(y=m.mapping.map(v+p.tableStart,1),t({node:s,row:b,col:w}).createAndFill(u[k]))}m.setNodeMarkup(i,t({node:s,row:p.top,col:p.left}),u[0]),r instanceof Lt&&m.setSelection(new Lt(m.doc.resolve(r.$anchorCell.pos),y?m.doc.resolve(y):void 0)),n(m)}return!0}}function hO(t,e){return function(n,r){if(!Or(n))return!1;const s=td(n);if(s.nodeAfter.attrs[t]===e)return!1;if(r){const i=n.tr;n.selection instanceof Lt?n.selection.forEachCell((l,c)=>{l.attrs[t]!==e&&i.setNodeMarkup(c,null,{...l.attrs,[t]:e})}):i.setNodeMarkup(s.pos,null,{...s.nodeAfter.attrs,[t]:e}),r(i)}return!0}}function pO(t){return function(e,n){if(!Or(e))return!1;if(n){const r=Ln(e.schema),s=Vr(e),i=e.tr,l=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),c=l.map(u=>s.table.nodeAt(u));for(let u=0;u<l.length;u++)c[u].type==r.header_cell&&i.setNodeMarkup(s.tableStart+l[u],r.cell,c[u].attrs);if(i.steps.length===0)for(let u=0;u<l.length;u++)i.setNodeMarkup(s.tableStart+l[u],r.header_cell,c[u].attrs);n(i)}return!0}}function Cv(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 i=e.table.nodeAt(r[s]);if(i&&i.type!==n.header_cell)return!1}return!0}function Vl(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?pO(t):function(n,r){if(!Or(n))return!1;if(r){const s=Ln(n.schema),i=Vr(n),l=n.tr,c=Cv("row",i,s),u=Cv("column",i,s),f=(t==="column"?c:t==="row"&&u)?1:0,p=t=="column"?{left:0,top:f,right:1,bottom:i.map.height}:t=="row"?{left:f,top:0,right:i.map.width,bottom:1}:i,m=t=="column"?u?s.cell:s.header_cell:t=="row"?c?s.cell:s.header_cell:s.cell;i.map.cellsInRect(p).forEach(y=>{const b=y+i.tableStart,v=l.doc.nodeAt(b);v&&l.setNodeMarkup(b,m,v.attrs)}),r(l)}return!0}}Vl("row",{useDeprecatedLogic:!0});Vl("column",{useDeprecatedLogic:!0});const mO=Vl("cell",{useDeprecatedLogic:!0});function gO(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 i=t.node(-1).child(r),l=i.lastChild;if(l)return s-1-l.nodeSize;s-=i.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 i=n.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}return null}function _v(t){return function(e,n){if(!Or(e))return!1;const r=gO(td(e),t);if(r==null)return!1;if(n){const s=e.doc.resolve(r);n(e.tr.setSelection(Fe.between(s,G2(s))).scrollIntoView())}return!0}}function yO(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 vc(t,e){const n=t.selection;if(!(n instanceof Lt))return!1;if(e){const r=t.tr,s=Ln(t.schema).cell.createAndFill().content;n.forEachCell((i,l)=>{i.content.eq(s)||r.replace(r.mapping.map(l+1),r.mapping.map(l+i.nodeSize-1),new Se(s,0,0))}),r.docChanged&&e(r)}return!0}function bO(t){if(t.size===0)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),i=s.type.spec.tableRole,l=s.type.schema,c=[];if(i=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const p=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,r-1);(p||m)&&(f=up(Ln(l).row,new Se(f,p,m)).content),c.push(f)}else if(i=="cell"||i=="header_cell")c.push(n||r?up(Ln(l).row,new Se(e,n,r)).content:e);else return null;return vO(l,c)}function vO(t,e){const n=[];for(let s=0;s<e.length;s++){const i=e[s];for(let l=i.childCount-1;l>=0;l--){const{rowspan:c,colspan:u}=i.child(l).attrs;for(let f=s;f<s+c;f++)n[f]=(n[f]||0)+u}}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(ae.empty),n[s]<r){const i=Ln(t).cell.createAndFill(),l=[];for(let c=n[s];c<r;c++)l.push(i);e[s]=e[s].append(ae.from(l))}return{height:e.length,width:r,rows:e}}function up(t,e){const n=t.createAndFill();return new wp(n).replace(0,n.content.size,e).doc}function xO({width:t,height:e,rows:n},r,s){if(t!=r){const i=[],l=[];for(let c=0;c<n.length;c++){const u=n[c],f=[];for(let p=i[c]||0,m=0;p<r;m++){let y=u.child(m%u.childCount);p+y.attrs.colspan>r&&(y=y.type.createChecked(Di(y.attrs,y.attrs.colspan,p+y.attrs.colspan-r),y.content)),f.push(y),p+=y.attrs.colspan;for(let b=1;b<y.attrs.rowspan;b++)i[c+b]=(i[c+b]||0)+y.attrs.colspan}l.push(ae.from(f))}n=l,t=r}if(e!=s){const i=[];for(let l=0,c=0;l<s;l++,c++){const u=[],f=n[c%e];for(let p=0;p<f.childCount;p++){let m=f.child(p);l+m.attrs.rowspan>s&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,s-m.attrs.rowspan)},m.content)),u.push(m)}i.push(ae.from(u))}n=i,e=s}return{width:t,height:e,rows:n}}function wO(t,e,n,r,s,i,l){const c=t.doc.type.schema,u=Ln(c);let f,p;if(s>e.width)for(let m=0,y=0;m<e.height;m++){const b=n.child(m);y+=b.nodeSize;const v=[];let w;b.lastChild==null||b.lastChild.type==u.cell?w=f||(f=u.cell.createAndFill()):w=p||(p=u.header_cell.createAndFill());for(let k=e.width;k<s;k++)v.push(w);t.insert(t.mapping.slice(l).map(y-1+r),v)}if(i>e.height){const m=[];for(let v=0,w=(e.height-1)*e.width;v<Math.max(e.width,s);v++){const k=v>=e.width?!1:n.nodeAt(e.map[w+v]).type==u.header_cell;m.push(k?p||(p=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const y=u.row.create(null,ae.from(m)),b=[];for(let v=e.height;v<i;v++)b.push(y);t.insert(t.mapping.slice(l).map(r+n.nodeSize-2),b)}return!!(f||p)}function Tv(t,e,n,r,s,i,l,c){if(l==0||l==e.height)return!1;let u=!1;for(let f=s;f<i;f++){const p=l*e.width+f,m=e.map[p];if(e.map[p-e.width]==m){u=!0;const y=n.nodeAt(m),{top:b,left:v}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(c).map(m+r),null,{...y.attrs,rowspan:l-b}),t.insert(t.mapping.slice(c).map(e.positionAt(l,v,n)),y.type.createAndFill({...y.attrs,rowspan:b+y.attrs.rowspan-l})),f+=y.attrs.colspan-1}}return u}function Mv(t,e,n,r,s,i,l,c){if(l==0||l==e.width)return!1;let u=!1;for(let f=s;f<i;f++){const p=f*e.width+l,m=e.map[p];if(e.map[p-1]==m){u=!0;const y=n.nodeAt(m),b=e.colCount(m),v=t.mapping.slice(c).map(m+r);t.setNodeMarkup(v,null,Di(y.attrs,l-b,y.attrs.colspan-(l-b))),t.insert(v+y.nodeSize,y.type.createAndFill(Di(y.attrs,0,l-b))),f+=y.attrs.rowspan-1}}return u}function Av(t,e,n,r,s){let i=n?t.doc.nodeAt(n-1):t.doc;if(!i)throw new Error("No table found");let l=Qt.get(i);const{top:c,left:u}=r,f=u+s.width,p=c+s.height,m=t.tr;let y=0;function b(){if(i=n?m.doc.nodeAt(n-1):m.doc,!i)throw new Error("No table found");l=Qt.get(i),y=m.mapping.maps.length}wO(m,l,i,n,f,p,y)&&b(),Tv(m,l,i,n,u,f,c,y)&&b(),Tv(m,l,i,n,u,f,p,y)&&b(),Mv(m,l,i,n,c,p,u,y)&&b(),Mv(m,l,i,n,c,p,f,y)&&b();for(let v=c;v<p;v++){const w=l.positionAt(v,u,i),k=l.positionAt(v,f,i);m.replace(m.mapping.slice(y).map(w+n),m.mapping.slice(y).map(k+n),new Se(s.rows[v-c],0,0))}b(),m.setSelection(new Lt(m.doc.resolve(n+l.positionAt(c,u,i)),m.doc.resolve(n+l.positionAt(p-1,f-1,i)))),e(m)}const kO=Pp({ArrowLeft:xc("horiz",-1),ArrowRight:xc("horiz",1),ArrowUp:xc("vert",-1),ArrowDown:xc("vert",1),"Shift-ArrowLeft":wc("horiz",-1),"Shift-ArrowRight":wc("horiz",1),"Shift-ArrowUp":wc("vert",-1),"Shift-ArrowDown":wc("vert",1),Backspace:vc,"Mod-Backspace":vc,Delete:vc,"Mod-Delete":vc});function zc(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function xc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;if(i instanceof Lt)return zc(n,r,Ye.near(i.$headCell,e));if(t!="horiz"&&!i.empty)return!1;const l=Ok(s,t,e);if(l==null)return!1;if(t=="horiz")return zc(n,r,Ye.near(n.doc.resolve(i.head+e),e));{const c=n.doc.resolve(l),u=Ek(c,t,e);let f;return u?f=Ye.near(u,1):e<0?f=Ye.near(n.doc.resolve(c.before(-1)),-1):f=Ye.near(n.doc.resolve(c.after(-1)),1),zc(n,r,f)}}}function wc(t,e){return(n,r,s)=>{if(!s)return!1;const i=n.selection;let l;if(i instanceof Lt)l=i;else{const u=Ok(s,t,e);if(u==null)return!1;l=new Lt(n.doc.resolve(u))}const c=Ek(l.$headCell,t,e);return c?zc(n,r,new Lt(l.$anchorCell,c)):!1}}function SO(t,e){const n=t.state.doc,r=Li(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new Lt(r))),!0):!1}function EO(t,e,n){if(!Or(t.state))return!1;let r=bO(n);const s=t.state.selection;if(s instanceof Lt){r||(r={width:1,height:1,rows:[ae.from(up(Ln(t.state.schema).cell,n))]});const i=s.$anchorCell.node(-1),l=s.$anchorCell.start(-1),c=Qt.get(i).rectBetween(s.$anchorCell.pos-l,s.$headCell.pos-l);return r=xO(r,c.right-c.left,c.bottom-c.top),Av(t.state,t.dispatch,l,c,r),!0}else if(r){const i=td(t.state),l=i.start(-1);return Av(t.state,t.dispatch,l,Qt.get(i.node(-1)).findCell(i.pos-l),r),!0}else return!1}function NO(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=Ov(t,e.target);let s;if(e.shiftKey&&t.state.selection instanceof Lt)i(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(s=Li(t.state.selection.$anchor))!=null&&((n=xh(t,e))===null||n===void 0?void 0:n.pos)!=s.pos)i(s,e),e.preventDefault();else if(!r)return;function i(u,f){let p=xh(t,f);const m=$s.getState(t.state)==null;if(!p||!cm(u,p))if(m)p=u;else return;const y=new Lt(u,p);if(m||!t.state.selection.eq(y)){const b=t.state.tr.setSelection(y);m&&b.setMeta($s,u.pos),t.dispatch(b)}}function l(){t.root.removeEventListener("mouseup",l),t.root.removeEventListener("dragstart",l),t.root.removeEventListener("mousemove",c),$s.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta($s,-1))}function c(u){const f=u,p=$s.getState(t.state);let m;if(p!=null)m=t.state.doc.resolve(p);else if(Ov(t,f.target)!=r&&(m=xh(t,e),!m))return l();m&&i(m,f)}t.root.addEventListener("mouseup",l),t.root.addEventListener("dragstart",l),t.root.addEventListener("mousemove",c)}function Ok(t,e,n){if(!(t.state.selection instanceof Fe))return null;const{$head:r}=t.state.selection;for(let s=r.depth-1;s>=0;s--){const i=r.node(s);if((n<0?r.index(s):r.indexAfter(s))!=(n<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){const l=r.before(s),c=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(c)?l:null}}return null}function Ov(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function xh(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:s}=n;return r>=0&&Li(t.state.doc.resolve(r))||Li(t.state.doc.resolve(s))}var CO=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")),dp(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,dp(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function dp(t,e,n,r,s,i){let l=0,c=!0,u=e.firstChild;const f=t.firstChild;if(f){for(let m=0,y=0;m<f.childCount;m++){const{colspan:b,colwidth:v}=f.child(m).attrs;for(let w=0;w<b;w++,y++){const k=s==y?i:v&&v[w],N=k?k+"px":"";if(l+=k||r,k||(c=!1),u)u.style.width!=N&&(u.style.width=N),u=u.nextSibling;else{const T=document.createElement("col");T.style.width=N,e.appendChild(T)}}}for(;u;){var p;const m=u.nextSibling;(p=u.parentNode)===null||p===void 0||p.removeChild(u),u=m}c?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}const sr=new Ot("tableColumnResizing");function _O({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=CO,lastColumnResizable:s=!0}={}){const i=new kt({key:sr,state:{init(l,c){var u;const f=(u=i.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,p=Ln(c.schema).table.name;return r&&f&&(f[p]=(m,y)=>new r(m,n,y)),new TO(-1,!1)},apply(l,c){return c.apply(l)}},props:{attributes:l=>{const c=sr.getState(l);return c&&c.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(l,c)=>{MO(l,c,t,s)},mouseleave:l=>{AO(l)},mousedown:(l,c)=>{OO(l,c,e,n)}},decorations:l=>{const c=sr.getState(l);if(c&&c.activeHandle>-1)return DO(l,c.activeHandle)},nodeViews:{}}});return i}var TO=class $c{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(sr);if(r&&r.setHandle!=null)return new $c(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new $c(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let s=e.mapping.map(n.activeHandle,-1);return cp(e.doc.resolve(s))||(s=-1),new $c(s,n.dragging)}return n}};function MO(t,e,n,r){if(!t.editable)return;const s=sr.getState(t.state);if(s&&!s.dragging){const i=IO(e.target);let l=-1;if(i){const{left:c,right:u}=i.getBoundingClientRect();e.clientX-c<=n?l=Rv(t,e,"left",n):u-e.clientX<=n&&(l=Rv(t,e,"right",n))}if(l!=s.activeHandle){if(!r&&l!==-1){const c=t.state.doc.resolve(l),u=c.node(-1),f=Qt.get(u),p=c.start(-1);if(f.colCount(c.pos-p)+c.nodeAfter.attrs.colspan-1==f.width-1)return}Rk(t,l)}}}function AO(t){if(!t.editable)return;const e=sr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Rk(t,-1)}function OO(t,e,n,r){var s;if(!t.editable)return!1;const i=(s=t.dom.ownerDocument.defaultView)!==null&&s!==void 0?s:window,l=sr.getState(t.state);if(!l||l.activeHandle==-1||l.dragging)return!1;const c=t.state.doc.nodeAt(l.activeHandle),u=RO(t,l.activeHandle,c.attrs);t.dispatch(t.state.tr.setMeta(sr,{setDragging:{startX:e.clientX,startWidth:u}}));function f(m){i.removeEventListener("mouseup",f),i.removeEventListener("mousemove",p);const y=sr.getState(t.state);y!=null&&y.dragging&&(jO(t,y.activeHandle,Iv(y.dragging,m,n)),t.dispatch(t.state.tr.setMeta(sr,{setDragging:null})))}function p(m){if(!m.which)return f(m);const y=sr.getState(t.state);if(y&&y.dragging){const b=Iv(y.dragging,m,n);jv(t,y.activeHandle,b,r)}}return jv(t,l.activeHandle,u,r),i.addEventListener("mouseup",f),i.addEventListener("mousemove",p),e.preventDefault(),!0}function RO(t,e,{colspan:n,colwidth:r}){const s=r&&r[r.length-1];if(s)return s;const i=t.domAtPos(e);let l=i.node.childNodes[i.offset].offsetWidth,c=n;if(r)for(let u=0;u<n;u++)r[u]&&(l-=r[u],c--);return l/c}function IO(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function Rv(t,e,n,r){const s=n=="right"?-r:r,i=t.posAtCoords({left:e.clientX+s,top:e.clientY});if(!i)return-1;const{pos:l}=i,c=Li(t.state.doc.resolve(l));if(!c)return-1;if(n=="right")return c.pos;const u=Qt.get(c.node(-1)),f=c.start(-1),p=u.map.indexOf(c.pos-f);return p%u.width==0?-1:f+u.map[p-1]}function Iv(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Rk(t,e){t.dispatch(t.state.tr.setMeta(sr,{setHandle:e}))}function jO(t,e,n){const r=t.state.doc.resolve(e),s=r.node(-1),i=Qt.get(s),l=r.start(-1),c=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let f=0;f<i.height;f++){const p=f*i.width+c;if(f&&i.map[p]==i.map[p-i.width])continue;const m=i.map[p],y=s.nodeAt(m).attrs,b=y.colspan==1?0:c-i.colCount(m);if(y.colwidth&&y.colwidth[b]==n)continue;const v=y.colwidth?y.colwidth.slice():LO(y.colspan);v[b]=n,u.setNodeMarkup(l+m,null,{...y,colwidth:v})}u.docChanged&&t.dispatch(u)}function jv(t,e,n,r){const s=t.state.doc.resolve(e),i=s.node(-1),l=s.start(-1),c=Qt.get(i).colCount(s.pos-l)+s.nodeAfter.attrs.colspan-1;let u=t.domAtPos(s.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&dp(i,u.firstChild,u,r,c,n)}function LO(t){return Array(t).fill(0)}function DO(t,e){const n=[],r=t.doc.resolve(e),s=r.node(-1);if(!s)return bt.empty;const i=Qt.get(s),l=r.start(-1),c=i.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<i.height;f++){const p=c+f*i.width;if((c==i.width-1||i.map[p]!=i.map[p+1])&&(f==0||i.map[p]!=i.map[p-i.width])){var u;const m=i.map[p],y=l+m+s.nodeAt(m).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((u=sr.getState(t))===null||u===void 0)&&u.dragging&&n.push(jt.node(l+m,l+m+s.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(jt.widget(y,b))}}return bt.create(t.doc,n)}function PO({allowTableNodeSelection:t=!1}={}){return new kt({key:$s,state:{init(){return null},apply(e,n){const r=e.getMeta($s);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:s,pos:i}=e.mapping.mapResult(n);return s?null:i}},props:{decorations:Y2,handleDOMEvents:{mousedown:NO},createSelectionBetween(e){return $s.getState(e.state)!=null?e.state.selection:null},handleTripleClick:SO,handleKeyDown:kO,handlePaste:EO},appendTransaction(e,n,r){return Z2(r,Tk(r,n),t)}})}var Ik=vn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:t=>{var e,n;const r=t.getAttribute("colwidth"),s=r?r.split(",").map(i=>parseInt(i,10)):null;if(!s){const i=(e=t.closest("table"))==null?void 0:e.querySelectorAll("colgroup > col"),l=Array.from(((n=t.parentElement)==null?void 0:n.children)||[]).indexOf(t);if(l&&l>-1&&i&&i[l]){const c=i[l].getAttribute("width");return c?[parseInt(c,10)]:null}}return s}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",wt(this.options.HTMLAttributes,t),0]}}),jk=vn.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",wt(this.options.HTMLAttributes,t),0]}}),Lk=vn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",wt(this.options.HTMLAttributes,t),0]}});function fp(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function Lv(t,e,n,r,s,i){var l;let c=0,u=!0,f=e.firstChild;const p=t.firstChild;if(p!==null)for(let y=0,b=0;y<p.childCount;y+=1){const{colspan:v,colwidth:w}=p.child(y).attrs;for(let k=0;k<v;k+=1,b+=1){const N=s===b?i:w&&w[k],T=N?`${N}px`:"";if(c+=N||r,N||(u=!1),f){if(f.style.width!==T){const[I,_]=fp(r,N);f.style.setProperty(I,_)}f=f.nextSibling}else{const I=document.createElement("col"),[_,M]=fp(r,N);I.style.setProperty(_,M),e.appendChild(I)}}}for(;f;){const y=f.nextSibling;(l=f.parentNode)==null||l.removeChild(f),f=y}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${c}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${c}px`)}var BO=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")),t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Lv(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,Lv(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){const e=t.target,n=this.dom.contains(e),r=this.contentDOM.contains(e);return!!(n&&!r&&(t.type==="attributes"||t.type==="childList"||t.type==="characterData"))}};function zO(t,e,n,r){let s=0,i=!0;const l=[],c=t.firstChild;if(!c)return{};for(let m=0,y=0;m<c.childCount;m+=1){const{colspan:b,colwidth:v}=c.child(m).attrs;for(let w=0;w<b;w+=1,y+=1){const k=n===y?r:v&&v[w];s+=k||e,k||(i=!1);const[N,T]=fp(e,k);l.push(["col",{style:`${N}: ${T}`}])}}const u=i?`${s}px`:"",f=i?"":`${s}px`;return{colgroup:["colgroup",{},...l],tableWidth:u,tableMinWidth:f}}function Dv(t,e){return t.createAndFill()}function $O(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 FO(t,e,n,r,s){const i=$O(t),l=[],c=[];for(let f=0;f<n;f+=1){const p=Dv(i.cell);if(p&&c.push(p),r){const m=Dv(i.header_cell);m&&l.push(m)}}const u=[];for(let f=0;f<e;f+=1)u.push(i.row.createChecked(null,r&&f===0?l:c));return i.table.createChecked(null,u)}function UO(t){return t instanceof Lt}var kc=({editor:t})=>{const{selection:e}=t.state;if(!UO(e))return!1;let n=0;const r=Ow(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},HO="";function WO(t){return(t||"").replace(/\s+/g," ").trim()}function VO(t,e,n={}){var r;const s=(r=n.cellLineSeparator)!=null?r:HO;if(!t||!t.content||t.content.length===0)return"";const i=[];t.content.forEach(v=>{const w=[];v.content&&v.content.forEach(k=>{let N="";k.content&&Array.isArray(k.content)&&k.content.length>1?N=k.content.map(M=>e.renderChildren(M)).join(s):N=k.content?e.renderChildren(k.content):"";const T=WO(N),I=k.type==="tableHeader";w.push({text:T,isHeader:I})}),i.push(w)});const l=i.reduce((v,w)=>Math.max(v,w.length),0);if(l===0)return"";const c=new Array(l).fill(0);i.forEach(v=>{var w;for(let k=0;k<l;k+=1){const T=(((w=v[k])==null?void 0:w.text)||"").length;T>c[k]&&(c[k]=T),c[k]<3&&(c[k]=3)}});const u=(v,w)=>v+" ".repeat(Math.max(0,w-v.length)),f=i[0],p=f.some(v=>v.isHeader);let m=`
160
+ `;const y=new Array(l).fill(0).map((v,w)=>p&&f[w]&&f[w].text||"");return m+=`| ${y.map((v,w)=>u(v,c[w])).join(" | ")} |
161
+ `,m+=`| ${c.map(v=>"-".repeat(Math.max(3,v))).join(" | ")} |
162
+ `,(p?i.slice(1):i).forEach(v=>{m+=`| ${new Array(l).fill(0).map((w,k)=>u(v[k]&&v[k].text||"",c[k])).join(" | ")} |
163
+ `}),m}var KO=VO,Dk=vn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:BO,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}=zO(t,this.options.cellMinWidth),i=e.style;function l(){return i||(r?`width: ${r}`:`min-width: ${s}`)}const c=["table",wt(this.options.HTMLAttributes,e,{style:l()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},c]:c},parseMarkdown:(t,e)=>{const n=[];if(t.header){const r=[];t.header.forEach(s=>{r.push(e.createNode("tableHeader",{},[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},r))}return t.rows&&t.rows.forEach(r=>{const s=[];r.forEach(i=>{s.push(e.createNode("tableCell",{},[{type:"paragraph",content:e.parseInline(i.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>KO(t,e),addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const l=FO(i.schema,t,e,n);if(s){const c=r.selection.from+1;r.replaceSelectionWith(l).scrollIntoView().setSelection(Fe.near(r.doc.resolve(c)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>nO(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>rO(t,e),deleteColumn:()=>({state:t,dispatch:e})=>iO(t,e),addRowBefore:()=>({state:t,dispatch:e})=>lO(t,e),addRowAfter:()=>({state:t,dispatch:e})=>aO(t,e),deleteRow:()=>({state:t,dispatch:e})=>uO(t,e),deleteTable:()=>({state:t,dispatch:e})=>yO(t,e),mergeCells:()=>({state:t,dispatch:e})=>Ev(t,e),splitCell:()=>({state:t,dispatch:e})=>Nv(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>Vl("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>Vl("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>mO(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>Ev(t,e)?!0:Nv(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>hO(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>_v(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>_v(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Tk(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=Lt.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:kc,"Mod-Backspace":kc,Delete:kc,"Mod-Delete":kc}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[_O({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],PO({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:xt(Pe(t,"tableRole",e))}}});gt.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(Dk.configure(this.options.table)),this.options.tableCell!==!1&&t.push(Ik.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(jk.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(Lk.configure(this.options.tableRow)),t}});var GO=Object.defineProperty,qO=(t,e)=>{for(var n in e)GO(t,n,{get:e[n],enumerable:!0})},JO="listItem",Pv="textStyle",Bv=/^\s*([-+*])\s$/,Pk=vn.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",wt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>t.type!=="list"||t.ordered?[]:{type:"bulletList",content:t.items?e.parseChildren(t.items):[]},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
164
+ `):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(JO,this.editor.getAttributes(Pv)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=To({find:Bv,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=To({find:Bv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Pv),editor:this.editor})),[t]}}),Bk=vn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",wt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{if(t.type!=="list_item")return[];let n=[];if(t.tokens&&t.tokens.length>0)if(t.tokens.some(s=>s.type==="paragraph"))n=e.parseChildren(t.tokens);else{const s=t.tokens[0];if(s&&s.type==="text"&&s.tokens&&s.tokens.length>0){if(n=[{type:"paragraph",content:e.parseInline(s.tokens)}],t.tokens.length>1){const l=t.tokens.slice(1),c=e.parseChildren(l);n.push(...c)}}else n=e.parseChildren(t.tokens)}return n.length===0&&(n=[{type:"paragraph",content:[]}]),{type:"listItem",content:n}},renderMarkdown:(t,e,n)=>Jp(t,e,r=>{var s,i;return r.parentType==="bulletList"?"- ":r.parentType==="orderedList"?`${(((i=(s=r.meta)==null?void 0:s.parentAttrs)==null?void 0:i.start)||1)+r.index}. `:"- "},n),addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),YO={};qO(YO,{findListItemPos:()=>Ql,getNextListDepth:()=>um,handleBackspace:()=>hp,handleDelete:()=>pp,hasListBefore:()=>zk,hasListItemAfter:()=>QO,hasListItemBefore:()=>$k,listItemHasSubList:()=>Fk,nextListIsDeeper:()=>Uk,nextListIsHigher:()=>Hk});var Ql=(t,e)=>{const{$from:n}=e.selection,r=ln(t,e.schema);let s=null,i=n.depth,l=n.pos,c=null;for(;i>0&&c===null;)s=n.node(i),s.type===r?c=i:(i-=1,l-=1);return c===null?null:{$pos:e.doc.resolve(l),depth:c}},um=(t,e)=>{const n=Ql(t,e);if(!n)return!1;const[,r]=LT(e,t,n.$pos.pos+4);return r},zk=(t,e,n)=>{const{$anchor:r}=t.selection,s=Math.max(0,r.pos-2),i=t.doc.resolve(s).node();return!(!i||!n.includes(i.type.name))},$k=(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)},Fk=(t,e,n)=>{if(!n)return!1;const r=ln(t,e.schema);let s=!1;return n.descendants(i=>{i.type===r&&(s=!0)}),s},hp=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Ys(t.state,e)&&zk(t.state,e,n)){const{$anchor:c}=t.state.selection,u=t.state.doc.resolve(c.before()-1),f=[];u.node().descendants((y,b)=>{y.type.name===e&&f.push({node:y,pos:b})});const p=f.at(-1);if(!p)return!1;const m=t.state.doc.resolve(u.start()+p.pos+1);return t.chain().cut({from:c.start()-1,to:c.end()+1},m.end()).joinForward().run()}if(!Ys(t.state,e)||!zT(t.state))return!1;const r=Ql(e,t.state);if(!r)return!1;const i=t.state.doc.resolve(r.$pos.pos-2).node(r.depth),l=Fk(e,t.state,i);return $k(e,t.state)&&!l?t.commands.joinItemBackward():t.chain().liftListItem(e).run()},Uk=(t,e)=>{const n=um(t,e),r=Ql(t,e);return!r||!n?!1:n>r.depth},Hk=(t,e)=>{const n=um(t,e),r=Ql(t,e);return!r||!n?!1:n<r.depth},pp=(t,e)=>{if(!Ys(t.state,e)||!BT(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:s}=n;return!n.empty&&r.sameParent(s)?!1:Uk(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():Hk(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},QO=(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)},Wk=gt.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&&pp(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&&pp(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&&hp(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&&hp(t,n,r)&&(e=!0)}),e}}}}),zv=/^(\s*)(\d+)\.\s+(.*)$/,XO=/^\s/;function ZO(t){const e=[];let n=0,r=0;for(;n<t.length;){const s=t[n],i=s.match(zv);if(!i)break;const[,l,c,u]=i,f=l.length;let p=u,m=n+1;const y=[s];for(;m<t.length;){const b=t[m];if(b.match(zv))break;if(b.trim()==="")y.push(b),p+=`
165
+ `,m+=1;else if(b.match(XO))y.push(b),p+=`
166
+ ${b.slice(f+2)}`,m+=1;else break}e.push({indent:f,number:parseInt(c,10),content:p.trim(),raw:y.join(`
167
+ `)}),r=m,n=m}return[e,r]}function Vk(t,e,n){var r;const s=[];let i=0;for(;i<t.length;){const l=t[i];if(l.indent===e){const c=l.content.split(`
168
+ `),u=((r=c[0])==null?void 0:r.trim())||"",f=[];u&&f.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const p=c.slice(1).join(`
169
+ `).trim();if(p){const b=n.blockTokens(p);f.push(...b)}let m=i+1;const y=[];for(;m<t.length&&t[m].indent>e;)y.push(t[m]),m+=1;if(y.length>0){const b=Math.min(...y.map(w=>w.indent)),v=Vk(y,b,n);f.push({type:"list",ordered:!0,start:y[0].number,items:v,raw:y.map(w=>w.raw).join(`
170
+ `)})}s.push({type:"list_item",raw:l.raw,tokens:f}),i=m}else i+=1}return s}function eR(t,e){return t.map(n=>{if(n.type!=="list_item")return e.parseChildren([n])[0];const r=[];return n.tokens&&n.tokens.length>0&&n.tokens.forEach(s=>{if(s.type==="paragraph"||s.type==="list"||s.type==="blockquote"||s.type==="code")r.push(...e.parseChildren([s]));else if(s.type==="text"&&s.tokens){const i=e.parseChildren([s]);r.push({type:"paragraph",content:i})}else{const i=e.parseChildren([s]);i.length>0&&r.push(...i)}}),{type:"listItem",content:r}})}var tR="listItem",$v="textStyle",Fv=/^(\d+)\.\s$/,Kk=vn.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",wt(this.options.HTMLAttributes,n),0]:["ol",wt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.items?eR(t.items,e):[];return n!==1?{type:"orderedList",attrs:{start:n},content:r}:{type:"orderedList",content:r}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
171
+ `):"",markdownTokenizer:{name:"orderedList",level:"block",start:t=>{const e=t.match(/^(\s*)(\d+)\.\s+/),n=e==null?void 0:e.index;return n!==void 0?n:-1},tokenize:(t,e,n)=>{var r;const s=t.split(`
172
+ `),[i,l]=ZO(s);if(i.length===0)return;const c=Vk(i,0,n);return c.length===0?void 0:{type:"list",ordered:!0,start:((r=i[0])==null?void 0:r.number)||1,items:c,raw:s.slice(0,l).join(`
173
+ `)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(tR,this.editor.getAttributes($v)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=To({find:Fv,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=To({find:Fv,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes($v)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),nR=/^\s*(\[([( |x])?\])\s$/,Gk=vn.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",wt(this.options.HTMLAttributes,e,{"data-type":this.name}),["label",["input",{type:"checkbox",checked:t.attrs.checked?"checked":null}],["span"]],["div",0]]},parseMarkdown:(t,e)=>{const n=[];if(t.tokens&&t.tokens.length>0?n.push(e.createNode("paragraph",{},e.parseInline(t.tokens))):t.text?n.push(e.createNode("paragraph",{},[e.createNode("text",{text:t.text})])):n.push(e.createNode("paragraph",{},[])),t.nestedTokens&&t.nestedTokens.length>0){const r=e.parseChildren(t.nestedTokens);n.push(...r)}return e.createNode("taskItem",{checked:t.checked||!1},n)},renderMarkdown:(t,e)=>{var n;const s=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return Jp(t,e,s)},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"),i=document.createElement("label"),l=document.createElement("span"),c=document.createElement("input"),u=document.createElement("div"),f=m=>{var y,b;c.ariaLabel=((b=(y=this.options.a11y)==null?void 0:y.checkboxLabel)==null?void 0:b.call(y,m,c.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),i.contentEditable="false",c.type="checkbox",c.addEventListener("mousedown",m=>m.preventDefault()),c.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){c.checked=!c.checked;return}const{checked:y}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const v=n();if(typeof v!="number")return!1;const w=b.doc.nodeAt(v);return b.setNodeMarkup(v,void 0,{...w==null?void 0:w.attrs,checked:y}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,y)||(c.checked=!c.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,y])=>{s.setAttribute(m,y)}),s.dataset.checked=t.attrs.checked,c.checked=t.attrs.checked,i.append(c,l),s.append(i,u),Object.entries(e).forEach(([m,y])=>{s.setAttribute(m,y)});let p=new Set(Object.keys(e));return{dom:s,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;s.dataset.checked=m.attrs.checked,c.checked=m.attrs.checked,f(m);const y=r.extensionManager.attributes,b=Ul(m,y),v=new Set(Object.keys(b)),w=this.options.HTMLAttributes;return p.forEach(k=>{v.has(k)||(k in w?s.setAttribute(k,w[k]):s.removeAttribute(k))}),Object.entries(b).forEach(([k,N])=>{N==null?k in w?s.setAttribute(k,w[k]):s.removeAttribute(k):s.setAttribute(k,N)}),p=v,!0}}}},addInputRules(){return[To({find:nR,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),qk=vn.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",wt(this.options.HTMLAttributes,t,{"data-type":this.name}),0]},parseMarkdown:(t,e)=>e.createNode("taskList",{},e.parseChildren(t.items||[])),renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
174
+ `):"",markdownTokenizer:{name:"taskList",level:"block",start(t){var e;const n=(e=t.match(/^\s*[-+*]\s+\[([ xX])\]\s+/))==null?void 0:e.index;return n!==void 0?n:-1},tokenize(t,e,n){const r=i=>{const l=Qh(i,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:c=>({indentLevel:c[1].length,mainContent:c[4],checked:c[3].toLowerCase()==="x"}),createToken:(c,u)=>({type:"taskItem",raw:"",mainContent:c.mainContent,indentLevel:c.indentLevel,checked:c.checked,text:c.mainContent,tokens:n.inlineTokens(c.mainContent),nestedTokens:u}),customNestedParser:r},n);return l?[{type:"taskList",raw:l.raw,items:l.items}]:n.blockTokens(i)},s=Qh(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:i=>({indentLevel:i[1].length,mainContent:i[4],checked:i[3].toLowerCase()==="x"}),createToken:(i,l)=>({type:"taskItem",raw:"",mainContent:i.mainContent,indentLevel:i.indentLevel,checked:i.checked,text:i.mainContent,tokens:n.inlineTokens(i.mainContent),nestedTokens:l}),customNestedParser:r},n);if(s)return{type:"taskList",raw:s.raw,items:s.items}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleTaskList:()=>({commands:t})=>t.toggleList(this.name,this.options.itemTypeName)}},addKeyboardShortcuts(){return{"Mod-Shift-9":()=>this.editor.commands.toggleTaskList()}}});gt.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(Pk.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(Bk.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Wk.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Kk.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(Gk.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(qk.configure(this.options.taskList)),t}});var rR=Gk,sR=qk,iR=20,Jk=(t,e=0)=>{const n=[];return!t.children.length||e>iR||Array.from(t.children).forEach(r=>{r.tagName==="SPAN"?n.push(r):r.children.length&&n.push(...Jk(r,e+1))}),n},oR=t=>{if(!t.children.length)return;const e=Jk(t);e&&e.forEach(n=>{var r,s;const i=n.getAttribute("style"),l=(s=(r=n.parentElement)==null?void 0:r.closest("span"))==null?void 0:s.getAttribute("style");n.setAttribute("style",`${l};${i}`)})},Yk=Ar.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!0}},parseHTML(){return[{tag:"span",consuming:!1,getAttrs:t=>t.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&oR(t),{}):!1}]},renderHTML({HTMLAttributes:t}){return["span",wt(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(i=>!!i))||t.removeMark(r,r+n.nodeSize,this.type)}),!0}}}}),lR=gt.create({name:"backgroundColor",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const l=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(l==="background-color")return c.replace(/['"]+/g,"")}}}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()}}}),aR=gt.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:t=>{var e;const n=t.getAttribute("style");if(n){const r=n.split(";").map(s=>s.trim()).filter(Boolean);for(let s=r.length-1;s>=0;s-=1){const i=r[s].split(":");if(i.length>=2){const l=i[0].trim().toLowerCase(),c=i.slice(1).join(":").trim();if(l==="color")return c.replace(/['"]+/g,"")}}}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()}}}),cR=gt.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()}}}),uR=gt.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()}}}),dR=gt.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()}}});gt.create({name:"textStyleKit",addExtensions(){const t=[];return this.options.backgroundColor!==!1&&t.push(lR.configure(this.options.backgroundColor)),this.options.color!==!1&&t.push(aR.configure(this.options.color)),this.options.fontFamily!==!1&&t.push(cR.configure(this.options.fontFamily)),this.options.fontSize!==!1&&t.push(uR.configure(this.options.fontSize)),this.options.lineHeight!==!1&&t.push(dR.configure(this.options.lineHeight)),this.options.textStyle!==!1&&t.push(Yk.configure(this.options.textStyle)),t}});var fR=t=>Xt({find:/--$/,replace:t??"—"}),hR=t=>Xt({find:/\.\.\.$/,replace:t??"…"}),pR=t=>Xt({find:/(?:^|[\s{[(<'"\u2018\u201C])(")$/,replace:t??"“"}),mR=t=>Xt({find:/"$/,replace:t??"”"}),gR=t=>Xt({find:/(?:^|[\s{[(<'"\u2018\u201C])(')$/,replace:t??"‘"}),yR=t=>Xt({find:/'$/,replace:t??"’"}),bR=t=>Xt({find:/<-$/,replace:t??"←"}),vR=t=>Xt({find:/->$/,replace:t??"→"}),xR=t=>Xt({find:/\(c\)$/,replace:t??"©"}),wR=t=>Xt({find:/\(tm\)$/,replace:t??"™"}),kR=t=>Xt({find:/\(sm\)$/,replace:t??"℠"}),SR=t=>Xt({find:/\(r\)$/,replace:t??"®"}),ER=t=>Xt({find:/(?:^|\s)(1\/2)\s$/,replace:t??"½"}),NR=t=>Xt({find:/\+\/-$/,replace:t??"±"}),CR=t=>Xt({find:/!=$/,replace:t??"≠"}),_R=t=>Xt({find:/<<$/,replace:t??"«"}),TR=t=>Xt({find:/>>$/,replace:t??"»"}),MR=t=>Xt({find:/\d+\s?([*x])\s?\d+$/,replace:t??"×"}),AR=t=>Xt({find:/\^2$/,replace:t??"²"}),OR=t=>Xt({find:/\^3$/,replace:t??"³"}),RR=t=>Xt({find:/(?:^|\s)(1\/4)\s$/,replace:t??"¼"}),IR=t=>Xt({find:/(?:^|\s)(3\/4)\s$/,replace:t??"¾"}),jR=gt.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(fR(this.options.emDash)),this.options.ellipsis!==!1&&t.push(hR(this.options.ellipsis)),this.options.openDoubleQuote!==!1&&t.push(pR(this.options.openDoubleQuote)),this.options.closeDoubleQuote!==!1&&t.push(mR(this.options.closeDoubleQuote)),this.options.openSingleQuote!==!1&&t.push(gR(this.options.openSingleQuote)),this.options.closeSingleQuote!==!1&&t.push(yR(this.options.closeSingleQuote)),this.options.leftArrow!==!1&&t.push(bR(this.options.leftArrow)),this.options.rightArrow!==!1&&t.push(vR(this.options.rightArrow)),this.options.copyright!==!1&&t.push(xR(this.options.copyright)),this.options.trademark!==!1&&t.push(wR(this.options.trademark)),this.options.servicemark!==!1&&t.push(kR(this.options.servicemark)),this.options.registeredTrademark!==!1&&t.push(SR(this.options.registeredTrademark)),this.options.oneHalf!==!1&&t.push(ER(this.options.oneHalf)),this.options.plusMinus!==!1&&t.push(NR(this.options.plusMinus)),this.options.notEqual!==!1&&t.push(CR(this.options.notEqual)),this.options.laquo!==!1&&t.push(_R(this.options.laquo)),this.options.raquo!==!1&&t.push(TR(this.options.raquo)),this.options.multiplication!==!1&&t.push(MR(this.options.multiplication)),this.options.superscriptTwo!==!1&&t.push(AR(this.options.superscriptTwo)),this.options.superscriptThree!==!1&&t.push(OR(this.options.superscriptThree)),this.options.oneQuarter!==!1&&t.push(RR(this.options.oneQuarter)),this.options.threeQuarters!==!1&&t.push(IR(this.options.threeQuarters)),t}}),LR=jR,Qk=Ar.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",wt(this.options.HTMLAttributes,t),0]},parseMarkdown(t,e){return e.applyMark(this.name||"underline",e.parseInline(t.tokens||[]))},renderMarkdown(t,e){return`++${e.renderChildren(t)}++`},markdownTokenizer:{name:"underline",level:"inline",start(t){return t.indexOf("++")},tokenize(t,e,n){const s=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!s)return;const i=s[2].trim();return{type:"underline",raw:s[0],text:i,tokens:n.inlineTokens(i)}}},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()}}}),DR=Qk,Sn=[];for(var wh=0;wh<256;++wh)Sn.push((wh+256).toString(16).slice(1));function PR(t,e=0){return(Sn[t[e+0]]+Sn[t[e+1]]+Sn[t[e+2]]+Sn[t[e+3]]+"-"+Sn[t[e+4]]+Sn[t[e+5]]+"-"+Sn[t[e+6]]+Sn[t[e+7]]+"-"+Sn[t[e+8]]+Sn[t[e+9]]+"-"+Sn[t[e+10]]+Sn[t[e+11]]+Sn[t[e+12]]+Sn[t[e+13]]+Sn[t[e+14]]+Sn[t[e+15]]).toLowerCase()}var Sc,BR=new Uint8Array(16);function zR(){if(!Sc&&(Sc=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Sc))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Sc(BR)}var $R=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto);const Uv={randomUUID:$R};function FR(t,e,n){if(Uv.randomUUID&&!t)return Uv.randomUUID();t=t||{};var r=t.random||(t.rng||zR)();return r[6]=r[6]&15|64,r[8]=r[8]&63|128,PR(r)}function UR(t){const e=new Set,n=new Set;return t.forEach(r=>{e.has(r)?n.add(r):e.add(r)}),Array.from(n)}var HR=gt.create({name:"uniqueID",priority:1e4,addOptions(){return{attributeName:"id",types:[],generateID:()=>FR(),filterTransaction:null,updateDocument:!0}},addGlobalAttributes(){return[{types:this.options.types,attributes:{[this.options.attributeName]:{default:null,parseHTML:t=>t.getAttribute(`data-${this.options.attributeName}`),renderHTML:t=>t[this.options.attributeName]?{[`data-${this.options.attributeName}`]:t[this.options.attributeName]}:{}}}}]},onCreate(){var t;if(!this.options.updateDocument)return;const e=this.editor.extensionManager.extensions.find(c=>c.name==="collaboration"),n=this.editor.extensionManager.extensions.find(c=>c.name==="collaborationCaret"),s=[e,n].filter(Boolean).find(c=>{var u;return(u=c==null?void 0:c.options)==null?void 0:u.provider}),i=(t=s==null?void 0:s.options)==null?void 0:t.provider,l=()=>{const{view:c,state:u}=this.editor,{tr:f,doc:p}=u,{types:m,attributeName:y,generateID:b}=this.options;tu(p,w=>m.includes(w.type.name)&&w.attrs[y]===null).forEach(({node:w,pos:k})=>{f.setNodeMarkup(k,void 0,{...w.attrs,[y]:b({node:w,pos:k})})}),f.setMeta("addToHistory",!1),c.dispatch(f),i&&i.off("synced",l)};if(s){if(!i)return l();i.on("synced",l)}else return l()},addProseMirrorPlugins(){if(!this.options.updateDocument)return[];let t=null,e=!1;return[new kt({key:new Ot("uniqueID"),appendTransaction:(n,r,s)=>{const i=n.some(w=>w.docChanged)&&!r.doc.eq(s.doc),l=this.options.filterTransaction&&n.some(w=>{var k,N;return!((N=(k=this.options).filterTransaction)!=null&&N.call(k,w))});if(n.find(w=>w.getMeta("y-sync$"))||!i||l)return;const{tr:u}=s,{types:f,attributeName:p,generateID:m}=this.options,y=Fp(r.doc,n),{mapping:b}=y;if(Wp(y).forEach(({newRange:w})=>{const k=Aw(s.doc,w,T=>f.includes(T.type.name)),N=k.map(({node:T})=>T.attrs[p]).filter(T=>T!==null);k.forEach(({node:T,pos:I},_)=>{var M;const O=(M=u.doc.nodeAt(I))==null?void 0:M.attrs[p];if(O===null){u.setNodeMarkup(I,void 0,{...T.attrs,[p]:m({node:T,pos:I})});return}const P=k[_+1];if(P&&T.content.size===0){const J=u.doc.nodeAt(P.pos);if(J!=null&&J.attrs[p]&&J.attrs[p]!==O)return;u.setNodeMarkup(P.pos,void 0,{...P.node.attrs,[p]:O}),N[_+1]=O;const F=m({node:T,pos:I});return u.setNodeMarkup(I,void 0,{...T.attrs,[p]:F}),N[_]=F,u}const $=UR(N),{deleted:B}=b.invert().mapResult(I);B&&$.includes(O)&&u.setNodeMarkup(I,void 0,{...T.attrs,[p]:m({node:T,pos:I})})})}),!!u.steps.length)return u.setStoredMarks(s.tr.storedMarks),u.setMeta("__uniqueIDTransaction",!0),u},view(n){const r=s=>{var i;t=(i=n.dom.parentElement)!=null&&i.contains(s.target)?n.dom.parentElement:null};return window.addEventListener("dragstart",r),{destroy(){window.removeEventListener("dragstart",r)}}},props:{handleDOMEvents:{drop:(n,r)=>{var s,i;return(t!==n.dom.parentElement||((s=r.dataTransfer)==null?void 0:s.effectAllowed)==="copyMove"||((i=r.dataTransfer)==null?void 0:i.effectAllowed)==="copy")&&(t=null,e=!0),!1},paste:()=>(e=!0,!1)},transformPasted:n=>{if(!e)return n;const{types:r,attributeName:s}=this.options,i=l=>{const c=[];return l.forEach(u=>{if(u.isText){c.push(u);return}if(!r.includes(u.type.name)){c.push(u.copy(i(u.content)));return}const f=u.type.create({...u.attrs,[s]:null},i(u.content),u.marks);c.push(f)}),ae.from(c)};return e=!1,new Se(i(n.content),n.openStart,n.openEnd)}}})]}}),dm=HR,Ru=(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]},WR=/^\s*>\s$/,VR=vn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Ru("blockquote",{...wt(this.options.HTMLAttributes,t),children:Ru("slot",{})})},parseMarkdown:(t,e)=>e.createNode("blockquote",void 0,e.parseChildren(t.tokens||[])),renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach(s=>{const c=e.renderChildren([s]).split(`
175
+ `).map(u=>u.trim()===""?n:`${n} ${u}`);r.push(c.join(`
176
+ `))}),r.join(`
177
+ ${n}
178
+ `)},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[To({find:WR,type:this.type})]}}),KR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,GR=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,qR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,JR=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,YR=Ar.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 Ru("strong",{...wt(this.options.HTMLAttributes,t),children:Ru("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`**${e.renderChildren(t)}**`,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[ji({find:KR,type:this.type}),ji({find:qR,type:this.type})]},addPasteRules(){return[Qs({find:GR,type:this.type}),Qs({find:JR,type:this.type})]}}),QR=/(^|[^`])`([^`]+)`(?!`)$/,XR=/(^|[^`])`([^`]+)`(?!`)/g,ZR=Ar.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",wt(this.options.HTMLAttributes,t),0]},markdownTokenName:"codespan",parseMarkdown:(t,e)=>e.applyMark("code",[{type:"text",text:t.text||""}]),renderMarkdown:(t,e)=>t.content?`\`${e.renderChildren(t.content)}\``:"",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[ji({find:QR,type:this.type})]},addPasteRules(){return[Qs({find:XR,type:this.type})]}}),kh=4,eI=/^```([a-z]+)?[\s\n]$/,tI=/^~~~([a-z]+)?[\s\n]$/,Xk=vn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:kh,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;if(!n)return null;const i=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(l=>l.startsWith(n)).map(l=>l.replace(n,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",wt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&t.codeBlockStyle!=="indented"?[]:e.createNode("codeBlock",{language:t.lang||null},t.text?[e.createTextNode(t.text)]:[])},renderMarkdown:(t,e)=>{var n;let r="";const s=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${s}`,e.renderChildren(t.content),"```"].join(`
179
+ `):r=`\`\`\`${s}
180
+
181
+ \`\`\``,r},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},Tab:({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:kh,{state:r}=t,{selection:s}=r,{$from:i,empty:l}=s;if(i.parent.type!==this.type)return!1;const c=" ".repeat(n);return l?t.commands.insertContent(c):t.commands.command(({tr:u})=>{const{from:f,to:p}=s,b=r.doc.textBetween(f,p,`
182
+ `,`
183
+ `).split(`
184
+ `).map(v=>c+v).join(`
185
+ `);return u.replaceWith(f,p,r.schema.text(b)),!0})},"Shift-Tab":({editor:t})=>{var e;if(!this.options.enableTabIndentation)return!1;const n=(e=this.options.tabSize)!=null?e:kh,{state:r}=t,{selection:s}=r,{$from:i,empty:l}=s;return i.parent.type!==this.type?!1:l?t.commands.command(({tr:c})=>{var u;const{pos:f}=i,p=i.start(),m=i.end(),b=r.doc.textBetween(p,m,`
186
+ `,`
187
+ `).split(`
188
+ `);let v=0,w=0;const k=f-p;for(let O=0;O<b.length;O+=1){if(w+b[O].length>=k){v=O;break}w+=b[O].length+1}const T=((u=b[v].match(/^ */))==null?void 0:u[0])||"",I=Math.min(T.length,n);if(I===0)return!0;let _=p;for(let O=0;O<v;O+=1)_+=b[O].length+1;return c.delete(_,_+I),f-_<=I&&c.setSelection(Fe.create(c.doc,_)),!0}):t.commands.command(({tr:c})=>{const{from:u,to:f}=s,y=r.doc.textBetween(u,f,`
189
+ `,`
190
+ `).split(`
191
+ `).map(b=>{var v;const w=((v=b.match(/^ */))==null?void 0:v[0])||"",k=Math.min(w.length,n);return b.slice(k)}).join(`
192
+ `);return c.replaceWith(u,f,r.schema.text(y)),!0})},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 i=r.parentOffset===r.parent.nodeSize-2,l=r.parent.textContent.endsWith(`
193
+
194
+ `);return!i||!l?!1:t.chain().command(({tr:c})=>(c.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:i}=n;if(!i||s.parent.type!==this.type||!(s.parentOffset===s.parent.nodeSize-2))return!1;const c=s.after();return c===void 0?!1:r.nodeAt(c)?t.commands.command(({tr:f})=>(f.setSelection(Ye.near(r.resolve(c))),!0)):t.commands.exitCode()}}},addInputRules(){return[Yh({find:eI,type:this.type,getAttributes:t=>({language:t[1]})}),Yh({find:tI,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new kt({key:new Ot("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,i=s==null?void 0:s.mode;if(!n||!i)return!1;const{tr:l,schema:c}=t.state,u=c.text(n.replace(/\r\n?/g,`
195
+ `));return l.replaceSelectionWith(this.type.create({language:i},u)),l.selection.$from.parent.type!==this.type&&l.setSelection(Fe.near(l.doc.resolve(Math.max(0,l.selection.from-2)))),l.setMeta("paste",!0),t.dispatch(l),!0}}})]}}),nI=Xk,rI=vn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
196
+
197
+ `):""}),sI=vn.create({name:"hardBreak",markdownTokenName:"br",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",wt(this.options.HTMLAttributes,t)]},renderText(){return`
198
+ `},renderMarkdown:()=>`
199
+ `,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:s,storedMarks:i}=n;if(s.$from.parent.type.spec.isolating)return!1;const{keepMarks:l}=this.options,{splittableMarks:c}=r.extensionManager,u=i||s.$to.parentOffset&&s.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:p})=>{if(p&&u&&l){const m=u.filter(y=>c.includes(y.type.name));f.ensureMarks(m)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),iI=vn.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]}`,wt(this.options.HTMLAttributes,e),0]},parseMarkdown:(t,e)=>e.createNode("heading",{level:t.depth||1},e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>{var n;const r=(n=t.attrs)!=null&&n.level?parseInt(t.attrs.level,10):1,s="#".repeat(r);return t.content?`${s} ${e.renderChildren(t.content)}`:""},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=>Yh({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),oI=vn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",wt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!CM(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,s=t();return Bw(n)?s.insertContentAt(r.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({state:i,tr:l,dispatch:c})=>{if(c){const{$to:u}=l.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?l.setSelection(Fe.create(l.doc,u.pos+1)):u.nodeAfter.isBlock?l.setSelection(ze.create(l.doc,u.pos)):l.setSelection(Fe.create(l.doc,u.pos));else{const p=i.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=p==null?void 0:p.create();m&&(l.insert(f,m),l.setSelection(Fe.create(l.doc,f+1)))}l.scrollIntoView()}return!0}).run()}}},addInputRules(){return[tk({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),lI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,aI=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,cI=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,uI=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,dI=Ar.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",wt(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)}},markdownTokenName:"em",parseMarkdown:(t,e)=>e.applyMark("italic",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ji({find:lI,type:this.type}),ji({find:cI,type:this.type})]},addPasteRules(){return[Qs({find:aI,type:this.type}),Qs({find:uI,type:this.type})]}}),Hv="&nbsp;",fI=" ",hI=vn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",wt(this.options.HTMLAttributes,t),0]},parseMarkdown:(t,e)=>{const n=t.tokens||[];if(n.length===1&&n[0].type==="image")return e.parseChildren([n[0]]);const r=e.parseInline(n);return r.length===1&&r[0].type==="text"&&(r[0].text===Hv||r[0].text===fI)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e)=>{if(!t)return"";const n=Array.isArray(t.content)?t.content:[];return n.length===0?Hv:e.renderChildren(n)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),pI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,mI=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,gI=Ar.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",wt(this.options.HTMLAttributes,t),0]},markdownTokenName:"del",parseMarkdown:(t,e)=>e.applyMark("strike",e.parseInline(t.tokens||[])),renderMarkdown:(t,e)=>`~~${e.renderChildren(t)}~~`,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[ji({find:pI,type:this.type})]},addPasteRules(){return[Qs({find:mI,type:this.type})]}}),yI=vn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),bI=gt.create({name:"starterKit",addExtensions(){var t,e,n,r;const s=[];return this.options.bold!==!1&&s.push(YR.configure(this.options.bold)),this.options.blockquote!==!1&&s.push(VR.configure(this.options.blockquote)),this.options.bulletList!==!1&&s.push(Pk.configure(this.options.bulletList)),this.options.code!==!1&&s.push(ZR.configure(this.options.code)),this.options.codeBlock!==!1&&s.push(Xk.configure(this.options.codeBlock)),this.options.document!==!1&&s.push(rI.configure(this.options.document)),this.options.dropcursor!==!1&&s.push(O2.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&s.push(R2.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&s.push(sI.configure(this.options.hardBreak)),this.options.heading!==!1&&s.push(iI.configure(this.options.heading)),this.options.undoRedo!==!1&&s.push(D2.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&s.push(oI.configure(this.options.horizontalRule)),this.options.italic!==!1&&s.push(dI.configure(this.options.italic)),this.options.listItem!==!1&&s.push(Bk.configure(this.options.listItem)),this.options.listKeymap!==!1&&s.push(Wk.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&s.push(bk.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&s.push(Kk.configure(this.options.orderedList)),this.options.paragraph!==!1&&s.push(hI.configure(this.options.paragraph)),this.options.strike!==!1&&s.push(gI.configure(this.options.strike)),this.options.text!==!1&&s.push(yI.configure(this.options.text)),this.options.underline!==!1&&s.push(Qk.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&s.push(L2.configure((r=this.options)==null?void 0:r.trailingNode)),s}}),fm=bI,Sh,Wv;function vI(){if(Wv)return Sh;Wv=1;function t(L){return L instanceof Map?L.clear=L.delete=L.set=function(){throw new Error("map is read-only")}:L instanceof Set&&(L.add=L.clear=L.delete=function(){throw new Error("set is read-only")}),Object.freeze(L),Object.getOwnPropertyNames(L).forEach(oe=>{const xe=L[oe],Je=typeof xe;(Je==="object"||Je==="function")&&!Object.isFrozen(xe)&&t(xe)}),L}class e{constructor(oe){oe.data===void 0&&(oe.data={}),this.data=oe.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}}function n(L){return L.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function r(L,...oe){const xe=Object.create(null);for(const Je in L)xe[Je]=L[Je];return oe.forEach(function(Je){for(const Et in Je)xe[Et]=Je[Et]}),xe}const s="</span>",i=L=>!!L.scope,l=(L,{prefix:oe})=>{if(L.startsWith("language:"))return L.replace("language:","language-");if(L.includes(".")){const xe=L.split(".");return[`${oe}${xe.shift()}`,...xe.map((Je,Et)=>`${Je}${"_".repeat(Et+1)}`)].join(" ")}return`${oe}${L}`};class c{constructor(oe,xe){this.buffer="",this.classPrefix=xe.classPrefix,oe.walk(this)}addText(oe){this.buffer+=n(oe)}openNode(oe){if(!i(oe))return;const xe=l(oe.scope,{prefix:this.classPrefix});this.span(xe)}closeNode(oe){i(oe)&&(this.buffer+=s)}value(){return this.buffer}span(oe){this.buffer+=`<span class="${oe}">`}}const u=(L={})=>{const oe={children:[]};return Object.assign(oe,L),oe};class f{constructor(){this.rootNode=u(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(oe){this.top.children.push(oe)}openNode(oe){const xe=u({scope:oe});this.add(xe),this.stack.push(xe)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(oe){return this.constructor._walk(oe,this.rootNode)}static _walk(oe,xe){return typeof xe=="string"?oe.addText(xe):xe.children&&(oe.openNode(xe),xe.children.forEach(Je=>this._walk(oe,Je)),oe.closeNode(xe)),oe}static _collapse(oe){typeof oe!="string"&&oe.children&&(oe.children.every(xe=>typeof xe=="string")?oe.children=[oe.children.join("")]:oe.children.forEach(xe=>{f._collapse(xe)}))}}class p extends f{constructor(oe){super(),this.options=oe}addText(oe){oe!==""&&this.add(oe)}startScope(oe){this.openNode(oe)}endScope(){this.closeNode()}__addSublanguage(oe,xe){const Je=oe.root;xe&&(Je.scope=`language:${xe}`),this.add(Je)}toHTML(){return new c(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function m(L){return L?typeof L=="string"?L:L.source:null}function y(L){return w("(?=",L,")")}function b(L){return w("(?:",L,")*")}function v(L){return w("(?:",L,")?")}function w(...L){return L.map(xe=>m(xe)).join("")}function k(L){const oe=L[L.length-1];return typeof oe=="object"&&oe.constructor===Object?(L.splice(L.length-1,1),oe):{}}function N(...L){return"("+(k(L).capture?"":"?:")+L.map(Je=>m(Je)).join("|")+")"}function T(L){return new RegExp(L.toString()+"|").exec("").length-1}function I(L,oe){const xe=L&&L.exec(oe);return xe&&xe.index===0}const _=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function M(L,{joinWith:oe}){let xe=0;return L.map(Je=>{xe+=1;const Et=xe;let Mt=m(Je),Me="";for(;Mt.length>0;){const _e=_.exec(Mt);if(!_e){Me+=Mt;break}Me+=Mt.substring(0,_e.index),Mt=Mt.substring(_e.index+_e[0].length),_e[0][0]==="\\"&&_e[1]?Me+="\\"+String(Number(_e[1])+Et):(Me+=_e[0],_e[0]==="("&&xe++)}return Me}).map(Je=>`(${Je})`).join(oe)}const O=/\b\B/,P="[a-zA-Z]\\w*",$="[a-zA-Z_]\\w*",B="\\b\\d+(\\.\\d+)?",W="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",J="\\b(0b[01]+)",F="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",re=(L={})=>{const oe=/^#![ ]*\//;return L.binary&&(L.begin=w(oe,/.*\b/,L.binary,/\b.*/)),r({scope:"meta",begin:oe,end:/$/,relevance:0,"on:begin":(xe,Je)=>{xe.index!==0&&Je.ignoreMatch()}},L)},G={begin:"\\\\[\\s\\S]",relevance:0},te={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[G]},U={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[G]},ne={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/},H=function(L,oe,xe={}){const Je=r({scope:"comment",begin:L,end:oe,contains:[]},xe);Je.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 Et=N("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 Je.contains.push({begin:w(/[ ]+/,"(",Et,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),Je},X=H("//","$"),K=H("/\\*","\\*/"),A=H("#","$"),R={scope:"number",begin:B,relevance:0},Y={scope:"number",begin:W,relevance:0},se={scope:"number",begin:J,relevance:0},fe={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[G,{begin:/\[/,end:/\]/,relevance:0,contains:[G]}]},Z={scope:"title",begin:P,relevance:0},me={scope:"title",begin:$,relevance:0},Le={begin:"\\.\\s*"+$,relevance:0};var ce=Object.freeze({__proto__:null,APOS_STRING_MODE:te,BACKSLASH_ESCAPE:G,BINARY_NUMBER_MODE:se,BINARY_NUMBER_RE:J,COMMENT:H,C_BLOCK_COMMENT_MODE:K,C_LINE_COMMENT_MODE:X,C_NUMBER_MODE:Y,C_NUMBER_RE:W,END_SAME_AS_BEGIN:function(L){return Object.assign(L,{"on:begin":(oe,xe)=>{xe.data._beginMatch=oe[1]},"on:end":(oe,xe)=>{xe.data._beginMatch!==oe[1]&&xe.ignoreMatch()}})},HASH_COMMENT_MODE:A,IDENT_RE:P,MATCH_NOTHING_RE:O,METHOD_GUARD:Le,NUMBER_MODE:R,NUMBER_RE:B,PHRASAL_WORDS_MODE:ne,QUOTE_STRING_MODE:U,REGEXP_MODE:fe,RE_STARTERS_RE:F,SHEBANG:re,TITLE_MODE:Z,UNDERSCORE_IDENT_RE:$,UNDERSCORE_TITLE_MODE:me});function ve(L,oe){L.input[L.index-1]==="."&&oe.ignoreMatch()}function ie(L,oe){L.className!==void 0&&(L.scope=L.className,delete L.className)}function Be(L,oe){oe&&L.beginKeywords&&(L.begin="\\b("+L.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",L.__beforeBegin=ve,L.keywords=L.keywords||L.beginKeywords,delete L.beginKeywords,L.relevance===void 0&&(L.relevance=0))}function Te(L,oe){Array.isArray(L.illegal)&&(L.illegal=N(...L.illegal))}function Ue(L,oe){if(L.match){if(L.begin||L.end)throw new Error("begin & end are not supported with match");L.begin=L.match,delete L.match}}function Ee(L,oe){L.relevance===void 0&&(L.relevance=1)}const Qe=(L,oe)=>{if(!L.beforeMatch)return;if(L.starts)throw new Error("beforeMatch cannot be used with starts");const xe=Object.assign({},L);Object.keys(L).forEach(Je=>{delete L[Je]}),L.keywords=xe.keywords,L.begin=w(xe.beforeMatch,y(xe.begin)),L.starts={relevance:0,contains:[Object.assign(xe,{endsParent:!0})]},L.relevance=0,delete xe.beforeMatch},tt=["of","and","for","in","not","or","if","then","parent","list","value"],vt="keyword";function Ce(L,oe,xe=vt){const Je=Object.create(null);return typeof L=="string"?Et(xe,L.split(" ")):Array.isArray(L)?Et(xe,L):Object.keys(L).forEach(function(Mt){Object.assign(Je,Ce(L[Mt],oe,Mt))}),Je;function Et(Mt,Me){oe&&(Me=Me.map(_e=>_e.toLowerCase())),Me.forEach(function(_e){const Ve=_e.split("|");Je[Ve[0]]=[Mt,ke(Ve[0],Ve[1])]})}}function ke(L,oe){return oe?Number(oe):at(L)?0:1}function at(L){return tt.includes(L.toLowerCase())}const ft={},st=L=>{console.error(L)},ht=(L,...oe)=>{console.log(`WARN: ${L}`,...oe)},zt=(L,oe)=>{ft[`${L}/${oe}`]||(console.log(`Deprecated as of ${L}. ${oe}`),ft[`${L}/${oe}`]=!0)},Ct=new Error;function Vt(L,oe,{key:xe}){let Je=0;const Et=L[xe],Mt={},Me={};for(let _e=1;_e<=oe.length;_e++)Me[_e+Je]=Et[_e],Mt[_e+Je]=!0,Je+=T(oe[_e-1]);L[xe]=Me,L[xe]._emit=Mt,L[xe]._multi=!0}function xn(L){if(Array.isArray(L.begin)){if(L.skip||L.excludeBegin||L.returnBegin)throw st("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),Ct;if(typeof L.beginScope!="object"||L.beginScope===null)throw st("beginScope must be object"),Ct;Vt(L,L.begin,{key:"beginScope"}),L.begin=M(L.begin,{joinWith:""})}}function ee(L){if(Array.isArray(L.end)){if(L.skip||L.excludeEnd||L.returnEnd)throw st("skip, excludeEnd, returnEnd not compatible with endScope: {}"),Ct;if(typeof L.endScope!="object"||L.endScope===null)throw st("endScope must be object"),Ct;Vt(L,L.end,{key:"endScope"}),L.end=M(L.end,{joinWith:""})}}function He(L){L.scope&&typeof L.scope=="object"&&L.scope!==null&&(L.beginScope=L.scope,delete L.scope)}function We(L){He(L),typeof L.beginScope=="string"&&(L.beginScope={_wrap:L.beginScope}),typeof L.endScope=="string"&&(L.endScope={_wrap:L.endScope}),xn(L),ee(L)}function _t(L){function oe(Me,_e){return new RegExp(m(Me),"m"+(L.case_insensitive?"i":"")+(L.unicodeRegex?"u":"")+(_e?"g":""))}class xe{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(_e,Ve){Ve.position=this.position++,this.matchIndexes[this.matchAt]=Ve,this.regexes.push([Ve,_e]),this.matchAt+=T(_e)+1}compile(){this.regexes.length===0&&(this.exec=()=>null);const _e=this.regexes.map(Ve=>Ve[1]);this.matcherRe=oe(M(_e,{joinWith:"|"}),!0),this.lastIndex=0}exec(_e){this.matcherRe.lastIndex=this.lastIndex;const Ve=this.matcherRe.exec(_e);if(!Ve)return null;const rn=Ve.findIndex((Rr,hs)=>hs>0&&Rr!==void 0),Rt=this.matchIndexes[rn];return Ve.splice(0,rn),Object.assign(Ve,Rt)}}class Je{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(_e){if(this.multiRegexes[_e])return this.multiRegexes[_e];const Ve=new xe;return this.rules.slice(_e).forEach(([rn,Rt])=>Ve.addRule(rn,Rt)),Ve.compile(),this.multiRegexes[_e]=Ve,Ve}resumingScanAtSamePosition(){return this.regexIndex!==0}considerAll(){this.regexIndex=0}addRule(_e,Ve){this.rules.push([_e,Ve]),Ve.type==="begin"&&this.count++}exec(_e){const Ve=this.getMatcher(this.regexIndex);Ve.lastIndex=this.lastIndex;let rn=Ve.exec(_e);if(this.resumingScanAtSamePosition()&&!(rn&&rn.index===this.lastIndex)){const Rt=this.getMatcher(0);Rt.lastIndex=this.lastIndex+1,rn=Rt.exec(_e)}return rn&&(this.regexIndex+=rn.position+1,this.regexIndex===this.count&&this.considerAll()),rn}}function Et(Me){const _e=new Je;return Me.contains.forEach(Ve=>_e.addRule(Ve.begin,{rule:Ve,type:"begin"})),Me.terminatorEnd&&_e.addRule(Me.terminatorEnd,{type:"end"}),Me.illegal&&_e.addRule(Me.illegal,{type:"illegal"}),_e}function Mt(Me,_e){const Ve=Me;if(Me.isCompiled)return Ve;[ie,Ue,We,Qe].forEach(Rt=>Rt(Me,_e)),L.compilerExtensions.forEach(Rt=>Rt(Me,_e)),Me.__beforeBegin=null,[Be,Te,Ee].forEach(Rt=>Rt(Me,_e)),Me.isCompiled=!0;let rn=null;return typeof Me.keywords=="object"&&Me.keywords.$pattern&&(Me.keywords=Object.assign({},Me.keywords),rn=Me.keywords.$pattern,delete Me.keywords.$pattern),rn=rn||/\w+/,Me.keywords&&(Me.keywords=Ce(Me.keywords,L.case_insensitive)),Ve.keywordPatternRe=oe(rn,!0),_e&&(Me.begin||(Me.begin=/\B|\b/),Ve.beginRe=oe(Ve.begin),!Me.end&&!Me.endsWithParent&&(Me.end=/\B|\b/),Me.end&&(Ve.endRe=oe(Ve.end)),Ve.terminatorEnd=m(Ve.end)||"",Me.endsWithParent&&_e.terminatorEnd&&(Ve.terminatorEnd+=(Me.end?"|":"")+_e.terminatorEnd)),Me.illegal&&(Ve.illegalRe=oe(Me.illegal)),Me.contains||(Me.contains=[]),Me.contains=[].concat(...Me.contains.map(function(Rt){return it(Rt==="self"?Me:Rt)})),Me.contains.forEach(function(Rt){Mt(Rt,Ve)}),Me.starts&&Mt(Me.starts,_e),Ve.matcher=Et(Ve),Ve}if(L.compilerExtensions||(L.compilerExtensions=[]),L.contains&&L.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return L.classNameAliases=r(L.classNameAliases||{}),Mt(L)}function nt(L){return L?L.endsWithParent||nt(L.starts):!1}function it(L){return L.variants&&!L.cachedVariants&&(L.cachedVariants=L.variants.map(function(oe){return r(L,{variants:null},oe)})),L.cachedVariants?L.cachedVariants:nt(L)?r(L,{starts:L.starts?r(L.starts):null}):Object.isFrozen(L)?r(L):L}var qe="11.11.1";class Wn extends Error{constructor(oe,xe){super(oe),this.name="HTMLInjectionError",this.html=xe}}const un=n,le=r,be=Symbol("nomatch"),$e=7,Tt=function(L){const oe=Object.create(null),xe=Object.create(null),Je=[];let Et=!0;const Mt="Could not find the language '{}', did you forget to load/include a language module?",Me={disableAutodetect:!0,name:"Plain text",contains:[]};let _e={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:p};function Ve(ge){return _e.noHighlightRe.test(ge)}function rn(ge){let De=ge.className+" ";De+=ge.parentNode?ge.parentNode.className:"";const ot=_e.languageDetectRe.exec(De);if(ot){const ut=vr(ot[1]);return ut||(ht(Mt.replace("{}",ot[1])),ht("Falling back to no-highlight mode for this block.",ge)),ut?ot[1]:"no-highlight"}return De.split(/\s+/).find(ut=>Ve(ut)||vr(ut))}function Rt(ge,De,ot){let ut="",Zt="";typeof De=="object"?(ut=ge,ot=De.ignoreIllegals,Zt=De.language):(zt("10.7.0","highlight(lang, code, ...args) has been deprecated."),zt("10.7.0",`Please use highlight(code, options) instead.
200
+ https://github.com/highlightjs/highlight.js/issues/2277`),Zt=ge,ut=De),ot===void 0&&(ot=!0);const Ut={code:ut,language:Zt};ni("before:highlight",Ut);const Ir=Ut.result?Ut.result:Rr(Ut.language,Ut.code,ot);return Ir.code=Ut.code,ni("after:highlight",Ir),Ir}function Rr(ge,De,ot,ut){const Zt=Object.create(null);function Ut(we,Ae){return we.keywords[Ae]}function Ir(){if(!rt.keywords){en.addText(St);return}let we=0;rt.keywordPatternRe.lastIndex=0;let Ae=rt.keywordPatternRe.exec(St),Xe="";for(;Ae;){Xe+=St.substring(we,Ae.index);const dt=or.case_insensitive?Ae[0].toLowerCase():Ae[0],Gt=Ut(rt,dt);if(Gt){const[dn,cd]=Gt;if(en.addText(Xe),Xe="",Zt[dt]=(Zt[dt]||0)+1,Zt[dt]<=$e&&(ii+=cd),dn.startsWith("_"))Xe+=Ae[0];else{const ia=or.classNameAliases[dn]||dn;Bn(Ae[0],ia)}}else Xe+=Ae[0];we=rt.keywordPatternRe.lastIndex,Ae=rt.keywordPatternRe.exec(St)}Xe+=St.substring(we),en.addText(Xe)}function Fi(){if(St==="")return;let we=null;if(typeof rt.subLanguage=="string"){if(!oe[rt.subLanguage]){en.addText(St);return}we=Rr(rt.subLanguage,St,!0,Po[rt.subLanguage]),Po[rt.subLanguage]=we._top}else we=ti(St,rt.subLanguage.length?rt.subLanguage:null);rt.relevance>0&&(ii+=we.relevance),en.__addSublanguage(we._emitter,we.language)}function Pn(){rt.subLanguage!=null?Fi():Ir(),St=""}function Bn(we,Ae){we!==""&&(en.startScope(Ae),en.addText(we),en.endScope())}function ri(we,Ae){let Xe=1;const dt=Ae.length-1;for(;Xe<=dt;){if(!we._emit[Xe]){Xe++;continue}const Gt=or.classNameAliases[we[Xe]]||we[Xe],dn=Ae[Xe];Gt?Bn(dn,Gt):(St=dn,Ir(),St=""),Xe++}}function ps(we,Ae){return we.scope&&typeof we.scope=="string"&&en.openNode(or.classNameAliases[we.scope]||we.scope),we.beginScope&&(we.beginScope._wrap?(Bn(St,or.classNameAliases[we.beginScope._wrap]||we.beginScope._wrap),St=""):we.beginScope._multi&&(ri(we.beginScope,Ae),St="")),rt=Object.create(we,{parent:{value:rt}}),rt}function si(we,Ae,Xe){let dt=I(we.endRe,Xe);if(dt){if(we["on:end"]){const Gt=new e(we);we["on:end"](Ae,Gt),Gt.isMatchIgnored&&(dt=!1)}if(dt){for(;we.endsParent&&we.parent;)we=we.parent;return we}}if(we.endsWithParent)return si(we.parent,Ae,Xe)}function ld(we){return rt.matcher.regexIndex===0?(St+=we[0],1):(ys=!0,0)}function ad(we){const Ae=we[0],Xe=we.rule,dt=new e(Xe),Gt=[Xe.__beforeBegin,Xe["on:begin"]];for(const dn of Gt)if(dn&&(dn(we,dt),dt.isMatchIgnored))return ld(Ae);return Xe.skip?St+=Ae:(Xe.excludeBegin&&(St+=Ae),Pn(),!Xe.returnBegin&&!Xe.excludeBegin&&(St=Ae)),ps(Xe,we),Xe.returnBegin?0:Ae.length}function Lo(we){const Ae=we[0],Xe=De.substring(we.index),dt=si(rt,we,Xe);if(!dt)return be;const Gt=rt;rt.endScope&&rt.endScope._wrap?(Pn(),Bn(Ae,rt.endScope._wrap)):rt.endScope&&rt.endScope._multi?(Pn(),ri(rt.endScope,we)):Gt.skip?St+=Ae:(Gt.returnEnd||Gt.excludeEnd||(St+=Ae),Pn(),Gt.excludeEnd&&(St=Ae));do rt.scope&&en.closeNode(),!rt.skip&&!rt.subLanguage&&(ii+=rt.relevance),rt=rt.parent;while(rt!==dt.parent);return dt.starts&&ps(dt.starts,we),Gt.returnEnd?0:Ae.length}function sa(){const we=[];for(let Ae=rt;Ae!==or;Ae=Ae.parent)Ae.scope&&we.unshift(Ae.scope);we.forEach(Ae=>en.openNode(Ae))}let ms={};function gs(we,Ae){const Xe=Ae&&Ae[0];if(St+=we,Xe==null)return Pn(),0;if(ms.type==="begin"&&Ae.type==="end"&&ms.index===Ae.index&&Xe===""){if(St+=De.slice(Ae.index,Ae.index+1),!Et){const dt=new Error(`0 width match regex (${ge})`);throw dt.languageName=ge,dt.badRule=ms.rule,dt}return 1}if(ms=Ae,Ae.type==="begin")return ad(Ae);if(Ae.type==="illegal"&&!ot){const dt=new Error('Illegal lexeme "'+Xe+'" for mode "'+(rt.scope||"<unnamed>")+'"');throw dt.mode=rt,dt}else if(Ae.type==="end"){const dt=Lo(Ae);if(dt!==be)return dt}if(Ae.type==="illegal"&&Xe==="")return St+=`
201
+ `,1;if(oi>1e5&&oi>Ae.index*3)throw new Error("potential infinite loop, way more iterations than matches");return St+=Xe,Xe.length}const or=vr(ge);if(!or)throw st(Mt.replace("{}",ge)),new Error('Unknown language: "'+ge+'"');const Do=_t(or);let pt="",rt=ut||Do;const Po={},en=new _e.__emitter(_e);sa();let St="",ii=0,jr=0,oi=0,ys=!1;try{if(or.__emitTokens)or.__emitTokens(De,en);else{for(rt.matcher.considerAll();;){oi++,ys?ys=!1:rt.matcher.considerAll(),rt.matcher.lastIndex=jr;const we=rt.matcher.exec(De);if(!we)break;const Ae=De.substring(jr,we.index),Xe=gs(Ae,we);jr=we.index+Xe}gs(De.substring(jr))}return en.finalize(),pt=en.toHTML(),{language:ge,value:pt,relevance:ii,illegal:!1,_emitter:en,_top:rt}}catch(we){if(we.message&&we.message.includes("Illegal"))return{language:ge,value:un(De),illegal:!0,relevance:0,_illegalBy:{message:we.message,index:jr,context:De.slice(jr-100,jr+100),mode:we.mode,resultSoFar:pt},_emitter:en};if(Et)return{language:ge,value:un(De),illegal:!1,relevance:0,errorRaised:we,_emitter:en,_top:rt};throw we}}function hs(ge){const De={value:un(ge),illegal:!1,relevance:0,_top:Me,_emitter:new _e.__emitter(_e)};return De._emitter.addText(ge),De}function ti(ge,De){De=De||_e.languages||Object.keys(oe);const ot=hs(ge),ut=De.filter(vr).filter(ra).map(Pn=>Rr(Pn,ge,!1));ut.unshift(ot);const Zt=ut.sort((Pn,Bn)=>{if(Pn.relevance!==Bn.relevance)return Bn.relevance-Pn.relevance;if(Pn.language&&Bn.language){if(vr(Pn.language).supersetOf===Bn.language)return 1;if(vr(Bn.language).supersetOf===Pn.language)return-1}return 0}),[Ut,Ir]=Zt,Fi=Ut;return Fi.secondBest=Ir,Fi}function sd(ge,De,ot){const ut=De&&xe[De]||ot;ge.classList.add("hljs"),ge.classList.add(`language-${ut}`)}function Ro(ge){let De=null;const ot=rn(ge);if(Ve(ot))return;if(ni("before:highlightElement",{el:ge,language:ot}),ge.dataset.highlighted){console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",ge);return}if(ge.children.length>0&&(_e.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(ge)),_e.throwUnescapedHTML))throw new Wn("One of your code blocks includes unescaped HTML.",ge.innerHTML);De=ge;const ut=De.textContent,Zt=ot?Rt(ut,{language:ot,ignoreIllegals:!0}):ti(ut);ge.innerHTML=Zt.value,ge.dataset.highlighted="yes",sd(ge,ot,Zt.language),ge.result={language:Zt.language,re:Zt.relevance,relevance:Zt.relevance},Zt.secondBest&&(ge.secondBest={language:Zt.secondBest.language,relevance:Zt.secondBest.relevance}),ni("after:highlightElement",{el:ge,result:Zt,text:ut})}function id(ge){_e=le(_e,ge)}const Kr=()=>{zi(),zt("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")};function Xl(){zi(),zt("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")}let Io=!1;function zi(){function ge(){zi()}if(document.readyState==="loading"){Io||window.addEventListener("DOMContentLoaded",ge,!1),Io=!0;return}document.querySelectorAll(_e.cssSelector).forEach(Ro)}function Zl(ge,De){let ot=null;try{ot=De(L)}catch(ut){if(st("Language definition for '{}' could not be registered.".replace("{}",ge)),Et)st(ut);else throw ut;ot=Me}ot.name||(ot.name=ge),oe[ge]=ot,ot.rawDefinition=De.bind(null,L),ot.aliases&&na(ot.aliases,{languageName:ge})}function ea(ge){delete oe[ge];for(const De of Object.keys(xe))xe[De]===ge&&delete xe[De]}function ta(){return Object.keys(oe)}function vr(ge){return ge=(ge||"").toLowerCase(),oe[ge]||oe[xe[ge]]}function na(ge,{languageName:De}){typeof ge=="string"&&(ge=[ge]),ge.forEach(ot=>{xe[ot.toLowerCase()]=De})}function ra(ge){const De=vr(ge);return De&&!De.disableAutodetect}function Ft(ge){ge["before:highlightBlock"]&&!ge["before:highlightElement"]&&(ge["before:highlightElement"]=De=>{ge["before:highlightBlock"](Object.assign({block:De.el},De))}),ge["after:highlightBlock"]&&!ge["after:highlightElement"]&&(ge["after:highlightElement"]=De=>{ge["after:highlightBlock"](Object.assign({block:De.el},De))})}function od(ge){Ft(ge),Je.push(ge)}function jo(ge){const De=Je.indexOf(ge);De!==-1&&Je.splice(De,1)}function ni(ge,De){const ot=ge;Je.forEach(function(ut){ut[ot]&&ut[ot](De)})}function $i(ge){return zt("10.7.0","highlightBlock will be removed entirely in v12.0"),zt("10.7.0","Please use highlightElement now."),Ro(ge)}Object.assign(L,{highlight:Rt,highlightAuto:ti,highlightAll:zi,highlightElement:Ro,highlightBlock:$i,configure:id,initHighlighting:Kr,initHighlightingOnLoad:Xl,registerLanguage:Zl,unregisterLanguage:ea,listLanguages:ta,getLanguage:vr,registerAliases:na,autoDetection:ra,inherit:le,addPlugin:od,removePlugin:jo}),L.debugMode=function(){Et=!1},L.safeMode=function(){Et=!0},L.versionString=qe,L.regex={concat:w,lookahead:y,either:N,optional:v,anyNumberOfTimes:b};for(const ge in ce)typeof ce[ge]=="object"&&t(ce[ge]);return Object.assign(L,ce),L},Kt=Tt({});return Kt.newInstance=()=>Tt({}),Sh=Kt,Kt.HighlightJS=Kt,Kt.default=Kt,Sh}var xI=vI();const Zk=Bu(xI);function e1(t,e=[]){return t.flatMap(n=>{const r=[...e,...n.properties?n.properties.className:[]];return n.children?e1(n.children,r):{text:n.value,classes:r}})}function Vv(t){return t.value||t.children||[]}function wI(t){return!!Zk.getLanguage(t)}function Kv({doc:t,name:e,lowlight:n,defaultLanguage:r}){const s=[];return tu(t,i=>i.type.name===e).forEach(i=>{var l;let c=i.pos+1;const u=i.node.attrs.language||r,f=n.listLanguages(),p=u&&(f.includes(u)||wI(u)||(l=n.registered)!=null&&l.call(n,u))?Vv(n.highlight(u,i.node.textContent)):Vv(n.highlightAuto(i.node.textContent));e1(p).forEach(m=>{const y=c+m.text.length;if(m.classes.length){const b=jt.inline(c,y,{class:m.classes.join(" ")});s.push(b)}c=y})}),bt.create(t,s)}function kI(t){return typeof t=="function"}function SI({name:t,lowlight:e,defaultLanguage:n}){if(!["highlight","highlightAuto","listLanguages"].every(s=>kI(e[s])))throw Error("You should provide an instance of lowlight to use the code-block-lowlight extension");const r=new kt({key:new Ot("lowlight"),state:{init:(s,{doc:i})=>Kv({doc:i,name:t,lowlight:e,defaultLanguage:n}),apply:(s,i,l,c)=>{const u=l.selection.$head.parent.type.name,f=c.selection.$head.parent.type.name,p=tu(l.doc,y=>y.type.name===t),m=tu(c.doc,y=>y.type.name===t);return s.docChanged&&([u,f].includes(t)||m.length!==p.length||s.steps.some(y=>y.from!==void 0&&y.to!==void 0&&p.some(b=>b.pos>=y.from&&b.pos+b.node.nodeSize<=y.to)))?Kv({doc:s.doc,name:t,lowlight:e,defaultLanguage:n}):i.map(s.mapping,s.doc)}},props:{decorations(s){return r.getState(s)}}});return r}var EI=nI.extend({addOptions(){var t;return{...(t=this.parent)==null?void 0:t.call(this),lowlight:{},languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:4,HTMLAttributes:{}}},addProseMirrorPlugins(){var t;return[...((t=this.parent)==null?void 0:t.call(this))||[],SI({name:this.name,lowlight:this.options.lowlight,defaultLanguage:this.options.defaultLanguage})]}}),NI=EI;function CI(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",v=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],k=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],N=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],_={type:w,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:k},M={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},O=[M,m,c,n,t.C_BLOCK_COMMENT_MODE,p,f],P={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:_,contains:O.concat([{begin:/\(/,end:/\)/,keywords:_,contains:O.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:_,relevance:0},{begin:b,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:_,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(P,$,M,O,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:_,contains:["self",c]},{begin:t.IDENT_RE+"::",keywords:_},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function _I(t){const e={type:["boolean","byte","word","String"],built_in:["KeyboardController","MouseController","SoftwareSerial","EthernetServer","EthernetClient","LiquidCrystal","RobotControl","GSMVoiceCall","EthernetUDP","EsploraTFT","HttpClient","RobotMotor","WiFiClient","GSMScanner","FileSystem","Scheduler","GSMServer","YunClient","YunServer","IPAddress","GSMClient","GSMModem","Keyboard","Ethernet","Console","GSMBand","Esplora","Stepper","Process","WiFiUDP","GSM_SMS","Mailbox","USBHost","Firmata","PImage","Client","Server","GSMPIN","FileIO","Bridge","Serial","EEPROM","Stream","Mouse","Audio","Servo","File","Task","GPRS","WiFi","Wire","TFT","GSM","SPI","SD"],_hints:["setup","loop","runShellCommandAsynchronously","analogWriteResolution","retrieveCallingNumber","printFirmwareVersion","analogReadResolution","sendDigitalPortPair","noListenOnLocalhost","readJoystickButton","setFirmwareVersion","readJoystickSwitch","scrollDisplayRight","getVoiceCallStatus","scrollDisplayLeft","writeMicroseconds","delayMicroseconds","beginTransmission","getSignalStrength","runAsynchronously","getAsynchronously","listenOnLocalhost","getCurrentCarrier","readAccelerometer","messageAvailable","sendDigitalPorts","lineFollowConfig","countryNameWrite","runShellCommand","readStringUntil","rewindDirectory","readTemperature","setClockDivider","readLightSensor","endTransmission","analogReference","detachInterrupt","countryNameRead","attachInterrupt","encryptionType","readBytesUntil","robotNameWrite","readMicrophone","robotNameRead","cityNameWrite","userNameWrite","readJoystickY","readJoystickX","mouseReleased","openNextFile","scanNetworks","noInterrupts","digitalWrite","beginSpeaker","mousePressed","isActionDone","mouseDragged","displayLogos","noAutoscroll","addParameter","remoteNumber","getModifiers","keyboardRead","userNameRead","waitContinue","processInput","parseCommand","printVersion","readNetworks","writeMessage","blinkVersion","cityNameRead","readMessage","setDataMode","parsePacket","isListening","setBitOrder","beginPacket","isDirectory","motorsWrite","drawCompass","digitalRead","clearScreen","serialEvent","rightToLeft","setTextSize","leftToRight","requestFrom","keyReleased","compassRead","analogWrite","interrupts","WiFiServer","disconnect","playMelody","parseFloat","autoscroll","getPINUsed","setPINUsed","setTimeout","sendAnalog","readSlider","analogRead","beginWrite","createChar","motorsStop","keyPressed","tempoWrite","readButton","subnetMask","debugPrint","macAddress","writeGreen","randomSeed","attachGPRS","readString","sendString","remotePort","releaseAll","mouseMoved","background","getXChange","getYChange","answerCall","getResult","voiceCall","endPacket","constrain","getSocket","writeJSON","getButton","available","connected","findUntil","readBytes","exitValue","readGreen","writeBlue","startLoop","IPAddress","isPressed","sendSysex","pauseMode","gatewayIP","setCursor","getOemKey","tuneWrite","noDisplay","loadImage","switchPIN","onRequest","onReceive","changePIN","playFile","noBuffer","parseInt","overflow","checkPIN","knobRead","beginTFT","bitClear","updateIR","bitWrite","position","writeRGB","highByte","writeRed","setSpeed","readBlue","noStroke","remoteIP","transfer","shutdown","hangCall","beginSMS","endWrite","attached","maintain","noCursor","checkReg","checkPUK","shiftOut","isValid","shiftIn","pulseIn","connect","println","localIP","pinMode","getIMEI","display","noBlink","process","getBand","running","beginSD","drawBMP","lowByte","setBand","release","bitRead","prepare","pointTo","readRed","setMode","noFill","remove","listen","stroke","detach","attach","noTone","exists","buffer","height","bitSet","circle","config","cursor","random","IRread","setDNS","endSMS","getKey","micros","millis","begin","print","write","ready","flush","width","isPIN","blink","clear","press","mkdir","rmdir","close","point","yield","image","BSSID","click","delay","read","text","move","peek","beep","rect","line","open","seek","fill","size","turn","stop","home","find","step","tone","sqrt","RSSI","SSID","end","bit","tan","cos","sin","pow","map","abs","max","min","get","run","put"],literal:["DIGITAL_MESSAGE","FIRMATA_STRING","ANALOG_MESSAGE","REPORT_DIGITAL","REPORT_ANALOG","INPUT_PULLUP","SET_PIN_MODE","INTERNAL2V56","SYSTEM_RESET","LED_BUILTIN","INTERNAL1V1","SYSEX_START","INTERNAL","EXTERNAL","DEFAULT","OUTPUT","INPUT","HIGH","LOW"]},n=CI(t),r=n.keywords;return r.type=[...r.type,...e.type],r.literal=[...r.literal,...e.literal],r.built_in=[...r.built_in,...e.built_in],r._hints=e._hints,n.name="Arduino",n.aliases=["ino"],n.supersetOf="cpp",n}function TI(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]},i=t.inherit(t.COMMENT(),{match:[/(^|\s)/,/#.*$/],scope:{2:"comment"}}),l={begin:/<<-?\s*(?=\w+)/,starts:{contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,className:"string"})]}},c={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,n,s]};s.contains.push(c);const u={match:/\\"/},f={className:"string",begin:/'/,end:/'/},p={match:/\\'/},m={begin:/\$?\(\(/,end:/\)\)/,contains:[{begin:/\d+#[0-9a-f]+/,className:"number"},t.NUMBER_MODE,n]},y=["fish","bash","zsh","sh","csh","ksh","tcsh","dash","scsh"],b=t.SHEBANG({binary:`(${y.join("|")})`,relevance:10}),v={className:"function",begin:/\w[\w\d_]*\s*\(\s*\)\s*\{/,returnBegin:!0,contains:[t.inherit(t.TITLE_MODE,{begin:/\w[\w\d_]*/})],relevance:0},w=["if","then","else","elif","fi","time","for","while","until","in","do","done","case","esac","coproc","function","select"],k=["true","false"],N={match:/(\/[a-z._-]+)+/},T=["break","cd","continue","eval","exec","exit","export","getopts","hash","pwd","readonly","return","shift","test","times","trap","umask","unset"],I=["alias","bind","builtin","caller","command","declare","echo","enable","help","let","local","logout","mapfile","printf","read","readarray","source","sudo","type","typeset","ulimit","unalias"],_=["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:w,literal:k,built_in:[...T,...I,"set","shopt",..._,...M]},contains:[b,t.SHEBANG(),v,m,i,l,N,c,u,f,p,n]}}function MI(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",variants:[{begin:"\\b[a-z\\d_]*_t\\b"},{match:/\batomic_[a-z]{3,6}\b/}]},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{match:/\b(0b[01']+)/},{match:/(-?)\b([\d']+(\.[\d']*)?|\.[\d']+)((ll|LL|l|L)(u|U)?|(u|U)(ll|LL|l|L)?|f|F|b|B)/},{match:/(-?)\b(0[xX][a-fA-F0-9]+(?:'[a-fA-F0-9]+)*(?:\.[a-fA-F0-9]*(?:'[a-fA-F0-9]*)*)?(?:[pP][-+]?[0-9]+)?(l|L)?(u|U)?)/},{match:/(-?)\b\d+(?:'\d+)*(?:\.\d*(?:'\d*)*)?(?:[eE][-+]?\d+)?/}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef elifdef elifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",k={keyword:["asm","auto","break","case","continue","default","do","else","enum","extern","for","fortran","goto","if","inline","register","restrict","return","sizeof","typeof","typeof_unqual","struct","switch","typedef","union","volatile","while","_Alignas","_Alignof","_Atomic","_Generic","_Noreturn","_Static_assert","_Thread_local","alignas","alignof","noreturn","static_assert","thread_local","_Pragma"],type:["float","double","signed","unsigned","int","short","long","char","void","_Bool","_BitInt","_Complex","_Imaginary","_Decimal32","_Decimal64","_Decimal96","_Decimal128","_Decimal64x","_Decimal128x","_Float16","_Float32","_Float64","_Float128","_Float32x","_Float64x","_Float128x","const","static","constexpr","complex","bool","imaginary"],literal:"true false NULL",built_in:"std string wstring cin cout cerr clog stdin stdout stderr stringstream istringstream ostringstream auto_ptr deque list queue stack vector map set pair bitset multiset multimap unordered_set unordered_map unordered_multiset unordered_multimap priority_queue make_pair array shared_ptr abort terminate abs acos asin atan2 atan calloc ceil cosh cos exit exp fabs floor fmod fprintf fputs free frexp fscanf future isalnum isalpha iscntrl isdigit isgraph islower isprint ispunct isspace isupper isxdigit tolower toupper labs ldexp log10 log malloc realloc memchr memcmp memcpy memset modf pow printf putchar puts scanf sinh sin snprintf sprintf sqrt sscanf strcat strchr strcmp strcpy strcspn strlen strncat strncmp strncpy strpbrk strrchr strspn strstr tanh tan vfprintf vprintf vsprintf endl initializer_list unique_ptr"},N=[m,c,n,t.C_BLOCK_COMMENT_MODE,p,f],T={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:k,contains:N.concat([{begin:/\(/,end:/\)/,keywords:k,contains:N.concat(["self"]),relevance:0}]),relevance:0},I={begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:k,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:k,relevance:0},{begin:b,returnBegin:!0,contains:[t.inherit(y,{className:"title.function"})],relevance:0},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:k,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:k,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C",aliases:["h"],keywords:k,disableAutodetect:!0,illegal:"</",contains:[].concat(T,I,N,[m,{begin:t.IDENT_RE+"::",keywords:k},{className:"class",beginKeywords:"enum class struct union",end:/[{;:<>=]/,contains:[{beginKeywords:"final class struct"},t.TITLE_MODE]}]),exports:{preprocessor:m,strings:f,keywords:k}}}function AI(t){const e=t.regex,n=t.COMMENT("//","$",{contains:[{begin:/\\\n/}]}),r="decltype\\(auto\\)",s="[a-zA-Z_]\\w*::",l="(?!struct)("+r+"|"+e.optional(s)+"[a-zA-Z_]\\w*"+e.optional("<[^<>]+>")+")",c={className:"type",begin:"\\b[a-z\\d_]*_t\\b"},f={className:"string",variants:[{begin:'(u8?|U|L)?"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]},{begin:"(u8?|U|L)?'("+"\\\\(x[0-9A-Fa-f]{2}|u[0-9A-Fa-f]{4,8}|[0-7]{3}|\\S)"+"|.)",end:"'",illegal:"."},t.END_SAME_AS_BEGIN({begin:/(?:u8?|U|L)?R"([^()\\ ]{0,16})\(/,end:/\)([^()\\ ]{0,16})"/})]},p={className:"number",variants:[{begin:"[+-]?(?:(?:[0-9](?:'?[0-9])*\\.(?:[0-9](?:'?[0-9])*)?|\\.[0-9](?:'?[0-9])*)(?:[Ee][+-]?[0-9](?:'?[0-9])*)?|[0-9](?:'?[0-9])*[Ee][+-]?[0-9](?:'?[0-9])*|0[Xx](?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*(?:\\.(?:[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)?)?|\\.[0-9A-Fa-f](?:'?[0-9A-Fa-f])*)[Pp][+-]?[0-9](?:'?[0-9])*)(?:[Ff](?:16|32|64|128)?|(BF|bf)16|[Ll]|)"},{begin:"[+-]?\\b(?:0[Bb][01](?:'?[01])*|0[Xx][0-9A-Fa-f](?:'?[0-9A-Fa-f])*|0(?:'?[0-7])*|[1-9](?:'?[0-9])*)(?:[Uu](?:LL?|ll?)|[Uu][Zz]?|(?:LL?|ll?)[Uu]?|[Zz][Uu]|)"}],relevance:0},m={className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma _Pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(f,{className:"string"}),{className:"string",begin:/<.*?>/},n,t.C_BLOCK_COMMENT_MODE]},y={className:"title",begin:e.optional(s)+t.IDENT_RE,relevance:0},b=e.optional(s)+t.IDENT_RE+"\\s*\\(",v=["alignas","alignof","and","and_eq","asm","atomic_cancel","atomic_commit","atomic_noexcept","auto","bitand","bitor","break","case","catch","class","co_await","co_return","co_yield","compl","concept","const_cast|10","consteval","constexpr","constinit","continue","decltype","default","delete","do","dynamic_cast|10","else","enum","explicit","export","extern","false","final","for","friend","goto","if","import","inline","module","mutable","namespace","new","noexcept","not","not_eq","nullptr","operator","or","or_eq","override","private","protected","public","reflexpr","register","reinterpret_cast|10","requires","return","sizeof","static_assert","static_cast|10","struct","switch","synchronized","template","this","thread_local","throw","transaction_safe","transaction_safe_dynamic","true","try","typedef","typeid","typename","union","using","virtual","volatile","while","xor","xor_eq"],w=["bool","char","char16_t","char32_t","char8_t","double","float","int","long","short","void","wchar_t","unsigned","signed","const","static"],k=["any","auto_ptr","barrier","binary_semaphore","bitset","complex","condition_variable","condition_variable_any","counting_semaphore","deque","false_type","flat_map","flat_set","future","imaginary","initializer_list","istringstream","jthread","latch","lock_guard","multimap","multiset","mutex","optional","ostringstream","packaged_task","pair","promise","priority_queue","queue","recursive_mutex","recursive_timed_mutex","scoped_lock","set","shared_future","shared_lock","shared_mutex","shared_timed_mutex","shared_ptr","stack","string_view","stringstream","timed_mutex","thread","true_type","tuple","unique_lock","unique_ptr","unordered_map","unordered_multimap","unordered_multiset","unordered_set","variant","vector","weak_ptr","wstring","wstring_view"],N=["abort","abs","acos","apply","as_const","asin","atan","atan2","calloc","ceil","cerr","cin","clog","cos","cosh","cout","declval","endl","exchange","exit","exp","fabs","floor","fmod","forward","fprintf","fputs","free","frexp","fscanf","future","invoke","isalnum","isalpha","iscntrl","isdigit","isgraph","islower","isprint","ispunct","isspace","isupper","isxdigit","labs","launder","ldexp","log","log10","make_pair","make_shared","make_shared_for_overwrite","make_tuple","make_unique","malloc","memchr","memcmp","memcpy","memset","modf","move","pow","printf","putchar","puts","realloc","scanf","sin","sinh","snprintf","sprintf","sqrt","sscanf","std","stderr","stdin","stdout","strcat","strchr","strcmp","strcpy","strcspn","strlen","strncat","strncmp","strncpy","strpbrk","strrchr","strspn","strstr","swap","tan","tanh","terminate","to_underlying","tolower","toupper","vfprintf","visit","vprintf","vsprintf"],_={type:w,keyword:v,literal:["NULL","false","nullopt","nullptr","true"],built_in:["_Pragma"],_type_hints:k},M={className:"function.dispatch",relevance:0,keywords:{_hint:N},begin:e.concat(/\b/,/(?!decltype)/,/(?!if)/,/(?!for)/,/(?!switch)/,/(?!while)/,t.IDENT_RE,e.lookahead(/(<[^<>]+>|)\s*\(/))},O=[M,m,c,n,t.C_BLOCK_COMMENT_MODE,p,f],P={variants:[{begin:/=/,end:/;/},{begin:/\(/,end:/\)/},{beginKeywords:"new throw return else",end:/;/}],keywords:_,contains:O.concat([{begin:/\(/,end:/\)/,keywords:_,contains:O.concat(["self"]),relevance:0}]),relevance:0},$={className:"function",begin:"("+l+"[\\*&\\s]+)+"+b,returnBegin:!0,end:/[{;=]/,excludeEnd:!0,keywords:_,illegal:/[^\w\s\*&:<>.]/,contains:[{begin:r,keywords:_,relevance:0},{begin:b,returnBegin:!0,contains:[y],relevance:0},{begin:/::/,relevance:0},{begin:/:/,endsWithParent:!0,contains:[f,p]},{relevance:0,match:/,/},{className:"params",begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:[n,t.C_BLOCK_COMMENT_MODE,f,p,c,{begin:/\(/,end:/\)/,keywords:_,relevance:0,contains:["self",n,t.C_BLOCK_COMMENT_MODE,f,p,c]}]},c,n,t.C_BLOCK_COMMENT_MODE,m]};return{name:"C++",aliases:["cc","c++","h++","hpp","hh","hxx","cxx"],keywords:_,illegal:"</",classNameAliases:{"function.dispatch":"built_in"},contains:[].concat(P,$,M,O,[m,{begin:"\\b(deque|list|queue|priority_queue|pair|stack|vector|map|set|bitset|multiset|multimap|unordered_map|unordered_set|unordered_multiset|unordered_multimap|array|tuple|optional|variant|function|flat_map|flat_set)\\s*<(?!<)",end:">",keywords:_,contains:["self",c]},{begin:t.IDENT_RE+"::",keywords:_},{match:[/\b(?:enum(?:\s+(?:class|struct))?|class|struct|union)/,/\s+/,/\w+/],className:{1:"keyword",3:"title.class"}}])}}function OI(t){const e=["bool","byte","char","decimal","delegate","double","dynamic","enum","float","int","long","nint","nuint","object","sbyte","short","string","ulong","uint","ushort"],n=["public","private","protected","static","internal","protected","abstract","async","extern","override","unsafe","virtual","new","sealed","partial"],r=["default","false","null","true"],s=["abstract","as","base","break","case","catch","class","const","continue","do","else","event","explicit","extern","finally","fixed","for","foreach","goto","if","implicit","in","interface","internal","is","lock","namespace","new","operator","out","override","params","private","protected","public","readonly","record","ref","return","scoped","sealed","sizeof","stackalloc","static","struct","switch","this","throw","try","typeof","unchecked","unsafe","using","virtual","void","volatile","while"],i=["add","alias","and","ascending","args","async","await","by","descending","dynamic","equals","file","from","get","global","group","init","into","join","let","nameof","not","notnull","on","or","orderby","partial","record","remove","required","scoped","select","set","unmanaged","value|0","var","when","where","with","yield"],l={keyword:s.concat(i),built_in:e,literal:r},c=t.inherit(t.TITLE_MODE,{begin:"[a-zA-Z](\\.?\\w)*"}),u={className:"number",variants:[{begin:"\\b(0b[01']+)"},{begin:"(-?)\\b([\\d']+(\\.[\\d']*)?|\\.[\\d']+)(u|U|l|L|ul|UL|f|F|b|B)"},{begin:"(-?)(\\b0[xX][a-fA-F0-9']+|(\\b[\\d']+(\\.[\\d']*)?|\\.[\\d']+)([eE][-+]?[\\d']+)?)"}],relevance:0},f={className:"string",begin:/"""("*)(?!")(.|\n)*?"""\1/,relevance:1},p={className:"string",begin:'@"',end:'"',contains:[{begin:'""'}]},m=t.inherit(p,{illegal:/\n/}),y={className:"subst",begin:/\{/,end:/\}/,keywords:l},b=t.inherit(y,{illegal:/\n/}),v={className:"string",begin:/\$"/,end:'"',illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},t.BACKSLASH_ESCAPE,b]},w={className:"string",begin:/\$@"/,end:'"',contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},y]},k=t.inherit(w,{illegal:/\n/,contains:[{begin:/\{\{/},{begin:/\}\}/},{begin:'""'},b]});y.contains=[w,v,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.C_BLOCK_COMMENT_MODE],b.contains=[k,v,m,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,u,t.inherit(t.C_BLOCK_COMMENT_MODE,{illegal:/\n/})];const N={variants:[f,w,v,p,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},T={begin:"<",end:">",contains:[{beginKeywords:"in out"},c]},I=t.IDENT_RE+"(<"+t.IDENT_RE+"(\\s*,\\s*"+t.IDENT_RE+")*>)?(\\[\\])?",_={begin:"@"+t.IDENT_RE,relevance:0};return{name:"C#",aliases:["cs","c#"],keywords:l,illegal:/::/,contains:[t.COMMENT("///","$",{returnBegin:!0,contains:[{className:"doctag",variants:[{begin:"///",relevance:0},{begin:"<!--|-->"},{begin:"</?",end:">"}]}]}),t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"meta",begin:"#",end:"$",keywords:{keyword:"if else elif endif define undef warning error line region endregion pragma checksum"}},N,u,{beginKeywords:"class interface",relevance:0,end:/[{;=]/,illegal:/[^\s:,]/,contains:[{beginKeywords:"where class"},c,T,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"namespace",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"record",relevance:0,end:/[{;=]/,illegal:/[^\s:]/,contains:[c,T,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"meta",begin:"^\\s*\\[(?=[\\w])",excludeBegin:!0,end:"\\]",excludeEnd:!0,contains:[{className:"string",begin:/"/,end:/"/}]},{beginKeywords:"new return throw await else",relevance:0},{className:"function",begin:"("+I+"\\s+)+"+t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,end:/\s*[{;=]/,excludeEnd:!0,keywords:l,contains:[{beginKeywords:n.join(" "),relevance:0},{begin:t.IDENT_RE+"\\s*(<[^=]+>\\s*)?\\(",returnBegin:!0,contains:[t.TITLE_MODE,T],relevance:0},{match:/\(\)/},{className:"params",begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:l,relevance:0,contains:[N,u,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},_]}}const RI=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_-]*/}}),II=["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"],jI=["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"],LI=[...II,...jI],DI=["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(),PI=["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(),BI=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),zI=["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 $I(t){const e=t.regex,n=RI(t),r={begin:/-(webkit|moz|ms|o)-(?=[a-z])/},s="and or not only",i=/@-?\w[\w]*(-\w+)*/,l="[a-zA-Z-][a-zA-Z0-9_-]*",c=[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:"\\."+l,relevance:0},n.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{begin:":("+PI.join("|")+")"},{begin:":(:)?("+BI.join("|")+")"}]},n.CSS_VARIABLE,{className:"attribute",begin:"\\b("+zI.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,contains:[n.BLOCK_COMMENT,n.HEXCOLOR,n.IMPORTANT,n.CSS_NUMBER_MODE,...c,{begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"},contains:[...c,{className:"string",begin:/[^)]/,endsWithParent:!0,excludeEnd:!0}]},n.FUNCTION_DISPATCH]},{begin:e.lookahead(/@/),end:"[{;]",relevance:0,illegal:/:/,contains:[{className:"keyword",begin:i},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{$pattern:/[a-z-]+/,keyword:s,attribute:DI.join(" ")},contains:[{begin:/[a-z-]+(?=:)/,className:"attribute"},...c,n.CSS_NUMBER_MODE]}]},{className:"selector-tag",begin:"\\b("+LI.join("|")+")\\b"}]}}function FI(t){const e=t.regex;return{name:"Diff",aliases:["patch"],contains:[{className:"meta",relevance:10,match:e.either(/^@@ +-\d+,\d+ +\+\d+,\d+ +@@/,/^\*\*\* +\d+,\d+ +\*\*\*\*$/,/^--- +\d+,\d+ +----$/)},{className:"comment",variants:[{begin:e.either(/Index: /,/^index/,/={3,}/,/^-{3}/,/^\*{3} /,/^\+{3}/,/^diff --git/),end:/$/},{match:/^\*{15}$/}]},{className:"addition",begin:/^\+/,end:/$/},{className:"deletion",begin:/^-/,end:/$/},{className:"addition",begin:/^!/,end:/$/}]}}function UI(t){const i={keyword:["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var"],type:["bool","byte","complex64","complex128","error","float32","float64","int8","int16","int32","int64","string","uint8","uint16","uint32","uint64","int","uint","uintptr","rune"],literal:["true","false","iota","nil"],built_in:["append","cap","close","complex","copy","imag","len","make","new","panic","print","println","real","recover","delete"]};return{name:"Go",aliases:["golang"],keywords:i,illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{className:"string",variants:[t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{begin:"`",end:"`"}]},{className:"number",variants:[{match:/-?\b0[xX]\.[a-fA-F0-9](_?[a-fA-F0-9])*[pP][+-]?\d(_?\d)*i?/,relevance:0},{match:/-?\b0[xX](_?[a-fA-F0-9])+((\.([a-fA-F0-9](_?[a-fA-F0-9])*)?)?[pP][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b0[oO](_?[0-7])*i?/,relevance:0},{match:/-?\.\d(_?\d)*([eE][+-]?\d(_?\d)*)?i?/,relevance:0},{match:/-?\b\d(_?\d)*(\.(\d(_?\d)*)?)?([eE][+-]?\d(_?\d)*)?i?/,relevance:0}]},{begin:/:=/},{className:"function",beginKeywords:"func",end:"\\s*(\\{|$)",excludeEnd:!0,contains:[t.TITLE_MODE,{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:i,illegal:/["']/}]}]}}function HI(t){const e=t.regex,n=/[_A-Za-z][_0-9A-Za-z]*/;return{name:"GraphQL",aliases:["gql"],case_insensitive:!0,disableAutodetect:!1,keywords:{keyword:["query","mutation","subscription","type","input","schema","directive","interface","union","scalar","fragment","enum","on"],literal:["true","false","null"]},contains:[t.HASH_COMMENT_MODE,t.QUOTE_STRING_MODE,t.NUMBER_MODE,{scope:"punctuation",match:/[.]{3}/,relevance:0},{scope:"punctuation",begin:/[\!\(\)\:\=\[\]\{\|\}]{1}/,relevance:0},{scope:"variable",begin:/\$/,end:/\W/,excludeEnd:!0,relevance:0},{scope:"meta",match:/@\w+/,excludeEnd:!0},{scope:"symbol",begin:e.concat(n,e.lookahead(/\s*:/)),relevance:0}],illegal:[/[;<']/,/BEGIN/]}}function WI(t){const e=t.regex,n={className:"number",relevance:0,variants:[{begin:/([+-]+)?[\d]+_[\d_]+/},{begin:t.NUMBER_RE}]},r=t.COMMENT();r.variants=[{begin:/;/,end:/$/},{begin:/#/,end:/$/}];const s={className:"variable",variants:[{begin:/\$[\w\d"][\w\d_]*/},{begin:/\$\{(.*?)\}/}]},i={className:"literal",begin:/\bon|off|true|false|yes|no\b/},l={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:"'''",end:"'''",relevance:10},{begin:'"""',end:'"""',relevance:10},{begin:'"',end:'"'},{begin:"'",end:"'"}]},c={begin:/\[/,end:/\]/,contains:[r,i,s,l,n,"self"],relevance:0},u=/[A-Za-z0-9_-]+/,f=/"(\\"|[^"])*"/,p=/'[^']*'/,m=e.either(u,f,p),y=e.concat(m,"(\\s*\\.\\s*",m,")*",e.lookahead(/\s*=\s*[^#\s]/));return{name:"TOML, also INI",aliases:["toml"],case_insensitive:!0,illegal:/\S/,contains:[r,{className:"section",begin:/\[+/,end:/\]+/},{begin:y,className:"attr",starts:{end:/$/,contains:[r,c,i,s,l,n]}}]}}var yo="[0-9](_*[0-9])*",Ec=`\\.(${yo})`,Nc="[0-9a-fA-F](_*[0-9a-fA-F])*",Gv={className:"number",variants:[{begin:`(\\b(${yo})((${Ec})|\\.)?|(${Ec}))[eE][+-]?(${yo})[fFdD]?\\b`},{begin:`\\b(${yo})((${Ec})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Ec})[fFdD]?\\b`},{begin:`\\b(${yo})[fFdD]\\b`},{begin:`\\b0[xX]((${Nc})\\.?|(${Nc})?\\.(${Nc}))[pP][+-]?(${yo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${Nc})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function t1(t,e,n){return n===-1?"":t.replace(e,r=>t1(t,e,n-1))}function VI(t){const e=t.regex,n="[À-ʸa-zA-Z_$][À-ʸa-zA-Z_$0-9]*",r=n+t1("(?:<"+n+"~~~(?:\\s*,\\s*"+n+"~~~)*>)?",/~~~/g,2),u={keyword:["synchronized","abstract","private","var","static","if","const ","for","while","strictfp","finally","protected","import","native","final","void","enum","else","break","transient","catch","instanceof","volatile","case","assert","package","default","public","try","switch","continue","throws","protected","public","private","module","requires","exports","do","sealed","yield","permits","goto","when"],literal:["false","true","null"],type:["char","boolean","long","float","int","byte","short","double"],built_in:["super","this"]},f={className:"meta",begin:"@"+n,contains:[{begin:/\(/,end:/\)/,contains:["self"]}]},p={className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[t.C_BLOCK_COMMENT_MODE],endsParent:!0};return{name:"Java",aliases:["jsp"],keywords:u,illegal:/<\/|#/,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{begin:/\w+@/,relevance:0},{className:"doctag",begin:"@[A-Za-z]+"}]}),{begin:/import java\.[a-z]+\./,keywords:"import",relevance:2},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,{begin:/"""/,end:/"""/,className:"string",contains:[t.BACKSLASH_ESCAPE]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{match:[/\b(?:class|interface|enum|extends|implements|new)/,/\s+/,n],className:{1:"keyword",3:"title.class"}},{match:/non-sealed/,scope:"keyword"},{begin:[e.concat(/(?!else)/,n),/\s+/,n,/\s+/,/=(?!=)/],className:{1:"type",3:"variable",5:"operator"}},{begin:[/record/,/\s+/,n],className:{1:"keyword",3:"title.class"},contains:[p,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{beginKeywords:"new throw return else",relevance:0},{begin:["(?:"+r+"\\s+)",t.UNDERSCORE_IDENT_RE,/\s*(?=\()/],className:{2:"title.function"},keywords:u,contains:[{className:"params",begin:/\(/,end:/\)/,keywords:u,relevance:0,contains:[f,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,Gv,t.C_BLOCK_COMMENT_MODE]},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},Gv,f]}}const qv="[A-Za-z$_][0-9A-Za-z$_]*",KI=["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"],GI=["true","false","null","undefined","NaN","Infinity"],n1=["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"],r1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],s1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],qI=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],JI=[].concat(s1,n1,r1);function YI(t){const e=t.regex,n=(H,{after:X})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,X)!==-1},r=qv,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,X)=>{const K=H[0].length+H.index,A=H.input[K];if(A==="<"||A===","){X.ignoreMatch();return}A===">"&&(n(H,{after:K})||X.ignoreMatch());let R;const Y=H.input.substring(K);if(R=Y.match(/^\s*=/)){X.ignoreMatch();return}if((R=Y.match(/^\s+extends\s+/))&&R.index===0){X.ignoreMatch();return}}},c={$pattern:qv,keyword:KI,literal:GI,built_in:JI,"variable.language":qI},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\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},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},T={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]},I=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,{match:/\$\d+/},m];y.contains=I.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(I)});const _=[].concat(T,y.contains),M=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(_)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:M},P={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"}}]},$={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:{_:[...n1,...r1]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},W={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},J={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(H){return e.concat("(?!",H.join("|"),")")}const re={match:e.concat(/\b/,F([...s1,"super","import"].map(H=>`${H}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},G={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},te={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,T,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,t.REGEXP_MODE,{className:"function",begin:U,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:c,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},W,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},G,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},re,J,P,te,{match:/\$[(.]/}]}}function QI(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"}}var bo="[0-9](_*[0-9])*",Cc=`\\.(${bo})`,_c="[0-9a-fA-F](_*[0-9a-fA-F])*",XI={className:"number",variants:[{begin:`(\\b(${bo})((${Cc})|\\.)?|(${Cc}))[eE][+-]?(${bo})[fFdD]?\\b`},{begin:`\\b(${bo})((${Cc})[fFdD]?\\b|\\.([fFdD]\\b)?)`},{begin:`(${Cc})[fFdD]?\\b`},{begin:`\\b(${bo})[fFdD]\\b`},{begin:`\\b0[xX]((${_c})\\.?|(${_c})?\\.(${_c}))[pP][+-]?(${bo})[fFdD]?\\b`},{begin:"\\b(0|[1-9](_*[0-9])*)[lL]?\\b"},{begin:`\\b0[xX](${_c})[lL]?\\b`},{begin:"\\b0(_*[0-7])*[lL]?\\b"},{begin:"\\b0[bB][01](_*[01])*[lL]?\\b"}],relevance:0};function ZI(t){const e={keyword:"abstract as val var vararg get set class object open private protected public noinline crossinline dynamic final enum if else do while for when throw try catch finally import package is in fun override companion reified inline lateinit init interface annotation data sealed internal infix operator out by constructor super tailrec where const inner suspend typealias external expect actual",built_in:"Byte Short Char Int Long Boolean Float Double Void Unit Nothing",literal:"true false null"},n={className:"keyword",begin:/\b(break|continue|return|this)\b/,starts:{contains:[{className:"symbol",begin:/@\w+/}]}},r={className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"@"},s={className:"subst",begin:/\$\{/,end:/\}/,contains:[t.C_NUMBER_MODE]},i={className:"variable",begin:"\\$"+t.UNDERSCORE_IDENT_RE},l={className:"string",variants:[{begin:'"""',end:'"""(?=[^"])',contains:[i,s]},{begin:"'",end:"'",illegal:/\n/,contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"',illegal:/\n/,contains:[t.BACKSLASH_ESCAPE,i,s]}]};s.contains.push(l);const c={className:"meta",begin:"@(?:file|property|field|get|set|receiver|param|setparam|delegate)\\s*:(?:\\s*"+t.UNDERSCORE_IDENT_RE+")?"},u={className:"meta",begin:"@"+t.UNDERSCORE_IDENT_RE,contains:[{begin:/\(/,end:/\)/,contains:[t.inherit(l,{className:"string"}),"self"]}]},f=XI,p=t.COMMENT("/\\*","\\*/",{contains:[t.C_BLOCK_COMMENT_MODE]}),m={variants:[{className:"type",begin:t.UNDERSCORE_IDENT_RE},{begin:/\(/,end:/\)/,contains:[]}]},y=m;return y.variants[1].contains=[m],m.variants[1].contains=[y],{name:"Kotlin",aliases:["kt","kts"],keywords:e,contains:[t.COMMENT("/\\*\\*","\\*/",{relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"}]}),t.C_LINE_COMMENT_MODE,p,n,r,c,u,{className:"function",beginKeywords:"fun",end:"[(]|$",returnBegin:!0,excludeEnd:!0,keywords:e,relevance:5,contains:[{begin:t.UNDERSCORE_IDENT_RE+"\\s*\\(",returnBegin:!0,relevance:0,contains:[t.UNDERSCORE_TITLE_MODE]},{className:"type",begin:/</,end:/>/,keywords:"reified",relevance:0},{className:"params",begin:/\(/,end:/\)/,endsParent:!0,keywords:e,relevance:0,contains:[{begin:/:/,end:/[=,\/]/,endsWithParent:!0,contains:[m,t.C_LINE_COMMENT_MODE,p],relevance:0},t.C_LINE_COMMENT_MODE,p,c,u,l,t.C_NUMBER_MODE]},p]},{begin:[/class|interface|trait/,/\s+/,t.UNDERSCORE_IDENT_RE],beginScope:{3:"title.class"},keywords:"class interface trait",end:/[:\{(]|$/,excludeEnd:!0,illegal:"extends implements",contains:[{beginKeywords:"public protected internal private constructor"},t.UNDERSCORE_TITLE_MODE,{className:"type",begin:/</,end:/>/,excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:/[,:]\s*/,end:/[<\(,){\s]|$/,excludeBegin:!0,returnEnd:!0},c,u]},l,{className:"meta",begin:"^#!/usr/bin/env",end:"$",illegal:`
202
+ `},f]}}const ej=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_-]*/}}),tj=["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"],nj=["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"],rj=[...tj,...nj],sj=["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(),i1=["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(),o1=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),ij=["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(),oj=i1.concat(o1).sort().reverse();function lj(t){const e=ej(t),n=oj,r="and or not only",s="[\\w-]+",i="("+s+"|@\\{"+s+"\\})",l=[],c=[],u=function(I){return{className:"string",begin:"~?"+I+".*?"+I}},f=function(I,_,M){return{className:I,begin:_,relevance:M}},p={$pattern:/[a-z-]+/,keyword:r,attribute:sj.join(" ")},m={begin:"\\(",end:"\\)",contains:c,keywords:p,relevance:0};c.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,u("'"),u('"'),e.CSS_NUMBER_MODE,{begin:"(url|data-uri)\\(",starts:{className:"string",end:"[\\)\\n]",excludeEnd:!0}},e.HEXCOLOR,m,f("variable","@@?"+s,10),f("variable","@\\{"+s+"\\}"),f("built_in","~?`[^`]*?`"),{className:"attribute",begin:s+"\\s*:",end:":",returnBegin:!0,excludeEnd:!0},e.IMPORTANT,{beginKeywords:"and not"},e.FUNCTION_DISPATCH);const y=c.concat({begin:/\{/,end:/\}/,contains:l}),b={beginKeywords:"when",endsWithParent:!0,contains:[{beginKeywords:"and not"}].concat(c)},v={begin:i+"\\s*:",returnBegin:!0,end:/[;}]/,relevance:0,contains:[{begin:/-(webkit|moz|ms|o)-/},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+ij.join("|")+")\\b",end:/(?=:)/,starts:{endsWithParent:!0,illegal:"[<=$]",relevance:0,contains:c}}]},w={className:"keyword",begin:"@(import|media|charset|font-face|(-[a-z]+-)?keyframes|supports|document|namespace|page|viewport|host)\\b",starts:{end:"[;{}]",keywords:p,returnEnd:!0,contains:c,relevance:0}},k={className:"variable",variants:[{begin:"@"+s+"\\s*:",relevance:15},{begin:"@"+s}],starts:{end:"[;}]",returnEnd:!0,contains:y}},N={variants:[{begin:"[\\.#:&\\[>]",end:"[;{}]"},{begin:i,end:/\{/}],returnBegin:!0,returnEnd:!0,illegal:`[<='$"]`,relevance:0,contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,b,f("keyword","all\\b"),f("variable","@\\{"+s+"\\}"),{begin:"\\b("+rj.join("|")+")\\b",className:"selector-tag"},e.CSS_NUMBER_MODE,f("selector-tag",i,0),f("selector-id","#"+i),f("selector-class","\\."+i,0),f("selector-tag","&",0),e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",begin:":("+i1.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+o1.join("|")+")"},{begin:/\(/,end:/\)/,relevance:0,contains:y},{begin:"!important"},e.FUNCTION_DISPATCH]},T={begin:s+`:(:)?(${n.join("|")})`,returnBegin:!0,contains:[N]};return l.push(t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,w,k,T,v,N,b,e.FUNCTION_DISPATCH),{name:"Less",case_insensitive:!0,illegal:`[=>'/<($"]`,contains:l}}function aj(t){const e="\\[=*\\[",n="\\]=*\\]",r={begin:e,end:n,contains:["self"]},s=[t.COMMENT("--(?!"+e+")","$"),t.COMMENT("--"+e,n,{contains:[r],relevance:10})];return{name:"Lua",aliases:["pluto"],keywords:{$pattern:t.UNDERSCORE_IDENT_RE,literal:"true false nil",keyword:"and break do else elseif end for goto if in local not or repeat return then until while",built_in:"_G _ENV _VERSION __index __newindex __mode __call __metatable __tostring __len __gc __add __sub __mul __div __mod __pow __concat __unm __eq __lt __le assert collectgarbage dofile error getfenv getmetatable ipairs load loadfile loadstring module next pairs pcall print rawequal rawget rawset require select setfenv setmetatable tonumber tostring type unpack xpcall arg self coroutine resume yield status wrap create running debug getupvalue debug sethook getmetatable gethook setmetatable setlocal traceback setfenv getinfo setupvalue getlocal getregistry getfenv io lines write close flush open output type read stderr stdin input stdout popen tmpfile math log max acos huge ldexp pi cos tanh pow deg tan cosh sinh random randomseed frexp ceil floor rad abs sqrt modf asin min mod fmod log10 atan2 exp sin atan os exit setlocale date getenv difftime remove time clock tmpname rename execute package preload loadlib loaded loaders cpath config path seeall string sub upper len gfind rep find match char dump gmatch reverse byte format gsub lower table setn insert getn foreachi maxn foreach concat sort remove"},contains:s.concat([{className:"function",beginKeywords:"function",end:"\\)",contains:[t.inherit(t.TITLE_MODE,{begin:"([_a-zA-Z]\\w*\\.)*([_a-zA-Z]\\w*:)?[_a-zA-Z]\\w*"}),{className:"params",begin:"\\(",endsWithParent:!0,contains:s}].concat(s)},t.C_NUMBER_MODE,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,{className:"string",begin:e,end:n,contains:[r],relevance:5}])}}function cj(t){const e={className:"variable",variants:[{begin:"\\$\\("+t.UNDERSCORE_IDENT_RE+"\\)",contains:[t.BACKSLASH_ESCAPE]},{begin:/\$[@%<?\^\+\*]/}]},n={className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,e]},r={className:"variable",begin:/\$\([\w-]+\s/,end:/\)/,keywords:{built_in:"subst patsubst strip findstring filter filter-out sort word wordlist firstword lastword dir notdir suffix basename addsuffix addprefix join wildcard realpath abspath error warning shell origin flavor foreach if or and call eval file value"},contains:[e,n]},s={begin:"^"+t.UNDERSCORE_IDENT_RE+"\\s*(?=[:+?]?=)"},i={className:"meta",begin:/^\.PHONY:/,end:/$/,keywords:{$pattern:/[\.\w]+/,keyword:".PHONY"}},l={className:"section",begin:/^[^\s]+:/,end:/$/,contains:[e]};return{name:"Makefile",aliases:["mk","mak","make"],keywords:{$pattern:/[\w-]+/,keyword:"define endef undefine ifdef ifndef ifeq ifneq else endif include -include sinclude override export unexport private vpath"},contains:[t.HASH_COMMENT_MODE,e,n,r,s,i,l]}}function uj(t){const e=t.regex,n={begin:/<\/?[A-Za-z_]/,end:">",subLanguage:"xml",relevance:0},r={begin:"^[-\\*]{3,}",end:"$"},s={className:"code",variants:[{begin:"(`{3,})[^`](.|\\n)*?\\1`*[ ]*"},{begin:"(~{3,})[^~](.|\\n)*?\\1~*[ ]*"},{begin:"```",end:"```+[ ]*$"},{begin:"~~~",end:"~~~+[ ]*$"},{begin:"`.+?`"},{begin:"(?=^( {4}|\\t))",contains:[{begin:"^( {4}|\\t)",end:"(\\n)$"}],relevance:0}]},i={className:"bullet",begin:"^[ ]*([*+-]|(\\d+\\.))(?=\\s+)",end:"\\s+",excludeEnd:!0},l={begin:/^\[[^\n]+\]:/,returnBegin:!0,contains:[{className:"symbol",begin:/\[/,end:/\]/,excludeBegin:!0,excludeEnd:!0},{className:"link",begin:/:\s*/,end:/$/,excludeBegin:!0}]},c=/[A-Za-z][A-Za-z0-9+.-]*/,u={variants:[{begin:/\[.+?\]\[.*?\]/,relevance:0},{begin:/\[.+?\]\(((data|javascript|mailto):|(?:http|ftp)s?:\/\/).*?\)/,relevance:2},{begin:e.concat(/\[.+?\]\(/,c,/:\/\/.*?\)/),relevance:2},{begin:/\[.+?\]\([./?&#].*?\)/,relevance:1},{begin:/\[.*?\]\(.*?\)/,relevance:0}],returnBegin:!0,contains:[{match:/\[(?=\])/},{className:"string",relevance:0,begin:"\\[",end:"\\]",excludeBegin:!0,returnEnd:!0},{className:"link",relevance:0,begin:"\\]\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0},{className:"symbol",relevance:0,begin:"\\]\\[",end:"\\]",excludeBegin:!0,excludeEnd:!0}]},f={className:"strong",contains:[],variants:[{begin:/_{2}(?!\s)/,end:/_{2}/},{begin:/\*{2}(?!\s)/,end:/\*{2}/}]},p={className:"emphasis",contains:[],variants:[{begin:/\*(?![*\s])/,end:/\*/},{begin:/_(?![_\s])/,end:/_/,relevance:0}]},m=t.inherit(f,{contains:[]}),y=t.inherit(p,{contains:[]});f.contains.push(y),p.contains.push(m);let b=[n,u];return[f,p,m,y].forEach(N=>{N.contains=N.contains.concat(b)}),b=b.concat(f,p),{name:"Markdown",aliases:["md","mkdown","mkd"],contains:[{className:"section",variants:[{begin:"^#{1,6}",end:"$",contains:b},{begin:"(?=^.+?\\n[=-]{2,}$)",contains:[{begin:"^[=-]*$"},{begin:"^",end:"\\n",contains:b}]}]},n,i,f,p,{className:"quote",begin:"^>\\s+",contains:b,end:"$"},s,r,u,l,{scope:"literal",match:/&([a-zA-Z0-9]+|#[0-9]{1,7}|#[Xx][0-9a-fA-F]{1,6});/}]}}function dj(t){const e={className:"built_in",begin:"\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+"},n=/[a-zA-Z@][a-zA-Z0-9_]*/,c={"variable.language":["this","super"],$pattern:n,keyword:["while","export","sizeof","typedef","const","struct","for","union","volatile","static","mutable","if","do","return","goto","enum","else","break","extern","asm","case","default","register","explicit","typename","switch","continue","inline","readonly","assign","readwrite","self","@synchronized","id","typeof","nonatomic","IBOutlet","IBAction","strong","weak","copy","in","out","inout","bycopy","byref","oneway","__strong","__weak","__block","__autoreleasing","@private","@protected","@public","@try","@property","@end","@throw","@catch","@finally","@autoreleasepool","@synthesize","@dynamic","@selector","@optional","@required","@encode","@package","@import","@defs","@compatibility_alias","__bridge","__bridge_transfer","__bridge_retained","__bridge_retain","__covariant","__contravariant","__kindof","_Nonnull","_Nullable","_Null_unspecified","__FUNCTION__","__PRETTY_FUNCTION__","__attribute__","getter","setter","retain","unsafe_unretained","nonnull","nullable","null_unspecified","null_resettable","class","instancetype","NS_DESIGNATED_INITIALIZER","NS_UNAVAILABLE","NS_REQUIRES_SUPER","NS_RETURNS_INNER_POINTER","NS_INLINE","NS_AVAILABLE","NS_DEPRECATED","NS_ENUM","NS_OPTIONS","NS_SWIFT_UNAVAILABLE","NS_ASSUME_NONNULL_BEGIN","NS_ASSUME_NONNULL_END","NS_REFINED_FOR_SWIFT","NS_SWIFT_NAME","NS_SWIFT_NOTHROW","NS_DURING","NS_HANDLER","NS_ENDHANDLER","NS_VALUERETURN","NS_VOIDRETURN"],literal:["false","true","FALSE","TRUE","nil","YES","NO","NULL"],built_in:["dispatch_once_t","dispatch_queue_t","dispatch_sync","dispatch_async","dispatch_once"],type:["int","float","char","unsigned","signed","short","long","double","wchar_t","unichar","void","bool","BOOL","id|0","_Bool"]},u={$pattern:n,keyword:["@interface","@class","@protocol","@implementation"]};return{name:"Objective-C",aliases:["mm","objc","obj-c","obj-c++","objective-c++"],keywords:c,illegal:"</",contains:[e,t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,t.C_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,{className:"string",variants:[{begin:'@"',end:'"',illegal:"\\n",contains:[t.BACKSLASH_ESCAPE]}]},{className:"meta",begin:/#\s*[a-z]+\b/,end:/$/,keywords:{keyword:"if else elif endif define undef warning error line pragma ifdef ifndef include"},contains:[{begin:/\\\n/,relevance:0},t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),{className:"string",begin:/<.*?>/,end:/$/,illegal:"\\n"},t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE]},{className:"class",begin:"("+u.keyword.join("|")+")\\b",end:/(\{|$)/,excludeEnd:!0,keywords:u,contains:[t.UNDERSCORE_TITLE_MODE]},{begin:"\\."+t.UNDERSCORE_IDENT_RE,relevance:0}]}}function fj(t){const e=t.regex,n=["abs","accept","alarm","and","atan2","bind","binmode","bless","break","caller","chdir","chmod","chomp","chop","chown","chr","chroot","class","close","closedir","connect","continue","cos","crypt","dbmclose","dbmopen","defined","delete","die","do","dump","each","else","elsif","endgrent","endhostent","endnetent","endprotoent","endpwent","endservent","eof","eval","exec","exists","exit","exp","fcntl","field","fileno","flock","for","foreach","fork","format","formline","getc","getgrent","getgrgid","getgrnam","gethostbyaddr","gethostbyname","gethostent","getlogin","getnetbyaddr","getnetbyname","getnetent","getpeername","getpgrp","getpriority","getprotobyname","getprotobynumber","getprotoent","getpwent","getpwnam","getpwuid","getservbyname","getservbyport","getservent","getsockname","getsockopt","given","glob","gmtime","goto","grep","gt","hex","if","index","int","ioctl","join","keys","kill","last","lc","lcfirst","length","link","listen","local","localtime","log","lstat","lt","ma","map","method","mkdir","msgctl","msgget","msgrcv","msgsnd","my","ne","next","no","not","oct","open","opendir","or","ord","our","pack","package","pipe","pop","pos","print","printf","prototype","push","q|0","qq","quotemeta","qw","qx","rand","read","readdir","readline","readlink","readpipe","recv","redo","ref","rename","require","reset","return","reverse","rewinddir","rindex","rmdir","say","scalar","seek","seekdir","select","semctl","semget","semop","send","setgrent","sethostent","setnetent","setpgrp","setpriority","setprotoent","setpwent","setservent","setsockopt","shift","shmctl","shmget","shmread","shmwrite","shutdown","sin","sleep","socket","socketpair","sort","splice","split","sprintf","sqrt","srand","stat","state","study","sub","substr","symlink","syscall","sysopen","sysread","sysseek","system","syswrite","tell","telldir","tie","tied","time","times","tr","truncate","uc","ucfirst","umask","undef","unless","unlink","unpack","unshift","untie","until","use","utime","values","vec","wait","waitpid","wantarray","warn","when","while","write","x|0","xor","y|0"],r=/[dualxmsipngr]{0,12}/,s={$pattern:/[\w.]+/,keyword:n.join(" ")},i={className:"subst",begin:"[$@]\\{",end:"\\}",keywords:s},l={begin:/->\{/,end:/\}/},c={scope:"attr",match:/\s+:\s*\w+(\s*\(.*?\))?/},u={scope:"variable",variants:[{begin:/\$\d/},{begin:e.concat(/[$%@](?!")(\^\w\b|#\w+(::\w+)*|\{\w+\}|\w+(::\w*)*)/,"(?![A-Za-z])(?![@$%])")},{begin:/[$%@](?!")[^\s\w{=]|\$=/,relevance:0}],contains:[c]},f={className:"number",variants:[{match:/0?\.[0-9][0-9_]+\b/},{match:/\bv?(0|[1-9][0-9_]*(\.[0-9_]+)?|[1-9][0-9_]*)\b/},{match:/\b0[0-7][0-7_]*\b/},{match:/\b0x[0-9a-fA-F][0-9a-fA-F_]*\b/},{match:/\b0b[0-1][0-1_]*\b/}],relevance:0},p=[t.BACKSLASH_ESCAPE,i,u],m=[/!/,/\//,/\|/,/\?/,/'/,/"/,/#/],y=(w,k,N="\\1")=>{const T=N==="\\1"?N:e.concat(N,k);return e.concat(e.concat("(?:",w,")"),k,/(?:\\.|[^\\\/])*?/,T,/(?:\\.|[^\\\/])*?/,N,r)},b=(w,k,N)=>e.concat(e.concat("(?:",w,")"),k,/(?:\\.|[^\\\/])*?/,N,r),v=[u,t.HASH_COMMENT_MODE,t.COMMENT(/^=\w/,/=cut/,{endsWithParent:!0}),l,{className:"string",contains:p,variants:[{begin:"q[qwxr]?\\s*\\(",end:"\\)",relevance:5},{begin:"q[qwxr]?\\s*\\[",end:"\\]",relevance:5},{begin:"q[qwxr]?\\s*\\{",end:"\\}",relevance:5},{begin:"q[qwxr]?\\s*\\|",end:"\\|",relevance:5},{begin:"q[qwxr]?\\s*<",end:">",relevance:5},{begin:"qw\\s+q",end:"q",relevance:5},{begin:"'",end:"'",contains:[t.BACKSLASH_ESCAPE]},{begin:'"',end:'"'},{begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE]},{begin:/\{\w+\}/,relevance:0},{begin:"-?\\w+\\s*=>",relevance:0}]},f,{begin:"(\\/\\/|"+t.RE_STARTERS_RE+"|\\b(split|return|print|reverse|grep)\\b)\\s*",keywords:"split return print reverse grep",relevance:0,contains:[t.HASH_COMMENT_MODE,{className:"regexp",variants:[{begin:y("s|tr|y",e.either(...m,{capture:!0}))},{begin:y("s|tr|y","\\(","\\)")},{begin:y("s|tr|y","\\[","\\]")},{begin:y("s|tr|y","\\{","\\}")}],relevance:2},{className:"regexp",variants:[{begin:/(m|qr)\/\//,relevance:0},{begin:b("(?:m|qr)?",/\//,/\//)},{begin:b("m|qr",e.either(...m,{capture:!0}),/\1/)},{begin:b("m|qr",/\(/,/\)/)},{begin:b("m|qr",/\[/,/\]/)},{begin:b("m|qr",/\{/,/\}/)}]}]},{className:"function",beginKeywords:"sub method",end:"(\\s*\\(.*?\\))?[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c]},{className:"class",beginKeywords:"class",end:"[;{]",excludeEnd:!0,relevance:5,contains:[t.TITLE_MODE,c,f]},{begin:"-\\w\\b",relevance:0},{begin:"^__DATA__$",end:"^__END__$",subLanguage:"mojolicious",contains:[{begin:"^@@.*",end:"$",className:"comment"}]}];return i.contains=v,l.contains=v,{name:"Perl",aliases:["pl","pm"],keywords:s,contains:v}}function hj(t){const e=t.regex,n=/(?![A-Za-z0-9])(?![$])/,r=e.concat(/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/,n),s=e.concat(/(\\?[A-Z][a-z0-9_\x7f-\xff]+|\\?[A-Z]+(?=[A-Z][a-z0-9_\x7f-\xff])){1,}/,n),i=e.concat(/[A-Z]+/,n),l={scope:"variable",match:"\\$+"+r},c={scope:"meta",variants:[{begin:/<\?php/,relevance:10},{begin:/<\?=/},{begin:/<\?/,relevance:.1},{begin:/\?>/}]},u={scope:"subst",variants:[{begin:/\$\w+/},{begin:/\{\$/,end:/\}/}]},f=t.inherit(t.APOS_STRING_MODE,{illegal:null}),p=t.inherit(t.QUOTE_STRING_MODE,{illegal:null,contains:t.QUOTE_STRING_MODE.contains.concat(u)}),m={begin:/<<<[ \t]*(?:(\w+)|"(\w+)")\n/,end:/[ \t]*(\w+)\b/,contains:t.QUOTE_STRING_MODE.contains.concat(u),"on:begin":(G,te)=>{te.data._beginMatch=G[1]||G[2]},"on:end":(G,te)=>{te.data._beginMatch!==G[1]&&te.ignoreMatch()}},y=t.END_SAME_AS_BEGIN({begin:/<<<[ \t]*'(\w+)'\n/,end:/[ \t]*(\w+)\b/}),b=`[
203
+ ]`,v={scope:"string",variants:[p,f,m,y]},w={scope:"number",variants:[{begin:"\\b0[bB][01]+(?:_[01]+)*\\b"},{begin:"\\b0[oO][0-7]+(?:_[0-7]+)*\\b"},{begin:"\\b0[xX][\\da-fA-F]+(?:_[\\da-fA-F]+)*\\b"},{begin:"(?:\\b\\d+(?:_\\d+)*(\\.(?:\\d+(?:_\\d+)*))?|\\B\\.\\d+)(?:[eE][+-]?\\d+)?"}],relevance:0},k=["false","null","true"],N=["__CLASS__","__DIR__","__FILE__","__FUNCTION__","__COMPILER_HALT_OFFSET__","__LINE__","__METHOD__","__NAMESPACE__","__TRAIT__","die","echo","exit","include","include_once","print","require","require_once","array","abstract","and","as","binary","bool","boolean","break","callable","case","catch","class","clone","const","continue","declare","default","do","double","else","elseif","empty","enddeclare","endfor","endforeach","endif","endswitch","endwhile","enum","eval","extends","final","finally","float","for","foreach","from","global","goto","if","implements","instanceof","insteadof","int","integer","interface","isset","iterable","list","match|0","mixed","new","never","object","or","private","protected","public","readonly","real","return","string","switch","throw","trait","try","unset","use","var","void","while","xor","yield"],T=["Error|0","AppendIterator","ArgumentCountError","ArithmeticError","ArrayIterator","ArrayObject","AssertionError","BadFunctionCallException","BadMethodCallException","CachingIterator","CallbackFilterIterator","CompileError","Countable","DirectoryIterator","DivisionByZeroError","DomainException","EmptyIterator","ErrorException","Exception","FilesystemIterator","FilterIterator","GlobIterator","InfiniteIterator","InvalidArgumentException","IteratorIterator","LengthException","LimitIterator","LogicException","MultipleIterator","NoRewindIterator","OutOfBoundsException","OutOfRangeException","OuterIterator","OverflowException","ParentIterator","ParseError","RangeException","RecursiveArrayIterator","RecursiveCachingIterator","RecursiveCallbackFilterIterator","RecursiveDirectoryIterator","RecursiveFilterIterator","RecursiveIterator","RecursiveIteratorIterator","RecursiveRegexIterator","RecursiveTreeIterator","RegexIterator","RuntimeException","SeekableIterator","SplDoublyLinkedList","SplFileInfo","SplFileObject","SplFixedArray","SplHeap","SplMaxHeap","SplMinHeap","SplObjectStorage","SplObserver","SplPriorityQueue","SplQueue","SplStack","SplSubject","SplTempFileObject","TypeError","UnderflowException","UnexpectedValueException","UnhandledMatchError","ArrayAccess","BackedEnum","Closure","Fiber","Generator","Iterator","IteratorAggregate","Serializable","Stringable","Throwable","Traversable","UnitEnum","WeakReference","WeakMap","Directory","__PHP_Incomplete_Class","parent","php_user_filter","self","static","stdClass"],_={keyword:N,literal:(G=>{const te=[];return G.forEach(U=>{te.push(U),U.toLowerCase()===U?te.push(U.toUpperCase()):te.push(U.toLowerCase())}),te})(k),built_in:T},M=G=>G.map(te=>te.replace(/\|\d+$/,"")),O={variants:[{match:[/new/,e.concat(b,"+"),e.concat("(?!",M(T).join("\\b|"),"\\b)"),s],scope:{1:"keyword",4:"title.class"}}]},P=e.concat(r,"\\b(?!\\()"),$={variants:[{match:[e.concat(/::/,e.lookahead(/(?!class\b)/)),P],scope:{2:"variable.constant"}},{match:[/::/,/class/],scope:{2:"variable.language"}},{match:[s,e.concat(/::/,e.lookahead(/(?!class\b)/)),P],scope:{1:"title.class",3:"variable.constant"}},{match:[s,e.concat("::",e.lookahead(/(?!class\b)/))],scope:{1:"title.class"}},{match:[s,/::/,/class/],scope:{1:"title.class",3:"variable.language"}}]},B={scope:"attr",match:e.concat(r,e.lookahead(":"),e.lookahead(/(?!::)/))},W={relevance:0,begin:/\(/,end:/\)/,keywords:_,contains:[B,l,$,t.C_BLOCK_COMMENT_MODE,v,w,O]},J={relevance:0,match:[/\b/,e.concat("(?!fn\\b|function\\b|",M(N).join("\\b|"),"|",M(T).join("\\b|"),"\\b)"),r,e.concat(b,"*"),e.lookahead(/(?=\()/)],scope:{3:"title.function.invoke"},contains:[W]};W.contains.push(J);const F=[B,$,t.C_BLOCK_COMMENT_MODE,v,w,O],re={begin:e.concat(/#\[\s*\\?/,e.either(s,i)),beginScope:"meta",end:/]/,endScope:"meta",keywords:{literal:k,keyword:["new","array"]},contains:[{begin:/\[/,end:/]/,keywords:{literal:k,keyword:["new","array"]},contains:["self",...F]},...F,{scope:"meta",variants:[{match:s},{match:i}]}]};return{case_insensitive:!1,keywords:_,contains:[re,t.HASH_COMMENT_MODE,t.COMMENT("//","$"),t.COMMENT("/\\*","\\*/",{contains:[{scope:"doctag",match:"@[A-Za-z]+"}]}),{match:/__halt_compiler\(\);/,keywords:"__halt_compiler",starts:{scope:"comment",end:t.MATCH_NOTHING_RE,contains:[{match:/\?>/,scope:"meta",endsParent:!0}]}},c,{scope:"variable.language",match:/\$this\b/},l,J,$,{match:[/const/,/\s/,r],scope:{1:"keyword",3:"variable.constant"}},O,{scope:"function",relevance:0,beginKeywords:"fn function",end:/[;{]/,excludeEnd:!0,illegal:"[$%\\[]",contains:[{beginKeywords:"use"},t.UNDERSCORE_TITLE_MODE,{begin:"=>",endsParent:!0},{scope:"params",begin:"\\(",end:"\\)",excludeBegin:!0,excludeEnd:!0,keywords:_,contains:["self",re,l,$,t.C_BLOCK_COMMENT_MODE,v,w]}]},{scope:"class",variants:[{beginKeywords:"enum",illegal:/[($"]/},{beginKeywords:"class interface trait",illegal:/[:($"]/}],relevance:0,end:/\{/,excludeEnd:!0,contains:[{beginKeywords:"extends implements"},t.UNDERSCORE_TITLE_MODE]},{beginKeywords:"namespace",relevance:0,end:";",illegal:/[.']/,contains:[t.inherit(t.UNDERSCORE_TITLE_MODE,{scope:"title.class"})]},{beginKeywords:"use",relevance:0,end:";",contains:[{match:/\b(as|const|function)\b/,scope:"keyword"},t.UNDERSCORE_TITLE_MODE]},v,w]}}function pj(t){return{name:"PHP template",subLanguage:"xml",contains:[{begin:/<\?(php|=)?/,end:/\?>/,subLanguage:"php",contains:[{begin:"/\\*",end:"\\*/",skip:!0},{begin:'b"',end:'"',skip:!0},{begin:"b'",end:"'",skip:!0},t.inherit(t.APOS_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0}),t.inherit(t.QUOTE_STRING_MODE,{illegal:null,className:null,contains:null,skip:!0})]}]}}function mj(t){return{name:"Plain text",aliases:["text","txt"],disableAutodetect:!0}}function gj(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"],c={$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"]},u={className:"meta",begin:/^(>>>|\.\.\.) /},f={className:"subst",begin:/\{/,end:/\}/,keywords:c,illegal:/#/},p={begin:/\{\{/,relevance:0},m={className:"string",contains:[t.BACKSLASH_ESCAPE],variants:[{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([uU]|[bB]|[rR]|[bB][rR]|[rR][bB])?"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u],relevance:10},{begin:/([fF][rR]|[rR][fF]|[fF])'''/,end:/'''/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"""/,end:/"""/,contains:[t.BACKSLASH_ESCAPE,u,p,f]},{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,p,f]},{begin:/([fF][rR]|[rR][fF]|[fF])"/,end:/"/,contains:[t.BACKSLASH_ESCAPE,p,f]},t.APOS_STRING_MODE,t.QUOTE_STRING_MODE]},y="[0-9](_?[0-9])*",b=`(\\b(${y}))?\\.(${y})|\\b(${y})\\.`,v=`\\b|${r.join("|")}`,w={className:"number",relevance:0,variants:[{begin:`(\\b(${y})|(${b}))[eE][+-]?(${y})[jJ]?(?=${v})`},{begin:`(${b})[jJ]?`},{begin:`\\b([1-9](_?[0-9])*|0+(_?0)*)[lLjJ]?(?=${v})`},{begin:`\\b0[bB](_?[01])+[lL]?(?=${v})`},{begin:`\\b0[oO](_?[0-7])+[lL]?(?=${v})`},{begin:`\\b0[xX](_?[0-9a-fA-F])+[lL]?(?=${v})`},{begin:`\\b(${y})[jJ](?=${v})`}]},k={className:"comment",begin:e.lookahead(/# type:/),end:/$/,keywords:c,contains:[{begin:/# type:/},{begin:/#/,end:/\b\B/,endsWithParent:!0}]},N={className:"params",variants:[{className:"",begin:/\(\s*\)/,skip:!0},{begin:/\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:["self",u,w,m,t.HASH_COMMENT_MODE]}]};return f.contains=[m,w,u],{name:"Python",aliases:["py","gyp","ipython"],unicodeRegex:!0,keywords:c,illegal:/(<\/|\?)|=>/,contains:[u,w,{scope:"variable.language",match:/\bself\b/},{beginKeywords:"if",relevance:0},{match:/\bor\b/,scope:"keyword"},m,k,t.HASH_COMMENT_MODE,{match:[/\bdef/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[N]},{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:[w,N,m]}]}}function yj(t){return{aliases:["pycon"],contains:[{className:"meta.prompt",starts:{end:/ |$/,starts:{end:"$",subLanguage:"python"}},variants:[{begin:/^>>>(?=[ ]|$)/},{begin:/^\.\.\.(?=[ ]|$)/}]}]}}function bj(t){const e=t.regex,n=/(?:(?:[a-zA-Z]|\.[._a-zA-Z])[._a-zA-Z0-9]*)|\.(?!\d)/,r=e.either(/0[xX][0-9a-fA-F]+\.[0-9a-fA-F]*[pP][+-]?\d+i?/,/0[xX][0-9a-fA-F]+(?:[pP][+-]?\d+)?[Li]?/,/(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?[Li]?/),s=/[=!<>:]=|\|\||&&|:::?|<-|<<-|->>|->|\|>|[-+*\/?!$&|:<=>@^~]|\*\*/,i=e.either(/[()]/,/[{}]/,/\[\[/,/[[\]]/,/\\/,/,/);return{name:"R",keywords:{$pattern:n,keyword:"function if in break next repeat else for while",literal:"NULL NA TRUE FALSE Inf NaN NA_integer_|10 NA_real_|10 NA_character_|10 NA_complex_|10",built_in:"LETTERS letters month.abb month.name pi T F abs acos acosh all any anyNA Arg as.call as.character as.complex as.double as.environment as.integer as.logical as.null.default as.numeric as.raw asin asinh atan atanh attr attributes baseenv browser c call ceiling class Conj cos cosh cospi cummax cummin cumprod cumsum digamma dim dimnames emptyenv exp expression floor forceAndCall gamma gc.time globalenv Im interactive invisible is.array is.atomic is.call is.character is.complex is.double is.environment is.expression is.finite is.function is.infinite is.integer is.language is.list is.logical is.matrix is.na is.name is.nan is.null is.numeric is.object is.pairlist is.raw is.recursive is.single is.symbol lazyLoadDBfetch length lgamma list log max min missing Mod names nargs nzchar oldClass on.exit pos.to.env proc.time prod quote range Re rep retracemem return round seq_along seq_len seq.int sign signif sin sinh sinpi sqrt standardGeneric substitute sum switch tan tanh tanpi tracemem trigamma trunc unclass untracemem UseMethod xtfrm"},contains:[t.COMMENT(/#'/,/$/,{contains:[{scope:"doctag",match:/@examples/,starts:{end:e.lookahead(e.either(/\n^#'\s*(?=@[a-zA-Z]+)/,/\n^(?!#')/)),endsParent:!0}},{scope:"doctag",begin:"@param",end:/$/,contains:[{scope:"variable",variants:[{match:n},{match:/`(?:\\.|[^`\\])+`/}],endsParent:!0}]},{scope:"doctag",match:/@[a-zA-Z]+/},{scope:"keyword",match:/\\[a-zA-Z]+/}]}),t.HASH_COMMENT_MODE,{scope:"string",contains:[t.BACKSLASH_ESCAPE],variants:[t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\(/,end:/\)(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\{/,end:/\}(-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]"(-*)\[/,end:/\](-*)"/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\(/,end:/\)(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\{/,end:/\}(-*)'/}),t.END_SAME_AS_BEGIN({begin:/[rR]'(-*)\[/,end:/\](-*)'/}),{begin:'"',end:'"',relevance:0},{begin:"'",end:"'",relevance:0}]},{relevance:0,variants:[{scope:{1:"operator",2:"number"},match:[s,r]},{scope:{1:"operator",2:"number"},match:[/%[^%]*%/,r]},{scope:{1:"punctuation",2:"number"},match:[i,r]},{scope:{2:"number"},match:[/[^a-zA-Z0-9._]|^/,r]}]},{scope:{3:"operator"},match:[n,/\s+/,/<-/,/\s+/]},{scope:"operator",relevance:0,variants:[{match:s},{match:/%[^%]*%/}]},{scope:"punctuation",relevance:0,match:i},{begin:"`",end:"`",contains:[{begin:/\\./}]}]}}function vj(t){const e=t.regex,n="([a-zA-Z_]\\w*[!?=]?|[-+~]@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?)",r=e.either(/\b([A-Z]+[a-z0-9]+)+/,/\b([A-Z]+[a-z0-9]+)+[A-Z]+/),s=e.concat(r,/(::\w+)*/),l={"variable.constant":["__FILE__","__LINE__","__ENCODING__"],"variable.language":["self","super"],keyword:["alias","and","begin","BEGIN","break","case","class","defined","do","else","elsif","end","END","ensure","for","if","in","module","next","not","or","redo","require","rescue","retry","return","then","undef","unless","until","when","while","yield",...["include","extend","prepend","public","private","protected","raise","throw"]],built_in:["proc","lambda","attr_accessor","attr_reader","attr_writer","define_method","private_constant","module_function"],literal:["true","false","nil"]},c={className:"doctag",begin:"@[A-Za-z]+"},u={begin:"#<",end:">"},f=[t.COMMENT("#","$",{contains:[c]}),t.COMMENT("^=begin","^=end",{contains:[c],relevance:10}),t.COMMENT("^__END__",t.MATCH_NOTHING_RE)],p={className:"subst",begin:/#\{/,end:/\}/,keywords:l},m={className:"string",contains:[t.BACKSLASH_ESCAPE,p],variants:[{begin:/'/,end:/'/},{begin:/"/,end:/"/},{begin:/`/,end:/`/},{begin:/%[qQwWx]?\(/,end:/\)/},{begin:/%[qQwWx]?\[/,end:/\]/},{begin:/%[qQwWx]?\{/,end:/\}/},{begin:/%[qQwWx]?</,end:/>/},{begin:/%[qQwWx]?\//,end:/\//},{begin:/%[qQwWx]?%/,end:/%/},{begin:/%[qQwWx]?-/,end:/-/},{begin:/%[qQwWx]?\|/,end:/\|/},{begin:/\B\?(\\\d{1,3})/},{begin:/\B\?(\\x[A-Fa-f0-9]{1,2})/},{begin:/\B\?(\\u\{?[A-Fa-f0-9]{1,6}\}?)/},{begin:/\B\?(\\M-\\C-|\\M-\\c|\\c\\M-|\\M-|\\C-\\M-)[\x20-\x7e]/},{begin:/\B\?\\(c|C-)[\x20-\x7e]/},{begin:/\B\?\\?\S/},{begin:e.concat(/<<[-~]?'?/,e.lookahead(/(\w+)(?=\W)[^\n]*\n(?:[^\n]*\n)*?\s*\1\b/)),contains:[t.END_SAME_AS_BEGIN({begin:/(\w+)/,end:/(\w+)/,contains:[t.BACKSLASH_ESCAPE,p]})]}]},y="[1-9](_?[0-9])*|0",b="[0-9](_?[0-9])*",v={className:"number",relevance:0,variants:[{begin:`\\b(${y})(\\.(${b}))?([eE][+-]?(${b})|r)?i?\\b`},{begin:"\\b0[dD][0-9](_?[0-9])*r?i?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*r?i?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*r?i?\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*r?i?\\b"},{begin:"\\b0(_?[0-7])+r?i?\\b"}]},w={variants:[{match:/\(\)/},{className:"params",begin:/\(/,end:/(?=\))/,excludeBegin:!0,endsParent:!0,keywords:l}]},O=[m,{variants:[{match:[/class\s+/,s,/\s+<\s+/,s]},{match:[/\b(class|module)\s+/,s]}],scope:{2:"title.class",4:"title.class.inherited"},keywords:l},{match:[/(include|extend)\s+/,s],scope:{2:"title.class"},keywords:l},{relevance:0,match:[s,/\.new[. (]/],scope:{1:"title.class"}},{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},{relevance:0,match:r,scope:"title.class"},{match:[/def/,/\s+/,n],scope:{1:"keyword",3:"title.function"},contains:[w]},{begin:t.IDENT_RE+"::"},{className:"symbol",begin:t.UNDERSCORE_IDENT_RE+"(!|\\?)?:",relevance:0},{className:"symbol",begin:":(?!\\s)",contains:[m,{begin:n}],relevance:0},v,{className:"variable",begin:"(\\$\\W)|((\\$|@@?)(\\w+))(?=[^@$?])(?![A-Za-z])(?![@$?'])"},{className:"params",begin:/\|(?!=)/,end:/\|/,excludeBegin:!0,excludeEnd:!0,relevance:0,keywords:l},{begin:"("+t.RE_STARTERS_RE+"|unless)\\s*",keywords:"unless",contains:[{className:"regexp",contains:[t.BACKSLASH_ESCAPE,p],illegal:/\n/,variants:[{begin:"/",end:"/[a-z]*"},{begin:/%r\{/,end:/\}[a-z]*/},{begin:"%r\\(",end:"\\)[a-z]*"},{begin:"%r!",end:"![a-z]*"},{begin:"%r\\[",end:"\\][a-z]*"}]}].concat(u,f),relevance:0}].concat(u,f);p.contains=O,w.contains=O;const W=[{begin:/^\s*=>/,starts:{end:"$",contains:O}},{className:"meta.prompt",begin:"^("+"[>?]>"+"|"+"[\\w#]+\\(\\w+\\):\\d+:\\d+[>*]"+"|"+"(\\w+-)?\\d+\\.\\d+\\.\\d+(p\\d+)?[^\\d][^>]+>"+")(?=[ ])",starts:{end:"$",keywords:l,contains:O}}];return f.unshift(u),{name:"Ruby",aliases:["rb","gemspec","podspec","thor","irb"],keywords:l,illegal:/\/\*/,contains:[t.SHEBANG({binary:"ruby"})].concat(W).concat(f).concat(O)}}function xj(t){const e=t.regex,n=/(r#)?/,r=e.concat(n,t.UNDERSCORE_IDENT_RE),s=e.concat(n,t.IDENT_RE),i={className:"title.function.invoke",relevance:0,begin:e.concat(/\b/,/(?!let|for|while|if|else|match\b)/,s,e.lookahead(/\s*\(/))},l="([ui](8|16|32|64|128|size)|f(32|64))?",c=["abstract","as","async","await","become","box","break","const","continue","crate","do","dyn","else","enum","extern","false","final","fn","for","if","impl","in","let","loop","macro","match","mod","move","mut","override","priv","pub","ref","return","self","Self","static","struct","super","trait","true","try","type","typeof","union","unsafe","unsized","use","virtual","where","while","yield"],u=["true","false","Some","None","Ok","Err"],f=["drop ","Copy","Send","Sized","Sync","Drop","Fn","FnMut","FnOnce","ToOwned","Clone","Debug","PartialEq","PartialOrd","Eq","Ord","AsRef","AsMut","Into","From","Default","Iterator","Extend","IntoIterator","DoubleEndedIterator","ExactSizeIterator","SliceConcatExt","ToString","assert!","assert_eq!","bitflags!","bytes!","cfg!","col!","concat!","concat_idents!","debug_assert!","debug_assert_eq!","env!","eprintln!","panic!","file!","format!","format_args!","include_bytes!","include_str!","line!","local_data_key!","module_path!","option_env!","print!","println!","select!","stringify!","try!","unimplemented!","unreachable!","vec!","write!","writeln!","macro_rules!","assert_ne!","debug_assert_ne!"],p=["i8","i16","i32","i64","i128","isize","u8","u16","u32","u64","u128","usize","f32","f64","str","char","bool","Box","Option","Result","String","Vec"];return{name:"Rust",aliases:["rs"],keywords:{$pattern:t.IDENT_RE+"!?",type:p,keyword:c,literal:u,built_in:f},illegal:"</",contains:[t.C_LINE_COMMENT_MODE,t.COMMENT("/\\*","\\*/",{contains:["self"]}),t.inherit(t.QUOTE_STRING_MODE,{begin:/b?"/,illegal:null}),{className:"symbol",begin:/'[a-zA-Z_][a-zA-Z0-9_]*(?!')/},{scope:"string",variants:[{begin:/b?r(#*)"(.|\n)*?"\1(?!#)/},{begin:/b?'/,end:/'/,contains:[{scope:"char.escape",match:/\\('|\w|x\w{2}|u\w{4}|U\w{8})/}]}]},{className:"number",variants:[{begin:"\\b0b([01_]+)"+l},{begin:"\\b0o([0-7_]+)"+l},{begin:"\\b0x([A-Fa-f0-9_]+)"+l},{begin:"\\b(\\d[\\d_]*(\\.[0-9_]+)?([eE][+-]?[0-9_]+)?)"+l}],relevance:0},{begin:[/fn/,/\s+/,r],className:{1:"keyword",3:"title.function"}},{className:"meta",begin:"#!?\\[",end:"\\]",contains:[{className:"string",begin:/"/,end:/"/,contains:[t.BACKSLASH_ESCAPE]}]},{begin:[/let/,/\s+/,/(?:mut\s+)?/,r],className:{1:"keyword",3:"keyword",4:"variable"}},{begin:[/for/,/\s+/,r,/\s+/,/in/],className:{1:"keyword",3:"variable",5:"keyword"}},{begin:[/type/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:[/(?:trait|enum|struct|union|impl|for)/,/\s+/,r],className:{1:"keyword",3:"title.class"}},{begin:t.IDENT_RE+"::",keywords:{keyword:"Self",built_in:f,type:p}},{className:"punctuation",begin:"->"},i]}}const wj=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_-]*/}}),kj=["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"],Sj=["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"],Ej=[...kj,...Sj],Nj=["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(),Cj=["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(),_j=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),Tj=["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 Mj(t){const e=wj(t),n=_j,r=Cj,s="@[a-z-]+",i="and or not only",c={className:"variable",begin:"(\\$"+"[a-zA-Z-][a-zA-Z0-9_-]*"+")\\b",relevance:0};return{name:"SCSS",case_insensitive:!0,illegal:"[=/|']",contains:[t.C_LINE_COMMENT_MODE,t.C_BLOCK_COMMENT_MODE,e.CSS_NUMBER_MODE,{className:"selector-id",begin:"#[A-Za-z0-9_-]+",relevance:0},{className:"selector-class",begin:"\\.[A-Za-z0-9_-]+",relevance:0},e.ATTRIBUTE_SELECTOR_MODE,{className:"selector-tag",begin:"\\b("+Ej.join("|")+")\\b",relevance:0},{className:"selector-pseudo",begin:":("+r.join("|")+")"},{className:"selector-pseudo",begin:":(:)?("+n.join("|")+")"},c,{begin:/\(/,end:/\)/,contains:[e.CSS_NUMBER_MODE]},e.CSS_VARIABLE,{className:"attribute",begin:"\\b("+Tj.join("|")+")\\b"},{begin:"\\b(whitespace|wait|w-resize|visible|vertical-text|vertical-ideographic|uppercase|upper-roman|upper-alpha|underline|transparent|top|thin|thick|text|text-top|text-bottom|tb-rl|table-header-group|table-footer-group|sw-resize|super|strict|static|square|solid|small-caps|separate|se-resize|scroll|s-resize|rtl|row-resize|ridge|right|repeat|repeat-y|repeat-x|relative|progress|pointer|overline|outside|outset|oblique|nowrap|not-allowed|normal|none|nw-resize|no-repeat|no-drop|newspaper|ne-resize|n-resize|move|middle|medium|ltr|lr-tb|lowercase|lower-roman|lower-alpha|loose|list-item|line|line-through|line-edge|lighter|left|keep-all|justify|italic|inter-word|inter-ideograph|inside|inset|inline|inline-block|inherit|inactive|ideograph-space|ideograph-parenthesis|ideograph-numeric|ideograph-alpha|horizontal|hidden|help|hand|groove|fixed|ellipsis|e-resize|double|dotted|distribute|distribute-space|distribute-letter|distribute-all-lines|disc|disabled|default|decimal|dashed|crosshair|collapse|col-resize|circle|char|center|capitalize|break-word|break-all|bottom|both|bolder|bold|block|bidi-override|below|baseline|auto|always|all-scroll|absolute|table|table-cell)\\b"},{begin:/:/,end:/[;}{]/,relevance:0,contains:[e.BLOCK_COMMENT,c,e.HEXCOLOR,e.CSS_NUMBER_MODE,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.IMPORTANT,e.FUNCTION_DISPATCH]},{begin:"@(page|font-face)",keywords:{$pattern:s,keyword:"@page @font-face"}},{begin:"@",end:"[{;]",returnBegin:!0,keywords:{$pattern:/[a-z-]+/,keyword:i,attribute:Nj.join(" ")},contains:[{begin:s,className:"keyword"},{begin:/[a-z-]+(?=:)/,className:"attribute"},c,t.QUOTE_STRING_MODE,t.APOS_STRING_MODE,e.HEXCOLOR,e.CSS_NUMBER_MODE]},e.FUNCTION_DISPATCH]}}function Aj(t){return{name:"Shell Session",aliases:["console","shellsession"],contains:[{className:"meta.prompt",begin:/^\s{0,3}[/~\w\d[\]()@-]*[>%$#][ ]?/,starts:{end:/[^\\](?=\s*$)/,subLanguage:"bash"}}]}}function Oj(t){const e=t.regex,n=t.COMMENT("--","$"),r={scope:"string",variants:[{begin:/'/,end:/'/,contains:[{match:/''/}]}]},s={begin:/"/,end:/"/,contains:[{match:/""/}]},i=["true","false","unknown"],l=["double precision","large object","with timezone","without timezone"],c=["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"],u=["add","asc","collation","desc","final","first","last","view"],f=["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"],p=["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"],m=["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"],y=["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"],b=p,v=[...f,...u].filter(M=>!p.includes(M)),w={scope:"variable",match:/@[a-z0-9][a-z0-9_]*/},k={scope:"operator",match:/[-+*/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?/,relevance:0},N={match:e.concat(/\b/,e.either(...b),/\s*\(/),relevance:0,keywords:{built_in:b}};function T(M){return e.concat(/\b/,e.either(...M.map(O=>O.replace(/\s+/,"\\s+"))),/\b/)}const I={scope:"keyword",match:T(y),relevance:0};function _(M,{exceptions:O,when:P}={}){const $=P;return O=O||[],M.map(B=>B.match(/\|\d+$/)||O.includes(B)?B:$(B)?`${B}|0`:B)}return{name:"SQL",case_insensitive:!0,illegal:/[{}]|<\//,keywords:{$pattern:/\b[\w\.]+/,keyword:_(v,{when:M=>M.length<3}),literal:i,type:c,built_in:m},contains:[{scope:"type",match:T(l)},I,N,w,r,s,t.C_NUMBER_MODE,t.C_BLOCK_COMMENT_MODE,n,k]}}function l1(t){return t?typeof t=="string"?t:t.source:null}function yl(t){return Nt("(?=",t,")")}function Nt(...t){return t.map(n=>l1(n)).join("")}function Rj(t){const e=t[t.length-1];return typeof e=="object"&&e.constructor===Object?(t.splice(t.length-1,1),e):{}}function Fn(...t){return"("+(Rj(t).capture?"":"?:")+t.map(r=>l1(r)).join("|")+")"}const hm=t=>Nt(/\b/,t,/\w$/.test(t)?/\b/:/\B/),Ij=["Protocol","Type"].map(hm),Jv=["init","self"].map(hm),jj=["Any","Self"],Eh=["actor","any","associatedtype","async","await",/as\?/,/as!/,"as","borrowing","break","case","catch","class","consume","consuming","continue","convenience","copy","default","defer","deinit","didSet","distributed","do","dynamic","each","else","enum","extension","fallthrough",/fileprivate\(set\)/,"fileprivate","final","for","func","get","guard","if","import","indirect","infix",/init\?/,/init!/,"inout",/internal\(set\)/,"internal","in","is","isolated","nonisolated","lazy","let","macro","mutating","nonmutating",/open\(set\)/,"open","operator","optional","override","package","postfix","precedencegroup","prefix",/private\(set\)/,"private","protocol",/public\(set\)/,"public","repeat","required","rethrows","return","set","some","static","struct","subscript","super","switch","throws","throw",/try\?/,/try!/,"try","typealias",/unowned\(safe\)/,/unowned\(unsafe\)/,"unowned","var","weak","where","while","willSet"],Yv=["false","nil","true"],Lj=["assignment","associativity","higherThan","left","lowerThan","none","right"],Dj=["#colorLiteral","#column","#dsohandle","#else","#elseif","#endif","#error","#file","#fileID","#fileLiteral","#filePath","#function","#if","#imageLiteral","#keyPath","#line","#selector","#sourceLocation","#warning"],Qv=["abs","all","any","assert","assertionFailure","debugPrint","dump","fatalError","getVaList","isKnownUniquelyReferenced","max","min","numericCast","pointwiseMax","pointwiseMin","precondition","preconditionFailure","print","readLine","repeatElement","sequence","stride","swap","swift_unboxFromSwiftValueWithType","transcode","type","unsafeBitCast","unsafeDowncast","withExtendedLifetime","withUnsafeMutablePointer","withUnsafePointer","withVaList","withoutActuallyEscaping","zip"],a1=Fn(/[/=\-+!*%<>&|^~?]/,/[\u00A1-\u00A7]/,/[\u00A9\u00AB]/,/[\u00AC\u00AE]/,/[\u00B0\u00B1]/,/[\u00B6\u00BB\u00BF\u00D7\u00F7]/,/[\u2016-\u2017]/,/[\u2020-\u2027]/,/[\u2030-\u203E]/,/[\u2041-\u2053]/,/[\u2055-\u205E]/,/[\u2190-\u23FF]/,/[\u2500-\u2775]/,/[\u2794-\u2BFF]/,/[\u2E00-\u2E7F]/,/[\u3001-\u3003]/,/[\u3008-\u3020]/,/[\u3030]/),c1=Fn(a1,/[\u0300-\u036F]/,/[\u1DC0-\u1DFF]/,/[\u20D0-\u20FF]/,/[\uFE00-\uFE0F]/,/[\uFE20-\uFE2F]/),Nh=Nt(a1,c1,"*"),u1=Fn(/[a-zA-Z_]/,/[\u00A8\u00AA\u00AD\u00AF\u00B2-\u00B5\u00B7-\u00BA]/,/[\u00BC-\u00BE\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u00FF]/,/[\u0100-\u02FF\u0370-\u167F\u1681-\u180D\u180F-\u1DBF]/,/[\u1E00-\u1FFF]/,/[\u200B-\u200D\u202A-\u202E\u203F-\u2040\u2054\u2060-\u206F]/,/[\u2070-\u20CF\u2100-\u218F\u2460-\u24FF\u2776-\u2793]/,/[\u2C00-\u2DFF\u2E80-\u2FFF]/,/[\u3004-\u3007\u3021-\u302F\u3031-\u303F\u3040-\uD7FF]/,/[\uF900-\uFD3D\uFD40-\uFDCF\uFDF0-\uFE1F\uFE30-\uFE44]/,/[\uFE47-\uFEFE\uFF00-\uFFFD]/),Iu=Fn(u1,/\d/,/[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE20-\uFE2F]/),zr=Nt(u1,Iu,"*"),Tc=Nt(/[A-Z]/,Iu,"*"),Pj=["attached","autoclosure",Nt(/convention\(/,Fn("swift","block","c"),/\)/),"discardableResult","dynamicCallable","dynamicMemberLookup","escaping","freestanding","frozen","GKInspectable","IBAction","IBDesignable","IBInspectable","IBOutlet","IBSegueAction","inlinable","main","nonobjc","NSApplicationMain","NSCopying","NSManaged",Nt(/objc\(/,zr,/\)/),"objc","objcMembers","propertyWrapper","requires_stored_property_inits","resultBuilder","Sendable","testable","UIApplicationMain","unchecked","unknown","usableFromInline","warn_unqualified_access"],Bj=["iOS","iOSApplicationExtension","macOS","macOSApplicationExtension","macCatalyst","macCatalystApplicationExtension","watchOS","watchOSApplicationExtension","tvOS","tvOSApplicationExtension","swift"];function zj(t){const e={match:/\s+/,relevance:0},n=t.COMMENT("/\\*","\\*/",{contains:["self"]}),r=[t.C_LINE_COMMENT_MODE,n],s={match:[/\./,Fn(...Ij,...Jv)],className:{2:"keyword"}},i={match:Nt(/\./,Fn(...Eh)),relevance:0},l=Eh.filter(Ee=>typeof Ee=="string").concat(["_|0"]),c=Eh.filter(Ee=>typeof Ee!="string").concat(jj).map(hm),u={variants:[{className:"keyword",match:Fn(...c,...Jv)}]},f={$pattern:Fn(/\b\w+/,/#\w+/),keyword:l.concat(Dj),literal:Yv},p=[s,i,u],m={match:Nt(/\./,Fn(...Qv)),relevance:0},y={className:"built_in",match:Nt(/\b/,Fn(...Qv),/(?=\()/)},b=[m,y],v={match:/->/,relevance:0},w={className:"operator",relevance:0,variants:[{match:Nh},{match:`\\.(\\.|${c1})+`}]},k=[v,w],N="([0-9]_*)+",T="([0-9a-fA-F]_*)+",I={className:"number",relevance:0,variants:[{match:`\\b(${N})(\\.(${N}))?([eE][+-]?(${N}))?\\b`},{match:`\\b0x(${T})(\\.(${T}))?([pP][+-]?(${N}))?\\b`},{match:/\b0o([0-7]_*)+\b/},{match:/\b0b([01]_*)+\b/}]},_=(Ee="")=>({className:"subst",variants:[{match:Nt(/\\/,Ee,/[0\\tnr"']/)},{match:Nt(/\\/,Ee,/u\{[0-9a-fA-F]{1,8}\}/)}]}),M=(Ee="")=>({className:"subst",match:Nt(/\\/,Ee,/[\t ]*(?:[\r\n]|\r\n)/)}),O=(Ee="")=>({className:"subst",label:"interpol",begin:Nt(/\\/,Ee,/\(/),end:/\)/}),P=(Ee="")=>({begin:Nt(Ee,/"""/),end:Nt(/"""/,Ee),contains:[_(Ee),M(Ee),O(Ee)]}),$=(Ee="")=>({begin:Nt(Ee,/"/),end:Nt(/"/,Ee),contains:[_(Ee),O(Ee)]}),B={className:"string",variants:[P(),P("#"),P("##"),P("###"),$(),$("#"),$("##"),$("###")]},W=[t.BACKSLASH_ESCAPE,{begin:/\[/,end:/\]/,relevance:0,contains:[t.BACKSLASH_ESCAPE]}],J={begin:/\/[^\s](?=[^/\n]*\/)/,end:/\//,contains:W},F=Ee=>{const Qe=Nt(Ee,/\//),tt=Nt(/\//,Ee);return{begin:Qe,end:tt,contains:[...W,{scope:"comment",begin:`#(?!.*${tt})`,end:/$/}]}},re={scope:"regexp",variants:[F("###"),F("##"),F("#"),J]},G={match:Nt(/`/,zr,/`/)},te={className:"variable",match:/\$\d+/},U={className:"variable",match:`\\$${Iu}+`},ne=[G,te,U],H={match:/(@|#(un)?)available/,scope:"keyword",starts:{contains:[{begin:/\(/,end:/\)/,keywords:Bj,contains:[...k,I,B]}]}},X={scope:"keyword",match:Nt(/@/,Fn(...Pj),yl(Fn(/\(/,/\s+/)))},K={scope:"meta",match:Nt(/@/,zr)},A=[H,X,K],R={match:yl(/\b[A-Z]/),relevance:0,contains:[{className:"type",match:Nt(/(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)/,Iu,"+")},{className:"type",match:Tc,relevance:0},{match:/[?!]+/,relevance:0},{match:/\.\.\./,relevance:0},{match:Nt(/\s+&\s+/,yl(Tc)),relevance:0}]},Y={begin:/</,end:/>/,keywords:f,contains:[...r,...p,...A,v,R]};R.contains.push(Y);const se={match:Nt(zr,/\s*:/),keywords:"_|0",relevance:0},fe={begin:/\(/,end:/\)/,relevance:0,keywords:f,contains:["self",se,...r,re,...p,...b,...k,I,B,...ne,...A,R]},Z={begin:/</,end:/>/,keywords:"repeat each",contains:[...r,R]},me={begin:Fn(yl(Nt(zr,/\s*:/)),yl(Nt(zr,/\s+/,zr,/\s*:/))),end:/:/,relevance:0,contains:[{className:"keyword",match:/\b_\b/},{className:"params",match:zr}]},Le={begin:/\(/,end:/\)/,keywords:f,contains:[me,...r,...p,...k,I,B,...A,R,fe],endsParent:!0,illegal:/["']/},Ze={match:[/(func|macro)/,/\s+/,Fn(G.match,zr,Nh)],className:{1:"keyword",3:"title.function"},contains:[Z,Le,e],illegal:[/\[/,/%/]},ce={match:[/\b(?:subscript|init[?!]?)/,/\s*(?=[<(])/],className:{1:"keyword"},contains:[Z,Le,e],illegal:/\[|%/},ve={match:[/operator/,/\s+/,Nh],className:{1:"keyword",3:"title"}},ie={begin:[/precedencegroup/,/\s+/,Tc],className:{1:"keyword",3:"title"},contains:[R],keywords:[...Lj,...Yv],end:/}/},Be={match:[/class\b/,/\s+/,/func\b/,/\s+/,/\b[A-Za-z_][A-Za-z0-9_]*\b/],scope:{1:"keyword",3:"keyword",5:"title.function"}},Te={match:[/class\b/,/\s+/,/var\b/],scope:{1:"keyword",3:"keyword"}},Ue={begin:[/(struct|protocol|class|extension|enum|actor)/,/\s+/,zr,/\s*/],beginScope:{1:"keyword",3:"title.class"},keywords:f,contains:[Z,...p,{begin:/:/,end:/\{/,keywords:f,contains:[{scope:"title.class.inherited",match:Tc},...p],relevance:0}]};for(const Ee of B.variants){const Qe=Ee.contains.find(vt=>vt.label==="interpol");Qe.keywords=f;const tt=[...p,...b,...k,I,B,...ne];Qe.contains=[...tt,{begin:/\(/,end:/\)/,contains:["self",...tt]}]}return{name:"Swift",keywords:f,contains:[...r,Ze,ce,Be,Te,Ue,ve,ie,{beginKeywords:"import",end:/$/,contains:[...r],relevance:0},re,...p,...b,...k,I,B,...ne,...A,R,fe]}}const ju="[A-Za-z$_][0-9A-Za-z$_]*",d1=["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"],f1=["true","false","null","undefined","NaN","Infinity"],h1=["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"],p1=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],m1=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],g1=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],y1=[].concat(m1,h1,p1);function $j(t){const e=t.regex,n=(H,{after:X})=>{const K="</"+H[0].slice(1);return H.input.indexOf(K,X)!==-1},r=ju,s={begin:"<>",end:"</>"},i=/<[A-Za-z0-9\\._:-]+\s*\/>/,l={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(H,X)=>{const K=H[0].length+H.index,A=H.input[K];if(A==="<"||A===","){X.ignoreMatch();return}A===">"&&(n(H,{after:K})||X.ignoreMatch());let R;const Y=H.input.substring(K);if(R=Y.match(/^\s*=/)){X.ignoreMatch();return}if((R=Y.match(/^\s+extends\s+/))&&R.index===0){X.ignoreMatch();return}}},c={$pattern:ju,keyword:d1,literal:f1,built_in:y1,"variable.language":g1},u="[0-9](_?[0-9])*",f=`\\.(${u})`,p="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",m={className:"number",variants:[{begin:`(\\b(${p})((${f})|\\.)?|(${f}))[eE][+-]?(${u})\\b`},{begin:`\\b(${p})\\b((${f})\\b|\\.)?|(${f})\\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},y={className:"subst",begin:"\\$\\{",end:"\\}",keywords:c,contains:[]},b={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"xml"}},v={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"css"}},w={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[t.BACKSLASH_ESCAPE,y],subLanguage:"graphql"}},k={className:"string",begin:"`",end:"`",contains:[t.BACKSLASH_ESCAPE,y]},T={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]},I=[t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,{match:/\$\d+/},m];y.contains=I.concat({begin:/\{/,end:/\}/,keywords:c,contains:["self"].concat(I)});const _=[].concat(T,y.contains),M=_.concat([{begin:/(\s*)\(/,end:/\)/,keywords:c,contains:["self"].concat(_)}]),O={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:c,contains:M},P={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"}}]},$={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:{_:[...h1,...p1]}},B={label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},W={variants:[{match:[/function/,/\s+/,r,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[O],illegal:/%/},J={relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"};function F(H){return e.concat("(?!",H.join("|"),")")}const re={match:e.concat(/\b/,F([...m1,"super","import"].map(H=>`${H}\\s*\\(`)),r,e.lookahead(/\s*\(/)),className:"title.function",relevance:0},G={begin:e.concat(/\./,e.lookahead(e.concat(r,/(?![0-9A-Za-z$_(])/))),end:r,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},te={match:[/get|set/,/\s+/,r,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},O]},U="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+t.UNDERSCORE_IDENT_RE+")\\s*=>",ne={match:[/const|var|let/,/\s+/,r,/\s*/,/=\s*/,/(async\s*)?/,e.lookahead(U)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[O]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:c,exports:{PARAMS_CONTAINS:M,CLASS_REFERENCE:$},illegal:/#(?![$_A-z])/,contains:[t.SHEBANG({label:"shebang",binary:"node",relevance:5}),B,t.APOS_STRING_MODE,t.QUOTE_STRING_MODE,b,v,w,k,T,{match:/\$\d+/},m,$,{scope:"attr",match:r+e.lookahead(":"),relevance:0},ne,{begin:"("+t.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[T,t.REGEXP_MODE,{className:"function",begin:U,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:c,contains:M}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:s.begin,end:s.end},{match:i},{begin:l.begin,"on:begin":l.isTrulyOpeningTag,end:l.end}],subLanguage:"xml",contains:[{begin:l.begin,end:l.end,skip:!0,contains:["self"]}]}]},W,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+t.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[O,t.inherit(t.TITLE_MODE,{begin:r,className:"title.function"})]},{match:/\.\.\./,relevance:0},G,{match:"\\$"+r,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[O]},re,J,P,te,{match:/\$[(.]/}]}}function Fj(t){const e=t.regex,n=$j(t),r=ju,s=["any","void","number","boolean","string","object","never","symbol","bigint","unknown"],i={begin:[/namespace/,/\s+/,t.IDENT_RE],beginScope:{1:"keyword",3:"title.class"}},l={beginKeywords:"interface",end:/\{/,excludeEnd:!0,keywords:{keyword:"interface extends",built_in:s},contains:[n.exports.CLASS_REFERENCE]},c={className:"meta",relevance:10,begin:/^\s*['"]use strict['"]/},u=["type","interface","public","private","protected","implements","declare","abstract","readonly","enum","override","satisfies"],f={$pattern:ju,keyword:d1.concat(u),literal:f1,built_in:y1.concat(s),"variable.language":g1},p={className:"meta",begin:"@"+r},m=(w,k,N)=>{const T=w.contains.findIndex(I=>I.label===k);if(T===-1)throw new Error("can not find mode to replace");w.contains.splice(T,1,N)};Object.assign(n.keywords,f),n.exports.PARAMS_CONTAINS.push(p);const y=n.contains.find(w=>w.scope==="attr"),b=Object.assign({},y,{match:e.concat(r,e.lookahead(/\s*\?:/))});n.exports.PARAMS_CONTAINS.push([n.exports.CLASS_REFERENCE,y,b]),n.contains=n.contains.concat([p,i,l,b]),m(n,"shebang",t.SHEBANG()),m(n,"use_strict",c);const v=n.contains.find(w=>w.label==="func.def");return v.relevance=0,Object.assign(n,{name:"TypeScript",aliases:["ts","tsx","mts","cts"]}),n}function Uj(t){const e=t.regex,n={className:"string",begin:/"(""|[^/n])"C\b/},r={className:"string",begin:/"/,end:/"/,illegal:/\n/,contains:[{begin:/""/}]},s=/\d{1,2}\/\d{1,2}\/\d{4}/,i=/\d{4}-\d{1,2}-\d{1,2}/,l=/(\d|1[012])(:\d+){0,2} *(AM|PM)/,c=/\d{1,2}(:\d{1,2}){1,2}/,u={className:"literal",variants:[{begin:e.concat(/# */,e.either(i,s),/ *#/)},{begin:e.concat(/# */,c,/ *#/)},{begin:e.concat(/# */,l,/ *#/)},{begin:e.concat(/# */,e.either(i,s),/ +/,e.either(l,c),/ *#/)}]},f={className:"number",relevance:0,variants:[{begin:/\b\d[\d_]*((\.[\d_]+(E[+-]?[\d_]+)?)|(E[+-]?[\d_]+))[RFD@!#]?/},{begin:/\b\d[\d_]*((U?[SIL])|[%&])?/},{begin:/&H[\dA-F_]+((U?[SIL])|[%&])?/},{begin:/&O[0-7_]+((U?[SIL])|[%&])?/},{begin:/&B[01_]+((U?[SIL])|[%&])?/}]},p={className:"label",begin:/^\w+:/},m=t.COMMENT(/'''/,/$/,{contains:[{className:"doctag",begin:/<\/?/,end:/>/}]}),y=t.COMMENT(null,/$/,{variants:[{begin:/'/},{begin:/([\t ]|^)REM(?=\s)/}]});return{name:"Visual Basic .NET",aliases:["vb"],case_insensitive:!0,classNameAliases:{label:"symbol"},keywords:{keyword:"addhandler alias aggregate ansi as async assembly auto binary by byref byval call case catch class compare const continue custom declare default delegate dim distinct do each equals else elseif end enum erase error event exit explicit finally for friend from function get global goto group handles if implements imports in inherits interface into iterator join key let lib loop me mid module mustinherit mustoverride mybase myclass namespace narrowing new next notinheritable notoverridable of off on operator option optional order overloads overridable overrides paramarray partial preserve private property protected public raiseevent readonly redim removehandler resume return select set shadows shared skip static step stop structure strict sub synclock take text then throw to try unicode until using when where while widening with withevents writeonly yield",built_in:"addressof and andalso await directcast gettype getxmlnamespace is isfalse isnot istrue like mod nameof new not or orelse trycast typeof xor cbool cbyte cchar cdate cdbl cdec cint clng cobj csbyte cshort csng cstr cuint culng cushort",type:"boolean byte char date decimal double integer long object sbyte short single string uinteger ulong ushort",literal:"true false nothing"},illegal:"//|\\{|\\}|endif|gosub|variant|wend|^\\$ ",contains:[n,r,u,f,p,m,y,{className:"meta",begin:/[\t ]*#(const|disable|else|elseif|enable|end|externalsource|if|region)\b/,end:/$/,keywords:{keyword:"const disable else elseif enable end externalsource if region then"},contains:[y]}]}}function Hj(t){t.regex;const e=t.COMMENT(/\(;/,/;\)/);e.contains.push("self");const n=t.COMMENT(/;;/,/$/),r=["anyfunc","block","br","br_if","br_table","call","call_indirect","data","drop","elem","else","end","export","func","global.get","global.set","local.get","local.set","local.tee","get_global","get_local","global","if","import","local","loop","memory","memory.grow","memory.size","module","mut","nop","offset","param","result","return","select","set_global","set_local","start","table","tee_local","then","type","unreachable"],s={begin:[/(?:func|call|call_indirect)/,/\s+/,/\$[^\s)]+/],className:{1:"keyword",3:"title.function"}},i={className:"variable",begin:/\$[\w_]+/},l={match:/(\((?!;)|\))+/,className:"punctuation",relevance:0},c={className:"number",relevance:0,match:/[+-]?\b(?:\d(?:_?\d)*(?:\.\d(?:_?\d)*)?(?:[eE][+-]?\d(?:_?\d)*)?|0x[\da-fA-F](?:_?[\da-fA-F])*(?:\.[\da-fA-F](?:_?[\da-fA-D])*)?(?:[pP][+-]?\d(?:_?\d)*)?)\b|\binf\b|\bnan(?::0x[\da-fA-F](?:_?[\da-fA-D])*)?\b/},u={match:/(i32|i64|f32|f64)(?!\.)/,className:"type"},f={className:"keyword",match:/\b(f32|f64|i32|i64)(?:\.(?:abs|add|and|ceil|clz|const|convert_[su]\/i(?:32|64)|copysign|ctz|demote\/f64|div(?:_[su])?|eqz?|extend_[su]\/i32|floor|ge(?:_[su])?|gt(?:_[su])?|le(?:_[su])?|load(?:(?:8|16|32)_[su])?|lt(?:_[su])?|max|min|mul|nearest|neg?|or|popcnt|promote\/f32|reinterpret\/[fi](?:32|64)|rem_[su]|rot[lr]|shl|shr_[su]|store(?:8|16|32)?|sqrt|sub|trunc(?:_[su]\/f(?:32|64))?|wrap\/i64|xor))\b/};return{name:"WebAssembly",keywords:{$pattern:/[\w.]+/,keyword:r},contains:[n,e,{match:[/(?:offset|align)/,/\s*/,/=/],className:{1:"keyword",3:"operator"}},i,l,s,t.QUOTE_STRING_MODE,u,f,c]}}function Wj(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]+;/},i={begin:/\s/,contains:[{className:"keyword",begin:/#?[a-z_][a-z1-9_-]+/,illegal:/\n/}]},l=t.inherit(i,{begin:/\(/,end:/\)/}),c=t.inherit(t.APOS_STRING_MODE,{className:"string"}),u=t.inherit(t.QUOTE_STRING_MODE,{className:"string"}),f={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:[i,u,c,l,{begin:/\[/,end:/\]/,contains:[{className:"meta",begin:/<![a-z]/,end:/>/,contains:[i,l,u,c]}]}]},t.COMMENT(/<!--/,/-->/,{relevance:10}),{begin:/<!\[CDATA\[/,end:/\]\]>/,relevance:10},s,{className:"meta",end:/\?>/,variants:[{begin:/<\?xml/,relevance:10,contains:[u]},{begin:/<\?[a-z][a-z0-9]+/}]},{className:"tag",begin:/<style(?=\s|>)/,end:/>/,keywords:{name:"style"},contains:[f],starts:{end:/<\/style>/,returnEnd:!0,subLanguage:["css","xml"]}},{className:"tag",begin:/<script(?=\s|>)/,end:/>/,keywords:{name:"script"},contains:[f],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:f}]},{className:"tag",begin:e.concat(/<\//,e.lookahead(e.concat(n,/>/))),contains:[{className:"name",begin:n,relevance:0},{begin:/>/,relevance:0,endsParent:!0}]}]}}function Vj(t){const e="true false yes no null",n="[\\w#;/?:@&=+$,.~*'()[\\]]+",r={className:"attr",variants:[{begin:/[\w*@][\w*@ :()\./-]*:(?=[ \t]|$)/},{begin:/"[\w*@][\w*@ :()\./-]*":(?=[ \t]|$)/},{begin:/'[\w*@][\w*@ :()\./-]*':(?=[ \t]|$)/}]},s={className:"template-variable",variants:[{begin:/\{\{/,end:/\}\}/},{begin:/%\{/,end:/\}/}]},i={className:"string",relevance:0,begin:/'/,end:/'/,contains:[{match:/''/,scope:"char.escape",relevance:0}]},l={className:"string",relevance:0,variants:[{begin:/"/,end:/"/},{begin:/\S+/}],contains:[t.BACKSLASH_ESCAPE,s]},c=t.inherit(l,{variants:[{begin:/'/,end:/'/,contains:[{begin:/''/,relevance:0}]},{begin:/"/,end:/"/},{begin:/[^\s,{}[\]]+/}]}),y={className:"number",begin:"\\b"+"[0-9]{4}(-[0-9][0-9]){0,2}"+"([Tt \\t][0-9][0-9]?(:[0-9][0-9]){2})?"+"(\\.[0-9]*)?"+"([ \\t])*(Z|[-+][0-9][0-9]?(:[0-9][0-9])?)?"+"\\b"},b={end:",",endsWithParent:!0,excludeEnd:!0,keywords:e,relevance:0},v={begin:/\{/,end:/\}/,contains:[b],illegal:"\\n",relevance:0},w={begin:"\\[",end:"\\]",contains:[b],illegal:"\\n",relevance:0},k=[r,{className:"meta",begin:"^---\\s*$",relevance:10},{className:"string",begin:"[\\|>]([1-9]?[+-])?[ ]*\\n( +)[^ ][^\\n]*\\n(\\2[^\\n]+\\n?)*"},{begin:"<%[%=-]?",end:"[%-]?%>",subLanguage:"ruby",excludeBegin:!0,excludeEnd:!0,relevance:0},{className:"type",begin:"!\\w+!"+n},{className:"type",begin:"!<"+n+">"},{className:"type",begin:"!"+n},{className:"type",begin:"!!"+n},{className:"meta",begin:"&"+t.UNDERSCORE_IDENT_RE+"$"},{className:"meta",begin:"\\*"+t.UNDERSCORE_IDENT_RE+"$"},{className:"bullet",begin:"-(?=[ ]|$)",relevance:0},t.HASH_COMMENT_MODE,{beginKeywords:e,keywords:{literal:e}},y,{className:"number",begin:t.C_NUMBER_RE+"\\b",relevance:0},v,w,i,l],N=[...k];return N.pop(),N.push(c),b.contains=N,{name:"YAML",case_insensitive:!0,aliases:["yml"],contains:k}}const Kj={arduino:_I,bash:TI,c:MI,cpp:AI,csharp:OI,css:$I,diff:FI,go:UI,graphql:HI,ini:WI,java:VI,javascript:YI,json:QI,kotlin:ZI,less:lj,lua:aj,makefile:cj,markdown:uj,objectivec:dj,perl:fj,php:hj,"php-template":pj,plaintext:mj,python:gj,"python-repl":yj,r:bj,ruby:vj,rust:xj,scss:Mj,shell:Aj,sql:Oj,swift:zj,typescript:Fj,vbnet:Uj,wasm:Hj,xml:Wj,yaml:Vj},Xv={},Gj="hljs-";function qj(t){const e=Zk.newInstance();return t&&i(t),{highlight:n,highlightAuto:r,listLanguages:s,register:i,registerAlias:l,registered:c};function n(u,f,p){const m=p||Xv,y=typeof m.prefix=="string"?m.prefix:Gj;if(!e.getLanguage(u))throw new Error("Unknown language: `"+u+"` is not registered");e.configure({__emitter:Jj,classPrefix:y});const b=e.highlight(f,{ignoreIllegals:!0,language:u});if(b.errorRaised)throw new Error("Could not highlight with `Highlight.js`",{cause:b.errorRaised});const v=b._emitter.root,w=v.data;return w.language=b.language,w.relevance=b.relevance,v}function r(u,f){const m=(f||Xv).subset||s();let y=-1,b=0,v;for(;++y<m.length;){const w=m[y];if(!e.getLanguage(w))continue;const k=n(w,u,f);k.data&&k.data.relevance!==void 0&&k.data.relevance>b&&(b=k.data.relevance,v=k)}return v||{type:"root",children:[],data:{language:void 0,relevance:b}}}function s(){return e.listLanguages()}function i(u,f){if(typeof u=="string")e.registerLanguage(u,f);else{let p;for(p in u)Object.hasOwn(u,p)&&e.registerLanguage(p,u[p])}}function l(u,f){if(typeof u=="string")e.registerAliases(typeof f=="string"?f:[...f],{languageName:u});else{let p;for(p in u)if(Object.hasOwn(u,p)){const m=u[p];e.registerAliases(typeof m=="string"?m:[...m],{languageName:p})}}}function c(u){return!!e.getLanguage(u)}}class Jj{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(l,c){return c?l+"_".repeat(c):n.options.classPrefix+l}),s=this.stack[this.stack.length-1],i={type:"element",tagName:"span",properties:{className:r},children:[]};s.children.push(i),this.stack.push(i)}closeNode(){this.stack.pop()}finalize(){}toHTML(){return""}}const Yj=new Ot("blurredLoadingNode"),pm=gt.create({name:"blurredLoadingNode",addStorage(){return{loadingNodes:{}}},addCommands(){return{applyLoadingEffect:(t,e,n,r="paragraph")=>({editor:s})=>{const i={...this.storage.loadingNodes};return i[t]={from:e,to:n,id:t,active:!0,type:r},this.storage.loadingNodes=i,s.view.dispatch(s.view.state.tr),setTimeout(()=>{s.isFocused&&s.commands.setTextSelection({from:e,to:e})},0),!0},removeLoadingEffect:t=>({editor:e})=>{const n={...this.storage.loadingNodes};return n[t]&&(delete n[t],this.storage.loadingNodes=n,e.view.dispatch(e.view.state.tr),e.isFocused||setTimeout(()=>{e.commands.focus()},0)),!0}}},addProseMirrorPlugins(){return[new kt({key:Yj,props:{decorations:t=>{const e=this.storage.loadingNodes,n=[];return Object.entries(e).forEach(([,r])=>{const s=r;if(!s.active)return;const{from:i,to:l,type:c}=s;c==="selection"?n.push(jt.inline(i,l,{class:"node-blur-selection"})):t.doc.nodesBetween(i,l,(u,f)=>["paragraph","heading","blockquote","listItem","codeBlock"].includes(u.type.name)?(n.push(jt.node(f,f+u.nodeSize,{class:"node-blur-effect"})),!1):!0)}),bt.create(t.doc,n)}}})]}}),Qj=["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","taskList","taskItem","image"],mm=gt.create({name:"pendingAttributes",addGlobalAttributes(){return[{types:Qj,attributes:{pendingStatus:{default:null,parseHTML:t=>t.getAttribute("data-pending-status")||null,renderHTML:t=>t.pendingStatus?{"data-pending-status":t.pendingStatus}:{}},pendingOriginalContent:{default:null,rendered:!1},pendingSelectionFrom:{default:null,rendered:!1},pendingSelectionTo:{default:null,rendered:!1},pendingOriginalFrom:{default:null,rendered:!1},pendingOriginalTo:{default:null,rendered:!1},pendingGroupId:{default:null,rendered:!1}}}]}}),Xj=qj(Kj),gm=f2.extend({addAttributes(){var t;return{...(t=this.parent)==null?void 0:t.call(this),target:{default:null}}},renderHTML({HTMLAttributes:t}){var r;const{target:e,...n}=t;if((r=n.href)!=null&&r.startsWith("doc:")){const{href:s,...i}=n;return["span",{...i,"data-doc":s.slice(4),class:"doc-link"},0]}return["a",wt(this.options.HTMLAttributes,n),0]}}),Zj=[fm.configure({codeBlock:!1,link:!1,underline:!1}),NI.configure({lowlight:Xj}),gm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Yk,DR,zA,B2,$2,sR,rR.configure({nested:!0}),Xp,LR,Dk.configure({resizable:!1}),Lk,jk,Ik,pm,mm,ed.configure({placeholder:"Start writing..."}),dm.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","codeBlock","horizontalRule","table","tableRow","tableHeader","tableCell","taskList","taskItem","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],eL=[fm.configure({codeBlock:!1,horizontalRule:!1,heading:{levels:[1,2,3]},link:!1,underline:!1}),gm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Xp,pm,mm,ed.configure({placeholder:"Start writing..."}),dm.configure({types:["paragraph","heading","bulletList","orderedList","listItem","blockquote","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})],tL=gt.create({name:"tweetEnterHardBreak",addKeyboardShortcuts(){return{Enter:()=>{const{state:t}=this.editor,{$from:e}=t.selection,n=e.pos,r=n>0?t.doc.resolve(n).nodeBefore:null;if((r==null?void 0:r.type.name)==="hardBreak"){const{tr:s}=t;return s.delete(n-r.nodeSize,n),s.split(s.mapping.map(n)),this.editor.view.dispatch(s),!0}return this.editor.commands.setHardBreak()}}}}),b1=[fm.configure({codeBlock:!1,horizontalRule:!1,heading:!1,blockquote:!1,bulletList:!1,orderedList:!1,listItem:!1,link:!1,underline:!1}),gm.configure({openOnClick:!1,HTMLAttributes:{rel:"noopener noreferrer nofollow"}}),Xp,pm,mm,tL,dm.configure({types:["paragraph","image"],attributeName:"id",generateID:()=>crypto.randomUUID().replace(/-/g,"").slice(0,8)})];[...b1,ed.configure({placeholder:"What is happening?!"})];function Cr({onClick:t,active:e,disabled:n,title:r,children:s}){return d.jsx("button",{className:`floating-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function Zv(){return d.jsx("div",{className:"floating-toolbar__divider"})}function nL({editor:t}){const[e,n]=E.useState(!1),[r,s]=E.useState({top:0,left:0}),[,i]=E.useState(0),l=E.useRef(-1),c=E.useRef(-1),u=E.useRef(!1);return E.useEffect(()=>{const f=t.view.dom,p=()=>{u.current=!0},m=()=>{if(!u.current)return;u.current=!1;const{from:y,to:b}=t.state.selection;if(y!==b){const v=t.isActive("codeBlock"),w=!!document.querySelector(".context-menu");if(!v&&!w){l.current=y,c.current=b;const k=t.view.coordsAtPos(y),N=t.view.coordsAtPos(b,1),T=(k.left+N.right)/2;s({top:k.top,left:T}),n(!0)}}};return f.addEventListener("mousedown",p),document.addEventListener("mouseup",m),()=>{f.removeEventListener("mousedown",p),document.removeEventListener("mouseup",m)}},[t]),E.useEffect(()=>{const f=()=>{u.current=!1,n(!1),l.current=-1,c.current=-1};return t.on("blur",f),()=>{t.off("blur",f)}},[t]),E.useEffect(()=>{const f=()=>{const{from:p,to:m}=t.state.selection,y=p===m,b=t.isActive("codeBlock"),v=!!document.querySelector(".context-menu"),w=t.view.hasFocus();if(y||b||v||!w)n(!1),l.current=-1,c.current=-1;else if(!u.current&&(n(!0),p!==l.current||m!==c.current)){l.current=p,c.current=m;const k=t.view.coordsAtPos(p),N=t.view.coordsAtPos(m,1),T=(k.left+N.right)/2;s({top:k.top,left:T})}i(k=>k+1)};return t.on("transaction",f),()=>{t.off("transaction",f)}},[t]),e?d.jsxs("div",{className:"floating-toolbar",style:{position:"fixed",top:r.top,left:r.left,transform:"translate(-50%, -100%) translateY(-8px)",zIndex:1500},children:[d.jsx(Cr,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("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"})})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),d.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),d.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),d.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),d.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),d.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),d.jsx(Cr,{onClick:()=>{const f=t.getAttributes("link").href||"",p=window.prompt("Link URL:",f);p!==null&&(p===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:p}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),d.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}),d.jsx(Zv,{}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"m17 12 3-2v8"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),d.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),d.jsx(Zv,{}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M3 12h.01"}),d.jsx("path",{d:"M3 18h.01"}),d.jsx("path",{d:"M3 6h.01"}),d.jsx("path",{d:"M8 12h13"}),d.jsx("path",{d:"M8 18h13"}),d.jsx("path",{d:"M8 6h13"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M11 12h9"}),d.jsx("path",{d:"M11 18h9"}),d.jsx("path",{d:"M11 6h9"}),d.jsx("path",{d:"M4 10V4h1"}),d.jsx("path",{d:"M4 10h2"}),d.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),d.jsx(Cr,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6H3"}),d.jsx("path",{d:"M21 12H8"}),d.jsx("path",{d:"M21 18H8"}),d.jsx("path",{d:"M3 12v6"})]})})]}):null}const rL=new Ot("pendingDecoration");let v1=null,x1=null;function e0(t,e){v1=t,x1=e??null}let Lu=!1,w1=null,ym=null,k1=null;function bm(){return Lu}function sL(){return ym}function iL(){return k1}function mp(t,e,n,r){Lu=t,w1=t?e??null:null,ym=t?r??null:null,k1=t?n??null:null}function oL(t){switch(t){case"insert":return"pending-insert";case"rewrite":return"pending-rewrite";case"delete":return"pending-delete";default:return""}}function t0(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const l=t.child(i);if(l.isText){if(r+l.text.length>=n)return s+(n-r);r+=l.text.length,s+=l.nodeSize}else{const c=l.type.spec.leafText?l.type.spec.leafText(l).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=l.nodeSize}}return n===r?s:null}function n0(t){const e=[];return t.descendants((n,r)=>{var v,w,k,N,T,I,_;const s=(v=n.attrs)==null?void 0:v.pendingStatus;if(!s)return!0;const i=(w=n.attrs)==null?void 0:w.id,l=(k=n.attrs)==null?void 0:k.pendingGroupId,c=l&&l===x1,f=Lu&&i===w1||l&&Lu&&l===ym,p=f?(N=n.attrs)==null?void 0:N.pendingOriginalFrom:(T=n.attrs)==null?void 0:T.pendingSelectionFrom,m=f?(I=n.attrs)==null?void 0:I.pendingOriginalTo:(_=n.attrs)==null?void 0:_.pendingSelectionTo,y=p!=null&&m!=null,b=f?"pending-original":oL(s);if(y&&n.isTextblock&&b){const M=t0(n,r,p),O=t0(n,r,m);M!==null&&O!==null&&M<O&&e.push(jt.inline(M,O,{class:b}))}else b&&(n.isTextblock&&r+1<r+n.nodeSize-1?e.push(jt.inline(r+1,r+n.nodeSize-1,{class:b})):e.push(jt.node(r,r+n.nodeSize,{class:b})));if(i&&(i===v1||c)){const M=f?"original":s;e.push(jt.node(r,r+n.nodeSize,{class:`pending-active pending-active--${M}`}))}return!0}),bt.create(t,e)}function S1(){return new kt({key:rL,state:{init(t,e){return n0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceDecorationUpdate")?n0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function vm(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceDecorationUpdate",!0);n(r)}const lL=new Ot("markDecoration");let Fc=[];function r0(t){Fc=t}function s0(t,e,n){const s=e.textContent.indexOf(t.text);if(s===-1)return null;const i=o0(e,n,s),l=o0(e,n,s+t.text.length);return i===null||l===null||i>=l?null:jt.inline(i,l,{class:"agent-mark",title:t.note?`Agent Mark: ${t.note}`:"Agent Mark","data-mark-id":t.id})}function i0(t){if(Fc.length===0)return bt.empty;const e=[],n=new Set,r=new Map;t.descendants((i,l)=>{var c;return i.isTextblock&&((c=i.attrs)!=null&&c.id)&&r.set(i.attrs.id,{node:i,pos:l}),!0});for(const i of Fc){const l=r.get(i.nodeId);if(!l)continue;const c=s0(i,l.node,l.pos);c&&(n.add(i.id),e.push(c))}const s=Fc.filter(i=>!n.has(i.id));return s.length>0&&t.descendants((i,l)=>{if(!i.isTextblock)return!0;for(const c of s){if(n.has(c.id))continue;const u=s0(c,i,l);u&&(n.add(c.id),e.push(u))}return!0}),bt.create(t,e)}function o0(t,e,n){let r=0,s=e+1;for(let i=0;i<t.childCount;i++){const l=t.child(i);if(l.isText){if(r+l.text.length>=n)return s+(n-r);r+=l.text.length,s+=l.nodeSize}else{const c=l.type.spec.leafText?l.type.spec.leafText(l).length:0;if(c>0&&r+c>=n)return s;r+=c,s+=l.nodeSize}}return n===r?s:null}function E1(){return new kt({key:lL,state:{init(t,e){return i0(e.doc)},apply(t,e,n,r){return t.docChanged||t.getMeta("forceMarkUpdate")?i0(r.doc):e.map(t.mapping,t.doc)}},props:{decorations(t){return this.getState(t)}}})}function l0(t){const{state:e,dispatch:n}=t,r=e.tr.setMeta("forceMarkUpdate",!0);n(r)}async function a0(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json(),{state:i}=e,l=i.schema.nodes.image.create({src:s,alt:t.name}),c=i.tr.replaceSelectionWith(l);e.dispatch(c)}catch{}}function Mc({initialContent:t,extensions:e,onUpdate:n,onReady:r,onLinkClick:s}){const i=E.useRef(s);i.current=s;const l=ik({extensions:e||Zj,content:t||"<p></p>",onUpdate:({editor:c})=>{bm()||n==null||n(c.getJSON())},editorProps:{attributes:{class:"tiptap"},handlePaste:(c,u)=>{var p;const f=(p=u.clipboardData)==null?void 0:p.items;if(!f)return!1;for(const m of f)if(m.type.startsWith("image/")){u.preventDefault();const y=m.getAsFile();return y&&a0(y,c),!0}return!1},handleDrop:(c,u)=>{var p;const f=(p=u.dataTransfer)==null?void 0:p.files;if(!(f!=null&&f.length))return!1;for(const m of f)if(m.type.startsWith("image/"))return u.preventDefault(),a0(m,c),!0;return!1}}},[t]);return E.useEffect(()=>{if(!l)return;const c=l.view.dom,u=f=>{var b;const m=f.target.closest("span.doc-link[data-doc]");if(!m)return;const y=m.getAttribute("data-doc");(b=i.current)==null||b.call(i,y)};return c.addEventListener("click",u,!0),()=>c.removeEventListener("click",u,!0)},[l]),E.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="pendingDecoration$"))return;const u=S1(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),E.useEffect(()=>{if(!l)return;const{state:c}=l.view;if(c.plugins.some(p=>p.key==="markDecoration$"))return;const u=E1(),f=c.reconfigure({plugins:[...c.plugins,u]});l.view.updateState(f)},[l]),E.useEffect(()=>{l&&(r==null||r(l))},[l,r]),l?d.jsxs(d.Fragment,{children:[d.jsx(Yp,{editor:l}),d.jsx(nL,{editor:l})]}):null}function nn({onClick:t,active:e,disabled:n,title:r,children:s}){return d.jsx("button",{className:`format-toolbar__btn${e?" active":""}${n?" disabled":""}`,onMouseDown:i=>{i.preventDefault(),t()},disabled:n,title:r,children:s})}function ho(){return d.jsx("div",{className:"format-toolbar__divider"})}async function aL(t,e){const n=new FormData;n.append("image",t);try{const r=await fetch("/api/upload-image",{method:"POST",body:n});if(!r.ok)return;const{src:s}=await r.json();e.chain().focus().setImage({src:s,alt:t.name}).run()}catch{}}function cL({editor:t}){const[,e]=E.useState(0),n=E.useRef(null);E.useEffect(()=>{const s=()=>e(i=>i+1);return t.on("transaction",s),()=>{t.off("transaction",s)}},[t]);const r=s=>{var l;const i=(l=s.target.files)==null?void 0:l[0];i&&aL(i,t),s.target.value=""};return d.jsxs("div",{className:"format-toolbar",children:[d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBold().run(),active:t.isActive("bold"),title:"Bold (Ctrl+B)",children:d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("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"})})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleItalic().run(),active:t.isActive("italic"),title:"Italic (Ctrl+I)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"19",x2:"10",y1:"4",y2:"4"}),d.jsx("line",{x1:"14",x2:"5",y1:"20",y2:"20"}),d.jsx("line",{x1:"15",x2:"9",y1:"4",y2:"20"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleUnderline().run(),active:t.isActive("underline"),title:"Underline (Ctrl+U)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}),d.jsx("line",{x1:"4",x2:"20",y1:"20",y2:"20"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleStrike().run(),active:t.isActive("strike"),title:"Strikethrough",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),d.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),d.jsx("line",{x1:"4",x2:"20",y1:"12",y2:"12"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleCode().run(),active:t.isActive("code"),title:"Inline Code",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m16 18 6-6-6-6"}),d.jsx("path",{d:"m8 6-6 6 6 6"})]})})]}),d.jsx(ho,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleHighlight().run(),active:t.isActive("highlight"),title:"Highlight",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m9 11-6 6v3h9l3-3"}),d.jsx("path",{d:"m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleSubscript().run(),active:t.isActive("subscript"),title:"Subscript",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m4 5 8 8"}),d.jsx("path",{d:"m12 5-8 8"}),d.jsx("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"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleSuperscript().run(),active:t.isActive("superscript"),title:"Superscript",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m4 19 8-8"}),d.jsx("path",{d:"m12 19-8-8"}),d.jsx("path",{d:"M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"})]})})]}),d.jsx(ho,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:1}).run(),active:t.isActive("heading",{level:1}),title:"Heading 1",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"m17 12 3-2v8"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:2}).run(),active:t.isActive("heading",{level:2}),title:"Heading 2",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleHeading({level:3}).run(),active:t.isActive("heading",{level:3}),title:"Heading 3",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 12h8"}),d.jsx("path",{d:"M4 18V6"}),d.jsx("path",{d:"M12 18V6"}),d.jsx("path",{d:"M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2"}),d.jsx("path",{d:"M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().setParagraph().run(),active:t.isActive("paragraph")&&!t.isActive("heading"),title:"Paragraph",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M13 4v16"}),d.jsx("path",{d:"M17 4v16"}),d.jsx("path",{d:"M19 4H9.5a4.5 4.5 0 0 0 0 9H13"})]})})]}),d.jsx(ho,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBulletList().run(),active:t.isActive("bulletList"),title:"Bullet List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M3 12h.01"}),d.jsx("path",{d:"M3 18h.01"}),d.jsx("path",{d:"M3 6h.01"}),d.jsx("path",{d:"M8 12h13"}),d.jsx("path",{d:"M8 18h13"}),d.jsx("path",{d:"M8 6h13"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleOrderedList().run(),active:t.isActive("orderedList"),title:"Ordered List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M11 12h9"}),d.jsx("path",{d:"M11 18h9"}),d.jsx("path",{d:"M11 6h9"}),d.jsx("path",{d:"M4 10V4h1"}),d.jsx("path",{d:"M4 10h2"}),d.jsx("path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleTaskList().run(),active:t.isActive("taskList"),title:"Task List",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"m3 17 2 2 4-4"}),d.jsx("path",{d:"m3 7 2 2 4-4"}),d.jsx("path",{d:"M13 6h8"}),d.jsx("path",{d:"M13 12h8"}),d.jsx("path",{d:"M13 18h8"})]})})]}),d.jsx(ho,{}),d.jsx("div",{className:"format-toolbar__group",children:d.jsx(nn,{onClick:()=>{const s=t.getAttributes("link").href||"",i=window.prompt("Link URL:",s);i!==null&&(i===""?t.chain().focus().unsetLink().run():t.chain().focus().setLink({href:i}).run())},active:t.isActive("link"),title:"Link (Ctrl+K)",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),d.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})})}),d.jsx(ho,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>t.chain().focus().toggleBlockquote().run(),active:t.isActive("blockquote"),title:"Blockquote",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6H3"}),d.jsx("path",{d:"M21 12H8"}),d.jsx("path",{d:"M21 18H8"}),d.jsx("path",{d:"M3 12v6"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().toggleCodeBlock().run(),active:t.isActive("codeBlock"),title:"Code Block",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"m10 9-3 3 3 3"}),d.jsx("path",{d:"m14 15 3-3-3-3"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().setHorizontalRule().run(),title:"Horizontal Rule",children:d.jsx("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M5 12h14"})})})]}),d.jsx(ho,{}),d.jsxs("div",{className:"format-toolbar__group",children:[d.jsx(nn,{onClick:()=>{var s;return(s=n.current)==null?void 0:s.click()},title:"Insert Image",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2"}),d.jsx("circle",{cx:"9",cy:"9",r:"2"}),d.jsx("path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21"})]})}),d.jsx(nn,{onClick:()=>t.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),title:"Insert Table",children:d.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"M12 3v18"}),d.jsx("path",{d:"M3 9h18"}),d.jsx("path",{d:"M3 15h18"})]})})]}),d.jsx("input",{ref:n,type:"file",accept:"image/*",className:"format-toolbar__file-input",onChange:r})]})}const uL={tree:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M3 3h7v7H3zM14 3h7v4h-7zM14 10h7v4h-7zM3 13h7v8H3z"})}),timeline:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"12",y1:"2",x2:"12",y2:"22"}),d.jsx("circle",{cx:"12",cy:"6",r:"2"}),d.jsx("circle",{cx:"12",cy:"12",r:"2"}),d.jsx("circle",{cx:"12",cy:"18",r:"2"}),d.jsx("line",{x1:"14",y1:"6",x2:"20",y2:"6"}),d.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"}),d.jsx("line",{x1:"14",y1:"18",x2:"20",y2:"18"})]}),board:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"5",height:"18",rx:"1"}),d.jsx("rect",{x:"10",y:"3",width:"5",height:"12",rx:"1"}),d.jsx("rect",{x:"17",y:"3",width:"5",height:"15",rx:"1"})]}),shelf:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 19V5"}),d.jsx("path",{d:"M8 19V7"}),d.jsx("path",{d:"M12 19V4"}),d.jsx("path",{d:"M16 19V8"}),d.jsx("path",{d:"M20 19V6"}),d.jsx("line",{x1:"2",y1:"20",x2:"22",y2:"20"})]})};function dL(){const[t,e]=E.useState(!1),[n,r]=E.useState(F0),[s,i]=E.useState(U0),[l,c]=E.useState(zu),u=H0(),[f,p]=E.useState(V0),[m,y]=E.useState(K0),b=E.useRef(null),v=(_=n,M=s,O=l,P=u,$=f,B=m)=>{G0(_,M,O,P,$,B)},w=_=>{r(_),v(_)},k=()=>{const _=s==="light"?"dark":"light";i(_),v(void 0,_)},N=_=>{c(_),v(void 0,void 0,_),window.dispatchEvent(new CustomEvent("ow-sidebar-mode-change",{detail:_}))},T=_=>{p(_),v(void 0,void 0,void 0,void 0,_)},I=_=>{y(_),v(void 0,void 0,void 0,void 0,void 0,_)};return E.useEffect(()=>{if(!t)return;const _=M=>{b.current&&!b.current.contains(M.target)&&e(!1)};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[t]),d.jsxs("div",{className:"appearance-wrapper",ref:b,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Appearance",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("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"}),d.jsx("circle",{cx:"13.5",cy:"6.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"17.5",cy:"10.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"6.5",cy:"12.5",r:"1",fill:"currentColor",stroke:"none"}),d.jsx("circle",{cx:"8.5",cy:"7.5",r:"1",fill:"currentColor",stroke:"none"})]})}),t&&d.jsxs("div",{className:"appearance-dropdown",children:[d.jsx("div",{className:"appearance-section",children:d.jsxs("div",{className:"appearance-section-header",children:[d.jsx("span",{className:"appearance-section-title",children:"Mode"}),d.jsxs("button",{className:"appearance-mode-btn",onClick:k,title:s==="light"?"Switch to dark":"Switch to light",children:[s==="light"?d.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"5"}),d.jsx("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),d.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),d.jsx("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),d.jsx("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),d.jsx("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),d.jsx("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),d.jsx("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),d.jsx("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]}):d.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})}),d.jsx("span",{children:s==="light"?"Light":"Dark"})]})]})}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Typography"})}),d.jsx("div",{className:"appearance-typeface-grid",children:P0.map(_=>d.jsx("button",{className:`appearance-style-option ${n===_.id?"active":""}`,onClick:()=>w(_.id),title:_.description,children:_.label},_.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Spacing"})}),d.jsx("div",{className:"appearance-typography-grid",children:$0.map(_=>d.jsx("button",{className:`appearance-style-option ${f===_.id?"active":""}`,onClick:()=>T(_.id),children:_.label},_.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Canvas"})}),d.jsx("div",{className:"appearance-style-grid",children:z0.map(_=>d.jsx("button",{className:`appearance-style-option ${m===_.id?"active":""}`,onClick:()=>I(_.id),children:_.label},_.id))})]}),d.jsxs("div",{className:"appearance-section",children:[d.jsx("div",{className:"appearance-section-header",children:d.jsx("span",{className:"appearance-section-title",children:"Layout"})}),d.jsx("div",{className:"appearance-mode-grid",children:B0.map(_=>d.jsxs("button",{className:`appearance-mode-option ${l===_.id?"active":""}`,onClick:()=>N(_.id),children:[uL[_.icon],d.jsx("span",{children:_.label})]},_.id))})]})]})]})}function fL(t){return t.replace(/^@openwriter\/plugin-/,"").replace(/-/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function hL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(new Set),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/available-plugins").then(y=>y.json()).then(y=>r(y.plugins||[])).catch(()=>{})},[]);E.useEffect(()=>{t&&f()},[t,f]),E.useEffect(()=>{const y=()=>f();return window.addEventListener("ow-plugins-changed",y),()=>window.removeEventListener("ow-plugins-changed",y)},[f]),E.useEffect(()=>{if(!t)return;const y=b=>{u.current&&!u.current.contains(b.target)&&e(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[t]);const p=E.useCallback(async(y,b)=>{i(y);try{(await fetch(b?"/api/plugins/disable":"/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y})})).ok&&f()}catch{}finally{i(null)}},[f]),m=E.useCallback((y,b,v)=>{fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:y,config:{[b]:v}})}).catch(()=>{})},[]);return d.jsxs("div",{className:"plugin-wrapper",ref:u,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Plugins",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12 22v-5"}),d.jsx("path",{d:"M9 8V2"}),d.jsx("path",{d:"M15 8V2"}),d.jsx("path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z"})]})}),t&&d.jsxs("div",{className:"plugin-dropdown",children:[d.jsx("div",{className:"plugin-dropdown-header",children:"Plugins"}),n.length===0?d.jsx("div",{className:"plugin-empty",children:"No plugins found"}):n.map(y=>d.jsxs("div",{className:"plugin-item",children:[d.jsxs("div",{className:"plugin-item-header",children:[d.jsxs("div",{className:"plugin-item-info",children:[d.jsxs("div",{className:"plugin-item-name",children:[fL(y.name),d.jsxs("span",{className:"plugin-item-version",children:["v",y.version]})]}),y.description&&d.jsx("div",{className:"plugin-item-desc",children:y.description})]}),d.jsxs("label",{className:`plugin-toggle${s===y.name?" loading":""}`,children:[d.jsx("input",{type:"checkbox",checked:y.enabled,disabled:s===y.name,onChange:()=>p(y.name,y.enabled)}),d.jsx("span",{className:"plugin-toggle-track"}),d.jsx("span",{className:"plugin-toggle-thumb"})]})]}),y.enabled&&Object.keys(y.configSchema).length>0&&d.jsxs("div",{className:"plugin-config-section",children:[d.jsxs("button",{className:"plugin-config-toggle",onClick:()=>c(b=>{const v=new Set(b);return v.has(y.name)?v.delete(y.name):v.add(y.name),v}),children:[d.jsx("svg",{className:`plugin-config-chevron${l.has(y.name)?" plugin-config-chevron--open":""}`,width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})}),"Settings"]}),l.has(y.name)&&d.jsx("div",{className:"plugin-config",children:Object.entries(y.configSchema).map(([b,v])=>d.jsxs("div",{className:"plugin-config-field",children:[d.jsx("label",{className:"plugin-config-label",children:v.description||b}),d.jsx("input",{className:"plugin-config-input",type:b.toLowerCase().includes("key")||b.toLowerCase().includes("secret")||b.toLowerCase().includes("token")?"password":"text",defaultValue:y.config[b]||"",placeholder:v.env?`$${v.env}`:"",onBlur:w=>m(y.name,b,w.target.value)})]},b))})]})]},y.name))]})]})}function pL(t){const e=Date.now()-t,n=Math.floor(e/1e3);if(n<60)return"Just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const s=Math.floor(r/60);if(s<24)return`${s}h ago`;const i=Math.floor(s/24);return i<7?`${i}d ago`:new Date(t).toLocaleDateString()}function mL(t){return t<1024?`${t} B`:`${(t/1024).toFixed(1)} KB`}function gL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(!1),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/versions").then(m=>m.json()).then(m=>{r(Array.isArray(m)?m:[]),i(null)}).catch(()=>r([]))},[]);E.useEffect(()=>{t&&f()},[t,f]),E.useEffect(()=>{if(!t)return;const m=y=>{u.current&&!u.current.contains(y.target)&&e(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[t]);const p=E.useCallback(async m=>{if(s!==null){c(!0);try{(await fetch(`/api/versions/${s}/restore`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:m})})).ok&&f()}catch{}c(!1)}},[s,f]);return d.jsxs("div",{className:"version-wrapper",ref:u,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Version history",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M12 7v5l3 3",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t&&d.jsxs("div",{className:"version-dropdown",children:[d.jsx("div",{className:"version-dropdown__header",children:"Version History"}),d.jsx("div",{className:"version-dropdown__list",children:n.length===0?d.jsx("div",{className:"version-dropdown__empty",children:"No versions yet. Versions are created automatically when you save."}):n.map(m=>d.jsxs("div",{className:`version-dropdown__item${s===m.timestamp?" version-dropdown__item--selected":""}`,onClick:()=>i(m.timestamp===s?null:m.timestamp),children:[d.jsx("span",{className:"version-dropdown__item-time",children:pL(m.timestamp)}),d.jsxs("span",{className:"version-dropdown__item-meta",children:[m.wordCount.toLocaleString()," words · ",mL(m.size)]})]},m.timestamp))}),n.length>0&&d.jsxs("div",{className:"version-dropdown__footer",children:[d.jsx("button",{className:"version-dropdown__review-btn",disabled:s===null||l,onClick:()=>p("review"),children:"Review"}),d.jsx("button",{className:"version-dropdown__restore-btn",disabled:s===null||l,onClick:()=>p("full"),children:"Restore"})]})]})]})}const yL=[{key:"md",label:"Markdown",desc:"Plain .md file",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("path",{d:"M14 2v6h6"})]})},{key:"html",label:"HTML",desc:"Styled web page",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"16 18 22 12 16 6"}),d.jsx("polyline",{points:"8 6 2 12 8 18"})]})},{key:"docx",label:"Word",desc:"Microsoft Word .docx",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),d.jsx("path",{d:"M14 2v6h6"}),d.jsx("path",{d:"M16 13H8"}),d.jsx("path",{d:"M16 17H8"}),d.jsx("path",{d:"M10 9H8"})]})},{key:"txt",label:"Plain Text",desc:"Unformatted .txt file",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M17 6.1H3"}),d.jsx("path",{d:"M21 12.1H3"}),d.jsx("path",{d:"M15.1 18H3"})]})},{key:"pdf",label:"PDF",desc:"Print preview for save as PDF",icon:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"6 9 6 2 18 2 18 9"}),d.jsx("path",{d:"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2"}),d.jsx("rect",{x:"6",y:"14",width:"12",height:"8"})]})}];function bL(){const[t,e]=E.useState(!1),n=E.useRef(null);E.useEffect(()=>{if(!t)return;const s=i=>{n.current&&!n.current.contains(i.target)&&e(!1)};return document.addEventListener("mousedown",s),()=>document.removeEventListener("mousedown",s)},[t]);const r=s=>{if(e(!1),s==="pdf"){window.open("/api/export?format=pdf","_blank");return}const i=document.createElement("a");i.href=`/api/export?format=${s}`,i.download="",document.body.appendChild(i),i.click(),document.body.removeChild(i)};return d.jsxs("div",{className:"export-wrapper",ref:n,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Export document",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]})}),t&&d.jsxs("div",{className:"export-dropdown",children:[d.jsx("div",{className:"export-dropdown__header",children:"Export"}),d.jsx("div",{className:"export-dropdown__list",children:yL.map(s=>d.jsxs("div",{className:"export-dropdown__item",onClick:()=>r(s.key),children:[d.jsx("span",{className:"export-dropdown__item-icon",children:s.icon}),d.jsxs("span",{className:"export-dropdown__item-text",children:[d.jsx("span",{className:"export-dropdown__item-label",children:s.label}),d.jsx("span",{className:"export-dropdown__item-desc",children:s.desc})]})]},s.key))})]})]})}function vL({existingConnection:t,onClose:e,onSaved:n}){const[r,s]=E.useState("form"),[i,l]=E.useState(null),[c,u]=E.useState((t==null?void 0:t.domain)||""),[f,p]=E.useState(""),[m,y]=E.useState((t==null?void 0:t.from_name)||""),[b,v]=E.useState(""),[w,k]=E.useState((t==null?void 0:t.id)||""),[N,T]=E.useState({dns_verified:!1,sender_verified:!1}),I=E.useRef(null),_=E.useRef(null);E.useEffect(()=>{const J=F=>{r!=="submitting"&&r!=="verifying"&&_.current&&!_.current.contains(F.target)&&e()};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[e,r]),E.useEffect(()=>{const J=F=>{F.key==="Escape"&&r!=="submitting"&&r!=="verifying"&&e()};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[e,r]),E.useEffect(()=>()=>{I.current&&clearInterval(I.current)},[]);async function M(){var J,F;s("submitting"),l(null);try{const G=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f,from_name:m||void 0,physical_address:b}})})).json(),te=(F=(J=G.content)==null?void 0:J[0])!=null&&F.text?JSON.parse(G.content[0].text):G;if(te.error){l(te.error),s("error");return}const U=te.connectionId||te.connection_id||w;U&&k(U),P(U)}catch(re){l(re.message),s("error")}}async function O(){var J,F;s("submitting"),l(null);try{const G=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"setup_custom_domain",arguments:{domain:c,from_email:f||void 0,from_name:m||void 0,physical_address:b||void 0}})})).json(),te=(F=(J=G.content)==null?void 0:J[0])!=null&&F.text?JSON.parse(G.content[0].text):G;if(te.error){l(te.error),s("error");return}s("done")}catch(re){l(re.message),s("error")}}function P(J){s("verifying"),I.current=setInterval(async()=>{var F,re;try{const te=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"check_domain_status",arguments:{connectionId:J}})})).json(),U=(re=(F=te.content)==null?void 0:F[0])!=null&&re.text?JSON.parse(te.content[0].text):te,ne=!!U.dns_verified,H=!!U.sender_verified;T({dns_verified:ne,sender_verified:H}),ne&&H&&(I.current&&clearInterval(I.current),I.current=null,s("done"))}catch{}},5e3)}function $(){w&&fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"resend_domain_verification",arguments:{connectionId:w}})}).catch(()=>{})}const B=!!t,W=c.trim()&&f.trim()&&b.trim();return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"newsletter-modal newsletter-modal--setup",ref:_,children:[d.jsxs("div",{className:"newsletter-modal__header",children:[d.jsx("h3",{children:B?"Newsletter Settings":"Set Up Newsletter"}),d.jsx("button",{className:"newsletter-modal__close",onClick:e,children:"×"})]}),d.jsxs("div",{className:"newsletter-modal__body",children:[r==="form"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsx("label",{className:"newsletter-modal__label",children:"Domain"}),d.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"yourdomain.com",value:c,onChange:J=>u(J.target.value),disabled:B,autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsx("label",{className:"newsletter-modal__label",children:"From Email"}),d.jsx("input",{className:"newsletter-modal__input",type:"email",placeholder:"newsletter@yourdomain.com",value:f,onChange:J=>p(J.target.value),autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsxs("label",{className:"newsletter-modal__label",children:["From Name ",d.jsx("span",{className:"newsletter-modal__optional",children:"(optional)"})]}),d.jsx("input",{className:"newsletter-modal__input",type:"text",placeholder:"Your Name or Brand",value:m,onChange:J=>y(J.target.value),autoComplete:"off"})]}),d.jsxs("div",{className:"newsletter-modal__field",children:[d.jsxs("label",{className:"newsletter-modal__label",children:["Physical Address ",d.jsx("span",{className:"newsletter-modal__required",children:"*"})]}),d.jsx("textarea",{className:"newsletter-modal__input newsletter-modal__textarea",rows:2,placeholder:"123 Main St, City, State 12345",value:b,onChange:J=>v(J.target.value)}),d.jsx("span",{className:"newsletter-modal__hint",children:"Required by CAN-SPAM. Included in email footer."})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:B?O:M,disabled:!W,children:B?"Save":"Set Up Domain"})]})]}),r==="submitting"&&d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:B?"Saving...":"Setting up domain..."})]}),r==="verifying"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__verify",children:[d.jsx("p",{className:"newsletter-modal__verify-title",children:"Verifying domain setup..."}),d.jsxs("div",{className:"newsletter-modal__verify-checks",children:[d.jsxs("div",{className:`newsletter-modal__verify-item${N.dns_verified?" newsletter-modal__verify-item--done":""}`,children:[N.dns_verified?"✓":d.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),d.jsx("span",{children:"DNS records"})]}),d.jsxs("div",{className:`newsletter-modal__verify-item${N.sender_verified?" newsletter-modal__verify-item--done":""}`,children:[N.sender_verified?"✓":d.jsx("span",{className:"newsletter-modal__spinner newsletter-modal__spinner--sm"}),d.jsx("span",{children:"Sender verification"})]})]}),d.jsx("p",{className:"newsletter-modal__hint",children:"This may take a few minutes. You can close and check back later."})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:$,children:"Resend Verification"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Close"})]})]}),r==="done"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:B?"Settings saved!":"Newsletter domain configured!"}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>{n(),e()},children:"Done"})})]}),r==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__error",children:i}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:e,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s("form"),children:"Try Again"})]})]})]})]})})}const xL={github:[{key:"owner",label:"Owner",placeholder:"username or org",readonly:!0},{key:"repo",label:"Repository",placeholder:"my-blog",readonly:!0},{key:"branch",label:"Branch",placeholder:"main"},{key:"contentDir",label:"Content Directory",placeholder:"src/content/blog",required:!0},{key:"imageDir",label:"Image Directory",placeholder:"public/images/blog"}],x:[],linkedin:[]};function wL({connectionId:t,provider:e,displayName:n,onClose:r,onSaved:s}){const[i,l]=E.useState("loading"),[c,u]=E.useState({}),[f,p]=E.useState(null),m=E.useRef(null),y=xL[e]||[];E.useEffect(()=>{fetch(`/api/connections/${t}/config`).then(w=>w.json()).then(w=>{u(w.config||{}),l("form")}).catch(w=>{p(w.message),l("error")})},[t]),E.useEffect(()=>{const w=k=>{i!=="saving"&&m.current&&!m.current.contains(k.target)&&r()};return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[r,i]),E.useEffect(()=>{const w=k=>{k.key==="Escape"&&i!=="saving"&&r()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[r,i]);async function b(){l("saving"),p(null);try{const w=await fetch(`/api/connections/${t}/config`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(c)}),k=await w.json();if(!w.ok)throw new Error(k.error||"Failed to save");l("saved"),s(),setTimeout(r,800)}catch(w){p(w.message),l("error")}}function v(w){switch(w){case"x":return"X (Twitter)";case"linkedin":return"LinkedIn";case"github":return"GitHub";default:return w}}return d.jsx("div",{className:"conn-config-overlay",children:d.jsxs("div",{className:"conn-config-modal",ref:m,children:[d.jsxs("div",{className:"conn-config-modal__header",children:[d.jsxs("div",{className:"conn-config-modal__title",children:[v(e)," Settings"]}),d.jsx("div",{className:"conn-config-modal__subtitle",children:n})]}),i==="loading"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("div",{className:"conn-config-spinner"}),d.jsx("span",{children:"Loading configuration..."})]}),(i==="form"||i==="error")&&y.length>0&&d.jsxs("div",{className:"conn-config-modal__body",children:[y.map(w=>d.jsxs("div",{className:"conn-config-field",children:[d.jsxs("label",{className:"conn-config-field__label",children:[w.label,w.readonly&&d.jsx("span",{className:"conn-config-field__badge",children:"read-only"})]}),d.jsx("input",{className:"conn-config-field__input",value:c[w.key]||"",placeholder:w.placeholder,readOnly:w.readonly,onChange:k=>u(N=>({...N,[w.key]:k.target.value}))})]},w.key)),f&&d.jsx("div",{className:"conn-config-modal__error",children:f})]}),(i==="form"||i==="error")&&y.length===0&&d.jsx("div",{className:"conn-config-modal__body conn-config-modal__center",children:d.jsxs("span",{className:"conn-config-modal__empty",children:["No configuration needed for ",v(e),"."]})}),i==="saving"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("div",{className:"conn-config-spinner"}),d.jsx("span",{children:"Saving..."})]}),i==="saved"&&d.jsxs("div",{className:"conn-config-modal__body conn-config-modal__center",children:[d.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"#22c55e",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),d.jsx("span",{children:"Saved"})]}),d.jsxs("div",{className:"conn-config-modal__footer",children:[d.jsx("button",{className:"conn-config-btn conn-config-btn--secondary",onClick:r,children:i==="saved"?"Close":"Cancel"}),y.length>0&&(i==="form"||i==="error")&&d.jsx("button",{className:"conn-config-btn conn-config-btn--primary",onClick:b,children:"Save"})]})]})})}const kL=[{id:"x",label:"X (Twitter)",oauth:!0},{id:"linkedin",label:"LinkedIn",oauth:!0},{id:"github",label:"GitHub",oauth:!0},{id:"newsletter",label:"Newsletter",oauth:!1}];function SL(){const[t,e]=E.useState(!1),[n,r]=E.useState([]),[s,i]=E.useState(null),[l,c]=E.useState(null),[u,f]=E.useState(null),[p,m]=E.useState(null),y=E.useRef(null),b=E.useRef(null);E.useEffect(()=>{if(!t)return;const _=M=>{y.current&&!y.current.contains(M.target)&&(e(!1),i(null))};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[t]),E.useEffect(()=>{t&&v()},[t]),E.useEffect(()=>()=>{b.current&&clearInterval(b.current)},[]);function v(){fetch("/api/connections").then(_=>_.json()).then(_=>{const M=(_.connections||[]).filter(O=>O&&O.id&&O.provider);r(M)}).catch(()=>{})}async function w(_){c(_);try{const M=await fetch(`/api/connections/oauth/${_}/start`,{method:"POST"}),O=await M.json();if(!M.ok||!O.url){c(null);return}window.open(O.url,"_blank","width=600,height=700"),b.current=setInterval(async()=>{try{const $=await(await fetch(`/api/connections/oauth/${_}/status/${O.state}`)).json();$.status==="completed"?(b.current&&clearInterval(b.current),b.current=null,c(null),v()):$.status==="failed"&&(b.current&&clearInterval(b.current),b.current=null,c(null))}catch{}},2e3)}catch{c(null)}}async function k(_){await fetch(`/api/connections/${_}`,{method:"DELETE"}),i(null),v()}function N(_){return _==="active"?"connections-status--active":_==="expired"?"connections-status--expired":_==="revoked"?"connections-status--revoked":"connections-status--pending"}function T(_){switch(_){case"x":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})});case"linkedin":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0h.003z"})});case"github":return d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:d.jsx("path",{d:"M12 0C5.374 0 0 5.373 0 12c0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23A11.509 11.509 0 0112 5.803c1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576C20.566 21.797 24 17.3 24 12c0-6.627-5.373-12-12-12z"})});case"newsletter":return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"2",y:"4",width:"20",height:"16",rx:"2"}),d.jsx("path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7"})]});default:return d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),d.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}}const I=new Map;for(const _ of n)I.set(_.provider,_);return d.jsxs("div",{className:"connections-wrapper",ref:y,children:[d.jsx("button",{className:`titlebar-nav-btn${t?" titlebar-nav-btn--active":""}`,onClick:()=>e(!t),title:"Connections",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"5",r:"3"}),d.jsx("circle",{cx:"5",cy:"19",r:"3"}),d.jsx("circle",{cx:"19",cy:"19",r:"3"}),d.jsx("line",{x1:"12",y1:"8",x2:"5",y2:"16"}),d.jsx("line",{x1:"12",y1:"8",x2:"19",y2:"16"})]})}),p&&d.jsx(wL,{connectionId:p.id,provider:p.provider,displayName:p.display_name,onClose:()=>m(null),onSaved:()=>v()}),u&&d.jsx(vL,{existingConnection:u==="edit"?I.get("newsletter"):null,onClose:()=>f(null),onSaved:()=>v()}),t&&d.jsxs("div",{className:"connections-dropdown",children:[d.jsx("div",{className:"connections-dropdown__header",children:"Connections"}),d.jsx("div",{className:"connections-dropdown__list",children:kL.map(_=>{const M=I.get(_.id);return M&&s===M.id?d.jsxs("div",{className:"connections-dropdown__confirm",children:[d.jsxs("span",{children:["Disconnect ",_.label,"?"]}),d.jsxs("div",{className:"connections-dropdown__confirm-btns",children:[d.jsx("button",{onClick:()=>k(M.id),children:"Yes"}),d.jsx("button",{onClick:()=>i(null),children:"No"})]})]},_.id):M?d.jsxs("div",{className:"connections-dropdown__item",children:[d.jsx("div",{className:"connections-dropdown__icon",children:T(_.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:M.display_name||M.domain||_.label}),d.jsxs("div",{className:"connections-dropdown__type",children:[d.jsx("span",{className:`connections-status ${N(M.status)}`}),"Connected"]})]}),d.jsxs("div",{className:"connections-dropdown__actions",children:[d.jsx("button",{className:"connections-dropdown__action-btn",onClick:()=>{_.id==="newsletter"?f("edit"):m({id:M.id,provider:_.id,display_name:M.display_name||_.label})},title:"Settings",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}),_.oauth&&d.jsx("button",{className:"connections-dropdown__action-btn connections-dropdown__action-btn--delete",onClick:()=>i(M.id),title:"Disconnect",children:"×"})]})]},_.id):_.oauth?d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:T(_.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:_.label}),d.jsx("div",{className:"connections-dropdown__type",children:"Not connected"})]}),d.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>w(_.id),disabled:l!==null,children:l===_.id?"Connecting…":"Connect"})]},_.id):d.jsxs("div",{className:"connections-dropdown__item connections-dropdown__item--disconnected",children:[d.jsx("div",{className:"connections-dropdown__icon",children:T(_.id)}),d.jsxs("div",{className:"connections-dropdown__info",children:[d.jsx("div",{className:"connections-dropdown__name",children:_.label}),d.jsx("div",{className:"connections-dropdown__type",children:"Built-in · Not configured"})]}),d.jsx("button",{className:"connections-dropdown__connect-inline-btn",onClick:()=>f("new"),children:"Configure"})]},_.id)})})]})]})}const EL=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),NL=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M9 14l2 2 4-4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),CL=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M12 16v-5M9.5 13.5L12 11l2.5 2.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),_L=()=>d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M18 10h-1.26A8 8 0 1 0 9 20h9a5 5 0 0 0 0-10z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M14 14l-4 4M10 14l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]});function TL({title:t,onTitleChange:e,syncStatus:n,onSync:r,onToggleSidebar:s,canGoBack:i,canGoForward:l,onGoBack:c,onGoForward:u,editor:f,onToggleToolbar:p,toolbarOpen:m}){const[y,b]=E.useState(!1),[,v]=E.useState(0),w=E.useRef(null),[k,N]=E.useState(!1),[T,I]=E.useState([]),[_,M]=E.useState(!1),O=E.useRef(null),P=E.useCallback(()=>{b(!0),setTimeout(()=>{var J;return(J=w.current)==null?void 0:J.select()},0)},[]),$=E.useCallback(()=>{b(!1)},[]),B=E.useCallback(J=>{J.key==="Enter"&&b(!1),J.key==="Escape"&&b(!1)},[]),W=E.useCallback(()=>{if(k){N(!1);return}N(!0),M(!0),fetch("/api/sync/pending").then(J=>J.json()).then(J=>I(J)).catch(()=>I([])).finally(()=>M(!1))},[k]);return E.useEffect(()=>{n.state!=="pending"&&N(!1)},[n.state]),E.useEffect(()=>{if(!k)return;const J=F=>{O.current&&!O.current.contains(F.target)&&N(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[k]),E.useEffect(()=>{if(!f)return;const J=()=>v(F=>F+1);return f.on("transaction",J),()=>{f.off("transaction",J)}},[f]),d.jsxs("div",{className:"titlebar",children:[d.jsxs("div",{className:"titlebar-left",children:[s&&d.jsx("button",{className:"titlebar-menu-btn",onClick:s,title:"Open sidebar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M14 10l2 2-2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),c&&d.jsx("button",{className:"titlebar-nav-btn",onClick:c,disabled:!i,title:"Go back (Alt+Left)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),u&&d.jsx("button",{className:"titlebar-nav-btn",onClick:u,disabled:!l,title:"Go forward (Alt+Right)",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),f&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"titlebar-divider"}),d.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().undo().run(),disabled:!f.can().undo(),title:"Undo (Ctrl+Z)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M3 10h10a5 5 0 0 1 0 10H9",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M7 6L3 10l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),d.jsx("button",{className:"titlebar-nav-btn",onClick:()=>f.chain().focus().redo().run(),disabled:!f.can().redo(),title:"Redo (Ctrl+Y)",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M21 10H11a5 5 0 0 0 0 10h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M17 6l4 4-4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),d.jsx("div",{className:"titlebar-center",children:y?d.jsx("input",{ref:w,className:"titlebar-input",value:t,onChange:J=>e(J.target.value),onBlur:$,onKeyDown:B,autoFocus:!0}):d.jsx("span",{className:"titlebar-title",onDoubleClick:P,children:t})}),d.jsxs("div",{className:"titlebar-right",children:[p&&d.jsx("button",{className:`titlebar-nav-btn${m?" titlebar-nav-btn--active":""}`,onClick:p,title:"Toggle format toolbar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M4 20h16"}),d.jsx("path",{d:"m6 16 6-12 6 12"}),d.jsx("path",{d:"M8 12h8"})]})}),d.jsx(hL,{}),d.jsx(SL,{}),d.jsx(dL,{}),d.jsx(gL,{}),d.jsx(bL,{}),d.jsxs("div",{className:"sync-btn-group",ref:O,children:[d.jsxs("button",{className:`titlebar-btn sync-btn-state sync-${n.state}`,onClick:r,disabled:n.state==="syncing",title:n.lastSyncTime?`Last synced: ${new Date(n.lastSyncTime).toLocaleString()}`:"Sync to GitHub",children:[n.state==="unconfigured"&&d.jsxs(d.Fragment,{children:[d.jsx(EL,{})," Sync"]}),n.state==="synced"&&d.jsxs(d.Fragment,{children:[d.jsx(NL,{})," Synced"]}),n.state==="pending"&&d.jsxs(d.Fragment,{children:[d.jsx(CL,{})," Sync",n.pendingFiles?` (${n.pendingFiles})`:""]}),n.state==="syncing"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sync-btn-spinner"})," Syncing..."]}),n.state==="error"&&d.jsxs(d.Fragment,{children:[d.jsx(_L,{})," Retry"]})]}),n.state==="pending"&&n.pendingFiles&&n.pendingFiles>0&&d.jsx("button",{className:"sync-details-btn",onClick:W,title:"View pending changes",children:d.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",children:d.jsx("path",{d:k?"M3 7.5L6 4.5L9 7.5":"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),k&&d.jsxs("div",{className:"sync-pending-dropdown",children:[d.jsx("div",{className:"sync-pending-header",children:"Changes to push"}),_?d.jsx("div",{className:"sync-pending-loading",children:"Loading..."}):T.length===0?d.jsx("div",{className:"sync-pending-loading",children:"No changes"}):d.jsx("div",{className:"sync-pending-list",children:T.map((J,F)=>d.jsxs("div",{className:`sync-pending-item sync-file-${J.status}`,children:[d.jsx("span",{className:"sync-file-badge",children:J.status[0].toUpperCase()}),d.jsx("span",{className:"sync-file-name",children:J.file})]},F))})]})]})]})]})}function bn(t,e){let n=null;return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function nd(t,e){const n=[];return t.state.doc.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.pendingGroupId)===e&&n.push({nodeId:r.attrs.id,pos:s,node:r}),!0}),n}function ko(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,"").slice(0,8):Math.random().toString(16).slice(2,10)}function Du(t){return t?Array.isArray(t)?t.map(Du).join(""):t.text?t.text:t.content&&Array.isArray(t.content)?t.content.map(e=>Du(e)).join(""):"":""}const ML=new Set(["paragraph","heading","codeBlock","horizontalRule","table","image"]);function Pu(t,e){for(const n of t)n.type&&ML.has(n.type)?n.attrs={...n.attrs,pendingStatus:e}:n.content&&Pu(n.content,e)}function gp(t,e,n){const r=Array.isArray(n)?n:[n];if(e.nodeId&&!e.afterNodeId&&!e.beforeNodeId){const b=bn(t,e.nodeId);if(!b)return{success:!1,error:`Node ${e.nodeId} not found`};const v=r.map((w,k)=>{var N;return{...w,attrs:{...w.attrs,id:((N=w.attrs)==null?void 0:N.id)||(k===0?e.nodeId:ko())}}});Pu(v,"insert");try{return t.chain().deleteRange({from:b.pos,to:b.pos+b.node.nodeSize}).insertContentAt(b.pos,v).run(),{success:!0,nodeId:e.nodeId}}catch(w){return{success:!1,error:`Failed to replace empty node: ${w}`}}}if(!e.afterNodeId&&!e.beforeNodeId)return{success:!1,error:"Insert requires afterNodeId, beforeNodeId, or nodeId"};const s=e.afterNodeId||e.beforeNodeId,i=!!e.afterNodeId,l=bn(t,s);if(!l)return{success:!1,error:`Anchor node ${s} not found`};const c=Du(n),u=i?l.pos+l.node.nodeSize:0,f=i?l.pos+l.node.nodeSize+5e3:l.pos;let p=null;if(t.state.doc.nodesBetween(u,Math.min(f,t.state.doc.content.size),b=>{var v,w;return((v=b.attrs)==null?void 0:v.pendingStatus)==="insert"&&((w=b.attrs)!=null&&w.id)&&(b.textContent||"")===c?(p=b.attrs.id,!1):!0}),p)return{success:!0,nodeId:p};const m=r.map(b=>{var v;return{...b,attrs:{...b.attrs,id:((v=b.attrs)==null?void 0:v.id)||ko()}}});Pu(m,"insert");const y=i?l.pos+l.node.nodeSize:l.pos;try{return t.chain().insertContentAt(y,m).run(),{success:!0,nodeId:m[0].attrs.id}}catch(b){return{success:!1,error:`Failed to insert content: ${b}`}}}function xm(t,e,n,r){var b;const s=bn(t,e);if(!s)return{success:!1,error:`Node ${e} not found`};const{node:i,pos:l}=s,c=Array.isArray(n)?n:[n],f=!((b=i.attrs)!=null&&b.pendingOriginalContent)?i.toJSON():i.attrs.pendingOriginalContent,p={...c[0],attrs:{...c[0].attrs,id:e,pendingStatus:"rewrite",pendingOriginalContent:f,...r?{pendingSelectionFrom:r.selectionFrom,pendingSelectionTo:r.selectionTo,pendingOriginalFrom:r.originalFrom,pendingOriginalTo:r.originalTo}:{}}},m=c.slice(1).map(v=>{var w;return{...v,attrs:{...v.attrs,id:((w=v.attrs)==null?void 0:w.id)||ko()}}});Pu(m,"insert");const y=[p,...m];try{return t.chain().deleteRange({from:l,to:l+i.nodeSize}).insertContentAt(l,y.length===1?y[0]:y).run(),{success:!0,nodeId:e}}catch(v){return{success:!1,error:`Failed to rewrite: ${v}`}}}function AL(t,e,n){if(e.length===0)return{success:!1,error:"Range rewrite requires original IDs"};if(!n||n.length===0)return{success:!1,error:"Range rewrite requires new content (received empty)"};if(n.map(m=>Du(m)).join("").trim().length===0)return{success:!1,error:"Range rewrite content is empty (no text) — aborting"};const s=bn(t,e[0]),i=bn(t,e[e.length-1]);if(!s||!i)return{success:!1,error:"Could not find original nodes for range rewrite"};const l=[];for(const m of e){const y=bn(t,m);y&&l.push(y.node.toJSON())}const c=s.pos,u=i.pos+i.node.nodeSize,f=ko()+ko(),p=n.map((m,y)=>{var b;return{...m,attrs:{...m.attrs,id:((b=m.attrs)==null?void 0:b.id)||ko(),pendingStatus:"rewrite",pendingGroupId:f,...y===0?{pendingOriginalContent:l}:{}}}});try{return t.chain().deleteRange({from:c,to:u}).insertContentAt(c,p).run(),{success:!0,nodeId:p[0].attrs.id}}catch(m){return{success:!1,error:`Failed to apply range rewrite: ${m}`}}}function N1(t,e){var i;const n=bn(t,e);if(!n)return{success:!1,error:`Node ${e} not found`};const{node:r,pos:s}=n;if(((i=r.attrs)==null?void 0:i.pendingStatus)==="delete")return{success:!0,nodeId:e};try{return t.chain().command(({tr:l})=>(l.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:"delete"}),!0)).run(),{success:!0,nodeId:e}}catch(l){return{success:!1,error:`Failed to mark for deletion: ${l}`}}}function OL(t,e){if(e.operation==="rewrite"&&e.nodeId&&e.content){const n=xm(t,e.nodeId,e.content);return{success:n.success,error:n.error}}if(e.operation==="insert"&&e.content){let n=null;if(e.nodeId&&!e.afterNodeId?n={nodeId:e.nodeId}:e.afterNodeId&&(n={afterNodeId:e.afterNodeId}),!n)return{success:!1,error:"Insert requires afterNodeId or nodeId"};const r=gp(t,n,e.content);return{success:r.success,error:r.error}}if(e.operation==="delete"&&e.nodeId){const n=N1(t,e.nodeId);return{success:n.success,error:n.error}}return{success:!1,error:`Invalid operation: ${e.operation}`}}function c0(t,e){if(e.length===0)return;if(e.length===1){OL(t,e[0]);return}const n=t.state.schema;t.chain().command(({tr:r})=>{var s;for(const i of e)try{if(i.operation==="rewrite"&&i.nodeId&&i.content){const l=Ac(r.doc,i.nodeId);if(!l)continue;const u=(Array.isArray(i.content)?i.content:[i.content]).map(f=>n.nodeFromJSON(f));r.replaceWith(l.pos,l.pos+l.node.nodeSize,u)}else if(i.operation==="insert"&&i.content){const c=(Array.isArray(i.content)?i.content:[i.content]).map(u=>n.nodeFromJSON(u));if(i.nodeId&&!i.afterNodeId){const u=Ac(r.doc,i.nodeId);if(!u)continue;r.replaceWith(u.pos,u.pos+u.node.nodeSize,c)}else if(i.afterNodeId){const u=Ac(r.doc,i.afterNodeId);if(!u)continue;const f=u.pos+u.node.nodeSize;r.insert(f,ae.fromArray(c))}}else if(i.operation==="delete"&&i.nodeId){const l=Ac(r.doc,i.nodeId);if(!l||((s=l.node.attrs)==null?void 0:s.pendingStatus)==="delete")continue;r.setNodeMarkup(l.pos,void 0,{...l.node.attrs,pendingStatus:"delete"})}}catch{continue}return!0}).run()}function Ac(t,e){let n=null;return t.descendants((r,s)=>{var i;return((i=r.attrs)==null?void 0:i.id)===e?(n={node:r,pos:s},!1):!0}),n}function u0(t,e,n,r){const s=[];if(r==="delete"){for(const l of n)s.push(N1(t,l));return s}if(r==="insert"){const l=n[n.length-1];return l&&e.length>0&&s.push(gp(t,{nodeId:l},e)),s}if(n.length>1){const l=AL(t,n,e);return s.push(l),s}const i=xm(t,n[0],e[0]);if(s.push(i),e.length>1){const l=e.slice(1);s.push(gp(t,{afterNodeId:n[0]},l))}return s}const d0="[[START_SELECTION]]",f0="[[END_SELECTION]]";function RL(t){if(!(t!=null&&t.content)||!Array.isArray(t.content))return 0;let e=0;for(const n of t.content)n.type==="text"&&typeof n.text=="string"?e+=n.text.length:n.type==="hardBreak"&&(e+=1);return e}function Oc(t,e,n){if(!(t!=null&&t.content)||!Array.isArray(t.content))return;const r=RL(t);let s=Math.max(0,Math.min(e,r));for(let i=0;i<t.content.length;i++){const l=t.content[i];if(l.type==="text"&&typeof l.text=="string"){if(s<=l.text.length){const c=Math.max(0,Math.min(l.text.length,s));l.text=l.text.slice(0,c)+n+l.text.slice(c);return}s-=l.text.length;continue}if(l.type==="hardBreak"){if(s===0){t.content.splice(i+1,0,{type:"text",text:n});return}s-=1;continue}if(s===0){t.content.splice(i,0,{type:"text",text:n});return}}t.content.push({type:"text",text:n})}function IL(t,e,n){const r=JSON.parse(JSON.stringify(t));return r.length===0?r:r.length===1?(Oc(r[0],n,f0),Oc(r[0],e,d0),r):(Oc(r[0],e,d0),Oc(r[r.length-1],n,f0),r)}function jL(t){const e=r=>r.replace(/\[\[(START|END)_SELECTION]]/g,""),n=r=>{r.type==="text"&&typeof r.text=="string"&&(r.text=e(r.text)),r.content&&Array.isArray(r.content)&&r.content.forEach(n)};Array.isArray(t)?t.forEach(n):n(t)}const LL=[{action:"agent-mark",label:"Agent Mark",shortcut:"M",condition:"has-selection"},{action:"delete",label:"Delete",shortcut:"D"}];function DL({editorRef:t,allEditors:e,documentId:n}){const[r,s]=E.useState(!1),[i,l]=E.useState({x:0,y:0}),[c,u]=E.useState(!1),[f,p]=E.useState(""),[m,y]=E.useState(!1),[b,v]=E.useState(""),[w,k]=E.useState(!1),[N,T]=E.useState([]),[I,_]=E.useState([]),[M,O]=E.useState(!1),[P,$]=E.useState(""),[B,W]=E.useState([]),[J,F]=E.useState(!1),[re,G]=E.useState(""),te=E.useRef(null),U=E.useRef(null),ne=E.useRef(null),H=E.useCallback(ce=>{if(e&&e.length>0){for(const ie of e)if(ie.view.dom.contains(ce))return ie}const ve=t.current;return ve&&ve.view.dom.contains(ce)?ve:null},[e,t]);E.useLayoutEffect(()=>{const ce=te.current;if(!ce||!r)return;const ve=ce.getBoundingClientRect(),ie=8;let{x:Be,y:Te}=i;Te+ve.height+ie>window.innerHeight&&(Te=i.y-ve.height),Be+ve.width+ie>window.innerWidth&&(Be=i.x-ve.width),Te<ie&&(Te=ie),Be<ie&&(Be=ie),(Be!==i.x||Te!==i.y)&&l({x:Be,y:Te})},[r,i]);const X=E.useCallback(()=>{fetch("/api/plugins").then(ce=>ce.json()).then(ce=>{const ve=[];for(const ie of ce.plugins||[]){const Be=ie.displayName||void 0;for(const Te of ie.contextMenuItems||[])ve.push({...Te,pluginDisplayName:Be})}W(ve)}).catch(()=>{})},[]);E.useEffect(()=>{X()},[X]),E.useEffect(()=>{const ce=()=>X();return window.addEventListener("ow-plugins-changed",ce),()=>window.removeEventListener("ow-plugins-changed",ce)},[X]),E.useEffect(()=>{const ce=ve=>{te.current&&!te.current.contains(ve.target)&&(s(!1),y(!1),k(!1),F(!1),G(""))};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[]);const K=E.useCallback(()=>{const ce=ne.current||t.current;return ce?ce.isActive("link"):!1},[t]),A=E.useCallback(()=>{const ce=ne.current||t.current,ve=U.current;if(!ce||!ve)return!1;const{from:ie,to:Be}=ve;let Te=!1;return ce.state.doc.nodesBetween(ie,Be,Ue=>{var Ee;return(Ee=Ue.attrs)!=null&&Ee.pendingStatus&&(Te=!0),!Te}),Te},[t]),R=E.useCallback(()=>{const ce=ne.current||t.current,ve=U.current,ie=(ve==null?void 0:ve.from)??0,Be=(ve==null?void 0:ve.to)??0,Te=ie!==Be,Ue=(()=>{if(!ce)return!1;try{return ce.state.doc.resolve(ie).parent.content.size===0}catch{return!1}})(),Ee=A(),Qe=[];for(const tt of B)tt.condition==="has-selection"&&!Te||tt.condition==="empty-node"&&!Ue||Qe.push({action:tt.action,label:tt.label,shortcut:tt.shortcut,isPlugin:!0,promptForInput:tt.promptForInput,pluginDisplayName:tt.pluginDisplayName});for(const tt of LL)tt.condition==="has-selection"&&(!Te||Ee)||Qe.push(tt);return Te&&Qe.push({action:"link",label:"Link to doc",shortcut:"L"}),K()&&Qe.push({action:"unlink",label:"Unlink"}),Qe},[t,K,B,A]);E.useEffect(()=>{const ce=ie=>{var tt;if(ie.button!==2)return;const Be=H(ie.target);if(!Be)return;ne.current=Be;const{from:Te,to:Ue}=Be.state.selection,Ee=[],Qe=[];if(Te!==Ue&&Be.state.doc.nodesBetween(Te,Ue,vt=>{vt.isBlock&&vt.type.name!=="doc"&&(Ee.push(vt.toJSON()),vt.attrs.id&&Qe.push(vt.attrs.id))}),Ee.length===0){const{$from:vt}=Be.state.selection,Ce=vt.parent;Ce&&Ce.type.name!=="doc"&&(Ee.push(Ce.toJSON()),(tt=Ce.attrs)!=null&&tt.id&&Qe.push(Ce.attrs.id))}U.current={from:Te,to:Ue,nodes:Ee,nodeIds:Qe}},ve=ie=>{H(ie.target)&&(ie.shiftKey||(ie.preventDefault(),l({x:ie.clientX,y:ie.clientY}),s(!0),y(!1),k(!1),F(!1),G("")))};return document.addEventListener("mousedown",ce,!0),document.addEventListener("contextmenu",ve),()=>{document.removeEventListener("mousedown",ce,!0),document.removeEventListener("contextmenu",ve)}},[H]);const Y=E.useCallback(async(ce,ve)=>{var at,ft,st,ht,zt;const ie=ne.current||t.current;if(!ie)return;const Be=U.current;if(!Be||Be.nodes.length===0){console.warn("[ContextMenu] No captured selection for action:",ce);return}let{nodes:Te,nodeIds:Ue}=Be;const{from:Ee,to:Qe}=Be;u(!0),s(!1),y(!1);const tt=`ctx-${Date.now()}`,vt=ie.state.doc.resolve(Ee),Ce=ie.state.doc.resolve(Qe),ke=vt.sameParent(Ce)&&Ee!==Qe;ie.commands.applyLoadingEffect(tt,Ee,Qe,ke?"selection":"paragraph");try{const Ct=[],Vt=[],xn=new Set(Ue);let ee=!1;const He=ie.state.doc;for(let $e=0;$e<He.childCount;$e++){const Tt=He.child($e),Kt=(at=Tt.attrs)==null?void 0:at.id;if(Kt&&xn.has(Kt))ee=!0;else if(ee){const L=Tt.textContent.trim();L&&Vt.push(L)}else{const L=Tt.textContent.trim();L&&Ct.push(L)}}const We=ce.includes(":")?ce.split(":").slice(1).join(":"):ce;let _t=Te,nt=!1,it=0,qe=0;if(ke&&Te.length===1){const $e=vt.start(vt.depth);it=Ee-$e,qe=Qe-$e;const Tt=((st=(ft=Te[0])==null?void 0:ft.content)==null?void 0:st.reduce((Kt,L)=>{var oe;return Kt+(((oe=L.text)==null?void 0:oe.length)||(L.type==="hardBreak"?1:0))},0))??0;(it>0||qe<Tt)&&(_t=IL(Te,it,qe),nt=!0)}const Wn=ie.state.doc.textContent,un={nodes:_t,action:We,nodeIds:Ue,contextBefore:Ct.slice(-3),contextAfter:Vt.slice(0,3),fullDocument:Wn,documentId:n,debug:!0};nt&&(un.hasSelectionMarkers=!0),ve&&(un.instruction=ve);const le=await fetch(`${window.location.origin}/api/voice/apply-editor`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(un)});if(!le.ok){const $e=await le.json().catch(()=>({}));console.error("[ContextMenu] API error:",le.status,$e);return}const be=await le.json();if(be.success&&be.nodes){let $e=be.nodes;if($e.length===1&&Array.isArray($e[0])&&($e=$e[0]),jL($e),nt&&$e.length===1&&Ue.length===1){const Tt=xe=>(xe==null?void 0:xe.reduce((Je,Et)=>{var Mt;return Je+(((Mt=Et.text)==null?void 0:Mt.length)||(Et.type==="hardBreak"?1:0))},0))??0,Kt=Tt((ht=Te[0])==null?void 0:ht.content),L=Tt((zt=$e[0])==null?void 0:zt.content),oe={selectionFrom:it,selectionTo:L-(Kt-qe),originalFrom:it,originalTo:qe};xm(ie,Ue[0],$e[0],oe)}else u0(ie,$e,Ue,We)}else console.warn("[ContextMenu] Unexpected response:",be)}catch(Ct){console.error("[ContextMenu] Plugin action failed:",Ct)}finally{ie.commands.removeLoadingEffect(tt),u(!1)}},[t]),se=E.useCallback(async ce=>{const ve=ne.current||t.current;if(!ve)return;const{$from:ie}=ve.state.selection,Be=ie.before(ie.depth),Te=ie.after(ie.depth),Ue=ie.parent.content.size===0;u(!0),s(!1),y(!1);const Ee=`ctx-img-${Date.now()}`;ve.commands.applyLoadingEffect(Ee,Be,Te,"paragraph");try{const tt=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:ce})})).json();tt.success&&tt.src?Ue?ve.chain().focus().deleteRange({from:Be,to:Te}).insertContentAt(Be,{type:"image",attrs:{src:tt.src,alt:ce}}).run():ve.chain().focus().insertContentAt(Te,{type:"image",attrs:{src:tt.src,alt:ce}}).run():console.error("[ContextMenu] Image generation failed:",tt.error)}catch(Qe){console.error("[ContextMenu] Image generation failed:",Qe)}finally{ve.commands.removeLoadingEffect(Ee),u(!1)}},[t]),fe=E.useCallback(ce=>{const{action:ve,isPlugin:ie,promptForInput:Be}=ce;if(ie&&Be){v(ve),y(!0);return}if(ie){if(ve.startsWith("img:"))return;Y(ve);return}if(ve==="agent-mark"){F(!0);return}if(ve==="delete"){const Te=ne.current||t.current;if(Te){const{from:Ue,to:Ee}=Te.state.selection;Te.state.doc.nodesBetween(Ue,Ee,Qe=>{Qe.isBlock&&Qe.type.name!=="doc"&&Qe.attrs.id&&u0(Te,[],[Qe.attrs.id],"delete")})}s(!1);return}if(ve==="link"){const Te=ne.current||t.current;if(Te){const Ue=[];Te.state.doc.descendants(Ee=>{var Qe;(Qe=Ee.marks)==null||Qe.forEach(tt=>{var vt,Ce;if(tt.type.name==="link"&&((Ce=(vt=tt.attrs)==null?void 0:vt.href)!=null&&Ce.startsWith("doc:"))){const ke=tt.attrs.href.slice(4);Ue.includes(ke)||Ue.push(ke)}})}),_(Ue)}fetch("/api/documents").then(Ue=>Ue.json()).then(Ue=>{Array.isArray(Ue)&&T(Ue.map(Ee=>({filename:Ee.filename,title:Ee.title}))),O(!1),$(""),k(!0)}).catch(()=>{});return}if(ve==="unlink"){const Te=ne.current||t.current;Te&&Te.chain().focus().unsetLink().run(),s(!1);return}},[Y,t]),Z=E.useCallback(()=>{f.trim()&&(b.startsWith("img:")?se(f.trim()):Y(b,f.trim()),p(""),v(""))},[Y,se,b,f]),me=E.useCallback(()=>{const ce=ne.current||t.current,ve=U.current;if(!ce||!ve||!n)return;const{from:ie,to:Be,nodeIds:Te}=ve;if(ie===Be||Te.length===0)return;const Ue=ce.state.doc.textBetween(ie,Be,`
204
+ `);Ue.trim()&&fetch("/api/marks",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:n,text:Ue,note:re.trim(),nodeId:Te[Te.length-1]})}).then(()=>{s(!1),F(!1),G("")}).catch(Ee=>{console.error("[ContextMenu] Agent mark failed:",Ee)})},[t,n,re]),Le=E.useCallback(ce=>{const ve=ne.current||t.current;ve&&ve.chain().focus().setLink({href:`doc:${ce}`}).run(),fetch("/api/auto-tag-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetFile:ce})}).catch(()=>{}),s(!1),k(!1)},[t]),Ze=E.useCallback(()=>{const ce=P.trim();if(!ce)return;const ve=ne.current||t.current;ve&&(fetch("/api/create-link-doc",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:ce})}).then(ie=>ie.json()).then(ie=>{ie.filename&&ve.chain().focus().setLink({href:`doc:${ie.filename}`}).run()}).catch(()=>{}),s(!1),k(!1),O(!1),$(""))},[t,P]);return r?d.jsx("div",{ref:te,className:"context-menu",style:{left:i.x,top:i.y},children:c?d.jsx("div",{className:"context-menu-loading",children:"Applying..."}):J?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:re,onChange:ce=>G(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&me(),ce.key==="Escape"&&(F(!1),G(""))},placeholder:"Note for agent (optional)..."}),d.jsx("button",{onClick:me,children:"Mark"})]}):m?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:f,onChange:ce=>p(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&Z(),ce.key==="Escape"&&s(!1)},placeholder:"Custom instruction..."}),d.jsx("button",{onClick:Z,children:"Apply"})]}):w?d.jsxs("div",{className:"context-menu-link-picker",children:[d.jsx("div",{className:"context-menu-link-header",children:"Link to document"}),M?d.jsxs("div",{className:"context-menu-custom",children:[d.jsx("input",{autoFocus:!0,value:P,onChange:ce=>$(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&Ze(),ce.key==="Escape"&&O(!1)},placeholder:"New document title..."}),d.jsx("button",{onClick:Ze,children:"Create"})]}):d.jsx("button",{className:"context-menu-item context-menu-new-link",onClick:()=>O(!0),children:d.jsx("span",{children:"+ New link doc"})}),d.jsxs("div",{className:"context-menu-link-list",children:[I.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-section-header",children:"Linked in this doc"}),N.filter(ce=>I.includes(ce.filename)).map(({filename:ce,title:ve})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Le(ce),children:d.jsx("span",{children:ve})},`linked-${ce}`))]}),d.jsx("div",{className:"context-menu-section-header",children:"All documents"}),N.filter(ce=>!I.includes(ce.filename)).map(({filename:ce,title:ve})=>d.jsx("button",{className:"context-menu-item",onClick:()=>Le(ce),children:d.jsx("span",{children:ve})},ce)),N.length===0&&d.jsx("div",{className:"context-menu-loading",children:"No documents"})]})]}):(()=>{const ce=R();let ve;return ce.map((ie,Be)=>{const Te=ie.isPlugin&&ie.pluginDisplayName&&ie.pluginDisplayName!==ve,Ue=ve!==void 0;ie.isPlugin?ve=ie.pluginDisplayName:ve=void 0;const Ee=!ie.isPlugin&&Ue;return d.jsxs("span",{children:[Te&&d.jsx("div",{className:"context-menu-section-header",children:ie.pluginDisplayName}),Ee&&d.jsx("div",{className:"context-menu-divider"}),d.jsxs("button",{className:"context-menu-item",onClick:()=>fe(ie),children:[d.jsx("span",{children:ie.label}),ie.shortcut&&d.jsx("span",{className:"context-menu-shortcut",children:ie.shortcut})]})]},ie.action)})})()}):null}function wm(t,e,n){let r=t.resolve(e);for(;r.depth>0;){const s=r.node(r.depth),i=r.before(r.depth),l=i+s.nodeSize;if(s.childCount===1)e=i,n=l,r=t.resolve(e);else break}return{from:e,to:n}}function PL(t,e){const n=bn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function BL(t,e){const n=bn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return t.chain().command(({tr:i})=>(i.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null,pendingOriginalContent:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run(),!0}function zL(t,e){var l;const n=bn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="delete")return!0;const i=wm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function $L(t,e){var l;const n=bn(t,e);if(!n)return!0;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="insert")return!0;const i=wm(t.state.doc,s,s+r.nodeSize);return t.chain().deleteRange(i).run(),!0}function FL(t,e){var l,c;const n=bn(t,e);if(!n)return!1;const{node:r,pos:s}=n;if(((l=r.attrs)==null?void 0:l.pendingStatus)!=="rewrite")return!0;const i=(c=r.attrs)==null?void 0:c.pendingOriginalContent;if(i)t.chain().deleteRange({from:s,to:s+r.nodeSize}).insertContentAt(s,i).run();else{const u=wm(t.state.doc,s,s+r.nodeSize);t.chain().deleteRange(u).run()}return!0}function UL(t,e){var i;const n=bn(t,e);if(!n)return!1;const{node:r,pos:s}=n;return((i=r.attrs)==null?void 0:i.pendingStatus)!=="delete"||t.chain().command(({tr:l})=>(l.setNodeMarkup(s,void 0,{...r.attrs,pendingStatus:null}),!0)).run(),!0}function HL(t,e){const n=nd(t,e);if(n.length===0)return!1;for(const r of[...n].reverse()){const s=bn(t,r.nodeId);s&&t.chain().command(({tr:i})=>(i.setNodeMarkup(s.pos,void 0,{...s.node.attrs,pendingStatus:null,pendingOriginalContent:null,pendingGroupId:null,pendingSelectionFrom:null,pendingSelectionTo:null,pendingOriginalFrom:null,pendingOriginalTo:null}),!0)).run()}return!0}function WL(t,e){var c;const n=nd(t,e);if(n.length===0)return!1;const r=(c=n[0].node.attrs)==null?void 0:c.pendingOriginalContent,s=n[0].pos,i=n[n.length-1],l=i.pos+i.node.nodeSize;try{return r&&Array.isArray(r)&&r.length>0?t.chain().deleteRange({from:s,to:l}).insertContentAt(s,r).run():t.chain().deleteRange({from:s,to:l}).run(),!0}catch{return!1}}function C1(t,e){var i,l;const n=bn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return HL(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return PL(t,e);case"rewrite":return BL(t,e);case"delete":return zL(t,e);default:return!1}}function _1(t,e){var i,l;const n=bn(t,e);if(!n)return!1;const r=(i=n.node.attrs)==null?void 0:i.pendingGroupId;if(r)return WL(t,r);switch((l=n.node.attrs)==null?void 0:l.pendingStatus){case"insert":return $L(t,e);case"rewrite":return FL(t,e);case"delete":return UL(t,e);default:return!1}}function VL(t){const e=T1(t).reverse();for(const n of e)C1(t,n);t.view&&vm(t.view)}function KL(t){const e=T1(t).reverse();for(const n of e)_1(t,n);t.view&&vm(t.view)}function km(t){const e=[],n=new Set;return t.state.doc.descendants((r,s)=>{var l,c,u;const i=(l=r.attrs)==null?void 0:l.pendingStatus;if(i&&((c=r.attrs)!=null&&c.id)){const f=(u=r.attrs)==null?void 0:u.pendingGroupId;if(f){if(n.has(f))return!0;n.add(f)}e.push({nodeId:r.attrs.id,pos:s,pendingStatus:i,groupId:f,editor:t})}return!0}),e}function Ch(t){const e=[];for(const n of t)n&&!n.isDestroyed&&e.push(...km(n));return e}function T1(t){return km(t).map(e=>e.nodeId)}function GL(t){let e=0,n=0,r=0;for(const s of t)s.pendingStatus==="insert"?e++:s.pendingStatus==="rewrite"?n++:s.pendingStatus==="delete"&&r++;return{insert:e,rewrite:n,delete:r,total:t.length}}function bl(t,e){if(t.isDestroyed)return;let n=-1;if(t.state.doc.descendants((i,l)=>{var c;return((c=i.attrs)==null?void 0:c.id)===e?(n=l,!1):!0}),n===-1)return;const r=t.view.nodeDOM(n),s=r instanceof HTMLElement?r:r==null?void 0:r.parentElement;if(s){s.scrollIntoView({behavior:"smooth",block:"center"});return}try{const i=t.view.coordsAtPos(n),l=t.view.dom.closest(".editor-container");if(l){const c=l.getBoundingClientRect(),u=i.top-c.top+l.scrollTop-l.clientHeight/2;l.scrollTo({top:u,behavior:"smooth"})}}catch{}}function qL(t){const[e,n]=E.useState([]),[r,s]=E.useState(0),i=E.useRef(),l=E.useRef(new Set),c=E.useCallback(()=>{const N=t.filter(O=>O&&!O.isDestroyed);if(N.length===0){n([]),l.current=new Set;return}const T=Ch(N);n(T);const I=l.current,_=new Set(T.map(O=>O.nodeId));let M=-1;if(I.size>0){for(let O=0;O<T.length;O++)if(!I.has(T[O].nodeId)){M=O;break}}l.current=_,M>=0?(s(M),bl(T[M].editor,T[M].nodeId)):T.length===0?s(0):s(O=>Math.min(O,T.length-1))},[t]);E.useEffect(()=>{const N=t.filter(_=>_&&!_.isDestroyed);if(N.length===0)return;const T=()=>{clearTimeout(i.current),i.current=setTimeout(c,50)};for(const _ of N)_.on("transaction",T);c();const I=setTimeout(()=>{const _=Ch(N.filter(M=>!M.isDestroyed));_.length>0&&bl(_[0].editor,_[0].nodeId)},150);return()=>{for(const _ of N)_.isDestroyed||_.off("transaction",T);clearTimeout(i.current),clearTimeout(I)}},[t,c]),E.useEffect(()=>{const N=e[r]??null;return e0((N==null?void 0:N.nodeId)??null,(N==null?void 0:N.groupId)??null),N!=null&&N.editor&&!N.editor.isDestroyed&&N.editor.view&&vm(N.editor.view),()=>{e0(null)}},[r,e]);const u=GL(e),f=e[r]??null,p=E.useCallback(()=>{if(e.length===0)return;const N=(r+1)%e.length;s(N),e[N]&&bl(e[N].editor,e[N].nodeId)},[e,r]),m=E.useCallback(()=>{if(e.length===0)return;const N=(r-1+e.length)%e.length;s(N),e[N]&&bl(e[N].editor,e[N].nodeId)},[e,r]),y=E.useCallback(()=>{const N=t.filter(_=>_&&!_.isDestroyed),T=Ch(N);if(T.length===0)return;const I=Math.min(r,T.length-1);bl(T[I].editor,T[I].nodeId)},[t,r]),b=E.useCallback(()=>{f&&(C1(f.editor,f.nodeId),c(),y())},[f,c,y]),v=E.useCallback(()=>{f&&(_1(f.editor,f.nodeId),c(),y())},[f,c,y]),w=E.useCallback(()=>{const N=t.filter(T=>T&&!T.isDestroyed);for(const T of N)VL(T);c()},[t,c]),k=E.useCallback(()=>{const N=t.filter(T=>T&&!T.isDestroyed);for(const T of N)KL(T);c()},[t,c]);return{pendingNodes:e,counts:u,currentNode:f,currentIndex:r,hasPending:u.total>0,goToNext:p,goToPrevious:m,acceptCurrent:b,rejectCurrent:v,acceptAll:w,rejectAll:k,refresh:c}}const Oo={strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round"},JL=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M10 3L5 8l5 5",stroke:"currentColor",...Oo})}),h0=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M6 3l5 5-5 5",stroke:"currentColor",...Oo})}),YL=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 10l5-5 5 5",stroke:"currentColor",...Oo})}),QL=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 6l5 5 5-5",stroke:"currentColor",...Oo})}),p0=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 8.5l3.5 3.5L13 5",stroke:"currentColor",...Oo})}),m0=()=>d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M4 4l8 8M12 4l-8 8",stroke:"currentColor",...Oo})});function M1(t,e,n){const r=bn(t,e);if(!r)return!1;const{pos:s,node:i}=r,l={type:n.type||i.type.name,attrs:{...n.attrs||{},id:i.attrs.id,pendingStatus:i.attrs.pendingStatus,pendingOriginalContent:i.attrs.pendingOriginalContent,pendingSelectionFrom:i.attrs.pendingSelectionFrom,pendingSelectionTo:i.attrs.pendingSelectionTo,pendingOriginalFrom:i.attrs.pendingOriginalFrom,pendingOriginalTo:i.attrs.pendingOriginalTo},content:n.content};try{return t.chain().command(({tr:c})=>(c.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:s+i.nodeSize}).insertContentAt(s,l).run(),!0}catch{return!1}}function A1(t,e,n){const r=nd(t,e);if(r.length===0)return!1;const s=r[0].pos,i=r[r.length-1].pos+r[r.length-1].node.nodeSize;try{return t.chain().command(({tr:l})=>(l.setMeta("addToHistory",!1),!0)).deleteRange({from:s,to:i}).insertContentAt(s,n).run(),!0}catch{return!1}}function Rc(t,e){if(!bm()||!e)return!1;const n=iL(),r=sL();return r&&n&&Array.isArray(n)?A1(t,r,n):n&&M1(t,e,n),mp(!1),!0}function XL({editors:t,pendingDocs:e,currentFilename:n,onSwitchDocument:r,sendMessage:s,getDocument:i}){const{counts:l,currentNode:c,currentIndex:u,hasPending:f,goToNext:p,goToPrevious:m,acceptCurrent:y,rejectCurrent:b,acceptAll:v,rejectAll:w}=qL(t),[k,N]=E.useState(!1),T=E.useRef(null),I=E.useRef(null),_=e.filenames.length,M=g0(e.filenames,n)>=0?_-1:_,O=f||_>0,P=g0(e.filenames,n),$=(c==null?void 0:c.pendingStatus)==="rewrite",B=!!(c!=null&&c.groupId),W=$,J=E.useCallback(()=>{var R,Y;const A=c==null?void 0:c.editor;if(!(!A||!c||c.pendingStatus!=="rewrite"))if(k)I.current&&Rc(I.current,T.current),T.current=null,I.current=null,N(!1);else if(B&&c.groupId){const se=nd(A,c.groupId);if(se.length===0)return;const fe=(R=se[0].node.attrs)==null?void 0:R.pendingOriginalContent;if(!fe||!Array.isArray(fe))return;const Z=se.map(Ze=>Ze.node.toJSON()),me=fe.map((Ze,ce)=>({...Ze,attrs:{...Ze.attrs||{},pendingStatus:"rewrite",pendingGroupId:c.groupId,...ce===0?{pendingOriginalContent:fe}:{}}}));if(!A1(A,c.groupId,me))return;mp(!0,c.nodeId,Z,c.groupId),T.current=c.nodeId,I.current=A,N(!0)}else{const se=bn(A,c.nodeId);if(!se)return;const{node:fe}=se,Z=(Y=fe.attrs)==null?void 0:Y.pendingOriginalContent;if(!Z)return;const me=fe.toJSON();if(!M1(A,c.nodeId,Z))return;mp(!0,c.nodeId,me),T.current=c.nodeId,I.current=A,N(!0)}},[c,k,B]);E.useEffect(()=>{if(!k)return;const A=T.current,R=I.current;A&&R&&(c==null?void 0:c.nodeId)!==A&&(Rc(R,A),T.current=null,I.current=null,N(!1))},[c==null?void 0:c.nodeId,k]),E.useEffect(()=>{if(t.length!==0)return()=>{bm()&&T.current&&I.current&&(Rc(I.current,T.current),T.current=null,I.current=null)}},[t]);const F=E.useCallback(A=>{if(!n)return;if(!t.some(Y=>!Y||Y.isDestroyed?!1:km(Y).length>0)){const Y=i==null?void 0:i();Y&&s({type:"doc-update",document:Y,filename:n}),s({type:"pending-resolved",filename:n,action:A})}},[t,n,s,i]),re=E.useCallback(()=>{I.current&&k&&T.current&&(Rc(I.current,T.current),T.current=null,I.current=null,N(!1))},[k]),G=E.useCallback(()=>{re(),y(),F("accept")},[re,y,F]),te=E.useCallback(()=>{re(),b(),F("reject")},[re,b,F]),U=E.useCallback(()=>{re(),v(),F("accept")},[re,v,F]),ne=E.useCallback(()=>{re(),w(),F("reject")},[re,w,F]),H=E.useCallback(()=>{if(_===0||_===1&&P===0)return;const A=P<=0?_-1:P-1;r(e.filenames[A])},[_,P,e.filenames,r]),X=E.useCallback(()=>{if(_===0||_===1&&P===0)return;const A=P>=_-1?0:P+1;r(e.filenames[A])},[_,P,e.filenames,r]);if(E.useEffect(()=>{if(!O)return;const A=R=>{if(!(R.target instanceof HTMLInputElement||R.target instanceof HTMLTextAreaElement)&&!(R.target instanceof HTMLElement&&R.target.closest("[contenteditable]")))switch(R.key){case"j":case"ArrowDown":!R.metaKey&&!R.ctrlKey&&(R.preventDefault(),p());break;case"k":case"ArrowUp":!R.metaKey&&!R.ctrlKey&&(R.preventDefault(),m());break;case"h":case"ArrowLeft":!R.metaKey&&!R.ctrlKey&&!R.altKey&&(R.preventDefault(),H());break;case"l":case"ArrowRight":!R.metaKey&&!R.ctrlKey&&!R.altKey&&(R.preventDefault(),X());break;case"a":!R.metaKey&&!R.ctrlKey&&!R.shiftKey&&(R.preventDefault(),G());break;case"r":!R.metaKey&&!R.ctrlKey&&(R.preventDefault(),te());break;case"A":R.shiftKey&&!R.metaKey&&!R.ctrlKey&&(R.preventDefault(),U());break;case"R":R.shiftKey&&!R.metaKey&&!R.ctrlKey&&(R.preventDefault(),ne());break;case"o":!R.metaKey&&!R.ctrlKey&&!R.shiftKey&&(R.preventDefault(),J());break}};return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[O,p,m,H,X,G,te,U,ne,J]),!O)return null;if(c!=null&&c.pendingStatus,!f&&M>0)return d.jsxs("div",{className:"review-panel",children:[d.jsxs("div",{className:"review-panel__status",children:["No changes here — ",M," other doc",M>1?"s have":" has"," changes"]}),d.jsx("div",{className:"review-panel__divider"}),d.jsx("div",{className:"review-panel__nav",children:d.jsx("button",{className:"review-panel__btn",onClick:X,title:"Next doc (l)",children:d.jsx(h0,{})})})]});const K=P>=0?P+1:"?";return d.jsxs("div",{className:"review-panel",children:[_>1&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"review-panel__nav",children:[d.jsx("button",{className:"review-panel__btn",onClick:H,title:"Previous doc (h)",children:d.jsx(JL,{})}),d.jsx("button",{className:"review-panel__btn",onClick:X,title:"Next doc (l)",children:d.jsx(h0,{})}),d.jsxs("span",{className:"review-panel__counter",children:[K,"/",_]})]}),d.jsx("div",{className:"review-panel__divider"})]}),d.jsxs("div",{className:"review-panel__nav",children:[d.jsx("button",{className:"review-panel__btn",onClick:m,disabled:l.total<=1,title:"Previous (k)",children:d.jsx(YL,{})}),d.jsx("button",{className:"review-panel__btn",onClick:p,disabled:l.total<=1,title:"Next (j)",children:d.jsx(QL,{})}),d.jsxs("span",{className:"review-panel__counter",children:[u+1,"/",l.total]})]}),d.jsx("div",{className:"review-panel__divider"}),d.jsxs("div",{className:"review-panel__toggle",children:[d.jsx("button",{className:`review-panel__toggle-btn${W&&!k?" review-panel__toggle-btn--active":""}`,onClick:()=>W&&k&&J(),disabled:!W,title:"Show modified (o)",children:"Modified"}),d.jsx("button",{className:`review-panel__toggle-btn${W&&k?" review-panel__toggle-btn--active":""}`,onClick:()=>W&&!k&&J(),disabled:!W,title:"Show original (o)",children:"Original"})]}),d.jsx("div",{className:"review-panel__divider"}),d.jsxs("div",{className:"review-panel__actions",children:[d.jsx("button",{className:"review-panel__accept",onClick:G,title:"Accept (a)",children:d.jsx(p0,{})}),d.jsx("button",{className:"review-panel__reject",onClick:te,title:"Reject (r)",children:d.jsx(m0,{})}),d.jsxs("button",{className:"review-panel__accept-all",onClick:U,title:"Accept all (Shift+A)",children:[d.jsx(p0,{}),d.jsx("span",{children:"All"})]}),d.jsxs("button",{className:"review-panel__reject-all",onClick:ne,title:"Reject all (Shift+R)",children:[d.jsx(m0,{}),d.jsx("span",{children:"All"})]})]})]})}function g0(t,e){return t.indexOf(e)}function Ic(t){return t.type==="doc"?t.file:t.id}function O1(t,e){for(const n of t)n.type==="doc"?e.add(n.file):n.type==="container"&&O1(n.items,e)}function Mo(t){const e=new Date(t),n=Date.now()-e.getTime();return n<6e4?"just now":n<36e5?`${Math.floor(n/6e4)}m ago`:n<864e5?`${Math.floor(n/36e5)}h ago`:n<6048e5?`${Math.floor(n/864e5)}d ago`:e.toLocaleDateString()}function yp(t){return/^[A-Z]:[/\\]|^\//.test(t)}function R1(t){const e=t.replace(/\\/g,"/").split("/");return e.length>=2?e[e.length-2]:""}function ZL(t){const e=new Date(t),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),s=new Date(r.getTime()-864e5),i=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.getTime()===r.getTime()?"Today":i.getTime()===s.getTime()?"Yesterday":n.getTime()-i.getTime()<6048e5?e.toLocaleDateString(void 0,{weekday:"long"}):e.toLocaleDateString(void 0,{month:"short",day:"numeric"})}function eD(t,e){const[n,r]=E.useState([]),[s,i]=E.useState([]),[l,c]=E.useState(new Set),u=E.useRef(null),f=E.useCallback(()=>{fetch("/api/documents").then(m=>m.json()).then(m=>{Array.isArray(m)&&r(m)}).catch(()=>{})},[]),p=E.useCallback(()=>{fetch("/api/workspaces").then(m=>m.json()).then(async m=>{if(!Array.isArray(m))return;const y=await Promise.all(m.map(async v=>{try{const k=await(await fetch(`/api/workspaces/${encodeURIComponent(v.filename)}`)).json();return{...v,workspace:k}}catch{return v}}));i(y);const b=new Set;for(const v of y)v.workspace&&O1(v.workspace.root,b);c(b)}).catch(()=>{})},[]);return E.useEffect(()=>{f()},[f,t]),E.useEffect(()=>{p()},[p,e,t]),E.useEffect(()=>{const m=requestAnimationFrame(()=>{var b;const y=(b=u.current)==null?void 0:b.querySelector(".sidebar-item.active");y==null||y.scrollIntoView({block:"nearest",behavior:"instant"})});return()=>cancelAnimationFrame(m)},[n]),{docs:n,workspaces:s,assignedFiles:l,fetchDocs:f,scrollRef:u}}function tD(t,e,n){const r=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),s=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}/archive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),i=E.useCallback(M=>{fetch(`/api/documents/${encodeURIComponent(M)}/unarchive`,{method:"POST"}).then(()=>e()).catch(()=>{})},[e]),l=E.useCallback((M,O,P)=>{!P.trim()||P.trim()===O||fetch(`/api/documents/${encodeURIComponent(M)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:P.trim()})}).then(()=>e()).catch(()=>{})},[e]),c=E.useCallback(()=>{fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:"Untitled Workspace"})}).catch(()=>{})},[]),u=E.useCallback(M=>{fetch(`/api/workspaces/${encodeURIComponent(M)}`,{method:"DELETE"}).catch(()=>{})},[]),f=E.useCallback((M,O,P)=>{fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(P?{metadata:P}:{})}).then($=>$.json()).then($=>{if($.filename)return fetch(`/api/workspaces/${encodeURIComponent(M)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:$.filename,title:$.title||"Untitled",containerId:O})})}).catch(()=>{})},[]),p=E.useCallback((M,O)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/docs/${encodeURIComponent(O)}`,{method:"DELETE"}).catch(()=>{})},[]),m=E.useCallback((M,O)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/containers`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:"Untitled",parentContainerId:O})}).catch(()=>{})},[]),y=E.useCallback((M,O)=>{fetch(`/api/workspaces/${encodeURIComponent(M)}/containers/${encodeURIComponent(O)}`,{method:"DELETE"}).catch(()=>{})},[]),b=E.useCallback((M,O,P)=>{P.trim()&&fetch(`/api/workspaces/${encodeURIComponent(M)}/containers/${encodeURIComponent(O)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:P.trim()})}).catch(()=>{})},[]),v=E.useCallback((M,O)=>{O.trim()&&fetch(`/api/workspaces/${encodeURIComponent(M)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:O.trim()})}).catch(()=>{})},[]),[w,k]=E.useState({}),N=E.useRef(-1);E.useEffect(()=>{n!==N.current&&(N.current=n??0,fetch("/api/documents").then(M=>M.json()).then(M=>{const O={};return Promise.all(M.map(P=>fetch(`/api/doc-tags/${encodeURIComponent(P.filename)}`).then($=>$.json()).then($=>{var B;(B=$.tags)!=null&&B.length&&(O[P.filename]=$.tags)}).catch(()=>{}))).then(()=>k(O))}).catch(()=>{}))},[n]);const T=E.useCallback(M=>w[M]||[],[w]),I=E.useCallback((M,O)=>{O.trim()&&(k(P=>{const $=P[M]||[];return $.includes(O.trim())?P:{...P,[M]:[...$,O.trim()]}}),fetch(`/api/doc-tags/${encodeURIComponent(M)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tag:O.trim()})}).catch(()=>{}))},[]),_=E.useCallback((M,O)=>{k(P=>{const B=(P[M]||[]).filter(W=>W!==O);if(B.length===0){const W={...P};return delete W[M],W}return{...P,[M]:B}}),fetch(`/api/doc-tags/${encodeURIComponent(M)}/${encodeURIComponent(O)}`,{method:"DELETE"}).catch(()=>{})},[]);return{fetchDocs:e,handleDelete:r,handleArchive:s,handleUnarchive:i,handleRename:l,handleCreateWorkspace:c,handleDeleteWorkspace:u,handleCreateInWorkspace:f,handleRemoveFromWorkspace:p,handleCreateContainer:m,handleDeleteContainer:y,handleRenameContainer:b,handleRenameWorkspace:v,getDocTags:T,handleAddTag:I,handleRemoveTag:_}}function nD({docs:t,workspaces:e,assignedFiles:n,scrollRef:r,setCollapsedSections:s}){const[i,l]=E.useState(null),[c,u]=E.useState(null),f=E.useRef(null),p=E.useRef(null),m=E.useRef(null),y=E.useRef(null),b=E.useRef(null),v=5,w=(W,J,F)=>F==="before"?J>0?Ic(W[J-1]):null:Ic(W[J]),k=E.useCallback((W,J)=>{if(J===null){const G=t.filter(U=>!n.has(U.filename)).map(U=>({type:"doc",file:U.filename,title:U.title})),te=G.findIndex(U=>Ic(U)===W);return te>=0?{siblings:G,index:te,containerId:null}:null}const F=e.find(G=>G.filename===J);if(!(F!=null&&F.workspace))return null;const re=(G,te)=>{for(let U=0;U<G.length;U++){if(Ic(G[U])===W)return{siblings:G,index:U,containerId:te};if(G[U].type==="container"){const ne=re(G[U].items,G[U].id);if(ne)return ne}}return null};return re(F.workspace.root,null)},[t,n,e]),N=E.useCallback(()=>{l(null),u(null),b.current=null,y.current=null,m.current&&(m.current.remove(),m.current=null),f.current&&(clearTimeout(f.current),f.current=null),p.current&&(cancelAnimationFrame(p.current),p.current=null),document.body.style.userSelect=""},[]),T=E.useCallback((W,J)=>{if(!W||!J)return;if(W.type==="workspace"){const H=J.itemId;if(H===W.filename)return;const X=e.map(R=>R.filename),K=X.indexOf(W.filename);if(K<0)return;X.splice(K,1);let A=X.indexOf(H);if(A<0)return;J.position==="after"&&(A+=1),X.splice(A,0,W.filename),fetch("/api/workspaces/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:X})}).catch(()=>{});return}const{wsFilename:F,containerId:re,afterId:G}=J,te=W.type==="doc"?W.file:W.id,U=W.sourceWs;if(J.itemId===te)return;if(W.type==="container"){if(U!==F||!F)return;fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(te)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:re??null,afterFile:G})}).catch(()=>{});return}const ne=W.file;if(U===null&&F===null){const H=t.filter(Y=>!n.has(Y.filename)).map(Y=>Y.filename),X=H.indexOf(ne);if(X<0)return;H.splice(X,1);let K=G?H.indexOf(G):-1;K>=0?K+=1:K=0,H.splice(K,0,ne);const A=[];let R=0;for(const Y of t)n.has(Y.filename)?A.push(Y.filename):A.push(H[R++]);fetch("/api/documents/reorder",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({order:A})}).catch(()=>{});return}if(U===null&&F!==null){fetch(`/api/workspaces/${encodeURIComponent(F)}/docs`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file:ne,title:ne.replace(/\.md$/,""),containerId:re??null,afterFile:G})}).catch(()=>{});return}if(U!==null&&F===null){fetch(`/api/workspaces/${encodeURIComponent(U)}/docs/${encodeURIComponent(ne)}`,{method:"DELETE"}).catch(()=>{});return}if(U===F&&F!==null){fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(ne)}/move`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({targetContainerId:re??null,afterFile:G})}).catch(()=>{});return}U!==null&&F!==null&&fetch(`/api/workspaces/${encodeURIComponent(F)}/docs/${encodeURIComponent(ne)}/cross-move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sourceWorkspace:U,containerId:re??null,afterFile:G,title:ne.replace(/\.md$/,"")})}).catch(()=>{})},[e,t,n]),I=E.useCallback((W,J)=>{const F=m.current;F&&(F.style.display="none");const re=document.elementFromPoint(W,J);if(F&&(F.style.display=""),!re)return null;if((i==null?void 0:i.type)==="workspace"){const Y=re.closest("[data-ws-drag]");if(Y){const se=Y.dataset.wsDrag,fe=Y.getBoundingClientRect(),Z=(J-fe.top)/fe.height;return{itemId:se,position:Z<.5?"before":"after",wsFilename:null,containerId:null,afterId:null}}return null}const G=re.closest("[data-drag-id]");if(!G){const Y=re.closest("[data-drop-ws]");return Y?{itemId:"__section__",position:"inside",wsFilename:Y.dataset.dropWs==="__docs__"?null:Y.dataset.dropWs,containerId:Y.dataset.dropContainer||null,afterId:null}:null}const te=G.dataset.dragId,U=G.dataset.dragType,ne=G.dataset.dragWs==="__docs__"?null:G.dataset.dragWs,H=G.getBoundingClientRect(),X=(J-H.top)/H.height;if(U==="container-header"){const Y=te,se=G.dataset.dragParent||null,fe=k(Y,ne);return fe?X<.25?{itemId:Y,position:"before",wsFilename:ne,containerId:se,afterId:w(fe.siblings,fe.index,"before")}:X>.75?{itemId:Y,position:"after",wsFilename:ne,containerId:se,afterId:w(fe.siblings,fe.index,"after")}:{itemId:Y,position:"inside",wsFilename:ne,containerId:Y,afterId:null}:null}const K=G.dataset.dragContainer||null,A=k(te,ne);if(!A)return null;const R=X<.5?"before":"after";return{itemId:te,position:R,wsFilename:ne,containerId:K,afterId:w(A.siblings,A.index,R)}},[k,i]),_=E.useCallback(W=>{const J=r.current;if(!J)return;const F=J.getBoundingClientRect(),re=80,G=18;let te=0;if(W<F.top+re?te=-G*Math.max(0,1-(W-F.top)/re):W>F.bottom-re&&(te=G*Math.max(0,1-(F.bottom-W)/re)),p.current&&(cancelAnimationFrame(p.current),p.current=null),te!==0){const U=()=>{J.scrollTop+=te,p.current=requestAnimationFrame(U)};p.current=requestAnimationFrame(U)}},[r]),M=E.useCallback((W,J)=>{const F=m.current;F&&(F.style.display="none");const re=document.elementFromPoint(W,J);F&&(F.style.display="");const G=re==null?void 0:re.closest("[data-section-key]");if(!G){f.current&&(clearTimeout(f.current),f.current=null);return}const te=G.dataset.sectionKey;f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{s(U=>{if(!U.has(te))return U;const ne=new Set(U);return ne.delete(te),ne})},500)},[s]);E.useEffect(()=>{if(!i)return;const W=F=>{m.current&&(m.current.style.left=`${F.clientX+12}px`,m.current.style.top=`${F.clientY-8}px`),u(I(F.clientX,F.clientY)),_(F.clientY),M(F.clientX,F.clientY)},J=F=>{T(i,I(F.clientX,F.clientY)),N()};return window.addEventListener("pointermove",W),window.addEventListener("pointerup",J),()=>{window.removeEventListener("pointermove",W),window.removeEventListener("pointerup",J)}},[i,I,T,N,_,M]);const O=E.useCallback((W,J,F)=>{if(W.button!==0||W.target.closest("input, button, .sidebar-tag-remove, .sidebar-tag-add, .sidebar-container-actions, .sidebar-delete-btn, .sidebar-confirm-delete, .sidebar-inline-confirm"))return;y.current={x:W.clientX,y:W.clientY},b.current=J;const G=U=>{if(!y.current||!b.current)return;const ne=U.clientX-y.current.x,H=U.clientY-y.current.y;if(Math.abs(ne)+Math.abs(H)>=v){document.body.style.userSelect="none",window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",te),l(b.current),b.current=null;const X=document.createElement("div");X.style.cssText="position:fixed;pointer-events:none;z-index:9999;padding:4px 10px;background:var(--bg-surface, white);border:1px solid var(--border, #cbd5e1);border-radius:6px;font-size:12px;box-shadow:0 2px 8px rgba(0,0,0,0.12);max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-dark, #334155);",X.textContent=F,document.body.appendChild(X),m.current=X,X.style.left=`${U.clientX+12}px`,X.style.top=`${U.clientY-8}px`}},te=()=>{window.removeEventListener("pointermove",G),window.removeEventListener("pointerup",te),y.current=null,b.current=null,document.body.style.userSelect=""};window.addEventListener("pointermove",G),window.addEventListener("pointerup",te)},[]);return{draggedItem:i,dropIndicator:c,handlePointerDown:O,dropClass:W=>!c||c.itemId!==W?"":c.position==="before"?"drop-before":c.position==="after"?"drop-after":c.position==="inside"?"drop-inside":"",isDragging:W=>i?i.type==="doc"?i.file===W:i.type==="workspace"?i.filename===W:i.id===W:!1,isContainerDropTarget:W=>!c||!i?!1:c.containerId===W}}function rD({x:t,y:e,filename:n,title:r,onClose:s,onDuplicate:i,onRename:l,onArchive:c,onDelete:u,onPluginAction:f,pluginItems:p,onNewsletterSend:m,onSchedulePost:y,onViewAnalytics:b,viewAnalyticsLabel:v}){const w=E.useRef(null),[k,N]=E.useState(!1),[T,I]=E.useState(!1),[_,M]=E.useState({left:t,top:e}),[O,P]=E.useState([]),[$,B]=E.useState(!1);E.useEffect(()=>{fetch("/api/connections").then(F=>F.json()).then(F=>{const re=(F.connections||[]).filter(G=>G.provider==="newsletter"&&G.status==="active");P(re)}).catch(()=>{})},[]),E.useLayoutEffect(()=>{const F=w.current;if(!F)return;const re=F.getBoundingClientRect(),G=8;let te=t,U=e;e+re.height+G>window.innerHeight&&(U=e-re.height),t+re.width+G>window.innerWidth&&(te=t-re.width),U<G&&(U=G),te<G&&(te=G),M({left:te,top:U})},[t,e]),E.useEffect(()=>{const F=re=>{w.current&&!w.current.contains(re.target)&&s()};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[s]),E.useEffect(()=>{const F=re=>{re.key==="Escape"&&s()};return document.addEventListener("keydown",F),()=>document.removeEventListener("keydown",F)},[s]);const W=E.useCallback(F=>{f(F.action,F),s()},[f,s]),J=E.useCallback(()=>{m&&(O.length===1?(m(O[0].id),s()):B(!$))},[m,O,$,s]);return d.jsxs("div",{ref:w,className:"context-menu",style:{left:_.left,top:_.top},children:[d.jsx("button",{className:"context-menu-item",onClick:()=>{i(),s()},children:d.jsx("span",{children:"Duplicate"})}),d.jsx("button",{className:"context-menu-item",onClick:()=>{l(),s()},children:d.jsx("span",{children:"Rename"})}),T?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:F=>F.stopPropagation(),children:[d.jsx("span",{children:"Archive?"}),d.jsx("button",{onClick:()=>{c(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>I(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item",onClick:()=>I(!0),children:d.jsx("span",{children:"Archive"})}),k?d.jsxs("div",{className:"context-menu-item sidebar-ctx-confirm",onClick:F=>F.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{u(),s()},children:"Yes"}),d.jsx("button",{onClick:()=>N(!1),children:"No"})]}):d.jsx("button",{className:"context-menu-item sidebar-ctx-delete",onClick:()=>N(!0),children:d.jsx("span",{children:"Delete"})}),y&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{y(),s()},children:d.jsx("span",{children:"Schedule Post"})})]}),O.length>0&&m&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:J,children:d.jsx("span",{children:"Send as Newsletter"})}),$&&O.length>1&&d.jsx("div",{className:"context-menu-sub",children:O.map(F=>d.jsx("button",{className:"context-menu-item context-menu-sub-item",onClick:()=>{m(F.id),s()},children:d.jsx("span",{children:F.display_name})},F.id))})]}),b&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"context-menu-divider"}),d.jsx("button",{className:"context-menu-item",onClick:()=>{b(),s()},children:d.jsx("span",{children:v||"View Analytics"})})]}),p.length>0&&d.jsx(d.Fragment,{children:(()=>{let F;return p.map(re=>{const G=re.pluginDisplayName&&re.pluginDisplayName!==F;return F=re.pluginDisplayName,d.jsxs("span",{children:[G&&d.jsx("div",{className:"context-menu-divider"}),G&&d.jsx("div",{className:"context-menu-section-header",children:re.pluginDisplayName}),d.jsx("button",{className:"context-menu-item",onClick:()=>W(re),children:d.jsx("span",{children:re.label})})]},re.action)})})()})]})}function sD({actionLabel:t,docTitle:e,onConfirm:n,onClose:r}){const[s,i]=E.useState(""),l=E.useRef(null);E.useEffect(()=>{var u;(u=l.current)==null||u.focus()},[]),E.useEffect(()=>{const u=f=>{f.key==="Escape"&&r()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[r]);const c=E.useCallback(()=>{n(s.trim())},[s,n]);return d.jsx("div",{className:"focus-modal-overlay",onClick:r,children:d.jsxs("div",{className:"focus-modal",onClick:u=>u.stopPropagation(),children:[d.jsxs("div",{className:"focus-modal-header",children:[d.jsx("h2",{children:t}),d.jsx("button",{className:"focus-modal-close",onClick:r,children:"×"})]}),d.jsxs("div",{className:"focus-modal-body",children:[d.jsxs("label",{children:['Focus instructions for "',e,'"',d.jsx("textarea",{ref:l,value:s,onChange:u=>i(u.target.value.slice(0,500)),placeholder:"Optional: guide the transformation (e.g. 'focus on the intro section', 'keep it professional')...",onKeyDown:u=>{u.key==="Enter"&&(u.ctrlKey||u.metaKey)&&c()}})]}),d.jsxs("div",{className:"focus-modal-hint",children:[s.length,"/500"]}),d.jsxs("div",{className:"focus-modal-actions",children:[d.jsx("button",{className:"focus-modal-btn secondary",onClick:r,children:"Cancel"}),d.jsx("button",{className:"focus-modal-btn primary",onClick:c,children:"Go"})]})]})]})})}function _h(t,e){if(!e)return[t];const n=[],r=t.toLowerCase(),s=e.toLowerCase();let i=0;for(;i<t.length;){const l=r.indexOf(s,i);if(l===-1){n.push(t.slice(i));break}l>i&&n.push(t.slice(i,l)),n.push(d.jsx("mark",{children:t.slice(l,l+e.length)},l)),i=l+e.length}return n}function y0({r:t,query:e,onClick:n}){return d.jsxs("div",{className:`sidebar-item search-result-item ${t.isActive?"active":""} ${t.isArchived?"search-result-archived":""}`,onClick:n,children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-item-title-text",children:t.matchType==="title"?_h(t.title,e):t.title}),t.isArchived&&d.jsx("span",{className:"search-archived-badge",children:"archived"})]}),t.matchType==="tag"&&t.matchedTag&&d.jsxs("div",{className:"search-result-tag",children:["Tag: ",_h(t.matchedTag,e)]}),t.matchType==="content"&&t.snippet&&d.jsx("div",{className:"search-result-snippet",children:_h(t.snippet,e)}),d.jsxs("div",{className:"sidebar-item-meta",children:[t.wordCount.toLocaleString()," words · ",Mo(t.lastModified)]})]})}function Sm({results:t,query:e,onSwitchDocument:n,actions:r}){if(t.length===0)return d.jsx("div",{className:"sidebar-scroll",children:d.jsxs("div",{className:"search-empty",children:['No results for "',e,'"']})});const s=t.filter(l=>!l.isArchived),i=t.filter(l=>l.isArchived);return d.jsx("div",{className:"sidebar-scroll",children:d.jsxs("div",{className:"search-results",children:[s.map(l=>d.jsx(y0,{r:l,query:e,onClick:()=>n(l.filename)},l.filename)),i.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"search-archived-divider",children:d.jsx("span",{children:"Archived"})}),i.map(l=>d.jsx(y0,{r:l,query:e,onClick:()=>r.handleUnarchive(l.filename)},l.filename))]})]})})}function I1({connectionId:t,subject:e,filename:n,onBeforeSend:r,onClose:s}){const[i,l]=E.useState("confirm"),[c,u]=E.useState("html"),[f,p]=E.useState(""),[m,y]=E.useState(null),[b,v]=E.useState(null),[w,k]=E.useState(0),[N,T]=E.useState(null),[I,_]=E.useState(null),[M,O]=E.useState("all"),[P,$]=E.useState([]),[B,W]=E.useState(""),J=E.useRef(null),F=P.find(U=>U.id===B),re=M==="exclude_issue"&&F&&I!=null?Math.max(0,I-F.recipient_count):I;E.useEffect(()=>{fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_subscribers",arguments:{limit:1}})}).then(U=>U.json()).then(U=>{var H,X;const ne=(X=(H=U.content)==null?void 0:H[0])!=null&&X.text?JSON.parse(U.content[0].text):U;ne.count!=null&&_(ne.count)}).catch(()=>{}),fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"list_newsletter_issues",arguments:{limit:10}})}).then(U=>U.json()).then(U=>{var H,X;const ne=(X=(H=U.content)==null?void 0:H[0])!=null&&X.text?JSON.parse(U.content[0].text):U;ne.issues&&$(ne.issues)}).catch(()=>{})},[]);const G=()=>i==="sent"?{sentCount:w,issueId:N,sentAt:new Date().toISOString()}:void 0;E.useEffect(()=>{const U=ne=>{i!=="sending"&&i!=="testing"&&J.current&&!J.current.contains(ne.target)&&s(G())};return document.addEventListener("mousedown",U),()=>document.removeEventListener("mousedown",U)},[s,i,w,N]),E.useEffect(()=>{const U=ne=>{ne.key==="Escape"&&i!=="sending"&&i!=="testing"&&s(G())};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[s,i,w,N]);async function te(U){var ne,H;l(U?"testing":"sending"),v(null);try{r&&await r();const X={subject:e,connectionId:t,format:c};U&&(X.test_email=U),!U&&M==="exclude_issue"&&B&&(X.exclude_issue_id=B);const A=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:"send_newsletter",arguments:X})})).json(),R=(H=(ne=A.content)==null?void 0:ne[0])!=null&&H.text?JSON.parse(A.content[0].text):A;if(R.error){v(R.error),l("error");return}if(R.test){y(R.sent_to),l("confirm");return}const Y=R.sent||0,se=R.issueId||null,fe=new Date().toISOString();k(Y),T(se),l("sent"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:{lastSend:{sentCount:Y,sentAt:fe,issueId:se||void 0}}})}).catch(()=>{})}catch(X){v(X.message),l("error")}}return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"newsletter-modal",ref:J,children:[d.jsxs("div",{className:"newsletter-modal__header",children:[d.jsx("h3",{children:"Send Newsletter"}),d.jsx("button",{className:"newsletter-modal__close",onClick:()=>s(G()),children:"×"})]}),d.jsxs("div",{className:"newsletter-modal__body",children:[i==="confirm"&&d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:"newsletter-modal__confirm-text",style:re==null?{visibility:"hidden"}:void 0,children:['Send "',d.jsx("strong",{children:e}),'" to ',re!=null?re.toLocaleString():0," subscriber",re!==1?"s":"","?"]}),d.jsxs("div",{className:"newsletter-modal__audience",children:[d.jsx("label",{className:"newsletter-modal__label",children:"Audience"}),d.jsxs("select",{className:"newsletter-modal__select",value:M,onChange:U=>{const ne=U.target.value;O(ne),ne==="all"&&W("")},children:[d.jsx("option",{value:"all",children:"All subscribers"}),P.length>0&&d.jsx("option",{value:"exclude_issue",children:"Exclude who received..."})]}),M==="exclude_issue"&&d.jsxs("select",{className:"newsletter-modal__select",value:B,onChange:U=>W(U.target.value),children:[d.jsx("option",{value:"",children:"Select a past issue"}),P.map(U=>d.jsxs("option",{value:U.id,children:[U.subject," (",U.recipient_count," sent)"]},U.id))]})]}),d.jsxs("div",{className:"newsletter-modal__format-toggle",children:[d.jsx("button",{className:`newsletter-modal__format-btn${c==="html"?" active":""}`,onClick:()=>u("html"),children:"HTML"}),d.jsx("button",{className:`newsletter-modal__format-btn${c==="plaintext"?" active":""}`,onClick:()=>u("plaintext"),children:"Plaintext"})]}),d.jsxs("div",{className:"newsletter-modal__test-section",children:[d.jsxs("div",{className:"newsletter-modal__test-row",children:[d.jsx("input",{type:"email",className:"newsletter-modal__test-input",placeholder:"Test email address",value:f,onChange:U=>p(U.target.value),onKeyDown:U=>{U.key==="Enter"&&f.trim()&&te(f.trim())}}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--test",disabled:!f.trim(),onClick:()=>te(f.trim()),children:"Send Test"})]}),m&&d.jsxs("p",{className:"newsletter-modal__test-success",children:["Test sent to ",m]})]}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",disabled:M==="exclude_issue"&&!B,onClick:()=>te(),children:"Send Now"})]})]}),(i==="sending"||i==="testing")&&d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:i==="testing"?"Sending test...":"Sending..."})]}),i==="sent"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"newsletter-modal__status newsletter-modal__status--success",children:["Sent to ",w," subscriber",w!==1?"s":"","!"]}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>s({sentCount:w,issueId:N,sentAt:new Date().toISOString()}),children:"Done"})})]}),i==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"newsletter-modal__error",children:b}),d.jsxs("div",{className:"newsletter-modal__actions",children:[d.jsx("button",{className:"newsletter-modal__btn",onClick:s,children:"Cancel"}),d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:()=>te(),children:"Retry"})]})]})]})]})})}async function Th(t,e={}){var s,i;const r=await(await fetch("/api/mcp-call",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tool:t,arguments:e})})).json();return(i=(s=r.content)==null?void 0:s[0])!=null&&i.text?JSON.parse(r.content[0].text):r}function Mh(t,e){return e?(t/e*100).toFixed(1)+"%":"0%"}function b0(t){return new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"})}function v0(t,e=50){try{const n=new URL(t),r=n.hostname+n.pathname+n.search;return r.length>e?r.slice(0,e)+"...":r}catch{return t.length>e?t.slice(0,e)+"...":t}}function iD({docId:t,title:e,onClose:n}){const[r,s]=E.useState("loading"),[i,l]=E.useState([]),[c,u]=E.useState(""),[f,p]=E.useState(null),[m,y]=E.useState(null),[b,v]=E.useState("links"),[w,k]=E.useState("all"),[N,T]=E.useState(!1),[I,_]=E.useState(!1),[M,O]=E.useState(""),[P,$]=E.useState(!1),[B,W]=E.useState(null),J=E.useRef(null);E.useEffect(()=>{let Z=!1;return(async()=>{try{const me=await Th("list_newsletter_issues",{limit:20});if(Z)return;if(!me.issues||me.issues.length===0){s("no-data");return}l(me.issues);const Le=me.issues[0].id;u(Le)}catch(me){Z||(y(me.message),s("error"))}})(),()=>{Z=!0}},[]),E.useEffect(()=>{if(!c)return;let Z=!1;return T(!0),_(!1),W(null),O(""),(async()=>{try{const me=await Th("get_newsletter_analytics",{issue_id:c});if(Z)return;if(me.error){y(me.error),s("error");return}p(me),s("loaded")}catch(me){Z||(y(me.message),s("error"))}finally{Z||T(!1)}})(),()=>{Z=!0}},[c]),E.useEffect(()=>{const Z=me=>{J.current&&!J.current.contains(me.target)&&n()};return document.addEventListener("mousedown",Z),()=>document.removeEventListener("mousedown",Z)},[n]),E.useEffect(()=>{const Z=me=>{me.key==="Escape"&&n()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[n]);const F=f?lD(f.subscriber_events):[],re=(f==null?void 0:f.issue.recipient_count)??0,G=f?f.stats.delivered||re-f.stats.bounces:0,te=f?new Set(f.subscriber_events.filter(Z=>{var me;return Z.event_type==="click"&&((me=Z.url)==null?void 0:me.includes("/newsletter/unsubscribe/"))}).map(Z=>Z.email)).size:0,U=f?f.stats.unsubscribes||te:0,ne=f?f.subscriber_events.filter(Z=>Z.event_type==="dropped").length:0,H=f?Math.max(0,re-f.stats.unique_opens):0,X=f!=null&&f.issue.sent_at?Date.now()-new Date(f.issue.sent_at).getTime():0,K=Math.floor(X/36e5),A=!!(f!=null&&f.issue.resent_at||B),R=Z=>{const me=Math.floor(Z/36e5);return me<1?"just now":me<24?`${me}h ago`:`${Math.floor(me/24)}d ${me%24}h ago`},Y=async()=>{if(!(!M.trim()||P)){$(!0);try{const Z=await Th("resend_to_unopened",{issue_id:c,subject:M});Z.error?(y(Z.error),s("error")):(W({sent:Z.sent,failed:Z.failed}),_(!1))}catch(Z){y(Z.message),s("error")}finally{$(!1)}}},se=Z=>{var me;return Z.event_type==="unsubscribe"||Z.event_type==="click"&&!!((me=Z.url)!=null&&me.includes("/newsletter/unsubscribe/"))},fe=f?oD(f.subscriber_events.filter(Z=>w==="all"?!0:w==="unsubscribe"?se(Z):Z.event_type===w)):[];return d.jsx("div",{className:"newsletter-modal-overlay",children:d.jsxs("div",{className:"na-modal",ref:J,children:[d.jsxs("div",{className:"na-header",children:[d.jsx("h3",{children:"Newsletter Analytics"}),d.jsx("button",{className:"newsletter-modal__close",onClick:n,children:"×"})]}),r==="loading"&&!f&&d.jsx("div",{className:"na-body",children:d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:"Loading analytics..."})]})}),r==="no-data"&&d.jsxs("div",{className:"na-body",children:[d.jsx("div",{className:"newsletter-modal__status",children:d.jsx("span",{children:"No newsletter sends found yet."})}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="error"&&d.jsxs("div",{className:"na-body",children:[d.jsx("div",{className:"newsletter-modal__error",children:m}),d.jsx("div",{className:"newsletter-modal__actions",children:d.jsx("button",{className:"newsletter-modal__btn newsletter-modal__btn--primary",onClick:n,children:"Done"})})]}),r==="loaded"&&f&&d.jsxs("div",{className:"na-body",children:[i.length>1&&d.jsx("select",{className:"newsletter-modal__select na-issue-select",value:c,onChange:Z=>u(Z.target.value),children:i.map(Z=>d.jsxs("option",{value:Z.id,children:[Z.subject," — ",b0(Z.sent_at)]},Z.id))}),N?d.jsxs("div",{className:"newsletter-modal__status",children:[d.jsx("div",{className:"newsletter-modal__spinner"}),d.jsx("span",{children:"Loading..."})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"na-kpi-row",children:[d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:G.toLocaleString()}),d.jsx("div",{className:"na-kpi__label",children:"Delivered"}),d.jsxs("div",{className:"na-kpi__sub",children:[re.toLocaleString()," sent"]})]}),d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:Mh(f.stats.unique_opens,G)}),d.jsx("div",{className:"na-kpi__label",children:"Open rate"}),d.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_opens.toLocaleString()," opens"]})]}),d.jsxs("div",{className:"na-kpi",children:[d.jsx("div",{className:"na-kpi__value",children:Mh(f.stats.unique_clicks,G)}),d.jsx("div",{className:"na-kpi__label",children:"Click rate"}),d.jsxs("div",{className:"na-kpi__sub",children:[f.stats.unique_clicks.toLocaleString()," clicks"]})]})]}),d.jsxs("div",{className:"na-kpi-row na-kpi-row--secondary",children:[d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:f.stats.bounces}),d.jsx("span",{className:"na-kpi__label--sm",children:"Bounces"})]}),d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:U}),d.jsx("span",{className:"na-kpi__label--sm",children:"Unsubs"})]}),d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:ne}),d.jsx("span",{className:"na-kpi__label--sm",children:"Dropped"})]}),f.stats.complaints>0&&d.jsxs("div",{className:"na-kpi na-kpi--sm",children:[d.jsx("span",{className:"na-kpi__value--sm",children:f.stats.complaints}),d.jsx("span",{className:"na-kpi__label--sm",children:"Spam"})]})]}),H>0&&!A&&d.jsx("div",{className:"na-resend",children:I?d.jsxs("div",{className:"na-resend-panel",children:[d.jsxs("div",{className:"na-resend-label-row",children:[d.jsx("span",{className:"na-resend-label",children:"New subject line"}),d.jsxs("span",{className:"na-resend-meta",children:["sent ",R(X),K<48?" · consider waiting 48h":""]})]}),d.jsx("input",{className:"na-resend-input",type:"text",value:M,onChange:Z=>O(Z.target.value),placeholder:"Try a different angle"}),d.jsxs("div",{className:"na-resend-actions",children:[d.jsx("button",{className:"na-resend-cancel",onClick:()=>_(!1),children:"Cancel"}),d.jsx("button",{className:"na-resend-send",onClick:Y,disabled:P||!M.trim(),children:P?"Sending...":`Send to ${H.toLocaleString()}`})]})]}):d.jsxs("button",{className:"na-resend-toggle",onClick:()=>{_(!0),O(f.issue.subject)},children:["Resend to ",H.toLocaleString()," non-openers ",d.jsx("span",{style:{float:"right"},children:"›"})]})}),A&&d.jsxs("div",{className:"na-resend-done",children:["Resent ",f.issue.resent_at?R(Date.now()-new Date(f.issue.resent_at).getTime()):"just now",B?` — ${B.sent} sent`:"",f.issue.resend_subject?` — "${f.issue.resend_subject}"`:""]}),d.jsxs("div",{className:"na-tabs",children:[d.jsxs("button",{className:`na-tab${b==="links"?" active":""}`,onClick:()=>v("links"),children:["Links (",F.length,")"]}),d.jsxs("button",{className:`na-tab${b==="activity"?" active":""}`,onClick:()=>v("activity"),children:["Activity (",f.subscriber_events.length,")"]})]}),b==="links"&&d.jsx("div",{className:"na-table-wrap",children:F.length===0?d.jsx("div",{className:"na-empty",children:"No link clicks recorded yet."}):d.jsxs("table",{className:"na-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Link"}),d.jsx("th",{children:"Unique"}),d.jsx("th",{children:"Total"}),d.jsx("th",{children:"CTR"})]})}),d.jsx("tbody",{children:F.map(Z=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__url",title:Z.url,children:d.jsx("a",{href:Z.url,target:"_blank",rel:"noopener noreferrer",children:v0(Z.url)})}),d.jsx("td",{children:Z.uniqueClicks}),d.jsx("td",{children:Z.totalClicks}),d.jsx("td",{children:Mh(Z.uniqueClicks,G)})]},Z.url))})]})}),b==="activity"&&d.jsxs("div",{className:"na-activity",children:[d.jsx("div",{className:"na-filter-row",children:["all","open","click","bounce","dropped","unsubscribe"].map(Z=>d.jsx("button",{className:`na-filter-btn${w===Z?" active":""}`,onClick:()=>k(Z),children:Z==="all"?"All":Z.charAt(0).toUpperCase()+Z.slice(1)+"s"},Z))}),d.jsxs("div",{className:"na-table-wrap",children:[fe.length===0?d.jsxs("div",{className:"na-empty",children:["No ",w==="all"?"":w+" ","events recorded."]}):d.jsxs("table",{className:"na-table",children:[d.jsx("thead",{children:d.jsxs("tr",{children:[d.jsx("th",{children:"Email"}),d.jsx("th",{children:"Event"}),d.jsx("th",{children:"Detail"}),d.jsx("th",{children:"Time"})]})}),d.jsx("tbody",{children:fe.slice(0,100).map(Z=>d.jsxs("tr",{children:[d.jsx("td",{className:"na-table__email",children:Z.email}),d.jsxs("td",{children:[d.jsx("span",{className:`na-badge na-badge--${Z.event_type}`,children:Z.event_type}),Z.count>1&&d.jsxs("span",{className:"na-count",children:[Z.count,"x"]})]}),d.jsx("td",{className:"na-table__url",children:Z.url?d.jsx("a",{href:Z.url,target:"_blank",rel:"noopener noreferrer",children:v0(Z.url,35)}):"—"}),d.jsx("td",{className:"na-table__time",children:b0(Z.latestTimestamp)})]},Z.key))})]}),fe.length>100&&d.jsxs("div",{className:"na-truncated",children:["Showing 100 of ",fe.length," events"]})]})]})]})]})]})})}function oD(t){const e=new Map;for(const n of t){const r=`${n.email}|${n.event_type}|${n.url||""}`,s=e.get(r);s?(s.count++,n.timestamp>s.latestTimestamp&&(s.latestTimestamp=n.timestamp)):e.set(r,{key:r,email:n.email,event_type:n.event_type,url:n.url,latestTimestamp:n.timestamp,count:1})}return Array.from(e.values()).sort((n,r)=>new Date(r.latestTimestamp).getTime()-new Date(n.latestTimestamp).getTime())}function lD(t){const e=t.filter(r=>r.event_type==="click"&&r.url),n=new Map;for(const r of e){const s=r.url;let i=n.get(s);i||(i={emails:new Set,total:0},n.set(s,i)),i.emails.add(r.email),i.total++}return Array.from(n.entries()).map(([r,{emails:s,total:i}])=>({url:r,uniqueClicks:s.size,totalClicks:i})).sort((r,s)=>s.uniqueClicks-r.uniqueClicks)}function aD(t){return t.tweetContext?"tweet":t.articleContext?"article":t.linkedinContext?"linkedin":t.newsletterContext?"newsletter":t.blogContext?"blog":"tweet"}function rd({filename:t,title:e,onClose:n}){const[r,s]=E.useState("queue"),[i,l]=E.useState(null),[c,u]=E.useState(null),[f,p]=E.useState(""),[m,y]=E.useState(!1),[b,v]=E.useState(null),[w,k]=E.useState(null);E.useEffect(()=>{fetch(`/api/documents/${encodeURIComponent(t)}/text`).then(I=>{if(!I.ok)throw new Error("Failed to load document");return I.json()}).then(I=>{u(I.text||""),l(aD(I.meta||{}))}).catch(I=>k(I.message))},[t]);const N=async()=>{var I;if(!(!c||!i)){y(!0);try{const _={content:c,content_type:i,mode:r};r==="custom"&&f&&(_.scheduled_at=new Date(f).toISOString());const M=await fetch("/api/scheduler/queue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),O=await M.json();if(M.ok){const P=(I=O.item)!=null&&I.scheduled_at?new Date(O.item.scheduled_at).toLocaleString():"now";v({success:!0,message:`Scheduled for ${P}`})}else v({success:!1,message:O.error||"Failed to schedule"})}catch(_){v({success:!1,message:_.message})}finally{y(!1)}}},T=i===null&&!w;return d.jsx("div",{className:"schedule-post-overlay",onClick:n,children:d.jsxs("div",{className:"schedule-post-modal",onClick:I=>I.stopPropagation(),children:[d.jsxs("div",{className:"schedule-post-modal-header",children:[d.jsx("h3",{children:"Schedule Post"}),d.jsx("button",{className:"schedule-post-modal-close",onClick:n,children:"×"})]}),d.jsx("div",{className:"schedule-post-modal-doc",children:e}),w?d.jsxs("div",{className:"schedule-post-modal-result error",children:[w,d.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):b?d.jsxs("div",{className:`schedule-post-modal-result ${b.success?"success":"error"}`,children:[b.message,d.jsx("button",{className:"schedule-post-modal-done",onClick:n,children:"Done"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Content Type"}),d.jsx("div",{className:"schedule-post-modal-type",children:T?"...":i})]}),d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Mode"}),d.jsxs("div",{className:"schedule-post-modal-modes",children:[d.jsx("button",{className:`schedule-post-mode ${r==="queue"?"active":""}`,onClick:()=>s("queue"),children:"Queue Next"}),d.jsx("button",{className:`schedule-post-mode ${r==="now"?"active":""}`,onClick:()=>s("now"),children:"Post Now"}),d.jsx("button",{className:`schedule-post-mode ${r==="custom"?"active":""}`,onClick:()=>s("custom"),children:"Custom Time"})]})]}),r==="custom"&&d.jsxs("div",{className:"schedule-post-modal-field",children:[d.jsx("label",{children:"Date & Time"}),d.jsx("input",{type:"datetime-local",value:f,onChange:I=>p(I.target.value)})]}),d.jsxs("div",{className:"schedule-post-modal-actions",children:[d.jsx("button",{className:"schedule-post-modal-cancel",onClick:n,children:"Cancel"}),d.jsx("button",{className:"schedule-post-modal-submit",onClick:N,disabled:m||T||r==="custom"&&!f,children:m?"Scheduling...":r==="now"?"Post Now":"Schedule"})]})]})]})})}const x0=[{key:"document",label:"Document"},{key:"tweet",label:"Tweet",metadata:{tweetContext:{mode:"tweet"}}},{key:"reply",label:"Reply",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{tweetContext:{mode:"reply"}}},{key:"quote",label:"Quote Tweet",needsUrl:!0,urlPlaceholder:"Paste tweet URL...",metadata:{tweetContext:{mode:"quote"}}},{key:"article",label:"Article",metadata:{articleContext:{active:!0}}},{key:"linkedin",label:"LinkedIn",metadata:{linkedinContext:{active:!0}}},{key:"newsletter",label:"Newsletter",metadata:{newsletterContext:{active:!0}}},{key:"blog",label:"Blog",metadata:{blogContext:{active:!0}}}];function cD({anchorRect:t,onSelect:e,onClose:n}){const r=E.useRef(null),[s,i]=E.useState(null),[l,c]=E.useState(""),u=E.useRef(null),[f,p]=E.useState({left:t.left,top:t.bottom+4});E.useLayoutEffect(()=>{const v=r.current;if(!v)return;const w=v.getBoundingClientRect(),k=8;let N=t.left,T=t.bottom+4;T+w.height+k>window.innerHeight&&(T=t.top-w.height-4),N+w.width+k>window.innerWidth&&(N=t.right-w.width),T<k&&(T=k),N<k&&(N=k),p({left:N,top:T})},[t]),E.useEffect(()=>{const v=w=>{r.current&&!r.current.contains(w.target)&&n()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),E.useEffect(()=>{const v=w=>{w.key==="Escape"&&n()};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[n]),E.useEffect(()=>{s&&setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},0)},[s]);const m=v=>{if(v.needsUrl){i(v.key),c("");return}e(v.metadata)},y=()=>{if(!s||!l.trim())return;const v=l.trim();if(!v.includes("x.com")&&!v.includes("twitter.com"))return;const w=x0.find(N=>N.key===s);if(!(w!=null&&w.metadata))return;const k=JSON.parse(JSON.stringify(w.metadata));k.tweetContext&&(k.tweetContext.url=v),e(k)},b=l.trim().includes("x.com")||l.trim().includes("twitter.com");return d.jsx("div",{ref:r,className:"create-doc-dropdown",style:{left:f.left,top:f.top},children:x0.map(v=>d.jsxs("div",{children:[d.jsx("button",{className:`create-doc-dropdown-item${s===v.key?" active":""}`,onClick:()=>m(v),children:v.label}),s===v.key&&d.jsxs("div",{className:"create-doc-dropdown-url",children:[d.jsx("input",{ref:u,type:"text",placeholder:v.urlPlaceholder,value:l,onChange:w=>c(w.target.value),onKeyDown:w=>{w.key==="Enter"&&(w.preventDefault(),y()),w.key==="Escape"&&(i(null),c(""))}}),d.jsx("button",{onClick:y,disabled:!b,children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})})]})]},v.key))})}function j1(t,e){if(!e)return!0;for(const n of t)if(n.type==="container"&&(n.id===e||j1(n.items,e)))return!0;return!1}function L1(t,e){for(const n of t){if(n.type==="doc"&&n.file===e)return[];if(n.type==="container"){const r=L1(n.items,e);if(r)return[n.id,...r]}}return null}function uD({docs:t,archivedDocs:e,workspaces:n,assignedFiles:r,pendingDocs:s,onSwitchDocument:i,onCreateDocument:l,actions:c,scrollRef:u,writingTitle:f,writingTarget:p,searchQuery:m,searchResults:y,onSearchChange:b}){const[v,w]=E.useState(null),[k,N]=E.useState(""),[T,I]=E.useState(null),[_,M]=E.useState(()=>{try{const ee=localStorage.getItem("ow-collapsed-sections");return ee?new Set(JSON.parse(ee)):new Set}catch{return new Set}}),[O,P]=E.useState(null),[$,B]=E.useState(null),[W,J]=E.useState(""),[F,re]=E.useState(null),[G,te]=E.useState(""),[U,ne]=E.useState(null),[H,X]=E.useState(""),[K,A]=E.useState(null),[R,Y]=E.useState(null),[se,fe]=E.useState([]),[Z,me]=E.useState(null),[Le,Ze]=E.useState(null),[ce,ve]=E.useState(null),[ie,Be]=E.useState(null),{draggedItem:Te,dropIndicator:Ue,handlePointerDown:Ee,dropClass:Qe,isDragging:tt,isContainerDropTarget:vt}=nD({docs:t,workspaces:n,assignedFiles:r,scrollRef:u,setCollapsedSections:M}),Ce=E.useCallback(()=>{fetch("/api/plugins").then(ee=>ee.json()).then(ee=>{const He=[];for(const We of ee.plugins||[]){const _t=We.displayName||void 0;for(const nt of We.sidebarMenuItems||[])He.push({...nt,pluginDisplayName:_t})}fe(He)}).catch(()=>{})},[]);E.useEffect(()=>{Ce()},[Ce]),E.useEffect(()=>{const ee=()=>Ce();return window.addEventListener("ow-plugins-changed",ee),()=>window.removeEventListener("ow-plugins-changed",ee)},[Ce]);const ke=E.useCallback((ee,He)=>{ee.preventDefault(),ee.stopPropagation(),A({x:ee.clientX,y:ee.clientY,filename:He.filename,title:He.title,docId:He.docId,lastSent:He.lastSent,postedUrl:He.postedUrl})},[]),at=E.useCallback(ee=>{fetch("/api/documents/duplicate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:ee})}).catch(()=>{})},[]),ft=E.useCallback((ee,He,We,_t,nt)=>{if(He.promptForFocus&&nt===void 0){me({action:ee,label:He.label,filename:We,title:_t});return}fetch("/api/plugins/sidebar-action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:ee,filename:We,title:_t,instructions:nt||"",label:He.label})}).catch(()=>{})},[]),st=ee=>{M(He=>{const We=new Set(He);return We.has(ee)?We.delete(ee):We.add(ee),localStorage.setItem("ow-collapsed-sections",JSON.stringify([...We])),We})},ht=t.find(ee=>ee.isActive),zt=E.useRef(n);if(zt.current=n,E.useEffect(()=>{var ee;if(ht)for(const He of zt.current){const We=L1(((ee=He.workspace)==null?void 0:ee.root)||[],ht.filename);if(We){M(_t=>{const nt=[He.filename,...We.map(qe=>`container-${qe}`)];if(nt.every(qe=>!_t.has(qe)))return _t;const it=new Set(_t);for(const qe of nt)it.delete(qe);return localStorage.setItem("ow-collapsed-sections",JSON.stringify([...it])),it});break}}},[ht==null?void 0:ht.filename]),y!==null)return d.jsx(Sm,{results:y,query:m,onSwitchDocument:i,actions:c});const Ct=t.filter(ee=>!r.has(ee.filename)),Vt=(ee,He,We,_t,nt)=>d.jsxs("div",{className:`sidebar-item ${ee.isActive?"active":""} ${tt(ee.filename)?"dragging":""} ${Qe(ee.filename)}`,"data-drag-id":ee.filename,"data-drag-type":"doc","data-drag-ws":He||"__docs__","data-drag-container":We||"",onPointerDown:it=>Ee(it,{type:"doc",file:ee.filename,sourceWs:He||null},ee.title),onClick:()=>!ee.isActive&&!Te&&i(ee.filename),onDoubleClick:()=>{w(ee.filename),N(ee.title)},onContextMenu:it=>ke(it,ee),children:[v===ee.filename?d.jsx("input",{className:"sidebar-rename-input",value:k,onChange:it=>N(it.target.value),onBlur:()=>{c.handleRename(ee.filename,ee.title,k),w(null)},onKeyDown:it=>{it.key==="Enter"&&(c.handleRename(ee.filename,ee.title,k),w(null)),it.key==="Escape"&&w(null)},autoFocus:!0,onClick:it=>it.stopPropagation()}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-item-title-text",children:ee.title}),ee.lastSent&&d.jsx("svg",{className:"sidebar-sent-icon",title:"Sent",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),s.filenames.includes(ee.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),yp(ee.filename)&&d.jsx("div",{className:"sidebar-item-context",children:R1(ee.filename)}),d.jsxs("div",{className:"sidebar-item-meta",children:[ee.wordCount.toLocaleString()," words · ",Mo(ee.lastModified)]}),d.jsxs("div",{className:"sidebar-tags",children:[c.getDocTags(ee.filename).map(it=>d.jsxs("span",{className:"sidebar-tag",onClick:qe=>qe.stopPropagation(),children:[it,d.jsx("span",{className:"sidebar-tag-remove",onClick:qe=>{qe.stopPropagation(),c.handleRemoveTag(ee.filename,it)},children:"×"})]},it)),U===ee.filename?d.jsx("input",{className:"sidebar-tag-input",value:H,onChange:it=>X(it.target.value),onBlur:()=>{H.trim()&&c.handleAddTag(ee.filename,H),ne(null)},onKeyDown:it=>{it.key==="Enter"&&(c.handleAddTag(ee.filename,H),ne(null),X("")),it.key==="Escape"&&(ne(null),X(""))},autoFocus:!0,onClick:it=>it.stopPropagation(),placeholder:"tag..."}):d.jsx("button",{className:"sidebar-tag-add",onClick:it=>{it.stopPropagation(),ne(ee.filename),X("")},children:"+"})]})]}),T===ee.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:it=>it.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{c.handleDelete(ee.filename),I(null)},children:"Yes"}),d.jsx("button",{onClick:()=>I(null),children:"No"})]}):d.jsx("button",{className:"sidebar-delete-btn",onClick:it=>{it.stopPropagation(),I(ee.filename)},title:"Delete document",children:"×"})]},ee.filename),xn=(ee,He,We,_t,nt,it)=>{if(ee.type==="doc"){const be=t.find($e=>$e.filename===ee.file);return be?Vt(be,We,_t):yp(ee.file)?d.jsx("div",{className:"sidebar-item sidebar-unavailable",children:d.jsxs("div",{className:"sidebar-item-title",children:[ee.title||ee.file," (unavailable)"]})},ee.file):d.jsxs("div",{className:"sidebar-item sidebar-missing",children:[d.jsxs("div",{className:"sidebar-item-title",children:[ee.title||ee.file," (missing)"]}),d.jsx("button",{className:"sidebar-delete-btn",onClick:()=>c.handleRemoveFromWorkspace(We,ee.file),title:"Remove",children:"×"})]},ee.file)}const qe=ee,Wn=`container-${qe.id}`,un=_.has(Wn),le=He<=2?`depth-${He}`:"depth-2";return d.jsxs("div",{className:`sidebar-container ${le} ${un?"collapsed":""} ${Qe(qe.id)} ${vt(qe.id)?"drop-inside":""}`,children:[d.jsxs("div",{className:`sidebar-container-header ${(Ue==null?void 0:Ue.itemId)===qe.id&&Ue.position==="inside"?"drop-inside":""}`,"data-drag-id":qe.id,"data-drag-type":"container-header","data-drag-ws":We,"data-drag-parent":_t||"","data-section-key":Wn,onPointerDown:be=>Ee(be,{type:"container",id:qe.id,sourceWs:We},qe.name),onClick:()=>!Te&&st(Wn),children:[d.jsx("span",{className:`sidebar-chevron ${un?"collapsed":""}`,children:"▾"}),$===qe.id?d.jsx("input",{className:"sidebar-rename-input",value:W,onChange:be=>J(be.target.value),onBlur:()=>{c.handleRenameContainer(We,qe.id,W),B(null)},onKeyDown:be=>{be.key==="Enter"&&(c.handleRenameContainer(We,qe.id,W),B(null)),be.key==="Escape"&&B(null)},autoFocus:!0,onClick:be=>be.stopPropagation()}):d.jsx("span",{className:"sidebar-container-name",onDoubleClick:be=>{be.stopPropagation(),B(qe.id),J(qe.name)},children:qe.name}),d.jsxs("div",{className:"sidebar-container-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:be=>{be.stopPropagation(),Be({anchor:be.target.getBoundingClientRect(),wsFilename:We,containerId:qe.id})},title:"New doc",children:"+"}),He<2&&d.jsx("button",{className:"sidebar-new-btn",onClick:be=>{be.stopPropagation(),c.handleCreateContainer(We,qe.id)},title:"New sub-container",children:"☐"}),d.jsx("button",{className:"sidebar-new-btn sidebar-container-delete",onClick:be=>{be.stopPropagation(),c.handleDeleteContainer(We,qe.id)},title:"Delete container",children:"×"})]})]}),!un&&d.jsxs("div",{className:"sidebar-container-list","data-drop-ws":We,"data-drop-container":qe.id,children:[f&&(p==null?void 0:p.wsFilename)===We&&p.containerId===qe.id&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===We&&p.containerId===qe.id?qe.items.filter(be=>be.type!=="doc"||be.title!==f):qe.items).map((be,$e)=>xn(be,He+1,We,qe.id,qe.items)),qe.items.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:Te?"Drop here":"Empty"})]})]},qe.id)};return d.jsxs("div",{className:"sidebar-scroll",ref:u,children:[d.jsxs("div",{className:`sidebar-section sidebar-docs-section ${_.has("docs")?"docs-collapsed":""}`,children:[d.jsxs("div",{className:"sidebar-section-header","data-section-key":"docs",onClick:()=>st("docs"),children:[d.jsx("span",{className:`sidebar-chevron ${_.has("docs")?"collapsed":""}`,children:"▾"}),d.jsx("span",{className:"sidebar-label",children:"Documents"}),d.jsx("button",{className:"sidebar-new-btn",onClick:ee=>{ee.stopPropagation(),Be({anchor:ee.target.getBoundingClientRect()})},title:"New document",children:"+"})]}),!_.has("docs")&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":"__docs__",children:[f&&(!p||!n.some(ee=>ee.filename===(p==null?void 0:p.wsFilename)))&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f?Ct.filter(ee=>ee.title!==f):Ct).map((ee,He)=>(Ct.map(We=>({type:"doc",file:We.filename,title:We.title})),Vt(ee,void 0,null))),Ct.length===0&&d.jsx("div",{className:"sidebar-empty",children:Te?"Drop here to unassign":"No unassigned documents"})]})]}),n.map(ee=>{var _t;const He=((_t=ee.workspace)==null?void 0:_t.root)||[],We=_.has(ee.filename);return d.jsxs("div",{className:`sidebar-section sidebar-workspace-section ${We?"ws-collapsed":""} ${tt(ee.filename)?"dragging":""} ${(Ue==null?void 0:Ue.itemId)===ee.filename?Ue.position==="before"?"drop-before":"drop-after":""}`,children:[d.jsxs("div",{className:"sidebar-section-header","data-section-key":ee.filename,"data-ws-drag":ee.filename,onPointerDown:nt=>Ee(nt,{type:"workspace",filename:ee.filename},ee.title),onClick:()=>!Te&&st(ee.filename),children:[d.jsx("span",{className:`sidebar-chevron ${We?"collapsed":""}`,children:"▾"}),F===ee.filename?d.jsx("input",{className:"sidebar-rename-input",value:G,onChange:nt=>te(nt.target.value),onBlur:()=>{c.handleRenameWorkspace(ee.filename,G),re(null)},onKeyDown:nt=>{nt.key==="Enter"&&(c.handleRenameWorkspace(ee.filename,G),re(null)),nt.key==="Escape"&&re(null)},autoFocus:!0,onClick:nt=>nt.stopPropagation()}):d.jsx("span",{className:"sidebar-label sidebar-workspace-label",onDoubleClick:nt=>{nt.stopPropagation(),re(ee.filename),te(ee.title)},children:ee.title}),d.jsxs("div",{className:"sidebar-workspace-actions",children:[d.jsx("button",{className:"sidebar-new-btn",onClick:nt=>{nt.stopPropagation(),Be({anchor:nt.target.getBoundingClientRect(),wsFilename:ee.filename,containerId:null})},title:"New document",children:"+"}),d.jsx("button",{className:"sidebar-new-btn",onClick:nt=>{nt.stopPropagation(),c.handleCreateContainer(ee.filename,null)},title:"New container",children:"☐"}),O===ee.filename?d.jsxs("span",{className:"sidebar-inline-confirm",onClick:nt=>nt.stopPropagation(),children:[d.jsx("button",{onClick:()=>{c.handleDeleteWorkspace(ee.filename),P(null)},children:"Yes"}),d.jsx("button",{onClick:()=>P(null),children:"No"})]}):d.jsx("button",{className:"sidebar-new-btn sidebar-workspace-delete",onClick:nt=>{nt.stopPropagation(),P(ee.filename)},title:"Delete workspace",children:"×"})]})]}),!We&&d.jsxs("div",{className:"sidebar-section-list","data-drop-ws":ee.filename,children:[f&&(p==null?void 0:p.wsFilename)===ee.filename&&(p.containerId===null||!j1(He,p.containerId))&&d.jsxs("div",{className:"sidebar-item sidebar-writing-placeholder",children:[d.jsxs("div",{className:"sidebar-item-title",children:[d.jsx("span",{className:"sidebar-writing-spinner"}),d.jsx("span",{className:"sidebar-item-title-text",children:f})]}),d.jsx("div",{className:"sidebar-item-meta",children:"Writing..."})]}),(f&&(p==null?void 0:p.wsFilename)===ee.filename&&p.containerId===null?He.filter(nt=>nt.type!=="doc"||nt.title!==f):He).map((nt,it)=>xn(nt,0,ee.filename,null)),He.length===0&&!f&&d.jsx("div",{className:"sidebar-empty",children:Te?"Drop here to add":"Empty workspace"})]})]},ee.filename)}),d.jsx("div",{className:"sidebar-new-workspace",children:d.jsx("button",{onClick:c.handleCreateWorkspace,children:"+ New Workspace"})}),K&&d.jsx(rD,{x:K.x,y:K.y,filename:K.filename,title:K.title,onClose:()=>A(null),onDuplicate:()=>at(K.filename),onRename:()=>{w(K.filename),N(K.title)},onArchive:()=>c.handleArchive(K.filename),onDelete:()=>c.handleDelete(K.filename),onPluginAction:(ee,He)=>ft(ee,He,K.filename,K.title),pluginItems:se,onNewsletterSend:ee=>{Ze({connectionId:ee,filename:K.filename,title:K.title}),A(null)},onSchedulePost:()=>{ve({filename:K.filename,title:K.title}),A(null)},onViewAnalytics:K.docId&&K.lastSent?()=>{K.postedUrl?window.open(K.postedUrl,"_blank"):Y({docId:K.docId,title:K.title}),A(null)}:void 0,viewAnalyticsLabel:K.postedUrl?"View on X":"View Analytics"}),Z&&d.jsx(sD,{actionLabel:Z.label,docTitle:Z.title,onClose:()=>me(null),onConfirm:ee=>{const He=se.find(We=>We.action===Z.action);He&&ft(Z.action,He,Z.filename,Z.title,ee),me(null)}}),Le&&d.jsx(I1,{connectionId:Le.connectionId,subject:Le.title,filename:Le.filename,onClose:()=>Ze(null)}),R&&d.jsx(iD,{docId:R.docId,title:R.title,onClose:()=>Y(null)}),ce&&d.jsx(rd,{filename:ce.filename,title:ce.title,onClose:()=>ve(null)}),ie&&d.jsx(cD,{anchorRect:ie.anchor,onClose:()=>Be(null),onSelect:ee=>{Be(null),ie.wsFilename?c.handleCreateInWorkspace(ie.wsFilename,ie.containerId??null,ee):ee?fetch("/api/documents",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({metadata:ee})}).catch(()=>{}):l()}})]})}function dD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,onCreateDocument:i,actions:l,scrollRef:c,searchQuery:u,searchResults:f}){const[p,m]=E.useState(null);if(f!==null)return d.jsx(Sm,{results:f,query:u,onSwitchDocument:s});const y=[...t].sort((k,N)=>new Date(N.lastModified).getTime()-new Date(k.lastModified).getTime()),b=[];let v="";for(const k of y){const N=ZL(k.lastModified);N!==v&&(b.push({label:N,docs:[]}),v=N),b[b.length-1].docs.push(k)}const w=k=>{for(const N of e){if(!N.workspace)continue;const T=I=>{for(const _ of I)if(_.type==="doc"&&_.file===k||_.type==="container"&&T(_.items))return!0;return!1};if(T(N.workspace.root))return N.title}return null};return d.jsxs("div",{className:"sidebar-scroll tl-scroll",ref:c,children:[d.jsxs("div",{className:"tl-header",children:[d.jsx("span",{className:"tl-title",children:"Timeline"}),d.jsx("button",{className:"sidebar-new-btn",onClick:i,title:"New document",children:"+"})]}),b.map(k=>d.jsxs("div",{className:"tl-group",children:[d.jsx("div",{className:"tl-date",children:k.label}),k.docs.map(N=>{const T=w(N.filename);return d.jsxs("div",{className:`tl-item ${N.isActive?"active":""}`,onClick:()=>!N.isActive&&s(N.filename),children:[d.jsx("div",{className:"tl-dot"}),d.jsxs("div",{className:"tl-content",children:[d.jsxs("div",{className:"tl-item-title",children:[d.jsx("span",{children:N.title}),r.filenames.includes(N.filename)&&d.jsx("span",{className:"sidebar-pending-dot"})]}),yp(N.filename)&&d.jsx("div",{className:"tl-item-context",children:R1(N.filename)}),d.jsxs("div",{className:"tl-item-meta",children:[N.wordCount.toLocaleString()," words · ",Mo(N.lastModified)]}),T&&d.jsx("div",{className:"tl-badge",children:T})]}),p===N.filename?d.jsxs("div",{className:"sidebar-confirm-delete",onClick:I=>I.stopPropagation(),children:[d.jsx("span",{children:"Delete?"}),d.jsx("button",{onClick:()=>{l.handleDelete(N.filename),m(null)},children:"Yes"}),d.jsx("button",{onClick:()=>m(null),children:"No"})]}):d.jsx("button",{className:"sidebar-delete-btn",onClick:I=>{I.stopPropagation(),m(N.filename)},title:"Delete",children:"×"})]},N.filename)})]},k.label)),t.length===0&&d.jsx("div",{className:"sidebar-empty",children:"No documents yet"})]})}function fD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:u,onSearchChange:f}){const[p,m]=E.useState([]),[y,b]=E.useState(null),[v,w]=E.useState(null),k=E.useRef(null);E.useEffect(()=>{if(!y)return;const A=R=>{k.current&&!k.current.contains(R.target)&&b(null)};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[y]);const N=(A,R)=>{for(const Y of A)if(Y.type==="container"){if(Y.id===R)return Y;const se=N(Y.items,R);if(se)return se}return null},T=A=>{let R=0;for(const Y of A)Y.type==="doc"?R++:Y.type==="container"&&(R+=T(Y.items));return R},I=A=>{const R=[];for(const Y of A)Y.type==="doc"?R.push(Y.file):Y.type==="container"&&R.push(...I(Y.items));return R},_=E.useMemo(()=>{if(p.length===0)return[];const A=p[p.length-1],R=e.find(se=>se.filename===A.wsFilename);if(!(R!=null&&R.workspace))return[];if(A.type==="workspace")return R.workspace.root;const Y=N(R.workspace.root,A.key);return Y?Y.items:[]},[p,e]),M=_.filter(A=>A.type==="container"),O=E.useMemo(()=>{const A=_.filter(R=>R.type==="doc").map(R=>R.file);return t.filter(R=>A.includes(R.filename))},[_,t]),P=A=>{const R=I(A.items);return t.filter(Y=>R.includes(Y.filename))},$=A=>{const R=e.find(se=>se.filename===A);if(!(R!=null&&R.workspace))return[];const Y=I(R.workspace.root);return t.filter(se=>Y.includes(se.filename))},B=E.useMemo(()=>t.filter(A=>!n.has(A.filename)),[t,n]),W=A=>{m(R=>[...R,A]),b(null)},J=()=>{m(A=>A.slice(0,-1)),b(null)},F=(A,R)=>{if(y===A){b(null);return}const se=R.currentTarget.getBoundingClientRect();w({top:se.bottom+4,left:se.left}),b(A)},re=A=>{s(A),b(null)},G=p.length>1?p[p.length-2].title:"All",te=E.useRef(null),U=E.useRef(null),[ne,H]=E.useState(null),X=E.useCallback(A=>{const Y=A.currentTarget.getBoundingClientRect();H({top:Y.bottom+4,left:Y.left})},[]);E.useEffect(()=>{if(!u)return;const A=R=>{U.current&&!U.current.contains(R.target)&&te.current&&!te.current.contains(R.target)&&f("")};return document.addEventListener("mousedown",A),()=>document.removeEventListener("mousedown",A)},[u,f]);const K=()=>{if(!y)return[];if(y==="__unassigned__")return B;if(y==="__level-docs__")return O;const A=e.find(R=>R.filename===y);if(A)return $(A.filename);for(const R of e){if(!R.workspace)continue;const Y=N(R.workspace.root,y);if(Y)return P(Y)}return[]};return d.jsxs("div",{className:"board-scroll",ref:l,children:[d.jsxs("div",{className:"board-search-pill",children:[d.jsxs("svg",{className:"board-search-icon",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("path",{d:"m21 21-4.3-4.3"})]}),d.jsx("input",{ref:te,className:"board-search-input",type:"text",placeholder:"Search...",value:c,onChange:A=>f(A.target.value),onFocus:X}),c&&d.jsx("button",{className:"board-search-clear",onClick:()=>f(""),children:"×"})]}),p.length===0?d.jsx("button",{className:"board-back board-back--static",tabIndex:-1,children:"All"}):d.jsxs("button",{className:"board-back",onClick:J,title:`Back to ${G}`,children:["← ",G]}),p.length===0&&d.jsxs(d.Fragment,{children:[B.length>0&&d.jsxs("button",{className:`board-chip ${y==="__unassigned__"?"open":""}`,onClick:A=>F("__unassigned__",A),children:["Documents ",d.jsx("span",{className:"board-chip-count",children:B.length})]}),e.map(A=>{var Y;const R=(Y=A.workspace)==null?void 0:Y.root.some(se=>se.type==="container");return d.jsxs("button",{className:`board-chip ${y===A.filename?"open":""}`,onClick:se=>R?W({type:"workspace",key:A.filename,title:A.title,wsFilename:A.filename}):F(A.filename,se),children:[A.title," ",d.jsx("span",{className:"board-chip-count",children:A.docCount}),R&&d.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.filename)}),d.jsx("button",{className:"board-chip board-chip-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),p.length>0&&d.jsxs(d.Fragment,{children:[O.length>0&&d.jsxs("button",{className:`board-chip board-chip-docs ${y==="__level-docs__"?"open":""}`,onClick:A=>F("__level-docs__",A),children:["Docs ",d.jsx("span",{className:"board-chip-count",children:O.length})]}),M.map(A=>{const R=A.items.some(Y=>Y.type==="container");return d.jsxs("button",{className:`board-chip ${y===A.id?"open":""}`,onClick:Y=>R?W({type:"container",key:A.id,title:A.name,wsFilename:p[p.length-1].wsFilename}):F(A.id,Y),children:[A.name," ",d.jsx("span",{className:"board-chip-count",children:T(A.items)}),R&&d.jsx("span",{className:"board-chip-arrow",children:"›"})]},A.id)})]}),y&&v&&(()=>{const A=K();return d.jsxs("div",{className:"board-dropdown",ref:k,style:{position:"fixed",top:v.top,left:v.left},children:[A.map(R=>d.jsxs("div",{className:`board-dropdown-item ${R.isActive?"active":""}`,onClick:()=>re(R.filename),children:[d.jsxs("span",{className:"board-dropdown-title",children:[R.title,r.filenames.includes(R.filename)&&d.jsx("span",{className:"board-pending-dot"})]}),d.jsxs("span",{className:"board-dropdown-meta",children:[R.wordCount.toLocaleString()," words · ",Mo(R.lastModified)]})]},R.filename)),A.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No documents"})]})})(),u&&ne&&d.jsxs("div",{className:"board-dropdown board-search-dropdown",ref:U,style:{position:"fixed",top:ne.top,left:ne.left},children:[u.map(A=>d.jsxs("div",{className:`board-dropdown-item ${A.isActive?"active":""}`,onClick:()=>{s(A.filename),f("")},children:[d.jsx("span",{className:"board-dropdown-title",children:A.title}),A.matchType==="tag"&&A.matchedTag&&d.jsxs("span",{className:"board-dropdown-meta",children:["Tag: ",A.matchedTag]}),A.matchType==="content"&&A.snippet&&d.jsx("span",{className:"board-dropdown-meta board-search-snippet",children:A.snippet}),d.jsxs("span",{className:"board-dropdown-meta",children:[A.wordCount.toLocaleString()," words · ",Mo(A.lastModified)]})]},A.filename)),u.length===0&&d.jsx("div",{className:"board-dropdown-empty",children:"No results"})]})]})}function hD({docs:t,workspaces:e,assignedFiles:n,pendingDocs:r,onSwitchDocument:s,actions:i,scrollRef:l,searchQuery:c,searchResults:u}){const[f,p]=E.useState([]);if(u!==null)return d.jsx(Sm,{results:u,query:c,onSwitchDocument:s});const m=(_,M)=>{for(const O of _)if(O.type==="container"){if(O.id===M)return O;const P=m(O.items,M);if(P)return P}return null},y=_=>{let M=0;for(const O of _)O.type==="doc"?M++:O.type==="container"&&(M+=y(O.items));return M},b=E.useMemo(()=>{if(f.length===0)return[];const _=f[f.length-1],M=e.find(P=>P.filename===_.wsFilename);if(!(M!=null&&M.workspace))return[];if(_.type==="workspace")return M.workspace.root;const O=m(M.workspace.root,_.key);return O?O.items:[]},[f,e]),v=b.filter(_=>_.type==="container"),w=E.useMemo(()=>{if(f.length===0)return t.filter(M=>!n.has(M.filename));const _=b.filter(M=>M.type==="doc").map(M=>M.file);return t.filter(M=>_.includes(M.filename))},[f,b,t,n]),k=_=>p(M=>[...M,_]),N=()=>p(_=>_.slice(0,-1)),T=f.length>1?f[f.length-2].title:"Shelf",I=f.length>0?f[f.length-1].title:"Documents";return d.jsxs("div",{className:"shelf-wrapper",children:[d.jsxs("div",{className:"shelf-spines",ref:l,children:[f.length>0&&d.jsxs("button",{className:"shelf-back",onClick:N,title:`Back to ${T}`,children:[d.jsx("span",{className:"shelf-back-arrow",children:"←"}),d.jsx("span",{className:"shelf-back-label",children:T})]}),f.length===0&&d.jsxs(d.Fragment,{children:[e.map(_=>d.jsxs("div",{className:"shelf-section-spine",onClick:()=>k({type:"workspace",key:_.filename,title:_.title,wsFilename:_.filename}),title:_.title,children:[d.jsx("span",{className:"shelf-section-title",children:_.title}),d.jsx("span",{className:"shelf-section-count",children:_.docCount})]},_.filename)),d.jsx("button",{className:"shelf-add",onClick:i.handleCreateWorkspace,title:"New workspace",children:"+"})]}),f.length>0&&v.map(_=>d.jsxs("div",{className:"shelf-section-spine shelf-section-container",onClick:()=>k({type:"container",key:_.id,title:_.name,wsFilename:f[f.length-1].wsFilename}),title:_.name,children:[d.jsx("span",{className:"shelf-section-title",children:_.name}),d.jsx("span",{className:"shelf-section-count",children:y(_.items)})]},_.id))]}),d.jsxs("div",{className:"shelf-docs",children:[d.jsx("div",{className:"shelf-docs-header",children:I}),d.jsxs("div",{className:"shelf-docs-list",children:[w.map(_=>d.jsxs("div",{className:`shelf-doc-item ${_.isActive?"active":""}`,onClick:()=>s(_.filename),children:[d.jsxs("div",{className:"shelf-doc-title",children:[d.jsx("span",{children:_.title}),r.filenames.includes(_.filename)&&d.jsx("span",{className:"shelf-pending-dot"})]}),d.jsxs("div",{className:"shelf-doc-meta",children:[_.wordCount.toLocaleString()," words · ",Mo(_.lastModified)]})]},_.filename)),w.length===0&&d.jsx("div",{className:"shelf-docs-empty",children:"No documents"})]})]})]})}const pD=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],mD=[{value:"any",label:"Any"},{value:"content_type",label:"Content Type"},{value:"connection",label:"Connection"}];function gD({slots:t,onBack:e}){const[n,r]=E.useState(t),[s,i]=E.useState("09:00"),[l,c]=E.useState(["default"]),[u,f]=E.useState("any"),[p,m]=E.useState(!1);async function y(){const w=await fetch("/api/scheduler/slots",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({time:s,days:l.includes("default")?["default"]:l,filter_type:u})});if(w.ok){const k=await w.json();r(N=>[...N,k.slot]),m(!1),i("09:00"),c(["default"]),f("any")}}async function b(w){(await fetch(`/api/scheduler/slots/${w}`,{method:"DELETE"})).ok&&r(N=>N.filter(T=>T.id!==w))}function v(w){c(k=>{if(w==="default")return["default"];const N=k.filter(T=>T!=="default");if(N.includes(w)){const T=N.filter(I=>I!==w);return T.length===0?["default"]:T}return[...N,w]})}return d.jsxs("div",{className:"sidebar-schedule",children:[d.jsxs("div",{className:"sidebar-schedule-header",children:[d.jsx("button",{className:"sidebar-schedule-btn",onClick:e,title:"Back",children:d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Slot Settings"}),d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>m(!p),children:p?"Cancel":"+ Add"})]}),p&&d.jsxs("div",{style:{padding:"12px",borderBottom:"1px solid var(--sidebar-border)"},children:[d.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"8px",alignItems:"center"},children:[d.jsx("input",{type:"time",value:s,onChange:w=>i(w.target.value),style:{background:"var(--sidebar-bg)",border:"1px solid var(--sidebar-border)",borderRadius:"4px",padding:"4px 8px",color:"var(--sidebar-text)",fontSize:"12px"}}),d.jsx("select",{value:u,onChange:w=>f(w.target.value),style:{background:"var(--sidebar-bg)",border:"1px solid var(--sidebar-border)",borderRadius:"4px",padding:"4px 8px",color:"var(--sidebar-text)",fontSize:"12px"},children:mD.map(w=>d.jsx("option",{value:w.value,children:w.label},w.value))})]}),d.jsxs("div",{style:{display:"flex",gap:"4px",flexWrap:"wrap",marginBottom:"8px"},children:[d.jsx("button",{className:`sidebar-schedule-btn ${l.includes("default")?"sidebar-schedule-btn--active":""}`,onClick:()=>v("default"),style:{fontSize:"10px",padding:"2px 6px"},children:"Every day"}),pD.map(w=>d.jsx("button",{className:`sidebar-schedule-btn ${l.includes(w.toLowerCase())?"sidebar-schedule-btn--active":""}`,onClick:()=>v(w.toLowerCase()),style:{fontSize:"10px",padding:"2px 6px"},children:w},w))]}),d.jsx("button",{className:"sidebar-schedule-btn sidebar-schedule-btn--active",onClick:y,style:{width:"100%"},children:"Create Slot"})]}),d.jsx("div",{style:{flex:1,overflow:"auto"},children:n.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No slots"}),d.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):n.map(w=>d.jsxs("div",{className:"schedule-item",style:{cursor:"default"},children:[d.jsx("div",{className:"schedule-item-time",style:{width:"60px",fontWeight:600},children:yD(w.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:w.days.includes("default")?"Every day":w.days.join(", ")}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsxs("span",{children:["Filter: ",w.filter_type]}),w.filter_value&&d.jsxs("span",{children:["(",w.filter_value,")"]}),d.jsx("span",{children:w.timezone})]})]}),d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>b(w.id),title:"Delete slot",style:{alignSelf:"center"},children:"×"})]},w.id))})]})}function yD(t){const[e,n]=t.split(":").map(Number),r=e>=12?"PM":"AM";return`${e%12||12}:${String(n).padStart(2,"0")} ${r}`}function bD({onBack:t}){const[e,n]=E.useState([]),[r,s]=E.useState([]),[i,l]=E.useState(!1),[c,u]=E.useState(null),[f,p]=E.useState(!0),m=E.useCallback(async()=>{try{const[v,w]=await Promise.all([fetch("/api/scheduler/queue"),fetch("/api/scheduler/slots")]);if(v.ok){const k=await v.json();n(k.items||[])}if(w.ok){const k=await w.json();s(k.slots||[])}}catch{}p(!1)},[]);E.useEffect(()=>{m()},[m]);const y=async v=>{(await fetch(`/api/scheduler/queue/${v}`,{method:"DELETE"})).ok&&(n(k=>k.filter(N=>N.id!==v)),u(null))};if(i)return d.jsx(gD,{slots:r,onBack:()=>{l(!1),m()}});const b=vD(r,e);return d.jsxs("div",{className:"sidebar-schedule",children:[d.jsxs("div",{className:"sidebar-schedule-header",children:[d.jsx("button",{className:"sidebar-schedule-back",onClick:t,title:"Back to documents",children:d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"m15 18-6-6 6-6"})})}),d.jsx("h3",{children:"Schedule"}),d.jsx("div",{className:"sidebar-schedule-actions",children:d.jsx("button",{className:"sidebar-schedule-btn",onClick:()=>l(!0),title:"Manage slots",children:d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"}),d.jsx("circle",{cx:"12",cy:"12",r:"3"})]})})})]}),f?null:r.length===0?d.jsxs("div",{className:"schedule-empty",children:[d.jsx("div",{className:"schedule-empty-title",children:"No time slots"}),d.jsx("div",{className:"schedule-empty-desc",children:"Create time slots to define your posting schedule."})]}):b.map(({label:v,entries:w})=>d.jsxs("div",{className:"schedule-day",children:[d.jsx("div",{className:"schedule-day-header",children:v}),w.map((k,N)=>{var T,I,_,M,O;return k.type==="empty"?d.jsxs("div",{className:"schedule-slot-empty",children:[d.jsx("div",{className:"schedule-item-time",children:k0(k.time)}),d.jsx("div",{className:"schedule-slot-empty-label",children:((T=k.slot)==null?void 0:T.filter_type)==="any"?"Open slot":`${(I=k.slot)==null?void 0:I.filter_type}: ${((_=k.slot)==null?void 0:_.filter_value)||"any"}`})]},`empty-${N}`):d.jsxs("div",{children:[d.jsxs("div",{className:"schedule-item",onClick:()=>u(c===k.item.id?null:k.item.id),children:[d.jsx("div",{className:"schedule-item-time",children:k0(k.time)}),d.jsxs("div",{className:"schedule-item-content",children:[d.jsx("div",{className:"schedule-item-text",children:((M=k.item.content)==null?void 0:M.text)||JSON.stringify(k.item.content)}),d.jsxs("div",{className:"schedule-item-meta",children:[d.jsx("span",{className:`schedule-item-status schedule-item-status--${k.item.status}`}),d.jsx("span",{children:k.item.status}),k.item.connection_name&&d.jsx("span",{children:k.item.connection_name}),k.item.provider&&d.jsx("span",{children:k.item.provider})]})]})]}),c===k.item.id&&d.jsxs("div",{className:"schedule-item-expanded",children:[d.jsx("div",{className:"schedule-item-full-text",children:((O=k.item.content)==null?void 0:O.text)||JSON.stringify(k.item.content,null,2)}),d.jsx("div",{className:"schedule-item-actions",children:d.jsx("button",{className:"schedule-item-action schedule-item-action--danger",onClick:()=>y(k.item.id),children:"Cancel"})})]})]},k.item.id)})]},v))]})}function vD(t,e){const n=new Date,r=[];for(let c=0;c<7;c++){const u=new Date(n);u.setDate(u.getDate()+c),u.setHours(0,0,0,0);let f;c===0?f="Today":c===1?f="Tomorrow":f=u.toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),r.push({label:f,date:u})}const s=new Map;for(const c of e){const u=new Date(c.scheduled_at),f=`${u.getFullYear()}-${u.getMonth()}-${u.getDate()}-${u.getHours()}-${u.getMinutes()}`;s.set(f,c)}const i=new Set,l=[];for(const{label:c,date:u}of r){const f=[],p=u.getDay(),y=["sun","mon","tue","wed","thu","fri","sat"][p];for(const b of t){if(!(b.days.includes("default")||b.days.includes(y)))continue;const[w,k]=b.time.split(":").map(Number),N=new Date(u);if(N.setHours(w,k,0,0),w0(u,n)&&N<n)continue;const T=`${N.getFullYear()}-${N.getMonth()}-${N.getDate()}-${w}-${k}`,I=s.get(T);I?(f.push({type:"filled",time:N,item:I,slot:b}),i.add(I.id)):f.push({type:"empty",time:N,slot:b})}for(const b of e){if(i.has(b.id))continue;const v=new Date(b.scheduled_at);w0(v,u)&&(f.push({type:"filled",time:v,item:b}),i.add(b.id))}f.sort((b,v)=>b.time.getTime()-v.time.getTime()),f.length>0&&l.push({label:c,entries:f})}return l}function w0(t,e){return t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function k0(t){return t.toLocaleTimeString("en-US",{hour:"numeric",minute:"2-digit",hour12:!0})}function xD({profiles:t,activeProfile:e,trashedProfiles:n,onSwitch:r,onCreate:s,onDelete:i,onRestore:l}){const[c,u]=E.useState(!1),[f,p]=E.useState(!1),[m,y]=E.useState(""),[b,v]=E.useState(null),w=E.useRef(null),k=E.useRef(null);E.useEffect(()=>{if(!c)return;const T=I=>{w.current&&!w.current.contains(I.target)&&(u(!1),p(!1),y(""),v(null))};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[c]),E.useEffect(()=>{f&&k.current&&k.current.focus()},[f]);const N=()=>{const T=m.trim();T&&(s(T),y(""),p(!1))};return d.jsxs("div",{className:"sidebar-profile-wrapper",ref:w,children:[d.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>u(!c),title:`Profile: ${e}`,children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"8",r:"4"}),d.jsx("path",{d:"M5.5 21a8.38 8.38 0 0 1 13 0"})]})}),c&&d.jsxs("div",{className:"sidebar-profile-dropdown",children:[t.map(T=>d.jsxs("div",{className:"sidebar-profile-row",children:[b===T?d.jsxs("div",{className:"sidebar-profile-confirm",children:[d.jsx("span",{children:"Delete?"}),d.jsxs("div",{className:"sidebar-inline-confirm",children:[d.jsx("button",{onClick:()=>{i(T),v(null)},children:"Yes"}),d.jsx("button",{onClick:()=>v(null),children:"No"})]})]}):d.jsx(d.Fragment,{children:d.jsxs("button",{className:`sidebar-profile-option ${T===e?"active":""}`,onClick:()=>{T!==e&&r(T),u(!1)},children:[d.jsx("span",{className:"sidebar-profile-check",children:T===e?"✓":""}),d.jsx("span",{children:T})]})}),T!=="Default"&&T!==e&&b!==T&&d.jsx("button",{className:"sidebar-profile-delete-btn",onClick:I=>{I.stopPropagation(),v(T)},title:"Delete profile",children:"×"})]},T)),n.length>0&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"sidebar-profile-divider"}),d.jsx("div",{className:"sidebar-profile-trash-label",children:"Trash"}),n.map(T=>d.jsxs("div",{className:"sidebar-profile-row sidebar-profile-trashed",children:[d.jsx("span",{className:"sidebar-profile-trash-name",children:T}),d.jsx("button",{className:"sidebar-profile-restore-btn",onClick:()=>l(T),children:"Restore"})]},T))]}),d.jsx("div",{className:"sidebar-profile-divider"}),f?d.jsx("div",{className:"sidebar-profile-add-input",children:d.jsx("input",{ref:k,type:"text",value:m,onChange:T=>y(T.target.value),onKeyDown:T=>{T.key==="Enter"&&N(),T.key==="Escape"&&(p(!1),y(""))},placeholder:"Profile name..."})}):d.jsxs("button",{className:"sidebar-profile-option sidebar-profile-add",onClick:()=>p(!0),children:[d.jsx("span",{className:"sidebar-profile-check",children:"+"}),d.jsx("span",{children:"New Profile"})]})]})]})}const wD=[{id:"full",label:"Full",lines:3},{id:"compact",label:"Compact",lines:2},{id:"minimal",label:"Minimal",lines:1}];function kD(){const[t,e]=E.useState(!1),[n,r]=E.useState(W0),s=E.useRef(null);E.useEffect(()=>{if(!t)return;const l=c=>{s.current&&!s.current.contains(c.target)&&e(!1)};return document.addEventListener("mousedown",l),()=>document.removeEventListener("mousedown",l)},[t]);const i=l=>{r(l),CE(l),e(!1)};return d.jsxs("div",{className:"sidebar-density-wrapper",ref:s,children:[d.jsx("button",{className:"sidebar-collapse-btn",onClick:()=>e(!t),title:"Card density",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("path",{d:"M21 9H3"}),d.jsx("path",{d:"M21 15H3"})]})}),t&&d.jsx("div",{className:"sidebar-density-dropdown",children:wD.map(l=>d.jsxs("button",{className:`sidebar-density-option ${n===l.id?"active":""}`,onClick:()=>i(l.id),children:[d.jsx("span",{className:"sidebar-density-icon",children:Array.from({length:l.lines},(c,u)=>d.jsx("span",{className:"sidebar-density-line"},u))}),d.jsx("span",{children:l.label})]},l.id))})]})}function S0({open:t,onSwitchDocument:e,onCreateDocument:n,refreshKey:r,workspacesRefreshKey:s,pendingDocs:i,writingTitle:l,writingTarget:c,onClose:u}){const{docs:f,workspaces:p,assignedFiles:m,fetchDocs:y,scrollRef:b}=eD(r,s),v=tD(p,y,r),w=zu(),[k,N]=E.useState(!1),[T,I]=E.useState([]),[_,M]=E.useState("Default"),O=E.useCallback(async()=>{try{const se=await fetch("/api/profiles");if(se.ok){const fe=await se.json();I(fe.profiles),M(fe.active)}}catch{}},[]);E.useEffect(()=>{O()},[O]);const P=E.useCallback(async se=>{try{(await fetch("/api/profiles/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:se})})).ok&&(M(se),O())}catch{}},[O]),$=E.useCallback(async se=>{try{(await fetch("/api/profiles",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:se})})).ok&&O()}catch{}},[O]),[B,W]=E.useState([]),J=E.useCallback(async()=>{try{const se=await fetch("/api/profiles/trash");if(se.ok){const fe=await se.json();W(fe.profiles)}}catch{}},[]);E.useEffect(()=>{J()},[J]);const F=E.useCallback(async se=>{try{(await fetch(`/api/profiles/${encodeURIComponent(se)}`,{method:"DELETE"})).ok&&(O(),J())}catch{}},[O,J]),re=E.useCallback(async se=>{try{(await fetch("/api/profiles/restore",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:se})})).ok&&(O(),J())}catch{}},[O,J]),[G,te]=E.useState(""),[U,ne]=E.useState(null),H=E.useRef(),X=E.useRef(null),K=E.useCallback(se=>{if(te(se),H.current&&clearTimeout(H.current),!se.trim()){ne(null);return}H.current=setTimeout(async()=>{try{const fe=await fetch(`/api/documents/search?q=${encodeURIComponent(se.trim())}&archived=true`);fe.ok&&ne(await fe.json())}catch{}},250)},[]);E.useEffect(()=>()=>{H.current&&clearTimeout(H.current)},[]);const A={docs:f,archivedDocs:[],workspaces:p,assignedFiles:m,pendingDocs:i,writingTitle:l,writingTarget:c,onSwitchDocument:e,onCreateDocument:n,actions:v,scrollRef:b,searchQuery:G,searchResults:U,onSearchChange:K},R=()=>{switch(w){case"timeline":return d.jsx(dD,{...A});case"board":return d.jsx(fD,{...A});case"shelf":return d.jsx(hD,{...A});default:return d.jsx(uD,{...A})}},Y=d.jsxs("div",{className:"sidebar-search",children:[d.jsxs("svg",{className:"sidebar-search-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"11",cy:"11",r:"8"}),d.jsx("path",{d:"m21 21-4.3-4.3"})]}),d.jsx("input",{ref:X,className:"sidebar-search-input",type:"text",placeholder:"Search...",value:G,onChange:se=>K(se.target.value)}),G&&d.jsx("button",{className:"sidebar-search-clear",onClick:()=>K(""),title:"Clear search",children:"×"})]});return w==="board"?d.jsx("div",{className:`sidebar sidebar-board-mode ${t?"open":""}`,children:R()}):d.jsxs("div",{className:`sidebar ${t?"open":""}`,children:[d.jsxs("div",{className:"sidebar-topbar",children:[d.jsxs("div",{className:"sidebar-logo",children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("path",{d:"M17 3a2.83 2.83 0 0 1 4 4L7.5 20.5 2 22l1.5-5.5Z",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),d.jsx("path",{d:"M15 5l4 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]}),d.jsx("span",{className:"sidebar-logo-text",children:"OpenWriter"})]}),d.jsxs("div",{className:"sidebar-topbar-actions",children:[d.jsx(xD,{profiles:T,activeProfile:_,trashedProfiles:B,onSwitch:P,onCreate:$,onDelete:F,onRestore:re}),d.jsx("button",{className:`sidebar-collapse-btn${k?" sidebar-collapse-btn--active":""}`,onClick:()=>N(!k),title:"Schedule",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"}),d.jsx("line",{x1:"16",x2:"16",y1:"1",y2:"5"}),d.jsx("line",{x1:"8",x2:"8",y1:"1",y2:"5"}),d.jsx("line",{x1:"3",x2:"21",y1:"9",y2:"9"})]})}),d.jsx(kD,{}),u&&d.jsx("button",{className:"sidebar-collapse-btn",onClick:u,title:"Close sidebar",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M9 3v18",stroke:"currentColor",strokeWidth:"2"}),d.jsx("path",{d:"M15 10l-2 2 2 2",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})})]})]}),k?d.jsx(bD,{onBack:()=>N(!1)}):d.jsxs(d.Fragment,{children:[Y,R()]})]})}function SD({onClose:t,onSetupComplete:e}){const[n,r]=E.useState("detecting"),[s,i]=E.useState(null),[l,c]=E.useState("gh"),[u,f]=E.useState("openwriter-docs"),[p,m]=E.useState(!0),[y,b]=E.useState(""),[v,w]=E.useState(""),[k,N]=E.useState(""),[T,I]=E.useState("");E.useEffect(()=>{fetch("/api/sync/capabilities").then(M=>M.json()).then(M=>{i(M),M.ghAuthenticated?c("gh"):(M.gitInstalled,c("pat")),r("setup")}).catch(()=>{N("Failed to detect git capabilities"),r("error")})},[]);const _=E.useCallback(async()=>{r("progress"),I(l==="connect"?"Connecting to repository...":"Creating repository and syncing...");try{const M={method:l,repoName:u,isPrivate:p};l==="pat"&&(M.pat=y),l==="connect"&&(M.remoteUrl=v,M.pat=y||void 0);const O=await fetch("/api/sync/setup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)});if(!O.ok){const P=await O.json().catch(()=>({}));throw new Error(P.error||`Setup failed (${O.status})`)}r("done"),e()}catch(M){N(M.message),r("error")}},[l,u,p,y,v,e]);return d.jsx("div",{className:"sync-modal-overlay",onClick:t,children:d.jsxs("div",{className:"sync-modal",onClick:M=>M.stopPropagation(),children:[d.jsxs("div",{className:"sync-modal-header",children:[d.jsx("h2",{children:"Sync to GitHub"}),d.jsx("button",{className:"sync-modal-close",onClick:t,children:"×"})]}),n==="detecting"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-spinner"}),d.jsx("p",{children:"Detecting git configuration..."})]}),n==="setup"&&s&&d.jsxs("div",{className:"sync-modal-body",children:[!s.gitInstalled&&d.jsxs("div",{className:"sync-warning",children:["Git is not installed. Please ",d.jsx("a",{href:"https://git-scm.com/downloads",target:"_blank",rel:"noreferrer",children:"install git"})," first."]}),s.gitInstalled&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"sync-tabs",children:[s.ghAuthenticated&&d.jsx("button",{className:`sync-tab${l==="gh"?" active":""}`,onClick:()=>c("gh"),children:"GitHub CLI"}),d.jsx("button",{className:`sync-tab${l==="pat"?" active":""}`,onClick:()=>c("pat"),children:"Personal Access Token"}),d.jsx("button",{className:`sync-tab${l==="connect"?" active":""}`,onClick:()=>c("connect"),children:"Connect Existing"})]}),l==="gh"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:M=>f(M.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:p,onChange:M=>m(M.target.checked)}),"Private repository"]})]}),l==="pat"&&d.jsxs("div",{className:"sync-form",children:[!s.ghAuthenticated&&!s.ghInstalled&&d.jsxs("p",{className:"sync-hint",children:["Create a ",d.jsx("a",{href:"https://github.com/settings/tokens/new?scopes=repo&description=OpenWriter",target:"_blank",rel:"noreferrer",children:"Personal Access Token"})," with ",d.jsx("code",{children:"repo"})," scope."]}),d.jsxs("label",{children:["Personal Access Token",d.jsx("input",{type:"password",value:y,onChange:M=>b(M.target.value),placeholder:"ghp_..."})]}),d.jsxs("label",{children:["Repository name",d.jsx("input",{type:"text",value:u,onChange:M=>f(M.target.value),placeholder:"openwriter-docs"})]}),d.jsxs("label",{className:"sync-checkbox",children:[d.jsx("input",{type:"checkbox",checked:p,onChange:M=>m(M.target.checked)}),"Private repository"]})]}),l==="connect"&&d.jsxs("div",{className:"sync-form",children:[d.jsxs("label",{children:["Remote URL",d.jsx("input",{type:"text",value:v,onChange:M=>w(M.target.value),placeholder:"https://github.com/user/repo.git"})]}),d.jsxs("label",{children:["PAT (optional, for private repos)",d.jsx("input",{type:"password",value:y,onChange:M=>b(M.target.value),placeholder:"ghp_..."})]})]}),d.jsxs("div",{className:"sync-modal-actions",children:[d.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Cancel"}),d.jsx("button",{className:"sync-btn primary",onClick:_,disabled:l==="pat"&&!y||l==="connect"&&!v||l!=="connect"&&!u,children:l==="connect"?"Connect & Sync":"Create & Sync"})]})]})]}),n==="progress"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-spinner"}),d.jsx("p",{children:T})]}),n==="done"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-success-icon",children:"✓"}),d.jsx("p",{children:"Successfully synced to GitHub!"}),d.jsx("div",{className:"sync-modal-actions",children:d.jsx("button",{className:"sync-btn primary",onClick:t,children:"Done"})})]}),n==="error"&&d.jsxs("div",{className:"sync-modal-body",children:[d.jsx("div",{className:"sync-error-msg",children:k}),d.jsxs("div",{className:"sync-modal-actions",children:[d.jsx("button",{className:"sync-btn secondary",onClick:()=>r("setup"),children:"Back"}),d.jsx("button",{className:"sync-btn secondary",onClick:t,children:"Close"})]})]})]})})}function ED({onNodeChanges:t,onAgentStatus:e,onDocumentSwitched:n,onDocumentsChanged:r,onWorkspacesChanged:s,onTitleChanged:i,onPendingDocsChanged:l,onMetadataChanged:c,onSyncStatus:u,onWritingStarted:f,onWritingFinished:p,getEditorState:m}){const y=E.useRef(null),[b,v]=E.useState(!1),w=E.useRef(t),k=E.useRef(e),N=E.useRef(n),T=E.useRef(r),I=E.useRef(s),_=E.useRef(i),M=E.useRef(l),O=E.useRef(u),P=E.useRef(c),$=E.useRef(f),B=E.useRef(p),W=E.useRef(m);w.current=t,k.current=e,N.current=n,T.current=r,I.current=s,_.current=i,M.current=l,P.current=c,O.current=u,$.current=f,B.current=p,W.current=m,E.useEffect(()=>{const re=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws`;let G,te=!1,U=1e3;function ne(){const X=new WebSocket(re);y.current=X,X.onopen=()=>{v(!0),U=1e3,te&&X.send(JSON.stringify({type:"request-document"})),te=!0},X.onmessage=K=>{var A,R,Y,se,fe,Z,me,Le,Ze,ce,ve;try{const ie=JSON.parse(K.data);ie.type==="node-changes"&&ie.changes&&((A=w.current)==null||A.call(w,ie.changes)),ie.type==="agent-status"&&((R=k.current)==null||R.call(k,!!ie.agentConnected)),ie.type==="document-switched"&&((Y=N.current)==null||Y.call(N,{document:ie.document,title:ie.title,filename:ie.filename,docId:ie.docId,metadata:ie.metadata})),ie.type==="metadata-changed"&&ie.metadata&&((se=P.current)==null||se.call(P,ie.metadata)),ie.type==="documents-changed"&&((fe=T.current)==null||fe.call(T)),ie.type==="workspaces-changed"&&((Z=I.current)==null||Z.call(I)),ie.type==="title-changed"&&ie.title&&((me=_.current)==null||me.call(_,ie.title)),ie.type==="pending-docs-changed"&&ie.pendingDocs&&((Le=M.current)==null||Le.call(M,ie.pendingDocs)),ie.type==="sync-status"&&((Ze=O.current)==null||Ze.call(O,{state:ie.state,lastSyncTime:ie.lastSyncTime,pendingFiles:ie.pendingFiles,error:ie.error})),ie.type==="writing-started"&&ie.title&&((ce=$.current)==null||ce.call($,ie.title,ie.target||null)),ie.type==="writing-finished"&&((ve=B.current)==null||ve.call(B)),ie.type==="plugins-changed"&&window.dispatchEvent(new CustomEvent("ow-plugins-changed")),ie.type==="marks-changed"&&ie.filename&&window.dispatchEvent(new CustomEvent("ow-marks-changed",{detail:{filename:ie.filename}}))}catch{}},X.onclose=()=>{v(!1),G=setTimeout(ne,U),U=Math.min(U*1.5,8e3)},X.onerror=()=>{X.close()}}ne();function H(){var X;document.visibilityState==="visible"&&((X=y.current)==null?void 0:X.readyState)!==WebSocket.OPEN&&(clearTimeout(G),U=1e3,ne())}return document.addEventListener("visibilitychange",H),()=>{var X;clearTimeout(G),document.removeEventListener("visibilitychange",H),(X=y.current)==null||X.close()}},[]);const J=E.useCallback(F=>{var re;((re=y.current)==null?void 0:re.readyState)===WebSocket.OPEN&&y.current.send(JSON.stringify(F))},[]);return{connected:b,sendMessage:J}}function ND(t){const[e,n]=E.useState(null),[r,s]=E.useState(!1),[i,l]=E.useState(null),c=E.useRef(void 0);return E.useEffect(()=>{if(!t){n(null),s(!1),l(null),c.current=void 0;return}t!==c.current&&(c.current=t,s(!0),l(null),fetch(`/api/tweet-embed?url=${encodeURIComponent(t)}`).then(u=>u.ok?u.json():u.json().then(f=>Promise.reject(new Error(f.error||`HTTP ${u.status}`)))).then(u=>{n(u),s(!1)}).catch(u=>{l(u.message),s(!1)}))},[t]),{tweet:e,loading:r,error:i}}function CD(t){var r;const e=t.view.dom,n=[];for(const s of e.children){const i=(r=s.innerText)==null?void 0:r.trim();i&&n.push(i)}return n.join(`
205
+
206
+ `)}function _D(t,e){const[n,r]=E.useState("idle"),s=E.useRef();return{copyText:E.useCallback(async()=>{const l=t.current[e];if(!l)return;const c=CD(l);if(c){try{await navigator.clipboard.writeText(c)}catch{const u=document.createElement("textarea");u.value=c,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.select(),document.execCommand("copy"),document.body.removeChild(u)}r("copied"),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>r("idle"),2e3)}},[t,e]),copyState:n}}function Ah(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e4?`${(t/1e3).toFixed(0)}K`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function TD(t){try{const e=Date.now(),n=new Date(t).getTime(),r=Math.floor((e-n)/1e3);if(r<60)return`${r}s`;const s=Math.floor(r/60);if(s<60)return`${s}m`;const i=Math.floor(s/60);return i<24?`${i}h`:new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric"})}catch{return""}}const MD=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M1.751 10c0-4.42 3.584-8 8.005-8h4.366c4.49 0 8.129 3.64 8.129 8.13 0 2.96-1.607 5.68-4.196 7.11l-8.054 4.46v-3.69h-.067c-4.49.1-8.183-3.51-8.183-8.01zm8.005-6c-3.317 0-6.005 2.69-6.005 6 0 3.37 2.77 6.08 6.138 6.01l.351-.01h1.761v2.3l5.087-2.81c1.951-1.08 3.163-3.13 3.163-5.36 0-3.39-2.744-6.13-6.129-6.13H9.756z"})}),AD=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M4.5 3.88l4.432 4.14-1.364 1.46L5.5 7.55V16c0 1.1.896 2 2 2H13v2H7.5c-2.209 0-4-1.79-4-4V7.55L1.432 9.48.068 8.02 4.5 3.88zM16.5 6H11V4h5.5c2.209 0 4 1.79 4 4v8.45l2.068-1.93 1.364 1.46-4.432 4.14-4.432-4.14 1.364-1.46 2.068 1.93V8c0-1.1-.896-2-2-2z"})}),OD=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M16.697 5.5c-1.222-.06-2.679.51-3.89 2.16l-.805 1.09-.806-1.09C9.984 6.01 8.526 5.44 7.304 5.5c-1.243.07-2.349.78-2.91 1.91-.552 1.12-.633 2.78.479 4.82 1.074 1.97 3.257 4.27 7.129 6.61 3.87-2.34 6.052-4.64 7.126-6.61 1.111-2.04 1.03-3.7.477-4.82-.561-1.13-1.666-1.84-2.908-1.91zm4.187 7.69c-1.351 2.48-4.001 5.12-8.379 7.67l-.503.3-.504-.3c-4.379-2.55-7.029-5.19-8.382-7.67-1.36-2.5-1.41-4.86-.514-6.67.887-1.79 2.647-2.91 4.601-3.01 1.651-.09 3.368.56 4.798 2.01 1.429-1.45 3.146-2.1 4.796-2.01 1.954.1 3.714 1.22 4.601 3.01.896 1.81.846 4.17-.514 6.67z"})}),RD=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M4 4.5C4 3.12 5.119 2 6.5 2h11C18.881 2 20 3.12 20 4.5v18.44l-8-5.71-8 5.71V4.5zM6.5 4c-.276 0-.5.22-.5.5v14.56l6-4.29 6 4.29V4.5c0-.28-.224-.5-.5-.5h-11z"})}),ID=()=>d.jsx("svg",{viewBox:"0 0 24 24","aria-hidden":"true",children:d.jsx("path",{fill:"currentColor",d:"M12 2.59l5.7 5.7-1.41 1.42L13 6.41V16h-2V6.41l-3.3 3.3-1.41-1.42L12 2.59zM21 15l-.02 3.51c0 1.38-1.12 2.49-2.5 2.49H5.5C4.11 21 3 19.88 3 18.5V15h2v3.5c0 .28.22.5.5.5h12.98c.28 0 .5-.22.5-.5L19 15h2z"})});function D1({tweet:t,nested:e,url:n}){const r=TD(t.createdAt);return d.jsxs("div",{className:`tweet-embed-card${e?" tweet-embed-nested":""}${n?" tweet-embed-card--clickable":""}`,onClick:n?()=>window.open(n,"_blank","noopener,noreferrer"):void 0,role:n?"link":void 0,children:[d.jsxs("div",{className:"tweet-author-row",children:[t.author.avatarUrl?d.jsx("img",{className:"tweet-avatar",src:t.author.avatarUrl,alt:""}):d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-author-name",children:t.author.name}),d.jsxs("span",{className:"tweet-author-handle",children:["@",t.author.username]}),r&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"tweet-author-separator",children:"·"}),d.jsx("span",{className:"tweet-author-timestamp",children:r})]})]})]}),d.jsx("div",{className:"tweet-text",children:t.text}),t.media&&t.media.length>0&&d.jsx("div",{className:"tweet-media",children:t.media.map((s,i)=>s.type==="photo"?d.jsx("img",{className:"tweet-media-img",src:s.url,alt:"",loading:"lazy"},i):s.type==="video"||s.type==="gif"?d.jsx("div",{className:"tweet-media-video-placeholder",children:d.jsx("span",{children:"Video"})},i):null)}),t.quoteTweet&&d.jsx(D1,{tweet:t.quoteTweet,nested:!0}),!e&&d.jsxs("div",{className:"tweet-actions-row",children:[d.jsxs("span",{className:"tweet-action tweet-action-reply",children:[d.jsx(MD,{}),t.metrics.replies>0&&Ah(t.metrics.replies)]}),d.jsxs("span",{className:"tweet-action tweet-action-retweet",children:[d.jsx(AD,{}),t.metrics.retweets>0&&Ah(t.metrics.retweets)]}),d.jsxs("span",{className:"tweet-action tweet-action-like",children:[d.jsx(OD,{}),t.metrics.likes>0&&Ah(t.metrics.likes)]}),d.jsx("span",{className:"tweet-action tweet-action-bookmark",children:d.jsx(RD,{})}),d.jsx("span",{className:"tweet-action tweet-action-share",children:d.jsx(ID,{})})]})]})}function jD({tweet:t,url:e}){return d.jsx(D1,{tweet:t,url:e})}function LD({initialContent:t,placeholder:e="What is happening?!",onUpdate:n,onReady:r,onFocus:s}){const i=ik({extensions:[...b1,ed.configure({placeholder:e})],content:t||"<p></p>",onUpdate:({editor:l})=>{n==null||n(l)},onFocus:()=>{s==null||s()}},[t]);return E.useEffect(()=>{if(!i)return;const{state:l}=i.view;if(l.plugins.some(f=>f.key==="pendingDecoration$"))return;const c=S1(),u=l.reconfigure({plugins:[...l.plugins,c]});i.view.updateState(u)},[i]),E.useEffect(()=>{if(!i)return;const{state:l}=i.view;if(l.plugins.some(f=>f.key==="markDecoration$"))return;const c=E1(),u=l.reconfigure({plugins:[...l.plugins,c]});i.view.updateState(u)},[i]),E.useEffect(()=>{i&&(r==null||r(i))},[i,r]),i?d.jsx(Yp,{editor:i}):null}function DD({count:t,softLimit:e=280}){const n=e-t,r=Math.min(t/e,1),s=26,i=2,l=(s-i)/2,c=2*Math.PI*l,u=c*(1-r);let f="var(--x-blue, #1d9bf0)";n<=0?f="var(--x-red, #f4212e)":n<=20&&(f="var(--x-yellow, #ffd400)");const p=n<=20;return t===0?null:d.jsxs("div",{className:"tweet-char-counter",title:`${t} / ${e}`,style:{width:s,height:s},children:[d.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[d.jsx("circle",{cx:s/2,cy:s/2,r:l,fill:"none",stroke:"var(--x-border, #eff3f4)",strokeWidth:i}),d.jsx("circle",{cx:s/2,cy:s/2,r:l,fill:"none",stroke:f,strokeWidth:i,strokeDasharray:c,strokeDashoffset:u,strokeLinecap:"round",transform:`rotate(-90 ${s/2} ${s/2})`,style:{transition:"stroke-dashoffset 0.15s ease, stroke 0.15s ease"}})]}),p&&d.jsx("span",{className:"tweet-char-number",style:{color:f},children:n})]})}const E0="@openwriter/plugin-x-api",N0=[{key:"api-key",label:"API Key",env:"X_API_KEY"},{key:"api-secret",label:"API Secret",env:"X_API_SECRET"},{key:"access-token",label:"Access Token",env:"X_ACCESS_TOKEN"},{key:"access-token-secret",label:"Access Token Secret",env:"X_ACCESS_TOKEN_SECRET"}];function PD({onConnected:t,onCancel:e}){const[n,r]=E.useState({"api-key":"","api-secret":"","access-token":"","access-token-secret":""}),[s,i]=E.useState(!1),[l,c]=E.useState(""),u=N0.every(p=>n[p.key].trim()),f=async()=>{i(!0),c("");try{if(!(await fetch("/api/plugins/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E0,config:n})})).ok)throw new Error("Failed to save config");const y=await(await fetch("/api/plugins/enable",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:E0})})).json();if(!y.success)throw new Error(y.error||"Failed to enable plugin");const v=await(await fetch("/api/x/status")).json();v.connected?t():c(v.error||"Could not verify X credentials. Check your API keys.")}catch(p){c(p.message||"Connection failed")}finally{i(!1)}};return d.jsxs("div",{className:"x-connect-prompt",children:[d.jsxs("div",{className:"x-connect-header",children:[d.jsx("span",{className:"x-connect-title",children:"Connect your X account to post"}),d.jsx("button",{className:"x-connect-cancel",onClick:e,title:"Cancel",children:d.jsx("svg",{viewBox:"0 0 24 24",width:"18",height:"18",children:d.jsx("path",{fill:"currentColor",d:"M10.59 12L4.54 5.96l1.42-1.42L12 10.59l6.04-6.05 1.42 1.42L13.41 12l6.05 6.04-1.42 1.42L12 13.41l-6.04 6.05-1.42-1.42L10.59 12z"})})})]}),d.jsx("div",{className:"x-connect-fields",children:N0.map(p=>d.jsxs("div",{className:"x-connect-field",children:[d.jsx("label",{className:"x-connect-label",children:p.label}),d.jsx("input",{type:"password",className:"x-connect-input",value:n[p.key],onChange:m=>r(y=>({...y,[p.key]:m.target.value})),placeholder:p.env,spellCheck:!1,autoComplete:"off"})]},p.key))}),l&&d.jsx("div",{className:"x-connect-error",children:l}),d.jsxs("div",{className:"x-connect-actions",children:[d.jsx("a",{className:"x-connect-dev-link",href:"https://developer.x.com/en/portal/dashboard",target:"_blank",rel:"noopener noreferrer",children:"Get credentials"}),d.jsx("button",{className:"x-connect-btn",onClick:f,disabled:!u||s,children:s?"Connecting...":"Connect"})]})]})}const C0="ow-x-handle";function BD(){const[t,e]=E.useState(()=>localStorage.getItem(C0)||""),[n,r]=E.useState(!1),[s,i]=E.useState(""),l=E.useRef(null),c=E.useRef(null),u=()=>{const m=s.replace(/^@/,"").trim();m&&(localStorage.setItem(C0,m),e(m)),r(!1)},f=()=>{i(t),r(!0),setTimeout(()=>{var m;return(m=l.current)==null?void 0:m.focus()},0)};E.useEffect(()=>{if(!n)return;const m=y=>{c.current&&!c.current.contains(y.target)&&u()};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[n,s]);const p=t?`https://unavatar.io/twitter/${t}`:"";return d.jsxs("div",{className:"tweet-compose-avatar-wrapper",ref:c,children:[t?d.jsx("img",{className:"tweet-compose-avatar tweet-compose-avatar-img",src:p,alt:`@${t}`,onClick:f,title:`@${t} — click to change`}):d.jsx("div",{className:"tweet-compose-avatar",onClick:f,title:"Set your @handle"}),n&&d.jsx("div",{className:"tweet-handle-popover",children:d.jsx("input",{ref:l,className:"tweet-handle-input",value:s,onChange:m=>i(m.target.value),onKeyDown:m=>{m.key==="Enter"&&u(),m.key==="Escape"&&r(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function _0(){return d.jsxs("div",{className:"tweet-skeleton",children:[d.jsxs("div",{className:"tweet-author-row",children:[d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder tweet-pulse"}),d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:120}}),d.jsx("span",{className:"tweet-skeleton-line tweet-pulse",style:{width:80}})]})]}),d.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"100%",height:16,marginTop:12}}),d.jsx("div",{className:"tweet-skeleton-line tweet-pulse",style:{width:"75%",height:16,marginTop:8}})]})}function zD(t){var e;if(t)return(e=t.match(/\/status\/(\d+)/))==null?void 0:e[1]}function T0(t){if(!t)return[null];if(typeof t=="string"){const e=t.split(/<hr\s*\/?>/i).map(n=>n.trim()).filter(Boolean);return e.length?e:[null]}if((t==null?void 0:t.type)==="doc"&&Array.isArray(t.content)){const e=[[]];for(const r of t.content)r.type==="horizontalRule"?e.push([]):e[e.length-1].push(r);const n=e.map(r=>r.length?{type:"doc",content:r}:null).filter(Boolean);return n.length?n:[null]}return[t]}function Oh(t){const e=[],n=t.filter(Boolean);return n.forEach((r,s)=>{const i=r.getJSON();i.content&&e.push(...i.content),s<n.length-1&&e.push({type:"horizontalRule"})}),{type:"doc",content:e}}function M0(t){const e=[],n=r=>{var s;r.type==="image"&&((s=r.attrs)!=null&&s.src)&&e.push(r.attrs.src),r.content&&r.content.forEach(n)};return n(t.getJSON()),e.slice(0,4)}function A0(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tweetContext:t})}).catch(()=>{})}function $D({tweetContext:t,initialContent:e,onUpdate:n,onEditorReady:r,onEditorsChange:s,filename:i,title:l}){const{tweet:c,loading:u,error:f}=ND(t==null?void 0:t.url),[p,m]=E.useState(()=>T0(e)),[y,b]=E.useState(0),v=E.useRef([]),w=E.useRef(null),k=E.useRef(!0),N=E.useRef(!1),T=E.useRef(p.length),[I,_]=E.useState(()=>p.map(()=>0)),[M,O]=E.useState(0),[P,$]=E.useState(0),[B,W]=E.useState(null),[J,F]=E.useState(),[re,G]=E.useState(!1),[te,U]=E.useState("idle"),[ne,H]=E.useState(""),X=E.useRef(),{copyText:K,copyState:A}=_D(v,M),[R,Y]=E.useState(!1);E.useEffect(()=>{let Ce=!1;return(async()=>{try{const ke=await fetch("/api/x/status");if(Ce)return;if(ke.ok){const at=await ke.json();W(at.connected),F(at.username)}else W(!1)}catch{Ce||W(!1)}})(),()=>{Ce=!0}},[]),E.useEffect(()=>{if(k.current){k.current=!1;return}if(!e||JSON.stringify(e)===w.current)return;const ke=T0(e);N.current=!0,T.current=ke.length,v.current=[],m(ke),_(ke.map(()=>0)),b(at=>at+1)},[e]);const se=E.useCallback((Ce,ke)=>{if(v.current[Ce]=ke,_(ft=>{const st=[...ft];return st[Ce]=ke.getText().length,st}),N.current)return;const at=Oh(v.current);w.current=JSON.stringify(at),n==null||n(at)},[n]),fe=E.useCallback((Ce,ke)=>{if(v.current[Ce]=ke,_(at=>{const ft=[...at];return ft[Ce]=ke.getText().length,ft}),$(at=>at+1),N.current&&v.current.filter(Boolean).length>=T.current){N.current=!1;const ft=Oh(v.current);w.current=JSON.stringify(ft)}Ce===0&&(r==null||r(ke)),s==null||s(v.current.filter(Boolean))},[r,s]),Z=p.length>1;I.reduce((Ce,ke)=>Ce+ke,0);const me=E.useCallback(()=>{const Ce=M+1;m(ke=>[...ke.slice(0,Ce),"<p></p>",...ke.slice(Ce)]),_(ke=>[...ke.slice(0,Ce),0,...ke.slice(Ce)]),O(Ce)},[M]),Le=E.useCallback(Ce=>{Ce!==0&&(v.current.splice(Ce,1),m(ke=>ke.filter((at,ft)=>ft!==Ce)),_(ke=>ke.filter((at,ft)=>ft!==Ce)),setTimeout(()=>{const ke=Oh(v.current);n==null||n(ke),s==null||s(v.current.filter(Boolean))},0))},[n,s]),Ze=!!(t!=null&&t.url),ce=(t==null?void 0:t.mode)==="reply",ve=v.current.filter(Boolean).some(ke=>ke.getText().trim()||M0(ke).length>0),ie=B&&ve&&te==="idle",Be=async()=>{if(!B){G(!0);return}if(ie){U("uploading"),H("");try{const Ce=v.current.filter(Boolean),ke=[];for(const ft of Ce){const st=ft.getText().trim(),ht=M0(ft);if(!st&&ht.length===0)continue;const zt=[];for(const Ct of ht){const xn=await(await fetch("/api/x/upload-media",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({src:Ct})})).json();if(!xn.success)throw new Error(xn.error||"Image upload failed");zt.push(xn.mediaId)}ke.push({text:st,mediaIds:zt})}if(ke.length===0)return;U("posting");const at=zD(t==null?void 0:t.url);if(ke.length===1){const ft={};ke[0].text&&(ft.text=ke[0].text),ke[0].mediaIds.length>0&&(ft.mediaIds=ke[0].mediaIds),(t==null?void 0:t.mode)==="reply"&&at?ft.replyTo=at:(t==null?void 0:t.mode)==="quote"&&at&&(ft.quoteTweetId=at);const ht=await(await fetch("/api/x/post",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ft)})).json();ht.success?(A0({lastPost:{postedAt:new Date().toISOString(),tweetUrl:ht.tweetUrl}}),U("success"),X.current=setTimeout(()=>U("idle"),2500)):(console.error("[TweetCompose] Post error:",ht.error),H(ht.error||"Post failed"),U("error"),setTimeout(()=>U("idle"),3e3))}else{const st={tweets:ke.map(Ct=>({text:Ct.text,...Ct.mediaIds.length>0?{mediaIds:Ct.mediaIds}:{}}))};(t==null?void 0:t.mode)==="reply"&&at&&(st.replyTo=at);const zt=await(await fetch("/api/x/post-thread",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(st)})).json();zt.success?(A0({lastPost:{postedAt:new Date().toISOString(),tweetUrl:zt.threadUrl}}),U("success"),X.current=setTimeout(()=>U("idle"),2500)):(H(zt.error||"Thread post failed"),U("error"),setTimeout(()=>U("idle"),3e3))}}catch(Ce){H(Ce.message||"Network error"),U("error"),setTimeout(()=>U("idle"),3e3)}}};E.useEffect(()=>()=>{X.current&&clearTimeout(X.current)},[]);const Te=()=>{W(!0),G(!1),fetch("/api/x/status").then(Ce=>Ce.json()).then(Ce=>{Ce.username&&F(Ce.username)}).catch(()=>{})},Ue=te==="uploading"?"Uploading...":te==="posting"?"Posting...":te==="success"?"Posted!":te==="error"?"Failed":Z?M===0?"Post Thread":"Post All":"Post",Ee=p.map((Ce,ke)=>ke===0?ce?"Post your reply":"What is happening?!":"Add another tweet"),Qe=Ce=>{var ke;return d.jsxs("div",{className:`tweet-compose-footer${Ce?" tweet-compose-footer--inline":""}`,children:[M===0&&((ke=t==null?void 0:t.lastPost)==null?void 0:ke.postedAt)&&d.jsxs("a",{className:"tweet-posted-status",href:t.lastPost.tweetUrl,target:"_blank",rel:"noopener noreferrer",title:t.lastPost.tweetUrl||"Posted to X",children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Posted ",new Date(t.lastPost.postedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," on X"]}),te==="error"&&ne&&d.jsx("span",{className:"tweet-post-error",children:ne}),d.jsx(DD,{count:I[M]||0}),d.jsx("button",{className:"tweet-thread-add",onClick:me,title:"Add another tweet",children:d.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:[d.jsx("line",{x1:"10",y1:"4",x2:"10",y2:"16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),d.jsx("line",{x1:"4",y1:"10",x2:"16",y2:"10",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}),d.jsx("button",{className:`tweet-copy-btn${A==="copied"?" tweet-copy-btn--copied":""}`,disabled:!ve,onClick:K,title:"Copy tweet text to clipboard",children:A==="copied"?d.jsxs(d.Fragment,{children:[d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:d.jsx("path",{d:"M3 8.5L6.5 12L13 4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}),"Copied!"]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[d.jsx("rect",{x:"5.5",y:"2",width:"8.5",height:"10.5",rx:"1.5",stroke:"currentColor",strokeWidth:"1.5"}),d.jsx("path",{d:"M3.5 5H2.5A1.5 1.5 0 001 6.5V13a1.5 1.5 0 001.5 1.5H9A1.5 1.5 0 0010.5 13v-1",stroke:"currentColor",strokeWidth:"1.5"})]}),"Copy"]})}),d.jsx("button",{className:`tweet-post-btn${ie||!B&&B!==null?" tweet-post-btn--active":""}${te==="success"?" tweet-post-btn--success":""}${te==="error"?" tweet-post-btn--error":""}`,disabled:B?!ie:!1,onClick:Be,title:B?J?`Post as @${J}`:"Post to X":"Connect X to post",children:Ue}),i&&d.jsx("button",{className:"tweet-schedule-btn",onClick:()=>Y(!0),title:"Schedule post",children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]})})]})},tt=Ze&&!ce,vt=()=>d.jsx("div",{className:"tweet-thread-editors",children:p.map((Ce,ke)=>d.jsxs("div",{className:`tweet-thread-item${ke===M?" tweet-thread-item--active":" tweet-thread-item--inactive"}`,children:[d.jsxs("div",{className:"tweet-thread-item-left",children:[d.jsx(BD,{}),ke<p.length-1&&d.jsx("div",{className:"tweet-thread-line"})]}),d.jsxs("div",{className:"tweet-thread-item-right",children:[ke>0&&d.jsx("button",{className:"tweet-thread-remove",onClick:()=>Le(ke),title:"Remove this tweet",children:"×"}),d.jsx("div",{className:`tweet-compose-box${ke===0&&!Z?" tweet-compose-box--standalone":""}`,children:d.jsx(LD,{initialContent:Ce,placeholder:Ee[ke],onUpdate:at=>se(ke,at),onReady:at=>fe(ke,at),onFocus:()=>O(ke)})}),ke===M&&!tt&&Qe(ke<p.length-1)]})]},`${y}-${ke}`))});return d.jsxs("div",{className:"tweet-compose-wrapper",children:[Ze&&ce&&d.jsxs(d.Fragment,{children:[u&&d.jsx("div",{className:"tweet-context-section",children:d.jsx(_0,{})}),f&&d.jsx("div",{className:"tweet-context-section",children:d.jsxs("div",{className:"tweet-embed-error",children:[d.jsx("span",{children:"Could not load tweet"}),d.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]})}),c&&d.jsx("div",{className:"tweet-reply-parent-section",children:d.jsxs("div",{className:"tweet-reply-thread",children:[d.jsxs("div",{className:"tweet-reply-thread-left",children:[c.author.avatarUrl?d.jsx("img",{className:"tweet-avatar",src:c.author.avatarUrl,alt:""}):d.jsx("div",{className:"tweet-avatar tweet-avatar-placeholder"}),d.jsx("div",{className:"tweet-reply-thread-line"})]}),d.jsxs("div",{className:"tweet-reply-thread-right",children:[d.jsxs("div",{className:"tweet-reply-parent",children:[d.jsxs("div",{className:"tweet-author-info",children:[d.jsx("span",{className:"tweet-author-name",children:c.author.name}),d.jsxs("span",{className:"tweet-author-handle",children:["@",c.author.username]})]}),d.jsx("div",{className:"tweet-text",children:c.text}),c.media&&c.media.length>0&&d.jsx("div",{className:"tweet-media",children:c.media.map((Ce,ke)=>Ce.type==="photo"?d.jsx("img",{className:"tweet-media-img",src:Ce.url,alt:"",loading:"lazy"},ke):d.jsx("div",{className:"tweet-media-video-placeholder",children:d.jsx("span",{children:"Video"})},ke))})]}),d.jsxs("div",{className:"tweet-replying-to-inline",children:["Replying to ",d.jsxs("span",{className:"tweet-reply-handle",children:["@",c.author.username]})]})]})]})}),vt()]}),tt&&d.jsxs(d.Fragment,{children:[vt(),d.jsxs("div",{className:"tweet-quote-section",style:{padding:"0 16px 12px"},children:[u&&d.jsx(_0,{}),f&&d.jsxs("div",{className:"tweet-embed-error",children:[d.jsx("span",{children:"Could not load tweet"}),d.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"tweet-fallback-link",children:t.url})]}),c&&d.jsx(jD,{tweet:c,url:t==null?void 0:t.url})]}),d.jsx("div",{className:"tweet-quote-footer",children:Qe()})]}),!Ze&&vt(),re&&d.jsx(PD,{onConnected:Te,onCancel:()=>G(!1)}),R&&i&&d.jsx(rd,{filename:i,title:l||"Untitled",onClose:()=>Y(!1)})]})}function FD(){const[t,e]=E.useState("idle"),n=E.useRef();return{copyAsHtml:E.useCallback(async()=>{const s=document.querySelector(".ProseMirror");if(!s)return;const i=s.cloneNode(!0);i.querySelectorAll(".ProseMirror-widget, [data-widget], .ProseMirror-gapcursor").forEach(p=>p.remove());let l="";const c=document.querySelector(".article-title-input");c!=null&&c.value&&c.value!=="Untitled"&&(l+=`<h1>${c.value}</h1>
207
+ `);const u=l+i.innerHTML,f=UD(i);try{const p=new ClipboardItem({"text/html":new Blob([u],{type:"text/html"}),"text/plain":new Blob([f],{type:"text/plain"})});await navigator.clipboard.write([p])}catch{try{await navigator.clipboard.writeText(f)}catch{const p=document.createElement("textarea");p.value=f,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.select(),document.execCommand("copy"),document.body.removeChild(p)}}e("copied"),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e("idle"),2e3)},[]),copyState:t}}function UD(t){var n;const e=[];for(const r of t.children){const s=(n=r.innerText)==null?void 0:n.trim();s&&e.push(s)}return e.join(`
208
+
209
+ `)}const Rh="ow-x-handle",O0="ow-x-name",HD=new Set(["Untitled","New Document","Article"]);function WD({src:t,coverImages:e}){const[n,r]=E.useState(t?"display":"empty"),[s,i]=E.useState(t||""),[l,c]=E.useState(e||(t?[t]:[])),[u,f]=E.useState(""),[p,m]=E.useState(""),y=E.useRef(null);E.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),E.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const b=s?l.indexOf(s):-1,v=l.length,w=v>1,k=E.useCallback(B=>{const W=l[B];W&&(i(W),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:W,coverImages:l}})}).catch(()=>{}))},[l]),N=E.useCallback(()=>{b>0&&k(b-1)},[b,k]),T=E.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),I=E.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const W=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(W.success&&W.src){const J=[...l,W.src];c(J),i(W.src),r("display"),f(""),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:W.src,coverImages:J}})}).catch(()=>{})}else m(W.error||"Generation failed"),r("prompt")}catch(B){m(B.message||"Network error"),r("prompt")}}},[u,l]),_=B=>{B.key==="Enter"&&I(),B.key==="Escape"&&(r("empty"),f(""),m(""))},M=()=>{r("prompt"),setTimeout(()=>{var B;return(B=y.current)==null?void 0:B.focus()},0)},O=()=>{const B=l.filter(W=>W!==s);if(c(B),B.length>0){const W=Math.min(b,B.length-1),J=B[W];i(J),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:J,coverImages:B}})}).catch(()=>{})}else i(""),r("empty"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({articleContext:{coverImage:null,coverImages:null}})}).catch(()=>{})},P=()=>{r("prompt"),setTimeout(()=>{var B;return(B=y.current)==null?void 0:B.focus()},0)},$=()=>{const B=document.createElement("a");B.href=s,B.download=`cover-${b+1}.png`,B.click()};return n==="display"&&s?d.jsxs("div",{className:"article-cover article-cover--display",children:[d.jsx("img",{className:"article-cover-img",src:s,alt:"Cover"}),d.jsxs("div",{className:"article-cover-overlay",children:[w&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--left",onClick:N,disabled:b<=0,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"15 18 9 12 15 6"})})}),d.jsxs("div",{className:"article-cover-overlay-center",children:[d.jsxs("button",{className:"article-cover-overlay-btn",onClick:P,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"23 4 23 10 17 10"}),d.jsx("polyline",{points:"1 20 1 14 7 14"}),d.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),d.jsxs("button",{className:"article-cover-overlay-btn",onClick:$,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),d.jsxs("button",{className:"article-cover-overlay-btn article-cover-overlay-btn--danger",onClick:O,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),w&&d.jsx("button",{className:"article-cover-arrow article-cover-arrow--right",onClick:T,disabled:b>=v-1,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})}),w&&d.jsxs("div",{className:"article-cover-counter",children:[b+1," / ",v]})]})]}):n==="loading"?d.jsxs("div",{className:"article-cover article-cover--loading",children:[d.jsx("div",{className:"article-cover-spinner"}),d.jsx("span",{className:"article-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?d.jsxs("div",{className:"article-cover article-cover--prompt",children:[d.jsxs("div",{className:"article-cover-prompt-row",children:[d.jsx("input",{ref:y,className:"article-cover-prompt-input",value:u,onChange:B=>f(B.target.value),onKeyDown:_,placeholder:"Describe your cover image...",spellCheck:!1}),d.jsx("button",{className:"article-cover-prompt-btn",onClick:I,disabled:!u.trim(),children:"Generate"}),d.jsx("button",{className:"article-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&d.jsx("div",{className:"article-cover-error",children:p})]}):d.jsxs("div",{className:"article-cover article-cover--empty",onClick:M,children:[d.jsxs("svg",{className:"article-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("polyline",{points:"21 15 16 10 5 21"})]}),d.jsx("span",{className:"article-cover-hint",children:"We recommend an image with a 5:2 aspect ratio for best results."})]})}function VD(){const[t,e]=E.useState(()=>localStorage.getItem(Rh)||""),[n,r]=E.useState(()=>localStorage.getItem(O0)||""),[s,i]=E.useState(!1),[l,c]=E.useState(""),u=E.useRef(null),f=E.useRef(null),p=()=>{const v=l.replace(/^@/,"").trim();v&&(localStorage.setItem(Rh,v),e(v)),i(!1)},m=()=>{c(t),i(!0),setTimeout(()=>{var v;return(v=u.current)==null?void 0:v.focus()},0)};E.useEffect(()=>{if(!s)return;const v=w=>{f.current&&!f.current.contains(w.target)&&p()};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s,l]),E.useEffect(()=>{const v=()=>{e(localStorage.getItem(Rh)||""),r(localStorage.getItem(O0)||"")};return window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[]);const y=t?`https://unavatar.io/twitter/${t}`:"",b=n||t||"Set your @handle";return d.jsxs("div",{className:"article-byline",ref:f,children:[d.jsxs("div",{className:"article-byline-row",onClick:m,title:t?`@${t} — click to change`:"Set your @handle",children:[t?d.jsx("img",{className:"article-byline-avatar",src:y,alt:`@${t}`}):d.jsx("div",{className:"article-byline-avatar article-byline-avatar--empty"}),d.jsx("span",{className:"article-byline-name",children:b}),t&&d.jsxs("span",{className:"article-byline-handle",children:["@",t]})]}),s&&d.jsx("div",{className:"article-byline-popover",children:d.jsx("input",{ref:u,className:"article-byline-input",value:l,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&p(),v.key==="Escape"&&i(!1)},placeholder:"your_handle",spellCheck:!1})})]})}function KD({children:t,title:e,onTitleChange:n,coverImage:r,coverImages:s}){const{copyAsHtml:i,copyState:l}=FD();return d.jsxs("div",{className:"article-compose-wrapper",children:[d.jsx(WD,{src:r,coverImages:s}),d.jsxs("div",{className:"article-compose-content",children:[d.jsx("input",{className:"article-title-input",type:"text",value:HD.has(e||"")?"":e||"",onChange:c=>n==null?void 0:n(c.target.value||"Untitled"),placeholder:"Add a title",spellCheck:!1}),d.jsx(VD,{}),d.jsx("div",{className:"article-compose-body",children:t})]}),d.jsx("div",{className:"article-compose-footer",children:d.jsx("button",{className:`article-copy-btn${l==="copied"?" article-copy-btn--copied":""}`,onClick:i,children:l==="copied"?d.jsxs(d.Fragment,{children:[d.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Copied!"]}):d.jsxs(d.Fragment,{children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),d.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),"Copy as HTML"]})})})]})}function GD({connectionId:t,repoName:e,title:n,slug:r,onClose:s}){const[i,l]=E.useState("confirm"),[c,u]=E.useState(null),[f,p]=E.useState(null),m=E.useRef(null),y=()=>i==="published"?{publishedAt:new Date().toISOString(),url:f||void 0,repo:e}:void 0;E.useEffect(()=>{const v=w=>{i!=="publishing"&&m.current&&!m.current.contains(w.target)&&s(y())};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[s,i,f]),E.useEffect(()=>{const v=w=>{w.key==="Escape"&&i!=="publishing"&&s(y())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[s,i,f]);async function b(){l("publishing"),u(null);try{const v=await fetch("/api/blog/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({connectionId:t})}),w=await v.json();if(!v.ok||w.error){u(w.error||`Publish failed (${v.status})`),l("error");return}w.url&&p(w.url),l("published"),fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:{lastPublish:{publishedAt:new Date().toISOString(),url:w.url||void 0,repo:e}}})}).catch(()=>{})}catch(v){u(v.message),l("error")}}return d.jsx("div",{className:"blog-publish-overlay",children:d.jsxs("div",{className:"blog-publish-modal",ref:m,children:[d.jsxs("div",{className:"blog-publish__header",children:[d.jsx("h3",{children:"Publish to GitHub"}),d.jsx("button",{className:"blog-publish__close",onClick:()=>s(y()),children:"×"})]}),d.jsxs("div",{className:"blog-publish__body",children:[i==="confirm"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"blog-publish__summary",children:[d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Repository"}),d.jsx("span",{className:"blog-publish__value",children:e})]}),d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Title"}),d.jsx("span",{className:"blog-publish__value",children:n})]}),r&&d.jsxs("div",{className:"blog-publish__row",children:[d.jsx("span",{className:"blog-publish__label",children:"Slug"}),d.jsx("span",{className:"blog-publish__value blog-publish__value--mono",children:r})]})]}),d.jsxs("div",{className:"blog-publish__actions",children:[d.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:b,children:"Publish"})]})]}),i==="publishing"&&d.jsxs("div",{className:"blog-publish__status",children:[d.jsx("div",{className:"blog-publish__spinner"}),d.jsxs("span",{children:["Publishing to ",e,"..."]})]}),i==="published"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"blog-publish__status blog-publish__status--success",children:["Published to ",e,"!"]}),f&&d.jsx("a",{className:"blog-publish__link",href:f,target:"_blank",rel:"noopener noreferrer",children:"View on GitHub"}),d.jsx("div",{className:"blog-publish__actions",children:d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:()=>s({publishedAt:new Date().toISOString(),url:f||void 0,repo:e}),children:"Done"})})]}),i==="error"&&d.jsxs(d.Fragment,{children:[d.jsx("div",{className:"blog-publish__error",children:c}),d.jsxs("div",{className:"blog-publish__actions",children:[d.jsx("button",{className:"blog-publish__btn",onClick:()=>s(),children:"Cancel"}),d.jsx("button",{className:"blog-publish__btn blog-publish__btn--primary",onClick:b,children:"Retry"})]})]})]})]})})}const R0={font:"sans",width:"standard",spacing:"comfortable"},I0=new Set(["Untitled","New Document","Blog"]);function qD(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function j0(){return new Date().toISOString().split("T")[0]}function as(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({blogContext:t})}).catch(()=>{})}function JD({src:t,coverImages:e}){const[n,r]=E.useState(t?"display":"empty"),[s,i]=E.useState(t||""),[l,c]=E.useState(e||(t?[t]:[])),[u,f]=E.useState(""),[p,m]=E.useState(""),y=E.useRef(null);E.useEffect(()=>{t?(i(t),r("display")):(i(""),r("empty"),f(""),m(""))},[t]),E.useEffect(()=>{e&&e.length>0?c(e):c(t?[t]:[])},[e]);const b=s?l.indexOf(s):-1,v=l.length,w=v>1,k=E.useCallback(B=>{const W=l[B];W&&(i(W),as({coverImage:W,coverImages:l}))},[l]),N=E.useCallback(()=>{b>0&&k(b-1)},[b,k]),T=E.useCallback(()=>{b<v-1&&k(b+1)},[b,v,k]),I=E.useCallback(async()=>{if(u.trim()){r("loading"),m("");try{const W=await(await fetch("/api/image-gen/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:u.trim()})})).json();if(W.success&&W.src){const J=[...l,W.src];c(J),i(W.src),r("display"),f(""),as({coverImage:W.src,coverImages:J})}else m(W.error||"Generation failed"),r("prompt")}catch(B){m(B.message||"Network error"),r("prompt")}}},[u,l]),_=B=>{B.key==="Enter"&&I(),B.key==="Escape"&&(r("empty"),f(""),m(""))},M=()=>{r("prompt"),setTimeout(()=>{var B;return(B=y.current)==null?void 0:B.focus()},0)},O=()=>{const B=l.filter(W=>W!==s);if(c(B),B.length>0){const W=Math.min(b,B.length-1),J=B[W];i(J),as({coverImage:J,coverImages:B})}else i(""),r("empty"),as({coverImage:void 0,coverImages:void 0})},P=()=>{r("prompt"),setTimeout(()=>{var B;return(B=y.current)==null?void 0:B.focus()},0)},$=()=>{const B=document.createElement("a");B.href=s,B.download=`cover-${b+1}.png`,B.click()};return n==="display"&&s?d.jsxs("div",{className:"blog-cover blog-cover--display",children:[d.jsx("img",{className:"blog-cover-img",src:s,alt:"Cover"}),d.jsxs("div",{className:"blog-cover-overlay",children:[w&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--left",onClick:N,disabled:b<=0,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"15 18 9 12 15 6"})})}),d.jsxs("div",{className:"blog-cover-overlay-center",children:[d.jsxs("button",{className:"blog-cover-btn",onClick:P,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("polyline",{points:"23 4 23 10 17 10"}),d.jsx("polyline",{points:"1 20 1 14 7 14"}),d.jsx("path",{d:"M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15"})]}),"Regenerate"]}),d.jsxs("button",{className:"blog-cover-btn",onClick:$,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),d.jsx("polyline",{points:"7 10 12 15 17 10"}),d.jsx("line",{x1:"12",y1:"15",x2:"12",y2:"3"})]}),"Save"]}),d.jsxs("button",{className:"blog-cover-btn blog-cover-btn--danger",onClick:O,children:[d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}),"Remove"]})]}),w&&d.jsx("button",{className:"blog-cover-arrow blog-cover-arrow--right",onClick:T,disabled:b>=v-1,children:d.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})})}),w&&d.jsxs("div",{className:"blog-cover-counter",children:[b+1," / ",v]})]})]}):n==="loading"?d.jsxs("div",{className:"blog-cover blog-cover--loading",children:[d.jsx("div",{className:"blog-cover-spinner"}),d.jsx("span",{className:"blog-cover-loading-text",children:"Generating cover image..."})]}):n==="prompt"?d.jsxs("div",{className:"blog-cover blog-cover--prompt",children:[d.jsxs("div",{className:"blog-cover-prompt-row",children:[d.jsx("input",{ref:y,className:"blog-cover-prompt-input",value:u,onChange:B=>f(B.target.value),onKeyDown:_,placeholder:"Describe your cover image...",spellCheck:!1}),d.jsx("button",{className:"blog-cover-prompt-btn",onClick:I,disabled:!u.trim(),children:"Generate"}),d.jsx("button",{className:"blog-cover-prompt-cancel",onClick:()=>{r(s?"display":"empty"),f(""),m("")},children:d.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),p&&d.jsx("div",{className:"blog-cover-error",children:p})]}):d.jsxs("div",{className:"blog-cover blog-cover--empty",onClick:M,children:[d.jsxs("svg",{className:"blog-cover-icon",width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),d.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),d.jsx("polyline",{points:"21 15 16 10 5 21"})]}),d.jsx("span",{className:"blog-cover-hint",children:"Add a featured image"})]})}function YD({tags:t,onChange:e}){const[n,r]=E.useState(""),s=E.useRef(null),i=u=>{const f=u.trim().toLowerCase();f&&!t.includes(f)&&e([...t,f]),r("")},l=u=>e(t.filter(f=>f!==u)),c=u=>{(u.key==="Enter"||u.key===",")&&(u.preventDefault(),i(n)),u.key==="Backspace"&&!n&&t.length>0&&l(t[t.length-1])};return d.jsxs("div",{className:"blog-tags",onClick:()=>{var u;return(u=s.current)==null?void 0:u.focus()},children:[t.map(u=>d.jsxs("span",{className:"blog-tag",children:[u,d.jsx("button",{className:"blog-tag-remove",onClick:f=>{f.stopPropagation(),l(u)},children:d.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[d.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),d.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},u)),d.jsx("input",{ref:s,className:"blog-tag-input",value:n,onChange:u=>r(u.target.value),onKeyDown:c,onBlur:()=>{n.trim()&&i(n)},placeholder:t.length===0?"Add tags...":"",spellCheck:!1})]})}function QD({style:t,onChange:e}){const n=r=>`blog-style-btn${r?" active":""}`;return d.jsxs("div",{className:"blog-style-controls",children:[d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Font"}),d.jsx("button",{className:n(t.font==="sans"),onClick:()=>e({...t,font:"sans"}),title:"Sans-serif",children:"Aa"}),d.jsx("button",{className:`${n(t.font==="serif")} serif-btn`,onClick:()=>e({...t,font:"serif"}),title:"Serif",children:"Aa"}),d.jsx("button",{className:`${n(t.font==="mono")} mono-btn`,onClick:()=>e({...t,font:"mono"}),title:"Monospace",children:"Aa"})]}),d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Width"}),d.jsx("button",{className:n(t.width==="narrow"),onClick:()=>e({...t,width:"narrow"}),title:"Narrow (600px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"4",y:"1",width:"8",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),d.jsx("button",{className:n(t.width==="standard"),onClick:()=>e({...t,width:"standard"}),title:"Standard (720px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"2",y:"1",width:"12",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})}),d.jsx("button",{className:n(t.width==="wide"),onClick:()=>e({...t,width:"wide"}),title:"Wide (900px)",children:d.jsx("svg",{width:"16",height:"14",viewBox:"0 0 16 14",children:d.jsx("rect",{x:"0.5",y:"1",width:"15",height:"12",rx:"1",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})})]}),d.jsxs("div",{className:"blog-style-group",children:[d.jsx("span",{className:"blog-style-label",children:"Spacing"}),d.jsx("button",{className:n(t.spacing==="compact"),onClick:()=>e({...t,spacing:"compact"}),title:"Compact",children:d.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("line",{x1:"1",y1:"3",x2:"15",y2:"3"}),d.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),d.jsx("line",{x1:"1",y1:"11",x2:"15",y2:"11"})]})}),d.jsx("button",{className:n(t.spacing==="comfortable"),onClick:()=>e({...t,spacing:"comfortable"}),title:"Comfortable",children:d.jsxs("svg",{width:"16",height:"14",viewBox:"0 0 16 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[d.jsx("line",{x1:"1",y1:"2",x2:"15",y2:"2"}),d.jsx("line",{x1:"1",y1:"7",x2:"15",y2:"7"}),d.jsx("line",{x1:"1",y1:"12",x2:"15",y2:"12"})]})})]})]})}function XD({children:t,title:e,onTitleChange:n,blogContext:r,filename:s}){var X;const i=r||{},[l,c]=E.useState(i.description||""),[u,f]=E.useState(!1),[p,m]=E.useState(i.date||j0()),[y,b]=E.useState(i.tags||[]),[v,w]=E.useState(i.author||""),[k,N]=E.useState(i.slug||""),[T,I]=E.useState(i.draft??!1),[_,M]=E.useState({...R0,...i.style}),[O,P]=E.useState(!1),[$,B]=E.useState(!!i.slug),[W,J]=E.useState(null),[F,re]=E.useState(!1);E.useEffect(()=>{fetch("/api/blog/connection").then(K=>K.json()).then(K=>{K.connection&&J(K.connection)}).catch(()=>{})},[]),E.useEffect(()=>{!$&&e&&!I0.has(e)&&N(qD(e))},[e,$]),E.useEffect(()=>{c(i.description||""),m(i.date||j0()),b(i.tags||[]),w(i.author||""),N(i.slug||""),I(i.draft??!1),M({...R0,...i.style}),B(!!i.slug)},[r]);const G=!!(r!=null&&r.active),te=E.useCallback(()=>{G&&as({description:l,date:p,tags:y,author:v,slug:k,draft:T,style:_})},[G,l,p,y,v,k,T,_]);E.useEffect(()=>{G&&as({tags:y})},[G,y]),E.useEffect(()=>{G&&as({style:_})},[G,_]),E.useEffect(()=>{G&&as({draft:T})},[G,T]);const U=l.length,ne=U>160,H=["blog-compose-wrapper",`blog--font-${_.font}`,`blog--width-${_.width}`,`blog--spacing-${_.spacing}`].join(" ");return d.jsxs("div",{className:H,children:[d.jsx(JD,{src:i.coverImage,coverImages:i.coverImages}),d.jsxs("div",{className:"blog-compose-content",children:[((X=i.lastPublish)==null?void 0:X.publishedAt)&&d.jsxs("a",{className:"blog-published-status",href:i.lastPublish.url,target:"_blank",rel:"noopener noreferrer",title:i.lastPublish.url||`Published to ${i.lastPublish.repo||"GitHub"}`,children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Published ",new Date(i.lastPublish.publishedAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}),i.lastPublish.repo?` to ${i.lastPublish.repo.split("/").pop()}`:""]}),d.jsx("input",{className:"blog-title-input",type:"text",value:I0.has(e||"")?"":e||"",onChange:K=>n==null?void 0:n(K.target.value||"Untitled"),placeholder:"Post title",spellCheck:!1}),d.jsxs("div",{className:"blog-description-wrap",children:[d.jsx("textarea",{className:`blog-description-input${ne?" over-limit":""}`,value:l,onChange:K=>c(K.target.value),onBlur:te,placeholder:"Write a short description for SEO and social previews...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`blog-description-count${ne?" over-limit":""}`,children:[U,"/160"]})]}),d.jsxs("div",{className:"blog-meta-toggle",onClick:()=>P(K=>!K),children:[d.jsx("svg",{className:`blog-meta-chevron${O?" open":""}`,width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"9 18 15 12 9 6"})}),d.jsx("span",{children:"Metadata"}),T&&d.jsx("span",{className:"blog-draft-badge",children:"Draft"})]}),O&&d.jsxs("div",{className:"blog-meta-fields",children:[d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Date"}),d.jsx("input",{type:"date",className:"blog-meta-input",value:p,onChange:K=>m(K.target.value),onBlur:te})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Author"}),d.jsx("input",{type:"text",className:"blog-meta-input",value:v,onChange:K=>w(K.target.value),onBlur:te,placeholder:"Author name",spellCheck:!1})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Slug"}),d.jsx("input",{type:"text",className:"blog-meta-input",value:k,onChange:K=>{B(!0),N(K.target.value)},onBlur:te,placeholder:"auto-generated-from-title",spellCheck:!1})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Tags"}),d.jsx(YD,{tags:y,onChange:b})]}),d.jsxs("div",{className:"blog-meta-row",children:[d.jsx("label",{className:"blog-meta-label",children:"Draft"}),d.jsx("button",{className:`blog-draft-toggle${T?" active":""}`,onClick:()=>I(K=>!K),children:d.jsx("div",{className:"blog-draft-toggle-knob"})})]})]}),d.jsx("div",{className:"blog-compose-body",children:t})]}),d.jsxs("div",{className:"blog-compose-footer",children:[d.jsx(QD,{style:_,onChange:M}),s&&d.jsxs("div",{className:"blog-footer-actions",children:[W&&d.jsxs("button",{className:"blog-footer-btn blog-footer-btn--primary",onClick:()=>re(!0),children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("path",{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"})}),"Publish"]}),d.jsxs("button",{className:"blog-footer-btn",onClick:()=>f(!0),children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]})]}),u&&s&&d.jsx(rd,{filename:s,title:e||"Untitled",onClose:()=>f(!1)}),F&&W&&d.jsx(GD,{connectionId:W.id,repoName:W.display_name,title:e||"Untitled",slug:k,onClose:K=>{re(!1),K&&as({lastPublish:K})}})]})}function L0(t){fetch("/api/metadata",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({newsletterContext:t})}).catch(()=>{})}function ZD({children:t,newsletterContext:e,filename:n,title:r,onBeforeSend:s}){var $;const i=e||{},[l,c]=E.useState(i.subject||""),[u,f]=E.useState(i.previewText||""),[p,m]=E.useState([]),[y,b]=E.useState(null),[v,w]=E.useState(!1),[k,N]=E.useState(($=i.lastSend)!=null&&$.sentAt?{sentCount:i.lastSend.sentCount,issueId:i.lastSend.issueId||null,sentAt:i.lastSend.sentAt}:null);E.useEffect(()=>{var B;c(i.subject||""),f(i.previewText||""),(B=i.lastSend)!=null&&B.sentAt&&N({sentCount:i.lastSend.sentCount,issueId:i.lastSend.issueId||null,sentAt:i.lastSend.sentAt})},[e]),E.useEffect(()=>{fetch("/api/connections").then(B=>B.json()).then(B=>{const W=(B.connections||[]).filter(J=>J.provider==="newsletter"&&J.status==="active");m(W)}).catch(()=>{})},[]);const T=!!(e!=null&&e.active),I=E.useCallback(()=>{T&&L0({subject:l,previewText:u})},[T,l,u]),_=u.length,M=_>=90,O=_>150,P=()=>{p.length===1&&b(p[0].id),p.length>1&&b(p[0].id)};return d.jsxs("div",{className:"nl-compose-wrapper",children:[k&&d.jsxs("div",{className:"nl-sent-status",children:[d.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:d.jsx("polyline",{points:"20 6 9 17 4 12"})}),"Sent ",new Date(k.sentAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})," to ",k.sentCount," subscriber",k.sentCount!==1?"s":""]}),d.jsxs("div",{className:"nl-compose-content",children:[d.jsx("input",{className:"nl-subject-input",type:"text",value:l,onChange:B=>c(B.target.value),onBlur:I,placeholder:"Subject line (defaults to title if empty)",autoComplete:"off","data-lpignore":"true","data-1p-ignore":!0,spellCheck:!1}),d.jsxs("div",{className:"nl-preview-wrap",children:[d.jsx("textarea",{className:`nl-preview-input${O?" over-limit":""}`,value:u,onChange:B=>f(B.target.value),onBlur:I,placeholder:"Preview text shown in inbox before opening...",rows:2,spellCheck:!1}),d.jsxs("span",{className:`nl-preview-count${O?" over-limit":M?" full":""}`,children:[_,"/90"]})]}),d.jsx("div",{className:"nl-compose-body",children:t})]}),n&&d.jsxs("div",{className:"nl-compose-footer",children:[p.length>0&&d.jsxs("button",{className:"nl-footer-btn nl-footer-btn--primary",onClick:P,children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),d.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),"Send"]}),d.jsxs("button",{className:"nl-footer-btn",onClick:()=>w(!0),children:[d.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[d.jsx("circle",{cx:"12",cy:"12",r:"10"}),d.jsx("polyline",{points:"12 6 12 12 16 14"})]}),"Schedule"]})]}),y&&n&&d.jsx(I1,{connectionId:y,subject:l||r||"Untitled",filename:n,onBeforeSend:s,onClose:B=>{b(null),B&&(N(B),L0({lastSend:{sentCount:B.sentCount,sentAt:B.sentAt,issueId:B.issueId||void 0}}))}}),v&&n&&d.jsx(rd,{filename:n,title:r||"Untitled",onClose:()=>w(!1)})]})}function eP(t){const e=t==null?void 0:t.articleContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function tP(t){const e=t==null?void 0:t.blogContext;return e!=null&&typeof e=="object"&&Object.keys(e).length>0}function nP(t){const e=t==null?void 0:t.newsletterContext;return e!=null&&typeof e=="object"&&(e.active===!0||Object.keys(e).length>0)}function rP(){var Wn,un;const t=E.useRef(null),e=E.useRef([]),[n,r]=E.useState(null),[s,i]=E.useState([]),[l,c]=E.useState("Untitled"),[u,f]=E.useState(void 0),[p,m]=E.useState(0),[y,b]=E.useState(!0),[v,w]=E.useState(0),[k,N]=E.useState(0),[T,I]=E.useState({filenames:[],counts:{}}),[_,M]=E.useState({state:"unconfigured"}),[O,P]=E.useState(!1),[$,B]=E.useState({}),[W,J]=E.useState(()=>localStorage.getItem("ow-toolbar")!=="hidden"),[F,re]=E.useState(null),[G,te]=E.useState(null),U=E.useRef(0),ne=E.useRef(null),H=1500,X=E.useCallback((le,be)=>{ne.current&&(clearTimeout(ne.current),ne.current=null),U.current=Date.now(),re(le),te(be)},[]),K=E.useCallback(()=>{if(ne.current)return;const le=Date.now()-U.current,be=H-le;be<=0?(re(null),te(null)):ne.current=setTimeout(()=>{ne.current=null,re(null),te(null)},be)},[]),[,A]=E.useState(0),R=E.useRef(null),Y=E.useRef(null),se=E.useRef([]),fe=E.useRef(-1),Z=E.useRef(!1),me=E.useRef(""),[Le,Ze]=E.useState(""),[ce,ve]=E.useState(!1),[ie,Be]=E.useState(!1),Te=eP($),Ue=tP($),Ee=nP($);E.useEffect(()=>(Te?document.documentElement.setAttribute("data-view","article"):Ue?document.documentElement.setAttribute("data-view","blog"):Ee?document.documentElement.setAttribute("data-view","newsletter"):$!=null&&$.tweetContext?document.documentElement.setAttribute("data-view","tweet"):document.documentElement.removeAttribute("data-view"),()=>document.documentElement.removeAttribute("data-view")),[$==null?void 0:$.tweetContext,Te,Ue,Ee]),E.useEffect(()=>{const le=()=>A(be=>be+1);return window.addEventListener("ow-sidebar-mode-change",le),()=>window.removeEventListener("ow-sidebar-mode-change",le)},[]),E.useEffect(()=>{fetch("/api/document").then(le=>le.json()).then(le=>{le.document&&(f(le.document),Y.current=le.document),le.title&&c(le.title),le.metadata&&B(le.metadata)}).catch(()=>{f(void 0)}),fetch("/api/pending-docs").then(le=>le.json()).then(le=>I(le)).catch(()=>{}),fetch("/api/sync/status").then(le=>le.json()).then(le=>M(le)).catch(()=>{})},[]);const Qe=E.useCallback(le=>{t.current=le,r(le),e.current=[le],i([le])},[]),tt=E.useCallback(le=>{e.current=le,i(le)},[]),vt=E.useCallback(le=>{R.current&&(clearTimeout(R.current),R.current=null);const be=me.current==="",$e=le.filename===me.current;if(me.current=le.filename,Y.current=le.document,Ze(le.filename),f(le.document),c(le.title),B(le.metadata||{}),!$e&&!be&&m(Tt=>Tt+1),w(Tt=>Tt+1),Z.current){const Tt=se.current[fe.current];Tt&&setTimeout(()=>{const Kt=document.querySelector(".editor-container");Kt&&(Kt.scrollTop=Tt.scrollTop)},50),Z.current=!1}ve(fe.current>0),Be(fe.current<se.current.length-1)},[]),Ce=E.useCallback(()=>{w(le=>le+1)},[]),ke=E.useCallback(()=>{N(le=>le+1)},[]),at=E.useCallback(le=>{I(le)},[]),{connected:ft,sendMessage:st}=ED({onNodeChanges:le=>{const be=e.current;if(be.length<=1){const $e=t.current;if(!$e)return;c0($e,le)}else for(const $e of be)c0($e,le)},onDocumentSwitched:vt,onDocumentsChanged:Ce,onWorkspacesChanged:ke,onPendingDocsChanged:at,onMetadataChanged:le=>B(le),onWritingStarted:(le,be)=>X(le,be),onWritingFinished:()=>K(),onSyncStatus:le=>M(le),onTitleChanged:le=>c(le),getEditorState:()=>{var be;const le=Y.current||((be=t.current)==null?void 0:be.getJSON());return le?{document:le}:null}}),ht=E.useCallback(()=>{var be;R.current&&(clearTimeout(R.current),R.current=null);const le=Y.current||((be=t.current)==null?void 0:be.getJSON());le&&st({type:"doc-update",document:le,filename:me.current})},[st]),zt=E.useCallback(async()=>{var be;const le=Y.current||((be=t.current)==null?void 0:be.getJSON());le&&await fetch("/api/documents/sync-content",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({document:le,filename:me.current})})},[]);E.useEffect(()=>{const le=()=>{var Kt;R.current&&(clearTimeout(R.current),R.current=null);const $e=Y.current||((Kt=t.current)==null?void 0:Kt.getJSON());if(!$e)return;const Tt=JSON.stringify({type:"flush",document:$e});navigator.sendBeacon("/api/flush",new Blob([Tt],{type:"application/json"}))},be=()=>{document.visibilityState==="hidden"&&le()};return window.addEventListener("beforeunload",le),document.addEventListener("visibilitychange",be),()=>{window.removeEventListener("beforeunload",le),document.removeEventListener("visibilitychange",be)}},[]);const Ct=E.useCallback(()=>{ht(),st({type:"create-document"})},[ht,st]),Vt=E.useCallback(le=>{const be=document.querySelector(".editor-container"),$e=(be==null?void 0:be.scrollTop)||0;!Z.current&&me.current&&(se.current=se.current.slice(0,fe.current+1),se.current.push({filename:me.current,scrollTop:$e}),fe.current=se.current.length-1),ht(),st({type:"switch-document",filename:le})},[ht,st]),xn=E.useCallback(()=>{if(fe.current<=0)return;const le=document.querySelector(".editor-container"),be=(le==null?void 0:le.scrollTop)||0;fe.current===se.current.length-1&&me.current?(se.current=se.current.slice(0,fe.current+1),se.current.push({filename:me.current,scrollTop:be})):me.current&&(se.current[fe.current+1]={filename:me.current,scrollTop:be});const $e=se.current[fe.current];fe.current--,Z.current=!0,ve(fe.current>0),Be(!0),ht(),st({type:"switch-document",filename:$e.filename})},[ht,st]),ee=E.useCallback(()=>{if(fe.current>=se.current.length-2)return;const le=document.querySelector(".editor-container"),be=(le==null?void 0:le.scrollTop)||0;me.current&&(se.current[fe.current+1]={filename:me.current,scrollTop:be}),fe.current++;const $e=se.current[fe.current+1];Z.current=!0,ve(!0),Be(fe.current<se.current.length-2),ht(),st({type:"switch-document",filename:$e.filename})},[ht,st]),He=E.useCallback(()=>{const le=me.current,be=t.current;!le||!be||fetch(`/api/marks/${encodeURIComponent(le)}`).then($e=>$e.json()).then($e=>{r0($e.marks||[]),l0(be.view)}).catch(()=>{r0([]),be!=null&&be.view&&l0(be.view)})},[]);E.useEffect(()=>{He()},[Le,He]),E.useEffect(()=>{const le=be=>{const $e=be.detail;($e==null?void 0:$e.filename)===me.current&&He()};return window.addEventListener("ow-marks-changed",le),()=>window.removeEventListener("ow-marks-changed",le)},[He]),E.useEffect(()=>{const le=be=>{be.altKey&&be.key==="ArrowLeft"&&(be.preventDefault(),xn()),be.altKey&&be.key==="ArrowRight"&&(be.preventDefault(),ee())};return window.addEventListener("keydown",le),()=>window.removeEventListener("keydown",le)},[xn,ee]);const We=E.useCallback(le=>{Y.current=le,R.current&&clearTimeout(R.current),R.current=setTimeout(()=>{st({type:"doc-update",document:le,filename:me.current})},1e3)},[st]),_t=E.useCallback(le=>{c(le),st({type:"title-update",title:le})},[st]),nt=E.useCallback(()=>{J(le=>(localStorage.setItem("ow-toolbar",le?"hidden":"visible"),!le))},[]),it=E.useCallback(()=>{if(_.state==="unconfigured"){P(!0);return}ht(),st({type:"save"}),fetch("/api/sync/push",{method:"POST"}).catch(()=>{})},[_.state,ht,st]),qe=zu()==="board";return d.jsxs("div",{className:"app",children:[!qe&&d.jsx(S0,{open:y,onSwitchDocument:Vt,onCreateDocument:Ct,refreshKey:v,workspacesRefreshKey:k,pendingDocs:T,writingTitle:F,writingTarget:G,onClose:()=>b(!1)}),d.jsxs("div",{className:"app-main",children:[d.jsx(TL,{title:l,onTitleChange:_t,syncStatus:_,onSync:it,onToggleSidebar:!qe&&!y?()=>b(!0):void 0,canGoBack:ce,canGoForward:ie,onGoBack:xn,onGoForward:ee,editor:n,onToggleToolbar:nt,toolbarOpen:W}),W&&n&&d.jsx(cL,{editor:n}),qe&&d.jsx(S0,{open:!0,onSwitchDocument:Vt,onCreateDocument:Ct,refreshKey:v,workspacesRefreshKey:k,pendingDocs:T,writingTitle:F,writingTarget:G}),!ft&&d.jsxs("div",{className:"connection-banner",children:[d.jsx("div",{className:"connection-banner-spinner"}),d.jsx("span",{children:"Reconnecting to server..."})]}),d.jsx("div",{className:"editor-container",children:Te?d.jsx(KD,{title:l,onTitleChange:_t,coverImage:(Wn=$==null?void 0:$.articleContext)==null?void 0:Wn.coverImage,coverImages:(un=$==null?void 0:$.articleContext)==null?void 0:un.coverImages,children:d.jsx(Mc,{initialContent:u,extensions:eL,onUpdate:We,onReady:Qe,onLinkClick:Vt},p)}):Ue?d.jsx(XD,{title:l,onTitleChange:_t,blogContext:$==null?void 0:$.blogContext,filename:Le,children:d.jsx(Mc,{initialContent:u,onUpdate:We,onReady:Qe,onLinkClick:Vt},p)}):Ee?d.jsx(ZD,{newsletterContext:$==null?void 0:$.newsletterContext,filename:Le,title:l,onBeforeSend:zt,children:d.jsx(Mc,{initialContent:u,onUpdate:We,onReady:Qe,onLinkClick:Vt},p)}):$!=null&&$.tweetContext?d.jsx($D,{tweetContext:$.tweetContext,initialContent:u,onUpdate:We,onEditorReady:Qe,onEditorsChange:tt,filename:Le,title:l},p):d.jsx(Mc,{initialContent:u,onUpdate:We,onReady:Qe,onLinkClick:Vt},p)}),d.jsx(XL,{editors:s,pendingDocs:T,currentFilename:Le,onSwitchDocument:Vt,sendMessage:st,getDocument:()=>Y.current})]}),d.jsx(DL,{editorRef:t,allEditors:s,documentId:Le}),O&&d.jsx(SD,{onClose:()=>P(!1),onSetupComplete:()=>{fetch("/api/sync/status").then(le=>le.json()).then(M).catch(()=>{})}})]})}_E();kE.createRoot(document.getElementById("root")).render(d.jsx(qs.StrictMode,{children:d.jsx(rP,{})}));