@vertebr/admin 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/database/connector.d.ts.map +1 -1
- package/dist/database/connector.js +1 -0
- package/dist/database/connector.js.map +1 -1
- package/dist/database/types.d.ts +3 -1
- package/dist/database/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/runtime/api/catalog.d.ts +10 -0
- package/dist/runtime/api/catalog.d.ts.map +1 -1
- package/dist/runtime/api/catalog.js +14 -0
- package/dist/runtime/api/catalog.js.map +1 -1
- package/dist/runtime/api/configs.d.ts +2 -0
- package/dist/runtime/api/configs.d.ts.map +1 -1
- package/dist/runtime/api/configs.js +5 -1
- package/dist/runtime/api/configs.js.map +1 -1
- package/dist/runtime/api/fonts.d.ts +42 -0
- package/dist/runtime/api/fonts.d.ts.map +1 -0
- package/dist/runtime/api/fonts.js +152 -0
- package/dist/runtime/api/fonts.js.map +1 -0
- package/dist/runtime/api/resources.d.ts +1 -0
- package/dist/runtime/api/resources.d.ts.map +1 -1
- package/dist/runtime/api/resources.js +5 -1
- package/dist/runtime/api/resources.js.map +1 -1
- package/dist/runtime/api/routes.d.ts.map +1 -1
- package/dist/runtime/api/routes.js +31 -0
- package/dist/runtime/api/routes.js.map +1 -1
- package/dist/runtime/constants.d.ts +2 -0
- package/dist/runtime/constants.d.ts.map +1 -1
- package/dist/runtime/constants.js +13 -1
- package/dist/runtime/constants.js.map +1 -1
- package/dist/runtime/createAdmin.d.ts.map +1 -1
- package/dist/runtime/createAdmin.js +7 -0
- package/dist/runtime/createAdmin.js.map +1 -1
- package/dist/runtime/services/state.d.ts +2 -1
- package/dist/runtime/services/state.d.ts.map +1 -1
- package/dist/runtime/types/actions.d.ts +2 -0
- package/dist/runtime/types/actions.d.ts.map +1 -1
- package/dist/runtime/types/admin.d.ts +6 -1
- package/dist/runtime/types/admin.d.ts.map +1 -1
- package/dist/runtime/types/config.d.ts +10 -0
- package/dist/runtime/types/config.d.ts.map +1 -1
- package/dist/runtime/types/layout.d.ts +5 -0
- package/dist/runtime/types/layout.d.ts.map +1 -1
- package/dist/runtime/utils/http.d.ts.map +1 -1
- package/dist/runtime/utils/http.js +6 -0
- package/dist/runtime/utils/http.js.map +1 -1
- package/dist/schema.d.ts +55 -1
- package/dist/schema.d.ts.map +1 -1
- package/package.json +1 -1
- package/static/assets/index-CQszzssl.js +337 -0
- package/static/assets/index-Gk0ADe4H.css +1 -0
- package/static/index.html +6 -3
- package/static/assets/index-DKyVvFeT.js +0 -332
- package/static/assets/index-DUwFg1bw.css +0 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
var eT=t=>{throw TypeError(t)};var tT=(t,e,n)=>e.has(t)||eT("Cannot "+n);var Vn=(t,e,n)=>(tT(t,e,"read from private field"),n?n.call(t):e.get(t)),nT=(t,e,n)=>e.has(t)?eT("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,n),Kb=(t,e,n,r)=>(tT(t,e,"write to private field"),r?r.call(t,n):e.set(t,n),n);function Mz(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function TM(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Zb={exports:{}},Ru={};var rT;function Nz(){if(rT)return Ru;rT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,i,s){var o=null;if(s!==void 0&&(o=""+s),i.key!==void 0&&(o=""+i.key),"key"in i){s={};for(var l in i)l!=="key"&&(s[l]=i[l])}else s=i;return i=s.ref,{$$typeof:t,type:r,key:o,ref:i!==void 0?i:null,props:s}}return Ru.Fragment=e,Ru.jsx=n,Ru.jsxs=n,Ru}var iT;function Oz(){return iT||(iT=1,Zb.exports=Nz()),Zb.exports}var y=Oz(),Yb={exports:{}},Je={};var sT;function Dz(){if(sT)return Je;sT=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),o=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function b(H){return H===null||typeof H!="object"?null:(H=g&&H[g]||H["@@iterator"],typeof H=="function"?H:null)}var x={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,k={};function C(H,Z,pe){this.props=H,this.context=Z,this.refs=k,this.updater=pe||x}C.prototype.isReactComponent={},C.prototype.setState=function(H,Z){if(typeof H!="object"&&typeof H!="function"&&H!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,H,Z,"setState")},C.prototype.forceUpdate=function(H){this.updater.enqueueForceUpdate(this,H,"forceUpdate")};function A(){}A.prototype=C.prototype;function R(H,Z,pe){this.props=H,this.context=Z,this.refs=k,this.updater=pe||x}var _=R.prototype=new A;_.constructor=R,S(_,C.prototype),_.isPureReactComponent=!0;var M=Array.isArray;function O(){}var D={H:null,A:null,T:null,S:null},I=Object.prototype.hasOwnProperty;function P(H,Z,pe){var ve=pe.ref;return{$$typeof:t,type:H,key:Z,ref:ve!==void 0?ve:null,props:pe}}function B(H,Z){return P(H.type,Z,H.props)}function re(H){return typeof H=="object"&&H!==null&&H.$$typeof===t}function K(H){var Z={"=":"=0",":":"=2"};return"$"+H.replace(/[=:]/g,function(pe){return Z[pe]})}var ee=/\/+/g;function Q(H,Z){return typeof H=="object"&&H!==null&&H.key!=null?K(""+H.key):Z.toString(36)}function fe(H){switch(H.status){case"fulfilled":return H.value;case"rejected":throw H.reason;default:switch(typeof H.status=="string"?H.then(O,O):(H.status="pending",H.then(function(Z){H.status==="pending"&&(H.status="fulfilled",H.value=Z)},function(Z){H.status==="pending"&&(H.status="rejected",H.reason=Z)})),H.status){case"fulfilled":return H.value;case"rejected":throw H.reason}}throw H}function z(H,Z,pe,ve,Ae){var Re=typeof H;(Re==="undefined"||Re==="boolean")&&(H=null);var $e=!1;if(H===null)$e=!0;else switch(Re){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(H.$$typeof){case t:case e:$e=!0;break;case h:return $e=H._init,z($e(H._payload),Z,pe,ve,Ae)}}if($e)return Ae=Ae(H),$e=ve===""?"."+Q(H,0):ve,M(Ae)?(pe="",$e!=null&&(pe=$e.replace(ee,"$&/")+"/"),z(Ae,Z,pe,"",function(me){return me})):Ae!=null&&(re(Ae)&&(Ae=B(Ae,pe+(Ae.key==null||H&&H.key===Ae.key?"":(""+Ae.key).replace(ee,"$&/")+"/")+$e)),Z.push(Ae)),1;$e=0;var _e=ve===""?".":ve+":";if(M(H))for(var ae=0;ae<H.length;ae++)ve=H[ae],Re=_e+Q(ve,ae),$e+=z(ve,Z,pe,Re,Ae);else if(ae=b(H),typeof ae=="function")for(H=ae.call(H),ae=0;!(ve=H.next()).done;)ve=ve.value,Re=_e+Q(ve,ae++),$e+=z(ve,Z,pe,Re,Ae);else if(Re==="object"){if(typeof H.then=="function")return z(fe(H),Z,pe,ve,Ae);throw Z=String(H),Error("Objects are not valid as a React child (found: "+(Z==="[object Object]"?"object with keys {"+Object.keys(H).join(", ")+"}":Z)+"). If you meant to render a collection of children, use an array instead.")}return $e}function L(H,Z,pe){if(H==null)return H;var ve=[],Ae=0;return z(H,ve,"","",function(Re){return Z.call(pe,Re,Ae++)}),ve}function G(H){if(H._status===-1){var Z=H._result;Z=Z(),Z.then(function(pe){(H._status===0||H._status===-1)&&(H._status=1,H._result=pe)},function(pe){(H._status===0||H._status===-1)&&(H._status=2,H._result=pe)}),H._status===-1&&(H._status=0,H._result=Z)}if(H._status===1)return H._result.default;throw H._result}var he=typeof reportError=="function"?reportError:function(H){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var Z=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof H=="object"&&H!==null&&typeof H.message=="string"?String(H.message):String(H),error:H});if(!window.dispatchEvent(Z))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",H);return}console.error(H)},ke={map:L,forEach:function(H,Z,pe){L(H,function(){Z.apply(this,arguments)},pe)},count:function(H){var Z=0;return L(H,function(){Z++}),Z},toArray:function(H){return L(H,function(Z){return Z})||[]},only:function(H){if(!re(H))throw Error("React.Children.only expected to receive a single React element child.");return H}};return Je.Activity=m,Je.Children=ke,Je.Component=C,Je.Fragment=n,Je.Profiler=i,Je.PureComponent=R,Je.StrictMode=r,Je.Suspense=u,Je.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=D,Je.__COMPILER_RUNTIME={__proto__:null,c:function(H){return D.H.useMemoCache(H)}},Je.cache=function(H){return function(){return H.apply(null,arguments)}},Je.cacheSignal=function(){return null},Je.cloneElement=function(H,Z,pe){if(H==null)throw Error("The argument must be a React element, but you passed "+H+".");var ve=S({},H.props),Ae=H.key;if(Z!=null)for(Re in Z.key!==void 0&&(Ae=""+Z.key),Z)!I.call(Z,Re)||Re==="key"||Re==="__self"||Re==="__source"||Re==="ref"&&Z.ref===void 0||(ve[Re]=Z[Re]);var Re=arguments.length-2;if(Re===1)ve.children=pe;else if(1<Re){for(var $e=Array(Re),_e=0;_e<Re;_e++)$e[_e]=arguments[_e+2];ve.children=$e}return P(H.type,Ae,ve)},Je.createContext=function(H){return H={$$typeof:o,_currentValue:H,_currentValue2:H,_threadCount:0,Provider:null,Consumer:null},H.Provider=H,H.Consumer={$$typeof:s,_context:H},H},Je.createElement=function(H,Z,pe){var ve,Ae={},Re=null;if(Z!=null)for(ve in Z.key!==void 0&&(Re=""+Z.key),Z)I.call(Z,ve)&&ve!=="key"&&ve!=="__self"&&ve!=="__source"&&(Ae[ve]=Z[ve]);var $e=arguments.length-2;if($e===1)Ae.children=pe;else if(1<$e){for(var _e=Array($e),ae=0;ae<$e;ae++)_e[ae]=arguments[ae+2];Ae.children=_e}if(H&&H.defaultProps)for(ve in $e=H.defaultProps,$e)Ae[ve]===void 0&&(Ae[ve]=$e[ve]);return P(H,Re,Ae)},Je.createRef=function(){return{current:null}},Je.forwardRef=function(H){return{$$typeof:l,render:H}},Je.isValidElement=re,Je.lazy=function(H){return{$$typeof:h,_payload:{_status:-1,_result:H},_init:G}},Je.memo=function(H,Z){return{$$typeof:f,type:H,compare:Z===void 0?null:Z}},Je.startTransition=function(H){var Z=D.T,pe={};D.T=pe;try{var ve=H(),Ae=D.S;Ae!==null&&Ae(pe,ve),typeof ve=="object"&&ve!==null&&typeof ve.then=="function"&&ve.then(O,he)}catch(Re){he(Re)}finally{Z!==null&&pe.types!==null&&(Z.types=pe.types),D.T=Z}},Je.unstable_useCacheRefresh=function(){return D.H.useCacheRefresh()},Je.use=function(H){return D.H.use(H)},Je.useActionState=function(H,Z,pe){return D.H.useActionState(H,Z,pe)},Je.useCallback=function(H,Z){return D.H.useCallback(H,Z)},Je.useContext=function(H){return D.H.useContext(H)},Je.useDebugValue=function(){},Je.useDeferredValue=function(H,Z){return D.H.useDeferredValue(H,Z)},Je.useEffect=function(H,Z){return D.H.useEffect(H,Z)},Je.useEffectEvent=function(H){return D.H.useEffectEvent(H)},Je.useId=function(){return D.H.useId()},Je.useImperativeHandle=function(H,Z,pe){return D.H.useImperativeHandle(H,Z,pe)},Je.useInsertionEffect=function(H,Z){return D.H.useInsertionEffect(H,Z)},Je.useLayoutEffect=function(H,Z){return D.H.useLayoutEffect(H,Z)},Je.useMemo=function(H,Z){return D.H.useMemo(H,Z)},Je.useOptimistic=function(H,Z){return D.H.useOptimistic(H,Z)},Je.useReducer=function(H,Z,pe){return D.H.useReducer(H,Z,pe)},Je.useRef=function(H){return D.H.useRef(H)},Je.useState=function(H){return D.H.useState(H)},Je.useSyncExternalStore=function(H,Z,pe){return D.H.useSyncExternalStore(H,Z,pe)},Je.useTransition=function(){return D.H.useTransition()},Je.version="19.2.8",Je}var oT;function Vd(){return oT||(oT=1,Yb.exports=Dz()),Yb.exports}var E=Vd();const qe=TM(E),Hd=Mz({__proto__:null,default:qe},[E]);var Xb={exports:{}},Mu={},Jb={exports:{}},Qb={};var aT;function Iz(){return aT||(aT=1,(function(t){function e(z,L){var G=z.length;z.push(L);e:for(;0<G;){var he=G-1>>>1,ke=z[he];if(0<i(ke,L))z[he]=L,z[G]=ke,G=he;else break e}}function n(z){return z.length===0?null:z[0]}function r(z){if(z.length===0)return null;var L=z[0],G=z.pop();if(G!==L){z[0]=G;e:for(var he=0,ke=z.length,H=ke>>>1;he<H;){var Z=2*(he+1)-1,pe=z[Z],ve=Z+1,Ae=z[ve];if(0>i(pe,G))ve<ke&&0>i(Ae,pe)?(z[he]=Ae,z[ve]=G,he=ve):(z[he]=pe,z[Z]=G,he=Z);else if(ve<ke&&0>i(Ae,G))z[he]=Ae,z[ve]=G,he=ve;else break e}}return L}function i(z,L){var G=z.sortIndex-L.sortIndex;return G!==0?G:z.id-L.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var s=performance;t.unstable_now=function(){return s.now()}}else{var o=Date,l=o.now();t.unstable_now=function(){return o.now()-l}}var u=[],f=[],h=1,m=null,g=3,b=!1,x=!1,S=!1,k=!1,C=typeof setTimeout=="function"?setTimeout:null,A=typeof clearTimeout=="function"?clearTimeout:null,R=typeof setImmediate<"u"?setImmediate:null;function _(z){for(var L=n(f);L!==null;){if(L.callback===null)r(f);else if(L.startTime<=z)r(f),L.sortIndex=L.expirationTime,e(u,L);else break;L=n(f)}}function M(z){if(S=!1,_(z),!x)if(n(u)!==null)x=!0,O||(O=!0,K());else{var L=n(f);L!==null&&fe(M,L.startTime-z)}}var O=!1,D=-1,I=5,P=-1;function B(){return k?!0:!(t.unstable_now()-P<I)}function re(){if(k=!1,O){var z=t.unstable_now();P=z;var L=!0;try{e:{x=!1,S&&(S=!1,A(D),D=-1),b=!0;var G=g;try{t:{for(_(z),m=n(u);m!==null&&!(m.expirationTime>z&&B());){var he=m.callback;if(typeof he=="function"){m.callback=null,g=m.priorityLevel;var ke=he(m.expirationTime<=z);if(z=t.unstable_now(),typeof ke=="function"){m.callback=ke,_(z),L=!0;break t}m===n(u)&&r(u),_(z)}else r(u);m=n(u)}if(m!==null)L=!0;else{var H=n(f);H!==null&&fe(M,H.startTime-z),L=!1}}break e}finally{m=null,g=G,b=!1}L=void 0}}finally{L?K():O=!1}}}var K;if(typeof R=="function")K=function(){R(re)};else if(typeof MessageChannel<"u"){var ee=new MessageChannel,Q=ee.port2;ee.port1.onmessage=re,K=function(){Q.postMessage(null)}}else K=function(){C(re,0)};function fe(z,L){D=C(function(){z(t.unstable_now())},L)}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(z){z.callback=null},t.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<z?Math.floor(1e3/z):5},t.unstable_getCurrentPriorityLevel=function(){return g},t.unstable_next=function(z){switch(g){case 1:case 2:case 3:var L=3;break;default:L=g}var G=g;g=L;try{return z()}finally{g=G}},t.unstable_requestPaint=function(){k=!0},t.unstable_runWithPriority=function(z,L){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var G=g;g=z;try{return L()}finally{g=G}},t.unstable_scheduleCallback=function(z,L,G){var he=t.unstable_now();switch(typeof G=="object"&&G!==null?(G=G.delay,G=typeof G=="number"&&0<G?he+G:he):G=he,z){case 1:var ke=-1;break;case 2:ke=250;break;case 5:ke=1073741823;break;case 4:ke=1e4;break;default:ke=5e3}return ke=G+ke,z={id:h++,callback:L,priorityLevel:z,startTime:G,expirationTime:ke,sortIndex:-1},G>he?(z.sortIndex=G,e(f,z),n(u)===null&&z===n(f)&&(S?(A(D),D=-1):S=!0,fe(M,G-he))):(z.sortIndex=ke,e(u,z),x||b||(x=!0,O||(O=!0,K()))),z},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(z){var L=g;return function(){var G=g;g=L;try{return z.apply(this,arguments)}finally{g=G}}}})(Qb)),Qb}var lT;function jz(){return lT||(lT=1,Jb.exports=Iz()),Jb.exports}var ev={exports:{}},Hn={};var cT;function Lz(){if(cT)return Hn;cT=1;var t=Vd();function e(u){var f="https://react.dev/errors/"+u;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)f+="&args[]="+encodeURIComponent(arguments[h])}return"Minified React error #"+u+"; visit "+f+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(e(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},i=Symbol.for("react.portal");function s(u,f,h){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:i,key:m==null?null:""+m,children:u,containerInfo:f,implementation:h}}var o=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(u,f){if(u==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return Hn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,Hn.createPortal=function(u,f){var h=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(e(299));return s(u,f,null,h)},Hn.flushSync=function(u){var f=o.T,h=r.p;try{if(o.T=null,r.p=2,u)return u()}finally{o.T=f,r.p=h,r.d.f()}},Hn.preconnect=function(u,f){typeof u=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,r.d.C(u,f))},Hn.prefetchDNS=function(u){typeof u=="string"&&r.d.D(u)},Hn.preinit=function(u,f){if(typeof u=="string"&&f&&typeof f.as=="string"){var h=f.as,m=l(h,f.crossOrigin),g=typeof f.integrity=="string"?f.integrity:void 0,b=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;h==="style"?r.d.S(u,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:m,integrity:g,fetchPriority:b}):h==="script"&&r.d.X(u,{crossOrigin:m,integrity:g,fetchPriority:b,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},Hn.preinitModule=function(u,f){if(typeof u=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var h=l(f.as,f.crossOrigin);r.d.M(u,{crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&r.d.M(u)},Hn.preload=function(u,f){if(typeof u=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var h=f.as,m=l(h,f.crossOrigin);r.d.L(u,h,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},Hn.preloadModule=function(u,f){if(typeof u=="string")if(f){var h=l(f.as,f.crossOrigin);r.d.m(u,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:h,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else r.d.m(u)},Hn.requestFormReset=function(u){r.d.r(u)},Hn.unstable_batchedUpdates=function(u,f){return u(f)},Hn.useFormState=function(u,f,h){return o.H.useFormState(u,f,h)},Hn.useFormStatus=function(){return o.H.useHostTransitionStatus()},Hn.version="19.2.8",Hn}var uT;function _M(){if(uT)return ev.exports;uT=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(),ev.exports=Lz(),ev.exports}var dT;function Pz(){if(dT)return Mu;dT=1;var t=jz(),e=Vd(),n=_M();function r(a){var c="https://react.dev/errors/"+a;if(1<arguments.length){c+="?args[]="+encodeURIComponent(arguments[1]);for(var d=2;d<arguments.length;d++)c+="&args[]="+encodeURIComponent(arguments[d])}return"Minified React error #"+a+"; visit "+c+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function i(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function s(a){var c=a,d=a;if(a.alternate)for(;c.return;)c=c.return;else{a=c;do c=a,(c.flags&4098)!==0&&(d=c.return),a=c.return;while(a)}return c.tag===3?d:null}function o(a){if(a.tag===13){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function l(a){if(a.tag===31){var c=a.memoizedState;if(c===null&&(a=a.alternate,a!==null&&(c=a.memoizedState)),c!==null)return c.dehydrated}return null}function u(a){if(s(a)!==a)throw Error(r(188))}function f(a){var c=a.alternate;if(!c){if(c=s(a),c===null)throw Error(r(188));return c!==a?null:a}for(var d=a,p=c;;){var v=d.return;if(v===null)break;var w=v.alternate;if(w===null){if(p=v.return,p!==null){d=p;continue}break}if(v.child===w.child){for(w=v.child;w;){if(w===d)return u(v),a;if(w===p)return u(v),c;w=w.sibling}throw Error(r(188))}if(d.return!==p.return)d=v,p=w;else{for(var T=!1,N=v.child;N;){if(N===d){T=!0,d=v,p=w;break}if(N===p){T=!0,p=v,d=w;break}N=N.sibling}if(!T){for(N=w.child;N;){if(N===d){T=!0,d=w,p=v;break}if(N===p){T=!0,p=w,d=v;break}N=N.sibling}if(!T)throw Error(r(189))}}if(d.alternate!==p)throw Error(r(190))}if(d.tag!==3)throw Error(r(188));return d.stateNode.current===d?a:c}function h(a){var c=a.tag;if(c===5||c===26||c===27||c===6)return a;for(a=a.child;a!==null;){if(c=h(a),c!==null)return c;a=a.sibling}return null}var m=Object.assign,g=Symbol.for("react.element"),b=Symbol.for("react.transitional.element"),x=Symbol.for("react.portal"),S=Symbol.for("react.fragment"),k=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),R=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),M=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),B=Symbol.for("react.memo_cache_sentinel"),re=Symbol.iterator;function K(a){return a===null||typeof a!="object"?null:(a=re&&a[re]||a["@@iterator"],typeof a=="function"?a:null)}var ee=Symbol.for("react.client.reference");function Q(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===ee?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case S:return"Fragment";case C:return"Profiler";case k:return"StrictMode";case M:return"Suspense";case O:return"SuspenseList";case P:return"Activity"}if(typeof a=="object")switch(a.$$typeof){case x:return"Portal";case R:return a.displayName||"Context";case A:return(a._context.displayName||"Context")+".Consumer";case _:var c=a.render;return a=a.displayName,a||(a=c.displayName||c.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case D:return c=a.displayName||null,c!==null?c:Q(a.type)||"Memo";case I:c=a._payload,a=a._init;try{return Q(a(c))}catch{}}return null}var fe=Array.isArray,z=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G={pending:!1,data:null,method:null,action:null},he=[],ke=-1;function H(a){return{current:a}}function Z(a){0>ke||(a.current=he[ke],he[ke]=null,ke--)}function pe(a,c){ke++,he[ke]=a.current,a.current=c}var ve=H(null),Ae=H(null),Re=H(null),$e=H(null);function _e(a,c){switch(pe(Re,c),pe(Ae,a),pe(ve,null),c.nodeType){case 9:case 11:a=(a=c.documentElement)&&(a=a.namespaceURI)?kE(a):0;break;default:if(a=c.tagName,c=c.namespaceURI)c=kE(c),a=CE(c,a);else switch(a){case"svg":a=1;break;case"math":a=2;break;default:a=0}}Z(ve),pe(ve,a)}function ae(){Z(ve),Z(Ae),Z(Re)}function me(a){a.memoizedState!==null&&pe($e,a);var c=ve.current,d=CE(c,a.type);c!==d&&(pe(Ae,a),pe(ve,d))}function Ie(a){Ae.current===a&&(Z(ve),Z(Ae)),$e.current===a&&(Z($e),Eu._currentValue=G)}var Ue,Ze;function ct(a){if(Ue===void 0)try{throw Error()}catch(d){var c=d.stack.trim().match(/\n( *(at )?)/);Ue=c&&c[1]||"",Ze=-1<d.stack.indexOf(`
|
|
2
|
+
at`)?" (<anonymous>)":-1<d.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
3
|
+
`+Ue+a+Ze}var yt=!1;function Pt(a,c){if(!a||yt)return"";yt=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var p={DetermineComponentFrameRoot:function(){try{if(c){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(te){var J=te}Reflect.construct(a,[],ue)}else{try{ue.call()}catch(te){J=te}a.call(ue.prototype)}}else{try{throw Error()}catch(te){J=te}(ue=a())&&typeof ue.catch=="function"&&ue.catch(function(){})}}catch(te){if(te&&J&&typeof te.stack=="string")return[te.stack,J.stack]}return[null,null]}};p.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var v=Object.getOwnPropertyDescriptor(p.DetermineComponentFrameRoot,"name");v&&v.configurable&&Object.defineProperty(p.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var w=p.DetermineComponentFrameRoot(),T=w[0],N=w[1];if(T&&N){var V=T.split(`
|
|
4
|
+
`),X=N.split(`
|
|
5
|
+
`);for(v=p=0;p<V.length&&!V[p].includes("DetermineComponentFrameRoot");)p++;for(;v<X.length&&!X[v].includes("DetermineComponentFrameRoot");)v++;if(p===V.length||v===X.length)for(p=V.length-1,v=X.length-1;1<=p&&0<=v&&V[p]!==X[v];)v--;for(;1<=p&&0<=v;p--,v--)if(V[p]!==X[v]){if(p!==1||v!==1)do if(p--,v--,0>v||V[p]!==X[v]){var oe=`
|
|
6
|
+
`+V[p].replace(" at new "," at ");return a.displayName&&oe.includes("<anonymous>")&&(oe=oe.replace("<anonymous>",a.displayName)),oe}while(1<=p&&0<=v);break}}}finally{yt=!1,Error.prepareStackTrace=d}return(d=a?a.displayName||a.name:"")?ct(d):""}function mn(a,c){switch(a.tag){case 26:case 27:case 5:return ct(a.type);case 16:return ct("Lazy");case 13:return a.child!==c&&c!==null?ct("Suspense Fallback"):ct("Suspense");case 19:return ct("SuspenseList");case 0:case 15:return Pt(a.type,!1);case 11:return Pt(a.type.render,!1);case 1:return Pt(a.type,!0);case 31:return ct("Activity");default:return""}}function Wt(a){try{var c="",d=null;do c+=mn(a,d),d=a,a=a.return;while(a);return c}catch(p){return`
|
|
7
|
+
Error generating stack: `+p.message+`
|
|
8
|
+
`+p.stack}}var yn=Object.prototype.hasOwnProperty,$n=t.unstable_scheduleCallback,Dr=t.unstable_cancelCallback,sr=t.unstable_shouldYield,Ir=t.unstable_requestPaint,Ht=t.unstable_now,xi=t.unstable_getCurrentPriorityLevel,yr=t.unstable_ImmediatePriority,ei=t.unstable_UserBlockingPriority,Bn=t.unstable_NormalPriority,ge=t.unstable_LowPriority,Ne=t.unstable_IdlePriority,j=t.log,$=t.unstable_setDisableYieldValue,U=null,ie=null;function le(a){if(typeof j=="function"&&$(a),ie&&typeof ie.setStrictMode=="function")try{ie.setStrictMode(U,a)}catch{}}var be=Math.clz32?Math.clz32:Be,we=Math.log,Te=Math.LN2;function Be(a){return a>>>=0,a===0?32:31-(we(a)/Te|0)|0}var se=256,F=262144,ne=4194304;function Ce(a){var c=a&42;if(c!==0)return c;switch(a&-a){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:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return a&261888;case 262144:case 524288:case 1048576:case 2097152:return a&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return a&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return a}}function Ge(a,c,d){var p=a.pendingLanes;if(p===0)return 0;var v=0,w=a.suspendedLanes,T=a.pingedLanes;a=a.warmLanes;var N=p&134217727;return N!==0?(p=N&~w,p!==0?v=Ce(p):(T&=N,T!==0?v=Ce(T):d||(d=N&~a,d!==0&&(v=Ce(d))))):(N=p&~w,N!==0?v=Ce(N):T!==0?v=Ce(T):d||(d=p&~a,d!==0&&(v=Ce(d)))),v===0?0:c!==0&&c!==v&&(c&w)===0&&(w=v&-v,d=c&-c,w>=d||w===32&&(d&4194048)!==0)?c:v}function Dt(a,c){return(a.pendingLanes&~(a.suspendedLanes&~a.pingedLanes)&c)===0}function Zn(a,c){switch(a){case 1:case 2:case 4:case 8:case 64:return c+250;case 16:case 32: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 c+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function or(){var a=ne;return ne<<=1,(ne&62914560)===0&&(ne=4194304),a}function wi(a){for(var c=[],d=0;31>d;d++)c.push(a);return c}function Ps(a,c){a.pendingLanes|=c,c!==268435456&&(a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0)}function $c(a,c,d,p,v,w){var T=a.pendingLanes;a.pendingLanes=d,a.suspendedLanes=0,a.pingedLanes=0,a.warmLanes=0,a.expiredLanes&=d,a.entangledLanes&=d,a.errorRecoveryDisabledLanes&=d,a.shellSuspendCounter=0;var N=a.entanglements,V=a.expirationTimes,X=a.hiddenUpdates;for(d=T&~d;0<d;){var oe=31-be(d),ue=1<<oe;N[oe]=0,V[oe]=-1;var J=X[oe];if(J!==null)for(X[oe]=null,oe=0;oe<J.length;oe++){var te=J[oe];te!==null&&(te.lane&=-536870913)}d&=~ue}p!==0&&sk(a,p,0),w!==0&&v===0&&a.tag!==0&&(a.suspendedLanes|=w&~(T&~c))}function sk(a,c,d){a.pendingLanes|=c,a.suspendedLanes&=~c;var p=31-be(c);a.entangledLanes|=c,a.entanglements[p]=a.entanglements[p]|1073741824|d&261930}function ok(a,c){var d=a.entangledLanes|=c;for(a=a.entanglements;d;){var p=31-be(d),v=1<<p;v&c|a[p]&c&&(a[p]|=c),d&=~v}}function ak(a,c){var d=c&-c;return d=(d&42)!==0?1:Pg(d),(d&(a.suspendedLanes|c))!==0?0:d}function Pg(a){switch(a){case 2:a=1;break;case 8:a=4;break;case 32:a=16;break;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:a=128;break;case 268435456:a=134217728;break;default:a=0}return a}function zg(a){return a&=-a,2<a?8<a?(a&134217727)!==0?32:268435456:8:2}function lk(){var a=L.p;return a!==0?a:(a=window.event,a===void 0?32:WE(a.type))}function ck(a,c){var d=L.p;try{return L.p=a,c()}finally{L.p=d}}var zs=Math.random().toString(36).slice(2),_n="__reactFiber$"+zs,ar="__reactProps$"+zs,nl="__reactContainer$"+zs,$g="__reactEvents$"+zs,v2="__reactListeners$"+zs,x2="__reactHandles$"+zs,uk="__reactResources$"+zs,Bc="__reactMarker$"+zs;function Bg(a){delete a[_n],delete a[ar],delete a[$g],delete a[v2],delete a[x2]}function rl(a){var c=a[_n];if(c)return c;for(var d=a.parentNode;d;){if(c=d[nl]||d[_n]){if(d=c.alternate,c.child!==null||d!==null&&d.child!==null)for(a=NE(a);a!==null;){if(d=a[_n])return d;a=NE(a)}return c}a=d,d=a.parentNode}return null}function il(a){if(a=a[_n]||a[nl]){var c=a.tag;if(c===5||c===6||c===13||c===31||c===26||c===27||c===3)return a}return null}function Vc(a){var c=a.tag;if(c===5||c===26||c===27||c===6)return a.stateNode;throw Error(r(33))}function sl(a){var c=a[uk];return c||(c=a[uk]={hoistableStyles:new Map,hoistableScripts:new Map}),c}function bn(a){a[Bc]=!0}var dk=new Set,fk={};function Qo(a,c){ol(a,c),ol(a+"Capture",c)}function ol(a,c){for(fk[a]=c,a=0;a<c.length;a++)dk.add(c[a])}var w2=RegExp("^[: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]*$"),hk={},pk={};function S2(a){return yn.call(pk,a)?!0:yn.call(hk,a)?!1:w2.test(a)?pk[a]=!0:(hk[a]=!0,!1)}function cf(a,c,d){if(S2(c))if(d===null)a.removeAttribute(c);else{switch(typeof d){case"undefined":case"function":case"symbol":a.removeAttribute(c);return;case"boolean":var p=c.toLowerCase().slice(0,5);if(p!=="data-"&&p!=="aria-"){a.removeAttribute(c);return}}a.setAttribute(c,""+d)}}function uf(a,c,d){if(d===null)a.removeAttribute(c);else{switch(typeof d){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(c);return}a.setAttribute(c,""+d)}}function Vi(a,c,d,p){if(p===null)a.removeAttribute(d);else{switch(typeof p){case"undefined":case"function":case"symbol":case"boolean":a.removeAttribute(d);return}a.setAttributeNS(c,d,""+p)}}function jr(a){switch(typeof a){case"bigint":case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function mk(a){var c=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(c==="checkbox"||c==="radio")}function k2(a,c,d){var p=Object.getOwnPropertyDescriptor(a.constructor.prototype,c);if(!a.hasOwnProperty(c)&&typeof p<"u"&&typeof p.get=="function"&&typeof p.set=="function"){var v=p.get,w=p.set;return Object.defineProperty(a,c,{configurable:!0,get:function(){return v.call(this)},set:function(T){d=""+T,w.call(this,T)}}),Object.defineProperty(a,c,{enumerable:p.enumerable}),{getValue:function(){return d},setValue:function(T){d=""+T},stopTracking:function(){a._valueTracker=null,delete a[c]}}}}function Vg(a){if(!a._valueTracker){var c=mk(a)?"checked":"value";a._valueTracker=k2(a,c,""+a[c])}}function gk(a){if(!a)return!1;var c=a._valueTracker;if(!c)return!0;var d=c.getValue(),p="";return a&&(p=mk(a)?a.checked?"true":"false":a.value),a=p,a!==d?(c.setValue(a),!0):!1}function df(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}var C2=/[\n"\\]/g;function Lr(a){return a.replace(C2,function(c){return"\\"+c.charCodeAt(0).toString(16)+" "})}function Hg(a,c,d,p,v,w,T,N){a.name="",T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?a.type=T:a.removeAttribute("type"),c!=null?T==="number"?(c===0&&a.value===""||a.value!=c)&&(a.value=""+jr(c)):a.value!==""+jr(c)&&(a.value=""+jr(c)):T!=="submit"&&T!=="reset"||a.removeAttribute("value"),c!=null?Ug(a,T,jr(c)):d!=null?Ug(a,T,jr(d)):p!=null&&a.removeAttribute("value"),v==null&&w!=null&&(a.defaultChecked=!!w),v!=null&&(a.checked=v&&typeof v!="function"&&typeof v!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?a.name=""+jr(N):a.removeAttribute("name")}function yk(a,c,d,p,v,w,T,N){if(w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(a.type=w),c!=null||d!=null){if(!(w!=="submit"&&w!=="reset"||c!=null)){Vg(a);return}d=d!=null?""+jr(d):"",c=c!=null?""+jr(c):d,N||c===a.value||(a.value=c),a.defaultValue=c}p=p??v,p=typeof p!="function"&&typeof p!="symbol"&&!!p,a.checked=N?a.checked:!!p,a.defaultChecked=!!p,T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"&&(a.name=T),Vg(a)}function Ug(a,c,d){c==="number"&&df(a.ownerDocument)===a||a.defaultValue===""+d||(a.defaultValue=""+d)}function al(a,c,d,p){if(a=a.options,c){c={};for(var v=0;v<d.length;v++)c["$"+d[v]]=!0;for(d=0;d<a.length;d++)v=c.hasOwnProperty("$"+a[d].value),a[d].selected!==v&&(a[d].selected=v),v&&p&&(a[d].defaultSelected=!0)}else{for(d=""+jr(d),c=null,v=0;v<a.length;v++){if(a[v].value===d){a[v].selected=!0,p&&(a[v].defaultSelected=!0);return}c!==null||a[v].disabled||(c=a[v])}c!==null&&(c.selected=!0)}}function bk(a,c,d){if(c!=null&&(c=""+jr(c),c!==a.value&&(a.value=c),d==null)){a.defaultValue!==c&&(a.defaultValue=c);return}a.defaultValue=d!=null?""+jr(d):""}function vk(a,c,d,p){if(c==null){if(p!=null){if(d!=null)throw Error(r(92));if(fe(p)){if(1<p.length)throw Error(r(93));p=p[0]}d=p}d==null&&(d=""),c=d}d=jr(c),a.defaultValue=d,p=a.textContent,p===d&&p!==""&&p!==null&&(a.value=p),Vg(a)}function ll(a,c){if(c){var d=a.firstChild;if(d&&d===a.lastChild&&d.nodeType===3){d.nodeValue=c;return}}a.textContent=c}var E2=new Set("animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp".split(" "));function xk(a,c,d){var p=c.indexOf("--")===0;d==null||typeof d=="boolean"||d===""?p?a.setProperty(c,""):c==="float"?a.cssFloat="":a[c]="":p?a.setProperty(c,d):typeof d!="number"||d===0||E2.has(c)?c==="float"?a.cssFloat=d:a[c]=(""+d).trim():a[c]=d+"px"}function wk(a,c,d){if(c!=null&&typeof c!="object")throw Error(r(62));if(a=a.style,d!=null){for(var p in d)!d.hasOwnProperty(p)||c!=null&&c.hasOwnProperty(p)||(p.indexOf("--")===0?a.setProperty(p,""):p==="float"?a.cssFloat="":a[p]="");for(var v in c)p=c[v],c.hasOwnProperty(v)&&d[v]!==p&&xk(a,v,p)}else for(var w in c)c.hasOwnProperty(w)&&xk(a,w,c[w])}function Fg(a){if(a.indexOf("-")===-1)return!1;switch(a){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 T2=new Map([["acceptCharset","accept-charset"],["htmlFor","for"],["httpEquiv","http-equiv"],["crossOrigin","crossorigin"],["accentHeight","accent-height"],["alignmentBaseline","alignment-baseline"],["arabicForm","arabic-form"],["baselineShift","baseline-shift"],["capHeight","cap-height"],["clipPath","clip-path"],["clipRule","clip-rule"],["colorInterpolation","color-interpolation"],["colorInterpolationFilters","color-interpolation-filters"],["colorProfile","color-profile"],["colorRendering","color-rendering"],["dominantBaseline","dominant-baseline"],["enableBackground","enable-background"],["fillOpacity","fill-opacity"],["fillRule","fill-rule"],["floodColor","flood-color"],["floodOpacity","flood-opacity"],["fontFamily","font-family"],["fontSize","font-size"],["fontSizeAdjust","font-size-adjust"],["fontStretch","font-stretch"],["fontStyle","font-style"],["fontVariant","font-variant"],["fontWeight","font-weight"],["glyphName","glyph-name"],["glyphOrientationHorizontal","glyph-orientation-horizontal"],["glyphOrientationVertical","glyph-orientation-vertical"],["horizAdvX","horiz-adv-x"],["horizOriginX","horiz-origin-x"],["imageRendering","image-rendering"],["letterSpacing","letter-spacing"],["lightingColor","lighting-color"],["markerEnd","marker-end"],["markerMid","marker-mid"],["markerStart","marker-start"],["overlinePosition","overline-position"],["overlineThickness","overline-thickness"],["paintOrder","paint-order"],["panose-1","panose-1"],["pointerEvents","pointer-events"],["renderingIntent","rendering-intent"],["shapeRendering","shape-rendering"],["stopColor","stop-color"],["stopOpacity","stop-opacity"],["strikethroughPosition","strikethrough-position"],["strikethroughThickness","strikethrough-thickness"],["strokeDasharray","stroke-dasharray"],["strokeDashoffset","stroke-dashoffset"],["strokeLinecap","stroke-linecap"],["strokeLinejoin","stroke-linejoin"],["strokeMiterlimit","stroke-miterlimit"],["strokeOpacity","stroke-opacity"],["strokeWidth","stroke-width"],["textAnchor","text-anchor"],["textDecoration","text-decoration"],["textRendering","text-rendering"],["transformOrigin","transform-origin"],["underlinePosition","underline-position"],["underlineThickness","underline-thickness"],["unicodeBidi","unicode-bidi"],["unicodeRange","unicode-range"],["unitsPerEm","units-per-em"],["vAlphabetic","v-alphabetic"],["vHanging","v-hanging"],["vIdeographic","v-ideographic"],["vMathematical","v-mathematical"],["vectorEffect","vector-effect"],["vertAdvY","vert-adv-y"],["vertOriginX","vert-origin-x"],["vertOriginY","vert-origin-y"],["wordSpacing","word-spacing"],["writingMode","writing-mode"],["xmlnsXlink","xmlns:xlink"],["xHeight","x-height"]]),_2=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function ff(a){return _2.test(""+a)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":a}function Hi(){}var qg=null;function Gg(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var cl=null,ul=null;function Sk(a){var c=il(a);if(c&&(a=c.stateNode)){var d=a[ar]||null;e:switch(a=c.stateNode,c.type){case"input":if(Hg(a,d.value,d.defaultValue,d.defaultValue,d.checked,d.defaultChecked,d.type,d.name),c=d.name,d.type==="radio"&&c!=null){for(d=a;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll('input[name="'+Lr(""+c)+'"][type="radio"]'),c=0;c<d.length;c++){var p=d[c];if(p!==a&&p.form===a.form){var v=p[ar]||null;if(!v)throw Error(r(90));Hg(p,v.value,v.defaultValue,v.defaultValue,v.checked,v.defaultChecked,v.type,v.name)}}for(c=0;c<d.length;c++)p=d[c],p.form===a.form&&gk(p)}break e;case"textarea":bk(a,d.value,d.defaultValue);break e;case"select":c=d.value,c!=null&&al(a,!!d.multiple,c,!1)}}}var Wg=!1;function kk(a,c,d){if(Wg)return a(c,d);Wg=!0;try{var p=a(c);return p}finally{if(Wg=!1,(cl!==null||ul!==null)&&(Qf(),cl&&(c=cl,a=ul,ul=cl=null,Sk(c),a)))for(c=0;c<a.length;c++)Sk(a[c])}}function Hc(a,c){var d=a.stateNode;if(d===null)return null;var p=d[ar]||null;if(p===null)return null;d=p[c];e:switch(c){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(p=!p.disabled)||(a=a.type,p=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!p;break e;default:a=!1}if(a)return null;if(d&&typeof d!="function")throw Error(r(231,c,typeof d));return d}var Ui=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Kg=!1;if(Ui)try{var Uc={};Object.defineProperty(Uc,"passive",{get:function(){Kg=!0}}),window.addEventListener("test",Uc,Uc),window.removeEventListener("test",Uc,Uc)}catch{Kg=!1}var $s=null,Zg=null,hf=null;function Ck(){if(hf)return hf;var a,c=Zg,d=c.length,p,v="value"in $s?$s.value:$s.textContent,w=v.length;for(a=0;a<d&&c[a]===v[a];a++);var T=d-a;for(p=1;p<=T&&c[d-p]===v[w-p];p++);return hf=v.slice(a,1<p?1-p:void 0)}function pf(a){var c=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&c===13&&(a=13)):a=c,a===10&&(a=13),32<=a||a===13?a:0}function mf(){return!0}function Ek(){return!1}function lr(a){function c(d,p,v,w,T){this._reactName=d,this._targetInst=v,this.type=p,this.nativeEvent=w,this.target=T,this.currentTarget=null;for(var N in a)a.hasOwnProperty(N)&&(d=a[N],this[N]=d?d(w):w[N]);return this.isDefaultPrevented=(w.defaultPrevented!=null?w.defaultPrevented:w.returnValue===!1)?mf:Ek,this.isPropagationStopped=Ek,this}return m(c.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=mf)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=mf)},persist:function(){},isPersistent:mf}),c}var ea={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},gf=lr(ea),Fc=m({},ea,{view:0,detail:0}),A2=lr(Fc),Yg,Xg,qc,yf=m({},Fc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Qg,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==qc&&(qc&&a.type==="mousemove"?(Yg=a.screenX-qc.screenX,Xg=a.screenY-qc.screenY):Xg=Yg=0,qc=a),Yg)},movementY:function(a){return"movementY"in a?a.movementY:Xg}}),Tk=lr(yf),R2=m({},yf,{dataTransfer:0}),M2=lr(R2),N2=m({},Fc,{relatedTarget:0}),Jg=lr(N2),O2=m({},ea,{animationName:0,elapsedTime:0,pseudoElement:0}),D2=lr(O2),I2=m({},ea,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),j2=lr(I2),L2=m({},ea,{data:0}),_k=lr(L2),P2={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},z2={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"},$2={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function B2(a){var c=this.nativeEvent;return c.getModifierState?c.getModifierState(a):(a=$2[a])?!!c[a]:!1}function Qg(){return B2}var V2=m({},Fc,{key:function(a){if(a.key){var c=P2[a.key]||a.key;if(c!=="Unidentified")return c}return a.type==="keypress"?(a=pf(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?z2[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Qg,charCode:function(a){return a.type==="keypress"?pf(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?pf(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),H2=lr(V2),U2=m({},yf,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ak=lr(U2),F2=m({},Fc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Qg}),q2=lr(F2),G2=m({},ea,{propertyName:0,elapsedTime:0,pseudoElement:0}),W2=lr(G2),K2=m({},yf,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),Z2=lr(K2),Y2=m({},ea,{newState:0,oldState:0}),X2=lr(Y2),J2=[9,13,27,32],ey=Ui&&"CompositionEvent"in window,Gc=null;Ui&&"documentMode"in document&&(Gc=document.documentMode);var Q2=Ui&&"TextEvent"in window&&!Gc,Rk=Ui&&(!ey||Gc&&8<Gc&&11>=Gc),Mk=" ",Nk=!1;function Ok(a,c){switch(a){case"keyup":return J2.indexOf(c.keyCode)!==-1;case"keydown":return c.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Dk(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var dl=!1;function eP(a,c){switch(a){case"compositionend":return Dk(c);case"keypress":return c.which!==32?null:(Nk=!0,Mk);case"textInput":return a=c.data,a===Mk&&Nk?null:a;default:return null}}function tP(a,c){if(dl)return a==="compositionend"||!ey&&Ok(a,c)?(a=Ck(),hf=Zg=$s=null,dl=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(c.ctrlKey||c.altKey||c.metaKey)||c.ctrlKey&&c.altKey){if(c.char&&1<c.char.length)return c.char;if(c.which)return String.fromCharCode(c.which)}return null;case"compositionend":return Rk&&c.locale!=="ko"?null:c.data;default:return null}}var nP={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 Ik(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c==="input"?!!nP[a.type]:c==="textarea"}function jk(a,c,d,p){cl?ul?ul.push(p):ul=[p]:cl=p,c=oh(c,"onChange"),0<c.length&&(d=new gf("onChange","change",null,d,p),a.push({event:d,listeners:c}))}var Wc=null,Kc=null;function rP(a){yE(a,0)}function bf(a){var c=Vc(a);if(gk(c))return a}function Lk(a,c){if(a==="change")return c}var Pk=!1;if(Ui){var ty;if(Ui){var ny="oninput"in document;if(!ny){var zk=document.createElement("div");zk.setAttribute("oninput","return;"),ny=typeof zk.oninput=="function"}ty=ny}else ty=!1;Pk=ty&&(!document.documentMode||9<document.documentMode)}function $k(){Wc&&(Wc.detachEvent("onpropertychange",Bk),Kc=Wc=null)}function Bk(a){if(a.propertyName==="value"&&bf(Kc)){var c=[];jk(c,Kc,a,Gg(a)),kk(rP,c)}}function iP(a,c,d){a==="focusin"?($k(),Wc=c,Kc=d,Wc.attachEvent("onpropertychange",Bk)):a==="focusout"&&$k()}function sP(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return bf(Kc)}function oP(a,c){if(a==="click")return bf(c)}function aP(a,c){if(a==="input"||a==="change")return bf(c)}function lP(a,c){return a===c&&(a!==0||1/a===1/c)||a!==a&&c!==c}var br=typeof Object.is=="function"?Object.is:lP;function Zc(a,c){if(br(a,c))return!0;if(typeof a!="object"||a===null||typeof c!="object"||c===null)return!1;var d=Object.keys(a),p=Object.keys(c);if(d.length!==p.length)return!1;for(p=0;p<d.length;p++){var v=d[p];if(!yn.call(c,v)||!br(a[v],c[v]))return!1}return!0}function Vk(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function Hk(a,c){var d=Vk(a);a=0;for(var p;d;){if(d.nodeType===3){if(p=a+d.textContent.length,a<=c&&p>=c)return{node:d,offset:c-a};a=p}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Vk(d)}}function Uk(a,c){return a&&c?a===c?!0:a&&a.nodeType===3?!1:c&&c.nodeType===3?Uk(a,c.parentNode):"contains"in a?a.contains(c):a.compareDocumentPosition?!!(a.compareDocumentPosition(c)&16):!1:!1}function Fk(a){a=a!=null&&a.ownerDocument!=null&&a.ownerDocument.defaultView!=null?a.ownerDocument.defaultView:window;for(var c=df(a.document);c instanceof a.HTMLIFrameElement;){try{var d=typeof c.contentWindow.location.href=="string"}catch{d=!1}if(d)a=c.contentWindow;else break;c=df(a.document)}return c}function ry(a){var c=a&&a.nodeName&&a.nodeName.toLowerCase();return c&&(c==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||c==="textarea"||a.contentEditable==="true")}var cP=Ui&&"documentMode"in document&&11>=document.documentMode,fl=null,iy=null,Yc=null,sy=!1;function qk(a,c,d){var p=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;sy||fl==null||fl!==df(p)||(p=fl,"selectionStart"in p&&ry(p)?p={start:p.selectionStart,end:p.selectionEnd}:(p=(p.ownerDocument&&p.ownerDocument.defaultView||window).getSelection(),p={anchorNode:p.anchorNode,anchorOffset:p.anchorOffset,focusNode:p.focusNode,focusOffset:p.focusOffset}),Yc&&Zc(Yc,p)||(Yc=p,p=oh(iy,"onSelect"),0<p.length&&(c=new gf("onSelect","select",null,c,d),a.push({event:c,listeners:p}),c.target=fl)))}function ta(a,c){var d={};return d[a.toLowerCase()]=c.toLowerCase(),d["Webkit"+a]="webkit"+c,d["Moz"+a]="moz"+c,d}var hl={animationend:ta("Animation","AnimationEnd"),animationiteration:ta("Animation","AnimationIteration"),animationstart:ta("Animation","AnimationStart"),transitionrun:ta("Transition","TransitionRun"),transitionstart:ta("Transition","TransitionStart"),transitioncancel:ta("Transition","TransitionCancel"),transitionend:ta("Transition","TransitionEnd")},oy={},Gk={};Ui&&(Gk=document.createElement("div").style,"AnimationEvent"in window||(delete hl.animationend.animation,delete hl.animationiteration.animation,delete hl.animationstart.animation),"TransitionEvent"in window||delete hl.transitionend.transition);function na(a){if(oy[a])return oy[a];if(!hl[a])return a;var c=hl[a],d;for(d in c)if(c.hasOwnProperty(d)&&d in Gk)return oy[a]=c[d];return a}var Wk=na("animationend"),Kk=na("animationiteration"),Zk=na("animationstart"),uP=na("transitionrun"),dP=na("transitionstart"),fP=na("transitioncancel"),Yk=na("transitionend"),Xk=new Map,ay="abort auxClick beforeToggle 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(" ");ay.push("scrollEnd");function ti(a,c){Xk.set(a,c),Qo(c,[a])}var vf=typeof reportError=="function"?reportError:function(a){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var c=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof a=="object"&&a!==null&&typeof a.message=="string"?String(a.message):String(a),error:a});if(!window.dispatchEvent(c))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",a);return}console.error(a)},Pr=[],pl=0,ly=0;function xf(){for(var a=pl,c=ly=pl=0;c<a;){var d=Pr[c];Pr[c++]=null;var p=Pr[c];Pr[c++]=null;var v=Pr[c];Pr[c++]=null;var w=Pr[c];if(Pr[c++]=null,p!==null&&v!==null){var T=p.pending;T===null?v.next=v:(v.next=T.next,T.next=v),p.pending=v}w!==0&&Jk(d,v,w)}}function wf(a,c,d,p){Pr[pl++]=a,Pr[pl++]=c,Pr[pl++]=d,Pr[pl++]=p,ly|=p,a.lanes|=p,a=a.alternate,a!==null&&(a.lanes|=p)}function cy(a,c,d,p){return wf(a,c,d,p),Sf(a)}function ra(a,c){return wf(a,null,null,c),Sf(a)}function Jk(a,c,d){a.lanes|=d;var p=a.alternate;p!==null&&(p.lanes|=d);for(var v=!1,w=a.return;w!==null;)w.childLanes|=d,p=w.alternate,p!==null&&(p.childLanes|=d),w.tag===22&&(a=w.stateNode,a===null||a._visibility&1||(v=!0)),a=w,w=w.return;return a.tag===3?(w=a.stateNode,v&&c!==null&&(v=31-be(d),a=w.hiddenUpdates,p=a[v],p===null?a[v]=[c]:p.push(c),c.lane=d|536870912),w):null}function Sf(a){if(50<bu)throw bu=0,bb=null,Error(r(185));for(var c=a.return;c!==null;)a=c,c=a.return;return a.tag===3?a.stateNode:null}var ml={};function hP(a,c,d,p){this.tag=a,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=c,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=p,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function vr(a,c,d,p){return new hP(a,c,d,p)}function uy(a){return a=a.prototype,!(!a||!a.isReactComponent)}function Fi(a,c){var d=a.alternate;return d===null?(d=vr(a.tag,c,a.key,a.mode),d.elementType=a.elementType,d.type=a.type,d.stateNode=a.stateNode,d.alternate=a,a.alternate=d):(d.pendingProps=c,d.type=a.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=a.flags&65011712,d.childLanes=a.childLanes,d.lanes=a.lanes,d.child=a.child,d.memoizedProps=a.memoizedProps,d.memoizedState=a.memoizedState,d.updateQueue=a.updateQueue,c=a.dependencies,d.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext},d.sibling=a.sibling,d.index=a.index,d.ref=a.ref,d.refCleanup=a.refCleanup,d}function Qk(a,c){a.flags&=65011714;var d=a.alternate;return d===null?(a.childLanes=0,a.lanes=c,a.child=null,a.subtreeFlags=0,a.memoizedProps=null,a.memoizedState=null,a.updateQueue=null,a.dependencies=null,a.stateNode=null):(a.childLanes=d.childLanes,a.lanes=d.lanes,a.child=d.child,a.subtreeFlags=0,a.deletions=null,a.memoizedProps=d.memoizedProps,a.memoizedState=d.memoizedState,a.updateQueue=d.updateQueue,a.type=d.type,c=d.dependencies,a.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),a}function kf(a,c,d,p,v,w){var T=0;if(p=a,typeof a=="function")uy(a)&&(T=1);else if(typeof a=="string")T=bz(a,d,ve.current)?26:a==="html"||a==="head"||a==="body"?27:5;else e:switch(a){case P:return a=vr(31,d,c,v),a.elementType=P,a.lanes=w,a;case S:return ia(d.children,v,w,c);case k:T=8,v|=24;break;case C:return a=vr(12,d,c,v|2),a.elementType=C,a.lanes=w,a;case M:return a=vr(13,d,c,v),a.elementType=M,a.lanes=w,a;case O:return a=vr(19,d,c,v),a.elementType=O,a.lanes=w,a;default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case R:T=10;break e;case A:T=9;break e;case _:T=11;break e;case D:T=14;break e;case I:T=16,p=null;break e}T=29,d=Error(r(130,a===null?"null":typeof a,"")),p=null}return c=vr(T,d,c,v),c.elementType=a,c.type=p,c.lanes=w,c}function ia(a,c,d,p){return a=vr(7,a,p,c),a.lanes=d,a}function dy(a,c,d){return a=vr(6,a,null,c),a.lanes=d,a}function eC(a){var c=vr(18,null,null,0);return c.stateNode=a,c}function fy(a,c,d){return c=vr(4,a.children!==null?a.children:[],a.key,c),c.lanes=d,c.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},c}var tC=new WeakMap;function zr(a,c){if(typeof a=="object"&&a!==null){var d=tC.get(a);return d!==void 0?d:(c={value:a,source:c,stack:Wt(c)},tC.set(a,c),c)}return{value:a,source:c,stack:Wt(c)}}var gl=[],yl=0,Cf=null,Xc=0,$r=[],Br=0,Bs=null,Si=1,ki="";function qi(a,c){gl[yl++]=Xc,gl[yl++]=Cf,Cf=a,Xc=c}function nC(a,c,d){$r[Br++]=Si,$r[Br++]=ki,$r[Br++]=Bs,Bs=a;var p=Si;a=ki;var v=32-be(p)-1;p&=~(1<<v),d+=1;var w=32-be(c)+v;if(30<w){var T=v-v%5;w=(p&(1<<T)-1).toString(32),p>>=T,v-=T,Si=1<<32-be(c)+v|d<<v|p,ki=w+a}else Si=1<<w|d<<v|p,ki=a}function hy(a){a.return!==null&&(qi(a,1),nC(a,1,0))}function py(a){for(;a===Cf;)Cf=gl[--yl],gl[yl]=null,Xc=gl[--yl],gl[yl]=null;for(;a===Bs;)Bs=$r[--Br],$r[Br]=null,ki=$r[--Br],$r[Br]=null,Si=$r[--Br],$r[Br]=null}function rC(a,c){$r[Br++]=Si,$r[Br++]=ki,$r[Br++]=Bs,Si=c.id,ki=c.overflow,Bs=a}var An=null,zt=null,ut=!1,Vs=null,Vr=!1,my=Error(r(519));function Hs(a){var c=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Jc(zr(c,a)),my}function iC(a){var c=a.stateNode,d=a.type,p=a.memoizedProps;switch(c[_n]=a,c[ar]=p,d){case"dialog":ot("cancel",c),ot("close",c);break;case"iframe":case"object":case"embed":ot("load",c);break;case"video":case"audio":for(d=0;d<xu.length;d++)ot(xu[d],c);break;case"source":ot("error",c);break;case"img":case"image":case"link":ot("error",c),ot("load",c);break;case"details":ot("toggle",c);break;case"input":ot("invalid",c),yk(c,p.value,p.defaultValue,p.checked,p.defaultChecked,p.type,p.name,!0);break;case"select":ot("invalid",c);break;case"textarea":ot("invalid",c),vk(c,p.value,p.defaultValue,p.children)}d=p.children,typeof d!="string"&&typeof d!="number"&&typeof d!="bigint"||c.textContent===""+d||p.suppressHydrationWarning===!0||wE(c.textContent,d)?(p.popover!=null&&(ot("beforetoggle",c),ot("toggle",c)),p.onScroll!=null&&ot("scroll",c),p.onScrollEnd!=null&&ot("scrollend",c),p.onClick!=null&&(c.onclick=Hi),c=!0):c=!1,c||Hs(a,!0)}function sC(a){for(An=a.return;An;)switch(An.tag){case 5:case 31:case 13:Vr=!1;return;case 27:case 3:Vr=!0;return;default:An=An.return}}function bl(a){if(a!==An)return!1;if(!ut)return sC(a),ut=!0,!1;var c=a.tag,d;if((d=c!==3&&c!==27)&&((d=c===5)&&(d=a.type,d=!(d!=="form"&&d!=="button")||Db(a.type,a.memoizedProps)),d=!d),d&&zt&&Hs(a),sC(a),c===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(317));zt=ME(a)}else if(c===31){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(317));zt=ME(a)}else c===27?(c=zt,no(a.type)?(a=zb,zb=null,zt=a):zt=c):zt=An?Ur(a.stateNode.nextSibling):null;return!0}function sa(){zt=An=null,ut=!1}function gy(){var a=Vs;return a!==null&&(fr===null?fr=a:fr.push.apply(fr,a),Vs=null),a}function Jc(a){Vs===null?Vs=[a]:Vs.push(a)}var yy=H(null),oa=null,Gi=null;function Us(a,c,d){pe(yy,c._currentValue),c._currentValue=d}function Wi(a){a._currentValue=yy.current,Z(yy)}function by(a,c,d){for(;a!==null;){var p=a.alternate;if((a.childLanes&c)!==c?(a.childLanes|=c,p!==null&&(p.childLanes|=c)):p!==null&&(p.childLanes&c)!==c&&(p.childLanes|=c),a===d)break;a=a.return}}function vy(a,c,d,p){var v=a.child;for(v!==null&&(v.return=a);v!==null;){var w=v.dependencies;if(w!==null){var T=v.child;w=w.firstContext;e:for(;w!==null;){var N=w;w=v;for(var V=0;V<c.length;V++)if(N.context===c[V]){w.lanes|=d,N=w.alternate,N!==null&&(N.lanes|=d),by(w.return,d,a),p||(T=null);break e}w=N.next}}else if(v.tag===18){if(T=v.return,T===null)throw Error(r(341));T.lanes|=d,w=T.alternate,w!==null&&(w.lanes|=d),by(T,d,a),T=null}else T=v.child;if(T!==null)T.return=v;else for(T=v;T!==null;){if(T===a){T=null;break}if(v=T.sibling,v!==null){v.return=T.return,T=v;break}T=T.return}v=T}}function vl(a,c,d,p){a=null;for(var v=c,w=!1;v!==null;){if(!w){if((v.flags&524288)!==0)w=!0;else if((v.flags&262144)!==0)break}if(v.tag===10){var T=v.alternate;if(T===null)throw Error(r(387));if(T=T.memoizedProps,T!==null){var N=v.type;br(v.pendingProps.value,T.value)||(a!==null?a.push(N):a=[N])}}else if(v===$e.current){if(T=v.alternate,T===null)throw Error(r(387));T.memoizedState.memoizedState!==v.memoizedState.memoizedState&&(a!==null?a.push(Eu):a=[Eu])}v=v.return}a!==null&&vy(c,a,d,p),c.flags|=262144}function Ef(a){for(a=a.firstContext;a!==null;){if(!br(a.context._currentValue,a.memoizedValue))return!0;a=a.next}return!1}function aa(a){oa=a,Gi=null,a=a.dependencies,a!==null&&(a.firstContext=null)}function Rn(a){return oC(oa,a)}function Tf(a,c){return oa===null&&aa(a),oC(a,c)}function oC(a,c){var d=c._currentValue;if(c={context:c,memoizedValue:d,next:null},Gi===null){if(a===null)throw Error(r(308));Gi=c,a.dependencies={lanes:0,firstContext:c},a.flags|=524288}else Gi=Gi.next=c;return d}var pP=typeof AbortController<"u"?AbortController:function(){var a=[],c=this.signal={aborted:!1,addEventListener:function(d,p){a.push(p)}};this.abort=function(){c.aborted=!0,a.forEach(function(d){return d()})}},mP=t.unstable_scheduleCallback,gP=t.unstable_NormalPriority,sn={$$typeof:R,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function xy(){return{controller:new pP,data:new Map,refCount:0}}function Qc(a){a.refCount--,a.refCount===0&&mP(gP,function(){a.controller.abort()})}var eu=null,wy=0,xl=0,wl=null;function yP(a,c){if(eu===null){var d=eu=[];wy=0,xl=Cb(),wl={status:"pending",value:void 0,then:function(p){d.push(p)}}}return wy++,c.then(aC,aC),c}function aC(){if(--wy===0&&eu!==null){wl!==null&&(wl.status="fulfilled");var a=eu;eu=null,xl=0,wl=null;for(var c=0;c<a.length;c++)(0,a[c])()}}function bP(a,c){var d=[],p={status:"pending",value:null,reason:null,then:function(v){d.push(v)}};return a.then(function(){p.status="fulfilled",p.value=c;for(var v=0;v<d.length;v++)(0,d[v])(c)},function(v){for(p.status="rejected",p.reason=v,v=0;v<d.length;v++)(0,d[v])(void 0)}),p}var lC=z.S;z.S=function(a,c){q1=Ht(),typeof c=="object"&&c!==null&&typeof c.then=="function"&&yP(a,c),lC!==null&&lC(a,c)};var la=H(null);function Sy(){var a=la.current;return a!==null?a:Mt.pooledCache}function _f(a,c){c===null?pe(la,la.current):pe(la,c.pool)}function cC(){var a=Sy();return a===null?null:{parent:sn._currentValue,pool:a}}var Sl=Error(r(460)),ky=Error(r(474)),Af=Error(r(542)),Rf={then:function(){}};function uC(a){return a=a.status,a==="fulfilled"||a==="rejected"}function dC(a,c,d){switch(d=a[d],d===void 0?a.push(c):d!==c&&(c.then(Hi,Hi),c=d),c.status){case"fulfilled":return c.value;case"rejected":throw a=c.reason,hC(a),a;default:if(typeof c.status=="string")c.then(Hi,Hi);else{if(a=Mt,a!==null&&100<a.shellSuspendCounter)throw Error(r(482));a=c,a.status="pending",a.then(function(p){if(c.status==="pending"){var v=c;v.status="fulfilled",v.value=p}},function(p){if(c.status==="pending"){var v=c;v.status="rejected",v.reason=p}})}switch(c.status){case"fulfilled":return c.value;case"rejected":throw a=c.reason,hC(a),a}throw ua=c,Sl}}function ca(a){try{var c=a._init;return c(a._payload)}catch(d){throw d!==null&&typeof d=="object"&&typeof d.then=="function"?(ua=d,Sl):d}}var ua=null;function fC(){if(ua===null)throw Error(r(459));var a=ua;return ua=null,a}function hC(a){if(a===Sl||a===Af)throw Error(r(483))}var kl=null,tu=0;function Mf(a){var c=tu;return tu+=1,kl===null&&(kl=[]),dC(kl,a,c)}function nu(a,c){c=c.props.ref,a.ref=c!==void 0?c:null}function Nf(a,c){throw c.$$typeof===g?Error(r(525)):(a=Object.prototype.toString.call(c),Error(r(31,a==="[object Object]"?"object with keys {"+Object.keys(c).join(", ")+"}":a)))}function pC(a){function c(W,q){if(a){var Y=W.deletions;Y===null?(W.deletions=[q],W.flags|=16):Y.push(q)}}function d(W,q){if(!a)return null;for(;q!==null;)c(W,q),q=q.sibling;return null}function p(W){for(var q=new Map;W!==null;)W.key!==null?q.set(W.key,W):q.set(W.index,W),W=W.sibling;return q}function v(W,q){return W=Fi(W,q),W.index=0,W.sibling=null,W}function w(W,q,Y){return W.index=Y,a?(Y=W.alternate,Y!==null?(Y=Y.index,Y<q?(W.flags|=67108866,q):Y):(W.flags|=67108866,q)):(W.flags|=1048576,q)}function T(W){return a&&W.alternate===null&&(W.flags|=67108866),W}function N(W,q,Y,ce){return q===null||q.tag!==6?(q=dy(Y,W.mode,ce),q.return=W,q):(q=v(q,Y),q.return=W,q)}function V(W,q,Y,ce){var Ve=Y.type;return Ve===S?oe(W,q,Y.props.children,ce,Y.key):q!==null&&(q.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===I&&ca(Ve)===q.type)?(q=v(q,Y.props),nu(q,Y),q.return=W,q):(q=kf(Y.type,Y.key,Y.props,null,W.mode,ce),nu(q,Y),q.return=W,q)}function X(W,q,Y,ce){return q===null||q.tag!==4||q.stateNode.containerInfo!==Y.containerInfo||q.stateNode.implementation!==Y.implementation?(q=fy(Y,W.mode,ce),q.return=W,q):(q=v(q,Y.children||[]),q.return=W,q)}function oe(W,q,Y,ce,Ve){return q===null||q.tag!==7?(q=ia(Y,W.mode,ce,Ve),q.return=W,q):(q=v(q,Y),q.return=W,q)}function ue(W,q,Y){if(typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint")return q=dy(""+q,W.mode,Y),q.return=W,q;if(typeof q=="object"&&q!==null){switch(q.$$typeof){case b:return Y=kf(q.type,q.key,q.props,null,W.mode,Y),nu(Y,q),Y.return=W,Y;case x:return q=fy(q,W.mode,Y),q.return=W,q;case I:return q=ca(q),ue(W,q,Y)}if(fe(q)||K(q))return q=ia(q,W.mode,Y,null),q.return=W,q;if(typeof q.then=="function")return ue(W,Mf(q),Y);if(q.$$typeof===R)return ue(W,Tf(W,q),Y);Nf(W,q)}return null}function J(W,q,Y,ce){var Ve=q!==null?q.key:null;if(typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint")return Ve!==null?null:N(W,q,""+Y,ce);if(typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case b:return Y.key===Ve?V(W,q,Y,ce):null;case x:return Y.key===Ve?X(W,q,Y,ce):null;case I:return Y=ca(Y),J(W,q,Y,ce)}if(fe(Y)||K(Y))return Ve!==null?null:oe(W,q,Y,ce,null);if(typeof Y.then=="function")return J(W,q,Mf(Y),ce);if(Y.$$typeof===R)return J(W,q,Tf(W,Y),ce);Nf(W,Y)}return null}function te(W,q,Y,ce,Ve){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return W=W.get(Y)||null,N(q,W,""+ce,Ve);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case b:return W=W.get(ce.key===null?Y:ce.key)||null,V(q,W,ce,Ve);case x:return W=W.get(ce.key===null?Y:ce.key)||null,X(q,W,ce,Ve);case I:return ce=ca(ce),te(W,q,Y,ce,Ve)}if(fe(ce)||K(ce))return W=W.get(Y)||null,oe(q,W,ce,Ve,null);if(typeof ce.then=="function")return te(W,q,Y,Mf(ce),Ve);if(ce.$$typeof===R)return te(W,q,Y,Tf(q,ce),Ve);Nf(q,ce)}return null}function Oe(W,q,Y,ce){for(var Ve=null,ht=null,Le=q,nt=q=0,lt=null;Le!==null&&nt<Y.length;nt++){Le.index>nt?(lt=Le,Le=null):lt=Le.sibling;var pt=J(W,Le,Y[nt],ce);if(pt===null){Le===null&&(Le=lt);break}a&&Le&&pt.alternate===null&&c(W,Le),q=w(pt,q,nt),ht===null?Ve=pt:ht.sibling=pt,ht=pt,Le=lt}if(nt===Y.length)return d(W,Le),ut&&qi(W,nt),Ve;if(Le===null){for(;nt<Y.length;nt++)Le=ue(W,Y[nt],ce),Le!==null&&(q=w(Le,q,nt),ht===null?Ve=Le:ht.sibling=Le,ht=Le);return ut&&qi(W,nt),Ve}for(Le=p(Le);nt<Y.length;nt++)lt=te(Le,W,nt,Y[nt],ce),lt!==null&&(a&<.alternate!==null&&Le.delete(lt.key===null?nt:lt.key),q=w(lt,q,nt),ht===null?Ve=lt:ht.sibling=lt,ht=lt);return a&&Le.forEach(function(ao){return c(W,ao)}),ut&&qi(W,nt),Ve}function Fe(W,q,Y,ce){if(Y==null)throw Error(r(151));for(var Ve=null,ht=null,Le=q,nt=q=0,lt=null,pt=Y.next();Le!==null&&!pt.done;nt++,pt=Y.next()){Le.index>nt?(lt=Le,Le=null):lt=Le.sibling;var ao=J(W,Le,pt.value,ce);if(ao===null){Le===null&&(Le=lt);break}a&&Le&&ao.alternate===null&&c(W,Le),q=w(ao,q,nt),ht===null?Ve=ao:ht.sibling=ao,ht=ao,Le=lt}if(pt.done)return d(W,Le),ut&&qi(W,nt),Ve;if(Le===null){for(;!pt.done;nt++,pt=Y.next())pt=ue(W,pt.value,ce),pt!==null&&(q=w(pt,q,nt),ht===null?Ve=pt:ht.sibling=pt,ht=pt);return ut&&qi(W,nt),Ve}for(Le=p(Le);!pt.done;nt++,pt=Y.next())pt=te(Le,W,nt,pt.value,ce),pt!==null&&(a&&pt.alternate!==null&&Le.delete(pt.key===null?nt:pt.key),q=w(pt,q,nt),ht===null?Ve=pt:ht.sibling=pt,ht=pt);return a&&Le.forEach(function(Rz){return c(W,Rz)}),ut&&qi(W,nt),Ve}function _t(W,q,Y,ce){if(typeof Y=="object"&&Y!==null&&Y.type===S&&Y.key===null&&(Y=Y.props.children),typeof Y=="object"&&Y!==null){switch(Y.$$typeof){case b:e:{for(var Ve=Y.key;q!==null;){if(q.key===Ve){if(Ve=Y.type,Ve===S){if(q.tag===7){d(W,q.sibling),ce=v(q,Y.props.children),ce.return=W,W=ce;break e}}else if(q.elementType===Ve||typeof Ve=="object"&&Ve!==null&&Ve.$$typeof===I&&ca(Ve)===q.type){d(W,q.sibling),ce=v(q,Y.props),nu(ce,Y),ce.return=W,W=ce;break e}d(W,q);break}else c(W,q);q=q.sibling}Y.type===S?(ce=ia(Y.props.children,W.mode,ce,Y.key),ce.return=W,W=ce):(ce=kf(Y.type,Y.key,Y.props,null,W.mode,ce),nu(ce,Y),ce.return=W,W=ce)}return T(W);case x:e:{for(Ve=Y.key;q!==null;){if(q.key===Ve)if(q.tag===4&&q.stateNode.containerInfo===Y.containerInfo&&q.stateNode.implementation===Y.implementation){d(W,q.sibling),ce=v(q,Y.children||[]),ce.return=W,W=ce;break e}else{d(W,q);break}else c(W,q);q=q.sibling}ce=fy(Y,W.mode,ce),ce.return=W,W=ce}return T(W);case I:return Y=ca(Y),_t(W,q,Y,ce)}if(fe(Y))return Oe(W,q,Y,ce);if(K(Y)){if(Ve=K(Y),typeof Ve!="function")throw Error(r(150));return Y=Ve.call(Y),Fe(W,q,Y,ce)}if(typeof Y.then=="function")return _t(W,q,Mf(Y),ce);if(Y.$$typeof===R)return _t(W,q,Tf(W,Y),ce);Nf(W,Y)}return typeof Y=="string"&&Y!==""||typeof Y=="number"||typeof Y=="bigint"?(Y=""+Y,q!==null&&q.tag===6?(d(W,q.sibling),ce=v(q,Y),ce.return=W,W=ce):(d(W,q),ce=dy(Y,W.mode,ce),ce.return=W,W=ce),T(W)):d(W,q)}return function(W,q,Y,ce){try{tu=0;var Ve=_t(W,q,Y,ce);return kl=null,Ve}catch(Le){if(Le===Sl||Le===Af)throw Le;var ht=vr(29,Le,null,W.mode);return ht.lanes=ce,ht.return=W,ht}}}var da=pC(!0),mC=pC(!1),Fs=!1;function Cy(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ey(a,c){a=a.updateQueue,c.updateQueue===a&&(c.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,callbacks:null})}function qs(a){return{lane:a,tag:0,payload:null,callback:null,next:null}}function Gs(a,c,d){var p=a.updateQueue;if(p===null)return null;if(p=p.shared,(bt&2)!==0){var v=p.pending;return v===null?c.next=c:(c.next=v.next,v.next=c),p.pending=c,c=Sf(a),Jk(a,null,d),c}return wf(a,p,c,d),Sf(a)}function ru(a,c,d){if(c=c.updateQueue,c!==null&&(c=c.shared,(d&4194048)!==0)){var p=c.lanes;p&=a.pendingLanes,d|=p,c.lanes=d,ok(a,d)}}function Ty(a,c){var d=a.updateQueue,p=a.alternate;if(p!==null&&(p=p.updateQueue,d===p)){var v=null,w=null;if(d=d.firstBaseUpdate,d!==null){do{var T={lane:d.lane,tag:d.tag,payload:d.payload,callback:null,next:null};w===null?v=w=T:w=w.next=T,d=d.next}while(d!==null);w===null?v=w=c:w=w.next=c}else v=w=c;d={baseState:p.baseState,firstBaseUpdate:v,lastBaseUpdate:w,shared:p.shared,callbacks:p.callbacks},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=c:a.next=c,d.lastBaseUpdate=c}var _y=!1;function iu(){if(_y){var a=wl;if(a!==null)throw a}}function su(a,c,d,p){_y=!1;var v=a.updateQueue;Fs=!1;var w=v.firstBaseUpdate,T=v.lastBaseUpdate,N=v.shared.pending;if(N!==null){v.shared.pending=null;var V=N,X=V.next;V.next=null,T===null?w=X:T.next=X,T=V;var oe=a.alternate;oe!==null&&(oe=oe.updateQueue,N=oe.lastBaseUpdate,N!==T&&(N===null?oe.firstBaseUpdate=X:N.next=X,oe.lastBaseUpdate=V))}if(w!==null){var ue=v.baseState;T=0,oe=X=V=null,N=w;do{var J=N.lane&-536870913,te=J!==N.lane;if(te?(at&J)===J:(p&J)===J){J!==0&&J===xl&&(_y=!0),oe!==null&&(oe=oe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var Oe=a,Fe=N;J=c;var _t=d;switch(Fe.tag){case 1:if(Oe=Fe.payload,typeof Oe=="function"){ue=Oe.call(_t,ue,J);break e}ue=Oe;break e;case 3:Oe.flags=Oe.flags&-65537|128;case 0:if(Oe=Fe.payload,J=typeof Oe=="function"?Oe.call(_t,ue,J):Oe,J==null)break e;ue=m({},ue,J);break e;case 2:Fs=!0}}J=N.callback,J!==null&&(a.flags|=64,te&&(a.flags|=8192),te=v.callbacks,te===null?v.callbacks=[J]:te.push(J))}else te={lane:J,tag:N.tag,payload:N.payload,callback:N.callback,next:null},oe===null?(X=oe=te,V=ue):oe=oe.next=te,T|=J;if(N=N.next,N===null){if(N=v.shared.pending,N===null)break;te=N,N=te.next,te.next=null,v.lastBaseUpdate=te,v.shared.pending=null}}while(!0);oe===null&&(V=ue),v.baseState=V,v.firstBaseUpdate=X,v.lastBaseUpdate=oe,w===null&&(v.shared.lanes=0),Xs|=T,a.lanes=T,a.memoizedState=ue}}function gC(a,c){if(typeof a!="function")throw Error(r(191,a));a.call(c)}function yC(a,c){var d=a.callbacks;if(d!==null)for(a.callbacks=null,a=0;a<d.length;a++)gC(d[a],c)}var Cl=H(null),Of=H(0);function bC(a,c){a=ns,pe(Of,a),pe(Cl,c),ns=a|c.baseLanes}function Ay(){pe(Of,ns),pe(Cl,Cl.current)}function Ry(){ns=Of.current,Z(Cl),Z(Of)}var xr=H(null),Hr=null;function Ws(a){var c=a.alternate;pe(en,en.current&1),pe(xr,a),Hr===null&&(c===null||Cl.current!==null||c.memoizedState!==null)&&(Hr=a)}function My(a){pe(en,en.current),pe(xr,a),Hr===null&&(Hr=a)}function vC(a){a.tag===22?(pe(en,en.current),pe(xr,a),Hr===null&&(Hr=a)):Ks()}function Ks(){pe(en,en.current),pe(xr,xr.current)}function wr(a){Z(xr),Hr===a&&(Hr=null),Z(en)}var en=H(0);function Df(a){for(var c=a;c!==null;){if(c.tag===13){var d=c.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||Lb(d)||Pb(d)))return c}else if(c.tag===19&&(c.memoizedProps.revealOrder==="forwards"||c.memoizedProps.revealOrder==="backwards"||c.memoizedProps.revealOrder==="unstable_legacy-backwards"||c.memoizedProps.revealOrder==="together")){if((c.flags&128)!==0)return c}else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return null;c=c.return}c.sibling.return=c.return,c=c.sibling}return null}var Ki=0,tt=null,Et=null,on=null,If=!1,El=!1,fa=!1,jf=0,ou=0,Tl=null,vP=0;function Kt(){throw Error(r(321))}function Ny(a,c){if(c===null)return!1;for(var d=0;d<c.length&&d<a.length;d++)if(!br(a[d],c[d]))return!1;return!0}function Oy(a,c,d,p,v,w){return Ki=w,tt=c,c.memoizedState=null,c.updateQueue=null,c.lanes=0,z.H=a===null||a.memoizedState===null?n1:Wy,fa=!1,w=d(p,v),fa=!1,El&&(w=wC(c,d,p,v)),xC(a),w}function xC(a){z.H=cu;var c=Et!==null&&Et.next!==null;if(Ki=0,on=Et=tt=null,If=!1,ou=0,Tl=null,c)throw Error(r(300));a===null||an||(a=a.dependencies,a!==null&&Ef(a)&&(an=!0))}function wC(a,c,d,p){tt=a;var v=0;do{if(El&&(Tl=null),ou=0,El=!1,25<=v)throw Error(r(301));if(v+=1,on=Et=null,a.updateQueue!=null){var w=a.updateQueue;w.lastEffect=null,w.events=null,w.stores=null,w.memoCache!=null&&(w.memoCache.index=0)}z.H=r1,w=c(d,p)}while(El);return w}function xP(){var a=z.H,c=a.useState()[0];return c=typeof c.then=="function"?au(c):c,a=a.useState()[0],(Et!==null?Et.memoizedState:null)!==a&&(tt.flags|=1024),c}function Dy(){var a=jf!==0;return jf=0,a}function Iy(a,c,d){c.updateQueue=a.updateQueue,c.flags&=-2053,a.lanes&=~d}function jy(a){if(If){for(a=a.memoizedState;a!==null;){var c=a.queue;c!==null&&(c.pending=null),a=a.next}If=!1}Ki=0,on=Et=tt=null,El=!1,ou=jf=0,Tl=null}function Yn(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return on===null?tt.memoizedState=on=a:on=on.next=a,on}function tn(){if(Et===null){var a=tt.alternate;a=a!==null?a.memoizedState:null}else a=Et.next;var c=on===null?tt.memoizedState:on.next;if(c!==null)on=c,Et=a;else{if(a===null)throw tt.alternate===null?Error(r(467)):Error(r(310));Et=a,a={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},on===null?tt.memoizedState=on=a:on=on.next=a}return on}function Lf(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function au(a){var c=ou;return ou+=1,Tl===null&&(Tl=[]),a=dC(Tl,a,c),c=tt,(on===null?c.memoizedState:on.next)===null&&(c=c.alternate,z.H=c===null||c.memoizedState===null?n1:Wy),a}function Pf(a){if(a!==null&&typeof a=="object"){if(typeof a.then=="function")return au(a);if(a.$$typeof===R)return Rn(a)}throw Error(r(438,String(a)))}function Ly(a){var c=null,d=tt.updateQueue;if(d!==null&&(c=d.memoCache),c==null){var p=tt.alternate;p!==null&&(p=p.updateQueue,p!==null&&(p=p.memoCache,p!=null&&(c={data:p.data.map(function(v){return v.slice()}),index:0})))}if(c==null&&(c={data:[],index:0}),d===null&&(d=Lf(),tt.updateQueue=d),d.memoCache=c,d=c.data[c.index],d===void 0)for(d=c.data[c.index]=Array(a),p=0;p<a;p++)d[p]=B;return c.index++,d}function Zi(a,c){return typeof c=="function"?c(a):c}function zf(a){var c=tn();return Py(c,Et,a)}function Py(a,c,d){var p=a.queue;if(p===null)throw Error(r(311));p.lastRenderedReducer=d;var v=a.baseQueue,w=p.pending;if(w!==null){if(v!==null){var T=v.next;v.next=w.next,w.next=T}c.baseQueue=v=w,p.pending=null}if(w=a.baseState,v===null)a.memoizedState=w;else{c=v.next;var N=T=null,V=null,X=c,oe=!1;do{var ue=X.lane&-536870913;if(ue!==X.lane?(at&ue)===ue:(Ki&ue)===ue){var J=X.revertLane;if(J===0)V!==null&&(V=V.next={lane:0,revertLane:0,gesture:null,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null}),ue===xl&&(oe=!0);else if((Ki&J)===J){X=X.next,J===xl&&(oe=!0);continue}else ue={lane:0,revertLane:X.revertLane,gesture:null,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null},V===null?(N=V=ue,T=w):V=V.next=ue,tt.lanes|=J,Xs|=J;ue=X.action,fa&&d(w,ue),w=X.hasEagerState?X.eagerState:d(w,ue)}else J={lane:ue,revertLane:X.revertLane,gesture:X.gesture,action:X.action,hasEagerState:X.hasEagerState,eagerState:X.eagerState,next:null},V===null?(N=V=J,T=w):V=V.next=J,tt.lanes|=ue,Xs|=ue;X=X.next}while(X!==null&&X!==c);if(V===null?T=w:V.next=N,!br(w,a.memoizedState)&&(an=!0,oe&&(d=wl,d!==null)))throw d;a.memoizedState=w,a.baseState=T,a.baseQueue=V,p.lastRenderedState=w}return v===null&&(p.lanes=0),[a.memoizedState,p.dispatch]}function zy(a){var c=tn(),d=c.queue;if(d===null)throw Error(r(311));d.lastRenderedReducer=a;var p=d.dispatch,v=d.pending,w=c.memoizedState;if(v!==null){d.pending=null;var T=v=v.next;do w=a(w,T.action),T=T.next;while(T!==v);br(w,c.memoizedState)||(an=!0),c.memoizedState=w,c.baseQueue===null&&(c.baseState=w),d.lastRenderedState=w}return[w,p]}function SC(a,c,d){var p=tt,v=tn(),w=ut;if(w){if(d===void 0)throw Error(r(407));d=d()}else d=c();var T=!br((Et||v).memoizedState,d);if(T&&(v.memoizedState=d,an=!0),v=v.queue,Vy(EC.bind(null,p,v,a),[a]),v.getSnapshot!==c||T||on!==null&&on.memoizedState.tag&1){if(p.flags|=2048,_l(9,{destroy:void 0},CC.bind(null,p,v,d,c),null),Mt===null)throw Error(r(349));w||(Ki&127)!==0||kC(p,c,d)}return d}function kC(a,c,d){a.flags|=16384,a={getSnapshot:c,value:d},c=tt.updateQueue,c===null?(c=Lf(),tt.updateQueue=c,c.stores=[a]):(d=c.stores,d===null?c.stores=[a]:d.push(a))}function CC(a,c,d,p){c.value=d,c.getSnapshot=p,TC(c)&&_C(a)}function EC(a,c,d){return d(function(){TC(c)&&_C(a)})}function TC(a){var c=a.getSnapshot;a=a.value;try{var d=c();return!br(a,d)}catch{return!0}}function _C(a){var c=ra(a,2);c!==null&&hr(c,a,2)}function $y(a){var c=Yn();if(typeof a=="function"){var d=a;if(a=d(),fa){le(!0);try{d()}finally{le(!1)}}}return c.memoizedState=c.baseState=a,c.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zi,lastRenderedState:a},c}function AC(a,c,d,p){return a.baseState=d,Py(a,Et,typeof p=="function"?p:Zi)}function wP(a,c,d,p,v){if(Vf(a))throw Error(r(485));if(a=c.action,a!==null){var w={payload:v,action:a,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(T){w.listeners.push(T)}};z.T!==null?d(!0):w.isTransition=!1,p(w),d=c.pending,d===null?(w.next=c.pending=w,RC(c,w)):(w.next=d.next,c.pending=d.next=w)}}function RC(a,c){var d=c.action,p=c.payload,v=a.state;if(c.isTransition){var w=z.T,T={};z.T=T;try{var N=d(v,p),V=z.S;V!==null&&V(T,N),MC(a,c,N)}catch(X){By(a,c,X)}finally{w!==null&&T.types!==null&&(w.types=T.types),z.T=w}}else try{w=d(v,p),MC(a,c,w)}catch(X){By(a,c,X)}}function MC(a,c,d){d!==null&&typeof d=="object"&&typeof d.then=="function"?d.then(function(p){NC(a,c,p)},function(p){return By(a,c,p)}):NC(a,c,d)}function NC(a,c,d){c.status="fulfilled",c.value=d,OC(c),a.state=d,c=a.pending,c!==null&&(d=c.next,d===c?a.pending=null:(d=d.next,c.next=d,RC(a,d)))}function By(a,c,d){var p=a.pending;if(a.pending=null,p!==null){p=p.next;do c.status="rejected",c.reason=d,OC(c),c=c.next;while(c!==p)}a.action=null}function OC(a){a=a.listeners;for(var c=0;c<a.length;c++)(0,a[c])()}function DC(a,c){return c}function IC(a,c){if(ut){var d=Mt.formState;if(d!==null){e:{var p=tt;if(ut){if(zt){t:{for(var v=zt,w=Vr;v.nodeType!==8;){if(!w){v=null;break t}if(v=Ur(v.nextSibling),v===null){v=null;break t}}w=v.data,v=w==="F!"||w==="F"?v:null}if(v){zt=Ur(v.nextSibling),p=v.data==="F!";break e}}Hs(p)}p=!1}p&&(c=d[0])}}return d=Yn(),d.memoizedState=d.baseState=c,p={pending:null,lanes:0,dispatch:null,lastRenderedReducer:DC,lastRenderedState:c},d.queue=p,d=QC.bind(null,tt,p),p.dispatch=d,p=$y(!1),w=Gy.bind(null,tt,!1,p.queue),p=Yn(),v={state:c,dispatch:null,action:a,pending:null},p.queue=v,d=wP.bind(null,tt,v,w,d),v.dispatch=d,p.memoizedState=a,[c,d,!1]}function jC(a){var c=tn();return LC(c,Et,a)}function LC(a,c,d){if(c=Py(a,c,DC)[0],a=zf(Zi)[0],typeof c=="object"&&c!==null&&typeof c.then=="function")try{var p=au(c)}catch(T){throw T===Sl?Af:T}else p=c;c=tn();var v=c.queue,w=v.dispatch;return d!==c.memoizedState&&(tt.flags|=2048,_l(9,{destroy:void 0},SP.bind(null,v,d),null)),[p,w,a]}function SP(a,c){a.action=c}function PC(a){var c=tn(),d=Et;if(d!==null)return LC(c,d,a);tn(),c=c.memoizedState,d=tn();var p=d.queue.dispatch;return d.memoizedState=a,[c,p,!1]}function _l(a,c,d,p){return a={tag:a,create:d,deps:p,inst:c,next:null},c=tt.updateQueue,c===null&&(c=Lf(),tt.updateQueue=c),d=c.lastEffect,d===null?c.lastEffect=a.next=a:(p=d.next,d.next=a,a.next=p,c.lastEffect=a),a}function zC(){return tn().memoizedState}function $f(a,c,d,p){var v=Yn();tt.flags|=a,v.memoizedState=_l(1|c,{destroy:void 0},d,p===void 0?null:p)}function Bf(a,c,d,p){var v=tn();p=p===void 0?null:p;var w=v.memoizedState.inst;Et!==null&&p!==null&&Ny(p,Et.memoizedState.deps)?v.memoizedState=_l(c,w,d,p):(tt.flags|=a,v.memoizedState=_l(1|c,w,d,p))}function $C(a,c){$f(8390656,8,a,c)}function Vy(a,c){Bf(2048,8,a,c)}function kP(a){tt.flags|=4;var c=tt.updateQueue;if(c===null)c=Lf(),tt.updateQueue=c,c.events=[a];else{var d=c.events;d===null?c.events=[a]:d.push(a)}}function BC(a){var c=tn().memoizedState;return kP({ref:c,nextImpl:a}),function(){if((bt&2)!==0)throw Error(r(440));return c.impl.apply(void 0,arguments)}}function VC(a,c){return Bf(4,2,a,c)}function HC(a,c){return Bf(4,4,a,c)}function UC(a,c){if(typeof c=="function"){a=a();var d=c(a);return function(){typeof d=="function"?d():c(null)}}if(c!=null)return a=a(),c.current=a,function(){c.current=null}}function FC(a,c,d){d=d!=null?d.concat([a]):null,Bf(4,4,UC.bind(null,c,a),d)}function Hy(){}function qC(a,c){var d=tn();c=c===void 0?null:c;var p=d.memoizedState;return c!==null&&Ny(c,p[1])?p[0]:(d.memoizedState=[a,c],a)}function GC(a,c){var d=tn();c=c===void 0?null:c;var p=d.memoizedState;if(c!==null&&Ny(c,p[1]))return p[0];if(p=a(),fa){le(!0);try{a()}finally{le(!1)}}return d.memoizedState=[p,c],p}function Uy(a,c,d){return d===void 0||(Ki&1073741824)!==0&&(at&261930)===0?a.memoizedState=c:(a.memoizedState=d,a=W1(),tt.lanes|=a,Xs|=a,d)}function WC(a,c,d,p){return br(d,c)?d:Cl.current!==null?(a=Uy(a,d,p),br(a,c)||(an=!0),a):(Ki&42)===0||(Ki&1073741824)!==0&&(at&261930)===0?(an=!0,a.memoizedState=d):(a=W1(),tt.lanes|=a,Xs|=a,c)}function KC(a,c,d,p,v){var w=L.p;L.p=w!==0&&8>w?w:8;var T=z.T,N={};z.T=N,Gy(a,!1,c,d);try{var V=v(),X=z.S;if(X!==null&&X(N,V),V!==null&&typeof V=="object"&&typeof V.then=="function"){var oe=bP(V,p);lu(a,c,oe,Cr(a))}else lu(a,c,p,Cr(a))}catch(ue){lu(a,c,{then:function(){},status:"rejected",reason:ue},Cr())}finally{L.p=w,T!==null&&N.types!==null&&(T.types=N.types),z.T=T}}function CP(){}function Fy(a,c,d,p){if(a.tag!==5)throw Error(r(476));var v=ZC(a).queue;KC(a,v,c,G,d===null?CP:function(){return YC(a),d(p)})}function ZC(a){var c=a.memoizedState;if(c!==null)return c;c={memoizedState:G,baseState:G,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zi,lastRenderedState:G},next:null};var d={};return c.next={memoizedState:d,baseState:d,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zi,lastRenderedState:d},next:null},a.memoizedState=c,a=a.alternate,a!==null&&(a.memoizedState=c),c}function YC(a){var c=ZC(a);c.next===null&&(c=a.alternate.memoizedState),lu(a,c.next.queue,{},Cr())}function qy(){return Rn(Eu)}function XC(){return tn().memoizedState}function JC(){return tn().memoizedState}function EP(a){for(var c=a.return;c!==null;){switch(c.tag){case 24:case 3:var d=Cr();a=qs(d);var p=Gs(c,a,d);p!==null&&(hr(p,c,d),ru(p,c,d)),c={cache:xy()},a.payload=c;return}c=c.return}}function TP(a,c,d){var p=Cr();d={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Vf(a)?e1(c,d):(d=cy(a,c,d,p),d!==null&&(hr(d,a,p),t1(d,c,p)))}function QC(a,c,d){var p=Cr();lu(a,c,d,p)}function lu(a,c,d,p){var v={lane:p,revertLane:0,gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null};if(Vf(a))e1(c,v);else{var w=a.alternate;if(a.lanes===0&&(w===null||w.lanes===0)&&(w=c.lastRenderedReducer,w!==null))try{var T=c.lastRenderedState,N=w(T,d);if(v.hasEagerState=!0,v.eagerState=N,br(N,T))return wf(a,c,v,0),Mt===null&&xf(),!1}catch{}if(d=cy(a,c,v,p),d!==null)return hr(d,a,p),t1(d,c,p),!0}return!1}function Gy(a,c,d,p){if(p={lane:2,revertLane:Cb(),gesture:null,action:p,hasEagerState:!1,eagerState:null,next:null},Vf(a)){if(c)throw Error(r(479))}else c=cy(a,d,p,2),c!==null&&hr(c,a,2)}function Vf(a){var c=a.alternate;return a===tt||c!==null&&c===tt}function e1(a,c){El=If=!0;var d=a.pending;d===null?c.next=c:(c.next=d.next,d.next=c),a.pending=c}function t1(a,c,d){if((d&4194048)!==0){var p=c.lanes;p&=a.pendingLanes,d|=p,c.lanes=d,ok(a,d)}}var cu={readContext:Rn,use:Pf,useCallback:Kt,useContext:Kt,useEffect:Kt,useImperativeHandle:Kt,useLayoutEffect:Kt,useInsertionEffect:Kt,useMemo:Kt,useReducer:Kt,useRef:Kt,useState:Kt,useDebugValue:Kt,useDeferredValue:Kt,useTransition:Kt,useSyncExternalStore:Kt,useId:Kt,useHostTransitionStatus:Kt,useFormState:Kt,useActionState:Kt,useOptimistic:Kt,useMemoCache:Kt,useCacheRefresh:Kt};cu.useEffectEvent=Kt;var n1={readContext:Rn,use:Pf,useCallback:function(a,c){return Yn().memoizedState=[a,c===void 0?null:c],a},useContext:Rn,useEffect:$C,useImperativeHandle:function(a,c,d){d=d!=null?d.concat([a]):null,$f(4194308,4,UC.bind(null,c,a),d)},useLayoutEffect:function(a,c){return $f(4194308,4,a,c)},useInsertionEffect:function(a,c){$f(4,2,a,c)},useMemo:function(a,c){var d=Yn();c=c===void 0?null:c;var p=a();if(fa){le(!0);try{a()}finally{le(!1)}}return d.memoizedState=[p,c],p},useReducer:function(a,c,d){var p=Yn();if(d!==void 0){var v=d(c);if(fa){le(!0);try{d(c)}finally{le(!1)}}}else v=c;return p.memoizedState=p.baseState=v,a={pending:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:v},p.queue=a,a=a.dispatch=TP.bind(null,tt,a),[p.memoizedState,a]},useRef:function(a){var c=Yn();return a={current:a},c.memoizedState=a},useState:function(a){a=$y(a);var c=a.queue,d=QC.bind(null,tt,c);return c.dispatch=d,[a.memoizedState,d]},useDebugValue:Hy,useDeferredValue:function(a,c){var d=Yn();return Uy(d,a,c)},useTransition:function(){var a=$y(!1);return a=KC.bind(null,tt,a.queue,!0,!1),Yn().memoizedState=a,[!1,a]},useSyncExternalStore:function(a,c,d){var p=tt,v=Yn();if(ut){if(d===void 0)throw Error(r(407));d=d()}else{if(d=c(),Mt===null)throw Error(r(349));(at&127)!==0||kC(p,c,d)}v.memoizedState=d;var w={value:d,getSnapshot:c};return v.queue=w,$C(EC.bind(null,p,w,a),[a]),p.flags|=2048,_l(9,{destroy:void 0},CC.bind(null,p,w,d,c),null),d},useId:function(){var a=Yn(),c=Mt.identifierPrefix;if(ut){var d=ki,p=Si;d=(p&~(1<<32-be(p)-1)).toString(32)+d,c="_"+c+"R_"+d,d=jf++,0<d&&(c+="H"+d.toString(32)),c+="_"}else d=vP++,c="_"+c+"r_"+d.toString(32)+"_";return a.memoizedState=c},useHostTransitionStatus:qy,useFormState:IC,useActionState:IC,useOptimistic:function(a){var c=Yn();c.memoizedState=c.baseState=a;var d={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return c.queue=d,c=Gy.bind(null,tt,!0,d),d.dispatch=c,[a,c]},useMemoCache:Ly,useCacheRefresh:function(){return Yn().memoizedState=EP.bind(null,tt)},useEffectEvent:function(a){var c=Yn(),d={impl:a};return c.memoizedState=d,function(){if((bt&2)!==0)throw Error(r(440));return d.impl.apply(void 0,arguments)}}},Wy={readContext:Rn,use:Pf,useCallback:qC,useContext:Rn,useEffect:Vy,useImperativeHandle:FC,useInsertionEffect:VC,useLayoutEffect:HC,useMemo:GC,useReducer:zf,useRef:zC,useState:function(){return zf(Zi)},useDebugValue:Hy,useDeferredValue:function(a,c){var d=tn();return WC(d,Et.memoizedState,a,c)},useTransition:function(){var a=zf(Zi)[0],c=tn().memoizedState;return[typeof a=="boolean"?a:au(a),c]},useSyncExternalStore:SC,useId:XC,useHostTransitionStatus:qy,useFormState:jC,useActionState:jC,useOptimistic:function(a,c){var d=tn();return AC(d,Et,a,c)},useMemoCache:Ly,useCacheRefresh:JC};Wy.useEffectEvent=BC;var r1={readContext:Rn,use:Pf,useCallback:qC,useContext:Rn,useEffect:Vy,useImperativeHandle:FC,useInsertionEffect:VC,useLayoutEffect:HC,useMemo:GC,useReducer:zy,useRef:zC,useState:function(){return zy(Zi)},useDebugValue:Hy,useDeferredValue:function(a,c){var d=tn();return Et===null?Uy(d,a,c):WC(d,Et.memoizedState,a,c)},useTransition:function(){var a=zy(Zi)[0],c=tn().memoizedState;return[typeof a=="boolean"?a:au(a),c]},useSyncExternalStore:SC,useId:XC,useHostTransitionStatus:qy,useFormState:PC,useActionState:PC,useOptimistic:function(a,c){var d=tn();return Et!==null?AC(d,Et,a,c):(d.baseState=a,[a,d.queue.dispatch])},useMemoCache:Ly,useCacheRefresh:JC};r1.useEffectEvent=BC;function Ky(a,c,d,p){c=a.memoizedState,d=d(p,c),d=d==null?c:m({},c,d),a.memoizedState=d,a.lanes===0&&(a.updateQueue.baseState=d)}var Zy={enqueueSetState:function(a,c,d){a=a._reactInternals;var p=Cr(),v=qs(p);v.payload=c,d!=null&&(v.callback=d),c=Gs(a,v,p),c!==null&&(hr(c,a,p),ru(c,a,p))},enqueueReplaceState:function(a,c,d){a=a._reactInternals;var p=Cr(),v=qs(p);v.tag=1,v.payload=c,d!=null&&(v.callback=d),c=Gs(a,v,p),c!==null&&(hr(c,a,p),ru(c,a,p))},enqueueForceUpdate:function(a,c){a=a._reactInternals;var d=Cr(),p=qs(d);p.tag=2,c!=null&&(p.callback=c),c=Gs(a,p,d),c!==null&&(hr(c,a,d),ru(c,a,d))}};function i1(a,c,d,p,v,w,T){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(p,w,T):c.prototype&&c.prototype.isPureReactComponent?!Zc(d,p)||!Zc(v,w):!0}function s1(a,c,d,p){a=c.state,typeof c.componentWillReceiveProps=="function"&&c.componentWillReceiveProps(d,p),typeof c.UNSAFE_componentWillReceiveProps=="function"&&c.UNSAFE_componentWillReceiveProps(d,p),c.state!==a&&Zy.enqueueReplaceState(c,c.state,null)}function ha(a,c){var d=c;if("ref"in c){d={};for(var p in c)p!=="ref"&&(d[p]=c[p])}if(a=a.defaultProps){d===c&&(d=m({},d));for(var v in a)d[v]===void 0&&(d[v]=a[v])}return d}function o1(a){vf(a)}function a1(a){console.error(a)}function l1(a){vf(a)}function Hf(a,c){try{var d=a.onUncaughtError;d(c.value,{componentStack:c.stack})}catch(p){setTimeout(function(){throw p})}}function c1(a,c,d){try{var p=a.onCaughtError;p(d.value,{componentStack:d.stack,errorBoundary:c.tag===1?c.stateNode:null})}catch(v){setTimeout(function(){throw v})}}function Yy(a,c,d){return d=qs(d),d.tag=3,d.payload={element:null},d.callback=function(){Hf(a,c)},d}function u1(a){return a=qs(a),a.tag=3,a}function d1(a,c,d,p){var v=d.type.getDerivedStateFromError;if(typeof v=="function"){var w=p.value;a.payload=function(){return v(w)},a.callback=function(){c1(c,d,p)}}var T=d.stateNode;T!==null&&typeof T.componentDidCatch=="function"&&(a.callback=function(){c1(c,d,p),typeof v!="function"&&(Js===null?Js=new Set([this]):Js.add(this));var N=p.stack;this.componentDidCatch(p.value,{componentStack:N!==null?N:""})})}function _P(a,c,d,p,v){if(d.flags|=32768,p!==null&&typeof p=="object"&&typeof p.then=="function"){if(c=d.alternate,c!==null&&vl(c,d,v,!0),d=xr.current,d!==null){switch(d.tag){case 31:case 13:return Hr===null?eh():d.alternate===null&&Zt===0&&(Zt=3),d.flags&=-257,d.flags|=65536,d.lanes=v,p===Rf?d.flags|=16384:(c=d.updateQueue,c===null?d.updateQueue=new Set([p]):c.add(p),wb(a,p,v)),!1;case 22:return d.flags|=65536,p===Rf?d.flags|=16384:(c=d.updateQueue,c===null?(c={transitions:null,markerInstances:null,retryQueue:new Set([p])},d.updateQueue=c):(d=c.retryQueue,d===null?c.retryQueue=new Set([p]):d.add(p)),wb(a,p,v)),!1}throw Error(r(435,d.tag))}return wb(a,p,v),eh(),!1}if(ut)return c=xr.current,c!==null?((c.flags&65536)===0&&(c.flags|=256),c.flags|=65536,c.lanes=v,p!==my&&(a=Error(r(422),{cause:p}),Jc(zr(a,d)))):(p!==my&&(c=Error(r(423),{cause:p}),Jc(zr(c,d))),a=a.current.alternate,a.flags|=65536,v&=-v,a.lanes|=v,p=zr(p,d),v=Yy(a.stateNode,p,v),Ty(a,v),Zt!==4&&(Zt=2)),!1;var w=Error(r(520),{cause:p});if(w=zr(w,d),yu===null?yu=[w]:yu.push(w),Zt!==4&&(Zt=2),c===null)return!0;p=zr(p,d),d=c;do{switch(d.tag){case 3:return d.flags|=65536,a=v&-v,d.lanes|=a,a=Yy(d.stateNode,p,a),Ty(d,a),!1;case 1:if(c=d.type,w=d.stateNode,(d.flags&128)===0&&(typeof c.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Js===null||!Js.has(w))))return d.flags|=65536,v&=-v,d.lanes|=v,v=u1(v),d1(v,a,d,p),Ty(d,v),!1}d=d.return}while(d!==null);return!1}var Xy=Error(r(461)),an=!1;function Mn(a,c,d,p){c.child=a===null?mC(c,null,d,p):da(c,a.child,d,p)}function f1(a,c,d,p,v){d=d.render;var w=c.ref;if("ref"in p){var T={};for(var N in p)N!=="ref"&&(T[N]=p[N])}else T=p;return aa(c),p=Oy(a,c,d,T,w,v),N=Dy(),a!==null&&!an?(Iy(a,c,v),Yi(a,c,v)):(ut&&N&&hy(c),c.flags|=1,Mn(a,c,p,v),c.child)}function h1(a,c,d,p,v){if(a===null){var w=d.type;return typeof w=="function"&&!uy(w)&&w.defaultProps===void 0&&d.compare===null?(c.tag=15,c.type=w,p1(a,c,w,p,v)):(a=kf(d.type,null,p,c,c.mode,v),a.ref=c.ref,a.return=c,c.child=a)}if(w=a.child,!sb(a,v)){var T=w.memoizedProps;if(d=d.compare,d=d!==null?d:Zc,d(T,p)&&a.ref===c.ref)return Yi(a,c,v)}return c.flags|=1,a=Fi(w,p),a.ref=c.ref,a.return=c,c.child=a}function p1(a,c,d,p,v){if(a!==null){var w=a.memoizedProps;if(Zc(w,p)&&a.ref===c.ref)if(an=!1,c.pendingProps=p=w,sb(a,v))(a.flags&131072)!==0&&(an=!0);else return c.lanes=a.lanes,Yi(a,c,v)}return Jy(a,c,d,p,v)}function m1(a,c,d,p){var v=p.children,w=a!==null?a.memoizedState:null;if(a===null&&c.stateNode===null&&(c.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),p.mode==="hidden"){if((c.flags&128)!==0){if(w=w!==null?w.baseLanes|d:d,a!==null){for(p=c.child=a.child,v=0;p!==null;)v=v|p.lanes|p.childLanes,p=p.sibling;p=v&~w}else p=0,c.child=null;return g1(a,c,w,d,p)}if((d&536870912)!==0)c.memoizedState={baseLanes:0,cachePool:null},a!==null&&_f(c,w!==null?w.cachePool:null),w!==null?bC(c,w):Ay(),vC(c);else return p=c.lanes=536870912,g1(a,c,w!==null?w.baseLanes|d:d,d,p)}else w!==null?(_f(c,w.cachePool),bC(c,w),Ks(),c.memoizedState=null):(a!==null&&_f(c,null),Ay(),Ks());return Mn(a,c,v,d),c.child}function uu(a,c){return a!==null&&a.tag===22||c.stateNode!==null||(c.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),c.sibling}function g1(a,c,d,p,v){var w=Sy();return w=w===null?null:{parent:sn._currentValue,pool:w},c.memoizedState={baseLanes:d,cachePool:w},a!==null&&_f(c,null),Ay(),vC(c),a!==null&&vl(a,c,p,!0),c.childLanes=v,null}function Uf(a,c){return c=qf({mode:c.mode,children:c.children},a.mode),c.ref=a.ref,a.child=c,c.return=a,c}function y1(a,c,d){return da(c,a.child,null,d),a=Uf(c,c.pendingProps),a.flags|=2,wr(c),c.memoizedState=null,a}function AP(a,c,d){var p=c.pendingProps,v=(c.flags&128)!==0;if(c.flags&=-129,a===null){if(ut){if(p.mode==="hidden")return a=Uf(c,p),c.lanes=536870912,uu(null,a);if(My(c),(a=zt)?(a=RE(a,Vr),a=a!==null&&a.data==="&"?a:null,a!==null&&(c.memoizedState={dehydrated:a,treeContext:Bs!==null?{id:Si,overflow:ki}:null,retryLane:536870912,hydrationErrors:null},d=eC(a),d.return=c,c.child=d,An=c,zt=null)):a=null,a===null)throw Hs(c);return c.lanes=536870912,null}return Uf(c,p)}var w=a.memoizedState;if(w!==null){var T=w.dehydrated;if(My(c),v)if(c.flags&256)c.flags&=-257,c=y1(a,c,d);else if(c.memoizedState!==null)c.child=a.child,c.flags|=128,c=null;else throw Error(r(558));else if(an||vl(a,c,d,!1),v=(d&a.childLanes)!==0,an||v){if(p=Mt,p!==null&&(T=ak(p,d),T!==0&&T!==w.retryLane))throw w.retryLane=T,ra(a,T),hr(p,a,T),Xy;eh(),c=y1(a,c,d)}else a=w.treeContext,zt=Ur(T.nextSibling),An=c,ut=!0,Vs=null,Vr=!1,a!==null&&rC(c,a),c=Uf(c,p),c.flags|=4096;return c}return a=Fi(a.child,{mode:p.mode,children:p.children}),a.ref=c.ref,c.child=a,a.return=c,a}function Ff(a,c){var d=c.ref;if(d===null)a!==null&&a.ref!==null&&(c.flags|=4194816);else{if(typeof d!="function"&&typeof d!="object")throw Error(r(284));(a===null||a.ref!==d)&&(c.flags|=4194816)}}function Jy(a,c,d,p,v){return aa(c),d=Oy(a,c,d,p,void 0,v),p=Dy(),a!==null&&!an?(Iy(a,c,v),Yi(a,c,v)):(ut&&p&&hy(c),c.flags|=1,Mn(a,c,d,v),c.child)}function b1(a,c,d,p,v,w){return aa(c),c.updateQueue=null,d=wC(c,p,d,v),xC(a),p=Dy(),a!==null&&!an?(Iy(a,c,w),Yi(a,c,w)):(ut&&p&&hy(c),c.flags|=1,Mn(a,c,d,w),c.child)}function v1(a,c,d,p,v){if(aa(c),c.stateNode===null){var w=ml,T=d.contextType;typeof T=="object"&&T!==null&&(w=Rn(T)),w=new d(p,w),c.memoizedState=w.state!==null&&w.state!==void 0?w.state:null,w.updater=Zy,c.stateNode=w,w._reactInternals=c,w=c.stateNode,w.props=p,w.state=c.memoizedState,w.refs={},Cy(c),T=d.contextType,w.context=typeof T=="object"&&T!==null?Rn(T):ml,w.state=c.memoizedState,T=d.getDerivedStateFromProps,typeof T=="function"&&(Ky(c,d,T,p),w.state=c.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof w.getSnapshotBeforeUpdate=="function"||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(T=w.state,typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount(),T!==w.state&&Zy.enqueueReplaceState(w,w.state,null),su(c,p,w,v),iu(),w.state=c.memoizedState),typeof w.componentDidMount=="function"&&(c.flags|=4194308),p=!0}else if(a===null){w=c.stateNode;var N=c.memoizedProps,V=ha(d,N);w.props=V;var X=w.context,oe=d.contextType;T=ml,typeof oe=="object"&&oe!==null&&(T=Rn(oe));var ue=d.getDerivedStateFromProps;oe=typeof ue=="function"||typeof w.getSnapshotBeforeUpdate=="function",N=c.pendingProps!==N,oe||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(N||X!==T)&&s1(c,w,p,T),Fs=!1;var J=c.memoizedState;w.state=J,su(c,p,w,v),iu(),X=c.memoizedState,N||J!==X||Fs?(typeof ue=="function"&&(Ky(c,d,ue,p),X=c.memoizedState),(V=Fs||i1(c,d,V,p,J,X,T))?(oe||typeof w.UNSAFE_componentWillMount!="function"&&typeof w.componentWillMount!="function"||(typeof w.componentWillMount=="function"&&w.componentWillMount(),typeof w.UNSAFE_componentWillMount=="function"&&w.UNSAFE_componentWillMount()),typeof w.componentDidMount=="function"&&(c.flags|=4194308)):(typeof w.componentDidMount=="function"&&(c.flags|=4194308),c.memoizedProps=p,c.memoizedState=X),w.props=p,w.state=X,w.context=T,p=V):(typeof w.componentDidMount=="function"&&(c.flags|=4194308),p=!1)}else{w=c.stateNode,Ey(a,c),T=c.memoizedProps,oe=ha(d,T),w.props=oe,ue=c.pendingProps,J=w.context,X=d.contextType,V=ml,typeof X=="object"&&X!==null&&(V=Rn(X)),N=d.getDerivedStateFromProps,(X=typeof N=="function"||typeof w.getSnapshotBeforeUpdate=="function")||typeof w.UNSAFE_componentWillReceiveProps!="function"&&typeof w.componentWillReceiveProps!="function"||(T!==ue||J!==V)&&s1(c,w,p,V),Fs=!1,J=c.memoizedState,w.state=J,su(c,p,w,v),iu();var te=c.memoizedState;T!==ue||J!==te||Fs||a!==null&&a.dependencies!==null&&Ef(a.dependencies)?(typeof N=="function"&&(Ky(c,d,N,p),te=c.memoizedState),(oe=Fs||i1(c,d,oe,p,J,te,V)||a!==null&&a.dependencies!==null&&Ef(a.dependencies))?(X||typeof w.UNSAFE_componentWillUpdate!="function"&&typeof w.componentWillUpdate!="function"||(typeof w.componentWillUpdate=="function"&&w.componentWillUpdate(p,te,V),typeof w.UNSAFE_componentWillUpdate=="function"&&w.UNSAFE_componentWillUpdate(p,te,V)),typeof w.componentDidUpdate=="function"&&(c.flags|=4),typeof w.getSnapshotBeforeUpdate=="function"&&(c.flags|=1024)):(typeof w.componentDidUpdate!="function"||T===a.memoizedProps&&J===a.memoizedState||(c.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&J===a.memoizedState||(c.flags|=1024),c.memoizedProps=p,c.memoizedState=te),w.props=p,w.state=te,w.context=V,p=oe):(typeof w.componentDidUpdate!="function"||T===a.memoizedProps&&J===a.memoizedState||(c.flags|=4),typeof w.getSnapshotBeforeUpdate!="function"||T===a.memoizedProps&&J===a.memoizedState||(c.flags|=1024),p=!1)}return w=p,Ff(a,c),p=(c.flags&128)!==0,w||p?(w=c.stateNode,d=p&&typeof d.getDerivedStateFromError!="function"?null:w.render(),c.flags|=1,a!==null&&p?(c.child=da(c,a.child,null,v),c.child=da(c,null,d,v)):Mn(a,c,d,v),c.memoizedState=w.state,a=c.child):a=Yi(a,c,v),a}function x1(a,c,d,p){return sa(),c.flags|=256,Mn(a,c,d,p),c.child}var Qy={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function eb(a){return{baseLanes:a,cachePool:cC()}}function tb(a,c,d){return a=a!==null?a.childLanes&~d:0,c&&(a|=kr),a}function w1(a,c,d){var p=c.pendingProps,v=!1,w=(c.flags&128)!==0,T;if((T=w)||(T=a!==null&&a.memoizedState===null?!1:(en.current&2)!==0),T&&(v=!0,c.flags&=-129),T=(c.flags&32)!==0,c.flags&=-33,a===null){if(ut){if(v?Ws(c):Ks(),(a=zt)?(a=RE(a,Vr),a=a!==null&&a.data!=="&"?a:null,a!==null&&(c.memoizedState={dehydrated:a,treeContext:Bs!==null?{id:Si,overflow:ki}:null,retryLane:536870912,hydrationErrors:null},d=eC(a),d.return=c,c.child=d,An=c,zt=null)):a=null,a===null)throw Hs(c);return Pb(a)?c.lanes=32:c.lanes=536870912,null}var N=p.children;return p=p.fallback,v?(Ks(),v=c.mode,N=qf({mode:"hidden",children:N},v),p=ia(p,v,d,null),N.return=c,p.return=c,N.sibling=p,c.child=N,p=c.child,p.memoizedState=eb(d),p.childLanes=tb(a,T,d),c.memoizedState=Qy,uu(null,p)):(Ws(c),nb(c,N))}var V=a.memoizedState;if(V!==null&&(N=V.dehydrated,N!==null)){if(w)c.flags&256?(Ws(c),c.flags&=-257,c=rb(a,c,d)):c.memoizedState!==null?(Ks(),c.child=a.child,c.flags|=128,c=null):(Ks(),N=p.fallback,v=c.mode,p=qf({mode:"visible",children:p.children},v),N=ia(N,v,d,null),N.flags|=2,p.return=c,N.return=c,p.sibling=N,c.child=p,da(c,a.child,null,d),p=c.child,p.memoizedState=eb(d),p.childLanes=tb(a,T,d),c.memoizedState=Qy,c=uu(null,p));else if(Ws(c),Pb(N)){if(T=N.nextSibling&&N.nextSibling.dataset,T)var X=T.dgst;T=X,p=Error(r(419)),p.stack="",p.digest=T,Jc({value:p,source:null,stack:null}),c=rb(a,c,d)}else if(an||vl(a,c,d,!1),T=(d&a.childLanes)!==0,an||T){if(T=Mt,T!==null&&(p=ak(T,d),p!==0&&p!==V.retryLane))throw V.retryLane=p,ra(a,p),hr(T,a,p),Xy;Lb(N)||eh(),c=rb(a,c,d)}else Lb(N)?(c.flags|=192,c.child=a.child,c=null):(a=V.treeContext,zt=Ur(N.nextSibling),An=c,ut=!0,Vs=null,Vr=!1,a!==null&&rC(c,a),c=nb(c,p.children),c.flags|=4096);return c}return v?(Ks(),N=p.fallback,v=c.mode,V=a.child,X=V.sibling,p=Fi(V,{mode:"hidden",children:p.children}),p.subtreeFlags=V.subtreeFlags&65011712,X!==null?N=Fi(X,N):(N=ia(N,v,d,null),N.flags|=2),N.return=c,p.return=c,p.sibling=N,c.child=p,uu(null,p),p=c.child,N=a.child.memoizedState,N===null?N=eb(d):(v=N.cachePool,v!==null?(V=sn._currentValue,v=v.parent!==V?{parent:V,pool:V}:v):v=cC(),N={baseLanes:N.baseLanes|d,cachePool:v}),p.memoizedState=N,p.childLanes=tb(a,T,d),c.memoizedState=Qy,uu(a.child,p)):(Ws(c),d=a.child,a=d.sibling,d=Fi(d,{mode:"visible",children:p.children}),d.return=c,d.sibling=null,a!==null&&(T=c.deletions,T===null?(c.deletions=[a],c.flags|=16):T.push(a)),c.child=d,c.memoizedState=null,d)}function nb(a,c){return c=qf({mode:"visible",children:c},a.mode),c.return=a,a.child=c}function qf(a,c){return a=vr(22,a,null,c),a.lanes=0,a}function rb(a,c,d){return da(c,a.child,null,d),a=nb(c,c.pendingProps.children),a.flags|=2,c.memoizedState=null,a}function S1(a,c,d){a.lanes|=c;var p=a.alternate;p!==null&&(p.lanes|=c),by(a.return,c,d)}function ib(a,c,d,p,v,w){var T=a.memoizedState;T===null?a.memoizedState={isBackwards:c,rendering:null,renderingStartTime:0,last:p,tail:d,tailMode:v,treeForkCount:w}:(T.isBackwards=c,T.rendering=null,T.renderingStartTime=0,T.last=p,T.tail=d,T.tailMode=v,T.treeForkCount=w)}function k1(a,c,d){var p=c.pendingProps,v=p.revealOrder,w=p.tail;p=p.children;var T=en.current,N=(T&2)!==0;if(N?(T=T&1|2,c.flags|=128):T&=1,pe(en,T),Mn(a,c,p,d),p=ut?Xc:0,!N&&a!==null&&(a.flags&128)!==0)e:for(a=c.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&S1(a,d,c);else if(a.tag===19)S1(a,d,c);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===c)break e;for(;a.sibling===null;){if(a.return===null||a.return===c)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}switch(v){case"forwards":for(d=c.child,v=null;d!==null;)a=d.alternate,a!==null&&Df(a)===null&&(v=d),d=d.sibling;d=v,d===null?(v=c.child,c.child=null):(v=d.sibling,d.sibling=null),ib(c,!1,v,d,w,p);break;case"backwards":case"unstable_legacy-backwards":for(d=null,v=c.child,c.child=null;v!==null;){if(a=v.alternate,a!==null&&Df(a)===null){c.child=v;break}a=v.sibling,v.sibling=d,d=v,v=a}ib(c,!0,d,null,w,p);break;case"together":ib(c,!1,null,null,void 0,p);break;default:c.memoizedState=null}return c.child}function Yi(a,c,d){if(a!==null&&(c.dependencies=a.dependencies),Xs|=c.lanes,(d&c.childLanes)===0)if(a!==null){if(vl(a,c,d,!1),(d&c.childLanes)===0)return null}else return null;if(a!==null&&c.child!==a.child)throw Error(r(153));if(c.child!==null){for(a=c.child,d=Fi(a,a.pendingProps),c.child=d,d.return=c;a.sibling!==null;)a=a.sibling,d=d.sibling=Fi(a,a.pendingProps),d.return=c;d.sibling=null}return c.child}function sb(a,c){return(a.lanes&c)!==0?!0:(a=a.dependencies,!!(a!==null&&Ef(a)))}function RP(a,c,d){switch(c.tag){case 3:_e(c,c.stateNode.containerInfo),Us(c,sn,a.memoizedState.cache),sa();break;case 27:case 5:me(c);break;case 4:_e(c,c.stateNode.containerInfo);break;case 10:Us(c,c.type,c.memoizedProps.value);break;case 31:if(c.memoizedState!==null)return c.flags|=128,My(c),null;break;case 13:var p=c.memoizedState;if(p!==null)return p.dehydrated!==null?(Ws(c),c.flags|=128,null):(d&c.child.childLanes)!==0?w1(a,c,d):(Ws(c),a=Yi(a,c,d),a!==null?a.sibling:null);Ws(c);break;case 19:var v=(a.flags&128)!==0;if(p=(d&c.childLanes)!==0,p||(vl(a,c,d,!1),p=(d&c.childLanes)!==0),v){if(p)return k1(a,c,d);c.flags|=128}if(v=c.memoizedState,v!==null&&(v.rendering=null,v.tail=null,v.lastEffect=null),pe(en,en.current),p)break;return null;case 22:return c.lanes=0,m1(a,c,d,c.pendingProps);case 24:Us(c,sn,a.memoizedState.cache)}return Yi(a,c,d)}function C1(a,c,d){if(a!==null)if(a.memoizedProps!==c.pendingProps)an=!0;else{if(!sb(a,d)&&(c.flags&128)===0)return an=!1,RP(a,c,d);an=(a.flags&131072)!==0}else an=!1,ut&&(c.flags&1048576)!==0&&nC(c,Xc,c.index);switch(c.lanes=0,c.tag){case 16:e:{var p=c.pendingProps;if(a=ca(c.elementType),c.type=a,typeof a=="function")uy(a)?(p=ha(a,p),c.tag=1,c=v1(null,c,a,p,d)):(c.tag=0,c=Jy(null,c,a,p,d));else{if(a!=null){var v=a.$$typeof;if(v===_){c.tag=11,c=f1(null,c,a,p,d);break e}else if(v===D){c.tag=14,c=h1(null,c,a,p,d);break e}}throw c=Q(a)||a,Error(r(306,c,""))}}return c;case 0:return Jy(a,c,c.type,c.pendingProps,d);case 1:return p=c.type,v=ha(p,c.pendingProps),v1(a,c,p,v,d);case 3:e:{if(_e(c,c.stateNode.containerInfo),a===null)throw Error(r(387));p=c.pendingProps;var w=c.memoizedState;v=w.element,Ey(a,c),su(c,p,null,d);var T=c.memoizedState;if(p=T.cache,Us(c,sn,p),p!==w.cache&&vy(c,[sn],d,!0),iu(),p=T.element,w.isDehydrated)if(w={element:p,isDehydrated:!1,cache:T.cache},c.updateQueue.baseState=w,c.memoizedState=w,c.flags&256){c=x1(a,c,p,d);break e}else if(p!==v){v=zr(Error(r(424)),c),Jc(v),c=x1(a,c,p,d);break e}else for(a=c.stateNode.containerInfo,a.nodeType===9?a=a.body:a=a.nodeName==="HTML"?a.ownerDocument.body:a,zt=Ur(a.firstChild),An=c,ut=!0,Vs=null,Vr=!0,d=mC(c,null,p,d),c.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(sa(),p===v){c=Yi(a,c,d);break e}Mn(a,c,p,d)}c=c.child}return c;case 26:return Ff(a,c),a===null?(d=jE(c.type,null,c.pendingProps,null))?c.memoizedState=d:ut||(d=c.type,a=c.pendingProps,p=ah(Re.current).createElement(d),p[_n]=c,p[ar]=a,Nn(p,d,a),bn(p),c.stateNode=p):c.memoizedState=jE(c.type,a.memoizedProps,c.pendingProps,a.memoizedState),null;case 27:return me(c),a===null&&ut&&(p=c.stateNode=OE(c.type,c.pendingProps,Re.current),An=c,Vr=!0,v=zt,no(c.type)?(zb=v,zt=Ur(p.firstChild)):zt=v),Mn(a,c,c.pendingProps.children,d),Ff(a,c),a===null&&(c.flags|=4194304),c.child;case 5:return a===null&&ut&&((v=p=zt)&&(p=sz(p,c.type,c.pendingProps,Vr),p!==null?(c.stateNode=p,An=c,zt=Ur(p.firstChild),Vr=!1,v=!0):v=!1),v||Hs(c)),me(c),v=c.type,w=c.pendingProps,T=a!==null?a.memoizedProps:null,p=w.children,Db(v,w)?p=null:T!==null&&Db(v,T)&&(c.flags|=32),c.memoizedState!==null&&(v=Oy(a,c,xP,null,null,d),Eu._currentValue=v),Ff(a,c),Mn(a,c,p,d),c.child;case 6:return a===null&&ut&&((a=d=zt)&&(d=oz(d,c.pendingProps,Vr),d!==null?(c.stateNode=d,An=c,zt=null,a=!0):a=!1),a||Hs(c)),null;case 13:return w1(a,c,d);case 4:return _e(c,c.stateNode.containerInfo),p=c.pendingProps,a===null?c.child=da(c,null,p,d):Mn(a,c,p,d),c.child;case 11:return f1(a,c,c.type,c.pendingProps,d);case 7:return Mn(a,c,c.pendingProps,d),c.child;case 8:return Mn(a,c,c.pendingProps.children,d),c.child;case 12:return Mn(a,c,c.pendingProps.children,d),c.child;case 10:return p=c.pendingProps,Us(c,c.type,p.value),Mn(a,c,p.children,d),c.child;case 9:return v=c.type._context,p=c.pendingProps.children,aa(c),v=Rn(v),p=p(v),c.flags|=1,Mn(a,c,p,d),c.child;case 14:return h1(a,c,c.type,c.pendingProps,d);case 15:return p1(a,c,c.type,c.pendingProps,d);case 19:return k1(a,c,d);case 31:return AP(a,c,d);case 22:return m1(a,c,d,c.pendingProps);case 24:return aa(c),p=Rn(sn),a===null?(v=Sy(),v===null&&(v=Mt,w=xy(),v.pooledCache=w,w.refCount++,w!==null&&(v.pooledCacheLanes|=d),v=w),c.memoizedState={parent:p,cache:v},Cy(c),Us(c,sn,v)):((a.lanes&d)!==0&&(Ey(a,c),su(c,null,null,d),iu()),v=a.memoizedState,w=c.memoizedState,v.parent!==p?(v={parent:p,cache:p},c.memoizedState=v,c.lanes===0&&(c.memoizedState=c.updateQueue.baseState=v),Us(c,sn,p)):(p=w.cache,Us(c,sn,p),p!==v.cache&&vy(c,[sn],d,!0))),Mn(a,c,c.pendingProps.children,d),c.child;case 29:throw c.pendingProps}throw Error(r(156,c.tag))}function Xi(a){a.flags|=4}function ob(a,c,d,p,v){if((c=(a.mode&32)!==0)&&(c=!1),c){if(a.flags|=16777216,(v&335544128)===v)if(a.stateNode.complete)a.flags|=8192;else if(X1())a.flags|=8192;else throw ua=Rf,ky}else a.flags&=-16777217}function E1(a,c){if(c.type!=="stylesheet"||(c.state.loading&4)!==0)a.flags&=-16777217;else if(a.flags|=16777216,!BE(c))if(X1())a.flags|=8192;else throw ua=Rf,ky}function Gf(a,c){c!==null&&(a.flags|=4),a.flags&16384&&(c=a.tag!==22?or():536870912,a.lanes|=c,Nl|=c)}function du(a,c){if(!ut)switch(a.tailMode){case"hidden":c=a.tail;for(var d=null;c!==null;)c.alternate!==null&&(d=c),c=c.sibling;d===null?a.tail=null:d.sibling=null;break;case"collapsed":d=a.tail;for(var p=null;d!==null;)d.alternate!==null&&(p=d),d=d.sibling;p===null?c||a.tail===null?a.tail=null:a.tail.sibling=null:p.sibling=null}}function $t(a){var c=a.alternate!==null&&a.alternate.child===a.child,d=0,p=0;if(c)for(var v=a.child;v!==null;)d|=v.lanes|v.childLanes,p|=v.subtreeFlags&65011712,p|=v.flags&65011712,v.return=a,v=v.sibling;else for(v=a.child;v!==null;)d|=v.lanes|v.childLanes,p|=v.subtreeFlags,p|=v.flags,v.return=a,v=v.sibling;return a.subtreeFlags|=p,a.childLanes=d,c}function MP(a,c,d){var p=c.pendingProps;switch(py(c),c.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return $t(c),null;case 1:return $t(c),null;case 3:return d=c.stateNode,p=null,a!==null&&(p=a.memoizedState.cache),c.memoizedState.cache!==p&&(c.flags|=2048),Wi(sn),ae(),d.pendingContext&&(d.context=d.pendingContext,d.pendingContext=null),(a===null||a.child===null)&&(bl(c)?Xi(c):a===null||a.memoizedState.isDehydrated&&(c.flags&256)===0||(c.flags|=1024,gy())),$t(c),null;case 26:var v=c.type,w=c.memoizedState;return a===null?(Xi(c),w!==null?($t(c),E1(c,w)):($t(c),ob(c,v,null,p,d))):w?w!==a.memoizedState?(Xi(c),$t(c),E1(c,w)):($t(c),c.flags&=-16777217):(a=a.memoizedProps,a!==p&&Xi(c),$t(c),ob(c,v,a,p,d)),null;case 27:if(Ie(c),d=Re.current,v=c.type,a!==null&&c.stateNode!=null)a.memoizedProps!==p&&Xi(c);else{if(!p){if(c.stateNode===null)throw Error(r(166));return $t(c),null}a=ve.current,bl(c)?iC(c):(a=OE(v,p,d),c.stateNode=a,Xi(c))}return $t(c),null;case 5:if(Ie(c),v=c.type,a!==null&&c.stateNode!=null)a.memoizedProps!==p&&Xi(c);else{if(!p){if(c.stateNode===null)throw Error(r(166));return $t(c),null}if(w=ve.current,bl(c))iC(c);else{var T=ah(Re.current);switch(w){case 1:w=T.createElementNS("http://www.w3.org/2000/svg",v);break;case 2:w=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;default:switch(v){case"svg":w=T.createElementNS("http://www.w3.org/2000/svg",v);break;case"math":w=T.createElementNS("http://www.w3.org/1998/Math/MathML",v);break;case"script":w=T.createElement("div"),w.innerHTML="<script><\/script>",w=w.removeChild(w.firstChild);break;case"select":w=typeof p.is=="string"?T.createElement("select",{is:p.is}):T.createElement("select"),p.multiple?w.multiple=!0:p.size&&(w.size=p.size);break;default:w=typeof p.is=="string"?T.createElement(v,{is:p.is}):T.createElement(v)}}w[_n]=c,w[ar]=p;e:for(T=c.child;T!==null;){if(T.tag===5||T.tag===6)w.appendChild(T.stateNode);else if(T.tag!==4&&T.tag!==27&&T.child!==null){T.child.return=T,T=T.child;continue}if(T===c)break e;for(;T.sibling===null;){if(T.return===null||T.return===c)break e;T=T.return}T.sibling.return=T.return,T=T.sibling}c.stateNode=w;e:switch(Nn(w,v,p),v){case"button":case"input":case"select":case"textarea":p=!!p.autoFocus;break e;case"img":p=!0;break e;default:p=!1}p&&Xi(c)}}return $t(c),ob(c,c.type,a===null?null:a.memoizedProps,c.pendingProps,d),null;case 6:if(a&&c.stateNode!=null)a.memoizedProps!==p&&Xi(c);else{if(typeof p!="string"&&c.stateNode===null)throw Error(r(166));if(a=Re.current,bl(c)){if(a=c.stateNode,d=c.memoizedProps,p=null,v=An,v!==null)switch(v.tag){case 27:case 5:p=v.memoizedProps}a[_n]=c,a=!!(a.nodeValue===d||p!==null&&p.suppressHydrationWarning===!0||wE(a.nodeValue,d)),a||Hs(c,!0)}else a=ah(a).createTextNode(p),a[_n]=c,c.stateNode=a}return $t(c),null;case 31:if(d=c.memoizedState,a===null||a.memoizedState!==null){if(p=bl(c),d!==null){if(a===null){if(!p)throw Error(r(318));if(a=c.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(r(557));a[_n]=c}else sa(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;$t(c),a=!1}else d=gy(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=d),a=!0;if(!a)return c.flags&256?(wr(c),c):(wr(c),null);if((c.flags&128)!==0)throw Error(r(558))}return $t(c),null;case 13:if(p=c.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(v=bl(c),p!==null&&p.dehydrated!==null){if(a===null){if(!v)throw Error(r(318));if(v=c.memoizedState,v=v!==null?v.dehydrated:null,!v)throw Error(r(317));v[_n]=c}else sa(),(c.flags&128)===0&&(c.memoizedState=null),c.flags|=4;$t(c),v=!1}else v=gy(),a!==null&&a.memoizedState!==null&&(a.memoizedState.hydrationErrors=v),v=!0;if(!v)return c.flags&256?(wr(c),c):(wr(c),null)}return wr(c),(c.flags&128)!==0?(c.lanes=d,c):(d=p!==null,a=a!==null&&a.memoizedState!==null,d&&(p=c.child,v=null,p.alternate!==null&&p.alternate.memoizedState!==null&&p.alternate.memoizedState.cachePool!==null&&(v=p.alternate.memoizedState.cachePool.pool),w=null,p.memoizedState!==null&&p.memoizedState.cachePool!==null&&(w=p.memoizedState.cachePool.pool),w!==v&&(p.flags|=2048)),d!==a&&d&&(c.child.flags|=8192),Gf(c,c.updateQueue),$t(c),null);case 4:return ae(),a===null&&Ab(c.stateNode.containerInfo),$t(c),null;case 10:return Wi(c.type),$t(c),null;case 19:if(Z(en),p=c.memoizedState,p===null)return $t(c),null;if(v=(c.flags&128)!==0,w=p.rendering,w===null)if(v)du(p,!1);else{if(Zt!==0||a!==null&&(a.flags&128)!==0)for(a=c.child;a!==null;){if(w=Df(a),w!==null){for(c.flags|=128,du(p,!1),a=w.updateQueue,c.updateQueue=a,Gf(c,a),c.subtreeFlags=0,a=d,d=c.child;d!==null;)Qk(d,a),d=d.sibling;return pe(en,en.current&1|2),ut&&qi(c,p.treeForkCount),c.child}a=a.sibling}p.tail!==null&&Ht()>Xf&&(c.flags|=128,v=!0,du(p,!1),c.lanes=4194304)}else{if(!v)if(a=Df(w),a!==null){if(c.flags|=128,v=!0,a=a.updateQueue,c.updateQueue=a,Gf(c,a),du(p,!0),p.tail===null&&p.tailMode==="hidden"&&!w.alternate&&!ut)return $t(c),null}else 2*Ht()-p.renderingStartTime>Xf&&d!==536870912&&(c.flags|=128,v=!0,du(p,!1),c.lanes=4194304);p.isBackwards?(w.sibling=c.child,c.child=w):(a=p.last,a!==null?a.sibling=w:c.child=w,p.last=w)}return p.tail!==null?(a=p.tail,p.rendering=a,p.tail=a.sibling,p.renderingStartTime=Ht(),a.sibling=null,d=en.current,pe(en,v?d&1|2:d&1),ut&&qi(c,p.treeForkCount),a):($t(c),null);case 22:case 23:return wr(c),Ry(),p=c.memoizedState!==null,a!==null?a.memoizedState!==null!==p&&(c.flags|=8192):p&&(c.flags|=8192),p?(d&536870912)!==0&&(c.flags&128)===0&&($t(c),c.subtreeFlags&6&&(c.flags|=8192)):$t(c),d=c.updateQueue,d!==null&&Gf(c,d.retryQueue),d=null,a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),p=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(p=c.memoizedState.cachePool.pool),p!==d&&(c.flags|=2048),a!==null&&Z(la),null;case 24:return d=null,a!==null&&(d=a.memoizedState.cache),c.memoizedState.cache!==d&&(c.flags|=2048),Wi(sn),$t(c),null;case 25:return null;case 30:return null}throw Error(r(156,c.tag))}function NP(a,c){switch(py(c),c.tag){case 1:return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 3:return Wi(sn),ae(),a=c.flags,(a&65536)!==0&&(a&128)===0?(c.flags=a&-65537|128,c):null;case 26:case 27:case 5:return Ie(c),null;case 31:if(c.memoizedState!==null){if(wr(c),c.alternate===null)throw Error(r(340));sa()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 13:if(wr(c),a=c.memoizedState,a!==null&&a.dehydrated!==null){if(c.alternate===null)throw Error(r(340));sa()}return a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 19:return Z(en),null;case 4:return ae(),null;case 10:return Wi(c.type),null;case 22:case 23:return wr(c),Ry(),a!==null&&Z(la),a=c.flags,a&65536?(c.flags=a&-65537|128,c):null;case 24:return Wi(sn),null;case 25:return null;default:return null}}function T1(a,c){switch(py(c),c.tag){case 3:Wi(sn),ae();break;case 26:case 27:case 5:Ie(c);break;case 4:ae();break;case 31:c.memoizedState!==null&&wr(c);break;case 13:wr(c);break;case 19:Z(en);break;case 10:Wi(c.type);break;case 22:case 23:wr(c),Ry(),a!==null&&Z(la);break;case 24:Wi(sn)}}function fu(a,c){try{var d=c.updateQueue,p=d!==null?d.lastEffect:null;if(p!==null){var v=p.next;d=v;do{if((d.tag&a)===a){p=void 0;var w=d.create,T=d.inst;p=w(),T.destroy=p}d=d.next}while(d!==v)}}catch(N){St(c,c.return,N)}}function Zs(a,c,d){try{var p=c.updateQueue,v=p!==null?p.lastEffect:null;if(v!==null){var w=v.next;p=w;do{if((p.tag&a)===a){var T=p.inst,N=T.destroy;if(N!==void 0){T.destroy=void 0,v=c;var V=d,X=N;try{X()}catch(oe){St(v,V,oe)}}}p=p.next}while(p!==w)}}catch(oe){St(c,c.return,oe)}}function _1(a){var c=a.updateQueue;if(c!==null){var d=a.stateNode;try{yC(c,d)}catch(p){St(a,a.return,p)}}}function A1(a,c,d){d.props=ha(a.type,a.memoizedProps),d.state=a.memoizedState;try{d.componentWillUnmount()}catch(p){St(a,c,p)}}function hu(a,c){try{var d=a.ref;if(d!==null){switch(a.tag){case 26:case 27:case 5:var p=a.stateNode;break;case 30:p=a.stateNode;break;default:p=a.stateNode}typeof d=="function"?a.refCleanup=d(p):d.current=p}}catch(v){St(a,c,v)}}function Ci(a,c){var d=a.ref,p=a.refCleanup;if(d!==null)if(typeof p=="function")try{p()}catch(v){St(a,c,v)}finally{a.refCleanup=null,a=a.alternate,a!=null&&(a.refCleanup=null)}else if(typeof d=="function")try{d(null)}catch(v){St(a,c,v)}else d.current=null}function R1(a){var c=a.type,d=a.memoizedProps,p=a.stateNode;try{e:switch(c){case"button":case"input":case"select":case"textarea":d.autoFocus&&p.focus();break e;case"img":d.src?p.src=d.src:d.srcSet&&(p.srcset=d.srcSet)}}catch(v){St(a,a.return,v)}}function ab(a,c,d){try{var p=a.stateNode;QP(p,a.type,d,c),p[ar]=c}catch(v){St(a,a.return,v)}}function M1(a){return a.tag===5||a.tag===3||a.tag===26||a.tag===27&&no(a.type)||a.tag===4}function lb(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||M1(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.tag===27&&no(a.type)||a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function cb(a,c,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,c?(d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d).insertBefore(a,c):(c=d.nodeType===9?d.body:d.nodeName==="HTML"?d.ownerDocument.body:d,c.appendChild(a),d=d._reactRootContainer,d!=null||c.onclick!==null||(c.onclick=Hi));else if(p!==4&&(p===27&&no(a.type)&&(d=a.stateNode,c=null),a=a.child,a!==null))for(cb(a,c,d),a=a.sibling;a!==null;)cb(a,c,d),a=a.sibling}function Wf(a,c,d){var p=a.tag;if(p===5||p===6)a=a.stateNode,c?d.insertBefore(a,c):d.appendChild(a);else if(p!==4&&(p===27&&no(a.type)&&(d=a.stateNode),a=a.child,a!==null))for(Wf(a,c,d),a=a.sibling;a!==null;)Wf(a,c,d),a=a.sibling}function N1(a){var c=a.stateNode,d=a.memoizedProps;try{for(var p=a.type,v=c.attributes;v.length;)c.removeAttributeNode(v[0]);Nn(c,p,d),c[_n]=a,c[ar]=d}catch(w){St(a,a.return,w)}}var Ji=!1,ln=!1,ub=!1,O1=typeof WeakSet=="function"?WeakSet:Set,vn=null;function OP(a,c){if(a=a.containerInfo,Nb=ph,a=Fk(a),ry(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var p=d.getSelection&&d.getSelection();if(p&&p.rangeCount!==0){d=p.anchorNode;var v=p.anchorOffset,w=p.focusNode;p=p.focusOffset;try{d.nodeType,w.nodeType}catch{d=null;break e}var T=0,N=-1,V=-1,X=0,oe=0,ue=a,J=null;t:for(;;){for(var te;ue!==d||v!==0&&ue.nodeType!==3||(N=T+v),ue!==w||p!==0&&ue.nodeType!==3||(V=T+p),ue.nodeType===3&&(T+=ue.nodeValue.length),(te=ue.firstChild)!==null;)J=ue,ue=te;for(;;){if(ue===a)break t;if(J===d&&++X===v&&(N=T),J===w&&++oe===p&&(V=T),(te=ue.nextSibling)!==null)break;ue=J,J=ue.parentNode}ue=te}d=N===-1||V===-1?null:{start:N,end:V}}else d=null}d=d||{start:0,end:0}}else d=null;for(Ob={focusedElem:a,selectionRange:d},ph=!1,vn=c;vn!==null;)if(c=vn,a=c.child,(c.subtreeFlags&1028)!==0&&a!==null)a.return=c,vn=a;else for(;vn!==null;){switch(c=vn,w=c.alternate,a=c.flags,c.tag){case 0:if((a&4)!==0&&(a=c.updateQueue,a=a!==null?a.events:null,a!==null))for(d=0;d<a.length;d++)v=a[d],v.ref.impl=v.nextImpl;break;case 11:case 15:break;case 1:if((a&1024)!==0&&w!==null){a=void 0,d=c,v=w.memoizedProps,w=w.memoizedState,p=d.stateNode;try{var Oe=ha(d.type,v);a=p.getSnapshotBeforeUpdate(Oe,w),p.__reactInternalSnapshotBeforeUpdate=a}catch(Fe){St(d,d.return,Fe)}}break;case 3:if((a&1024)!==0){if(a=c.stateNode.containerInfo,d=a.nodeType,d===9)jb(a);else if(d===1)switch(a.nodeName){case"HEAD":case"HTML":case"BODY":jb(a);break;default:a.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((a&1024)!==0)throw Error(r(163))}if(a=c.sibling,a!==null){a.return=c.return,vn=a;break}vn=c.return}}function D1(a,c,d){var p=d.flags;switch(d.tag){case 0:case 11:case 15:es(a,d),p&4&&fu(5,d);break;case 1:if(es(a,d),p&4)if(a=d.stateNode,c===null)try{a.componentDidMount()}catch(T){St(d,d.return,T)}else{var v=ha(d.type,c.memoizedProps);c=c.memoizedState;try{a.componentDidUpdate(v,c,a.__reactInternalSnapshotBeforeUpdate)}catch(T){St(d,d.return,T)}}p&64&&_1(d),p&512&&hu(d,d.return);break;case 3:if(es(a,d),p&64&&(a=d.updateQueue,a!==null)){if(c=null,d.child!==null)switch(d.child.tag){case 27:case 5:c=d.child.stateNode;break;case 1:c=d.child.stateNode}try{yC(a,c)}catch(T){St(d,d.return,T)}}break;case 27:c===null&&p&4&&N1(d);case 26:case 5:es(a,d),c===null&&p&4&&R1(d),p&512&&hu(d,d.return);break;case 12:es(a,d);break;case 31:es(a,d),p&4&&L1(a,d);break;case 13:es(a,d),p&4&&P1(a,d),p&64&&(a=d.memoizedState,a!==null&&(a=a.dehydrated,a!==null&&(d=VP.bind(null,d),az(a,d))));break;case 22:if(p=d.memoizedState!==null||Ji,!p){c=c!==null&&c.memoizedState!==null||ln,v=Ji;var w=ln;Ji=p,(ln=c)&&!w?ts(a,d,(d.subtreeFlags&8772)!==0):es(a,d),Ji=v,ln=w}break;case 30:break;default:es(a,d)}}function I1(a){var c=a.alternate;c!==null&&(a.alternate=null,I1(c)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(c=a.stateNode,c!==null&&Bg(c)),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}var Ut=null,cr=!1;function Qi(a,c,d){for(d=d.child;d!==null;)j1(a,c,d),d=d.sibling}function j1(a,c,d){if(ie&&typeof ie.onCommitFiberUnmount=="function")try{ie.onCommitFiberUnmount(U,d)}catch{}switch(d.tag){case 26:ln||Ci(d,c),Qi(a,c,d),d.memoizedState?d.memoizedState.count--:d.stateNode&&(d=d.stateNode,d.parentNode.removeChild(d));break;case 27:ln||Ci(d,c);var p=Ut,v=cr;no(d.type)&&(Ut=d.stateNode,cr=!1),Qi(a,c,d),Su(d.stateNode),Ut=p,cr=v;break;case 5:ln||Ci(d,c);case 6:if(p=Ut,v=cr,Ut=null,Qi(a,c,d),Ut=p,cr=v,Ut!==null)if(cr)try{(Ut.nodeType===9?Ut.body:Ut.nodeName==="HTML"?Ut.ownerDocument.body:Ut).removeChild(d.stateNode)}catch(w){St(d,c,w)}else try{Ut.removeChild(d.stateNode)}catch(w){St(d,c,w)}break;case 18:Ut!==null&&(cr?(a=Ut,_E(a.nodeType===9?a.body:a.nodeName==="HTML"?a.ownerDocument.body:a,d.stateNode),$l(a)):_E(Ut,d.stateNode));break;case 4:p=Ut,v=cr,Ut=d.stateNode.containerInfo,cr=!0,Qi(a,c,d),Ut=p,cr=v;break;case 0:case 11:case 14:case 15:Zs(2,d,c),ln||Zs(4,d,c),Qi(a,c,d);break;case 1:ln||(Ci(d,c),p=d.stateNode,typeof p.componentWillUnmount=="function"&&A1(d,c,p)),Qi(a,c,d);break;case 21:Qi(a,c,d);break;case 22:ln=(p=ln)||d.memoizedState!==null,Qi(a,c,d),ln=p;break;default:Qi(a,c,d)}}function L1(a,c){if(c.memoizedState===null&&(a=c.alternate,a!==null&&(a=a.memoizedState,a!==null))){a=a.dehydrated;try{$l(a)}catch(d){St(c,c.return,d)}}}function P1(a,c){if(c.memoizedState===null&&(a=c.alternate,a!==null&&(a=a.memoizedState,a!==null&&(a=a.dehydrated,a!==null))))try{$l(a)}catch(d){St(c,c.return,d)}}function DP(a){switch(a.tag){case 31:case 13:case 19:var c=a.stateNode;return c===null&&(c=a.stateNode=new O1),c;case 22:return a=a.stateNode,c=a._retryCache,c===null&&(c=a._retryCache=new O1),c;default:throw Error(r(435,a.tag))}}function Kf(a,c){var d=DP(a);c.forEach(function(p){if(!d.has(p)){d.add(p);var v=HP.bind(null,a,p);p.then(v,v)}})}function ur(a,c){var d=c.deletions;if(d!==null)for(var p=0;p<d.length;p++){var v=d[p],w=a,T=c,N=T;e:for(;N!==null;){switch(N.tag){case 27:if(no(N.type)){Ut=N.stateNode,cr=!1;break e}break;case 5:Ut=N.stateNode,cr=!1;break e;case 3:case 4:Ut=N.stateNode.containerInfo,cr=!0;break e}N=N.return}if(Ut===null)throw Error(r(160));j1(w,T,v),Ut=null,cr=!1,w=v.alternate,w!==null&&(w.return=null),v.return=null}if(c.subtreeFlags&13886)for(c=c.child;c!==null;)z1(c,a),c=c.sibling}var ni=null;function z1(a,c){var d=a.alternate,p=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:ur(c,a),dr(a),p&4&&(Zs(3,a,a.return),fu(3,a),Zs(5,a,a.return));break;case 1:ur(c,a),dr(a),p&512&&(ln||d===null||Ci(d,d.return)),p&64&&Ji&&(a=a.updateQueue,a!==null&&(p=a.callbacks,p!==null&&(d=a.shared.hiddenCallbacks,a.shared.hiddenCallbacks=d===null?p:d.concat(p))));break;case 26:var v=ni;if(ur(c,a),dr(a),p&512&&(ln||d===null||Ci(d,d.return)),p&4){var w=d!==null?d.memoizedState:null;if(p=a.memoizedState,d===null)if(p===null)if(a.stateNode===null){e:{p=a.type,d=a.memoizedProps,v=v.ownerDocument||v;t:switch(p){case"title":w=v.getElementsByTagName("title")[0],(!w||w[Bc]||w[_n]||w.namespaceURI==="http://www.w3.org/2000/svg"||w.hasAttribute("itemprop"))&&(w=v.createElement(p),v.head.insertBefore(w,v.querySelector("head > title"))),Nn(w,p,d),w[_n]=a,bn(w),p=w;break e;case"link":var T=zE("link","href",v).get(p+(d.href||""));if(T){for(var N=0;N<T.length;N++)if(w=T[N],w.getAttribute("href")===(d.href==null||d.href===""?null:d.href)&&w.getAttribute("rel")===(d.rel==null?null:d.rel)&&w.getAttribute("title")===(d.title==null?null:d.title)&&w.getAttribute("crossorigin")===(d.crossOrigin==null?null:d.crossOrigin)){T.splice(N,1);break t}}w=v.createElement(p),Nn(w,p,d),v.head.appendChild(w);break;case"meta":if(T=zE("meta","content",v).get(p+(d.content||""))){for(N=0;N<T.length;N++)if(w=T[N],w.getAttribute("content")===(d.content==null?null:""+d.content)&&w.getAttribute("name")===(d.name==null?null:d.name)&&w.getAttribute("property")===(d.property==null?null:d.property)&&w.getAttribute("http-equiv")===(d.httpEquiv==null?null:d.httpEquiv)&&w.getAttribute("charset")===(d.charSet==null?null:d.charSet)){T.splice(N,1);break t}}w=v.createElement(p),Nn(w,p,d),v.head.appendChild(w);break;default:throw Error(r(468,p))}w[_n]=a,bn(w),p=w}a.stateNode=p}else $E(v,a.type,a.stateNode);else a.stateNode=PE(v,p,a.memoizedProps);else w!==p?(w===null?d.stateNode!==null&&(d=d.stateNode,d.parentNode.removeChild(d)):w.count--,p===null?$E(v,a.type,a.stateNode):PE(v,p,a.memoizedProps)):p===null&&a.stateNode!==null&&ab(a,a.memoizedProps,d.memoizedProps)}break;case 27:ur(c,a),dr(a),p&512&&(ln||d===null||Ci(d,d.return)),d!==null&&p&4&&ab(a,a.memoizedProps,d.memoizedProps);break;case 5:if(ur(c,a),dr(a),p&512&&(ln||d===null||Ci(d,d.return)),a.flags&32){v=a.stateNode;try{ll(v,"")}catch(Oe){St(a,a.return,Oe)}}p&4&&a.stateNode!=null&&(v=a.memoizedProps,ab(a,v,d!==null?d.memoizedProps:v)),p&1024&&(ub=!0);break;case 6:if(ur(c,a),dr(a),p&4){if(a.stateNode===null)throw Error(r(162));p=a.memoizedProps,d=a.stateNode;try{d.nodeValue=p}catch(Oe){St(a,a.return,Oe)}}break;case 3:if(uh=null,v=ni,ni=lh(c.containerInfo),ur(c,a),ni=v,dr(a),p&4&&d!==null&&d.memoizedState.isDehydrated)try{$l(c.containerInfo)}catch(Oe){St(a,a.return,Oe)}ub&&(ub=!1,$1(a));break;case 4:p=ni,ni=lh(a.stateNode.containerInfo),ur(c,a),dr(a),ni=p;break;case 12:ur(c,a),dr(a);break;case 31:ur(c,a),dr(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,Kf(a,p)));break;case 13:ur(c,a),dr(a),a.child.flags&8192&&a.memoizedState!==null!=(d!==null&&d.memoizedState!==null)&&(Yf=Ht()),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,Kf(a,p)));break;case 22:v=a.memoizedState!==null;var V=d!==null&&d.memoizedState!==null,X=Ji,oe=ln;if(Ji=X||v,ln=oe||V,ur(c,a),ln=oe,Ji=X,dr(a),p&8192)e:for(c=a.stateNode,c._visibility=v?c._visibility&-2:c._visibility|1,v&&(d===null||V||Ji||ln||pa(a)),d=null,c=a;;){if(c.tag===5||c.tag===26){if(d===null){V=d=c;try{if(w=V.stateNode,v)T=w.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none";else{N=V.stateNode;var ue=V.memoizedProps.style,J=ue!=null&&ue.hasOwnProperty("display")?ue.display:null;N.style.display=J==null||typeof J=="boolean"?"":(""+J).trim()}}catch(Oe){St(V,V.return,Oe)}}}else if(c.tag===6){if(d===null){V=c;try{V.stateNode.nodeValue=v?"":V.memoizedProps}catch(Oe){St(V,V.return,Oe)}}}else if(c.tag===18){if(d===null){V=c;try{var te=V.stateNode;v?AE(te,!0):AE(V.stateNode,!1)}catch(Oe){St(V,V.return,Oe)}}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===a)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===a)break e;for(;c.sibling===null;){if(c.return===null||c.return===a)break e;d===c&&(d=null),c=c.return}d===c&&(d=null),c.sibling.return=c.return,c=c.sibling}p&4&&(p=a.updateQueue,p!==null&&(d=p.retryQueue,d!==null&&(p.retryQueue=null,Kf(a,d))));break;case 19:ur(c,a),dr(a),p&4&&(p=a.updateQueue,p!==null&&(a.updateQueue=null,Kf(a,p)));break;case 30:break;case 21:break;default:ur(c,a),dr(a)}}function dr(a){var c=a.flags;if(c&2){try{for(var d,p=a.return;p!==null;){if(M1(p)){d=p;break}p=p.return}if(d==null)throw Error(r(160));switch(d.tag){case 27:var v=d.stateNode,w=lb(a);Wf(a,w,v);break;case 5:var T=d.stateNode;d.flags&32&&(ll(T,""),d.flags&=-33);var N=lb(a);Wf(a,N,T);break;case 3:case 4:var V=d.stateNode.containerInfo,X=lb(a);cb(a,X,V);break;default:throw Error(r(161))}}catch(oe){St(a,a.return,oe)}a.flags&=-3}c&4096&&(a.flags&=-4097)}function $1(a){if(a.subtreeFlags&1024)for(a=a.child;a!==null;){var c=a;$1(c),c.tag===5&&c.flags&1024&&c.stateNode.reset(),a=a.sibling}}function es(a,c){if(c.subtreeFlags&8772)for(c=c.child;c!==null;)D1(a,c.alternate,c),c=c.sibling}function pa(a){for(a=a.child;a!==null;){var c=a;switch(c.tag){case 0:case 11:case 14:case 15:Zs(4,c,c.return),pa(c);break;case 1:Ci(c,c.return);var d=c.stateNode;typeof d.componentWillUnmount=="function"&&A1(c,c.return,d),pa(c);break;case 27:Su(c.stateNode);case 26:case 5:Ci(c,c.return),pa(c);break;case 22:c.memoizedState===null&&pa(c);break;case 30:pa(c);break;default:pa(c)}a=a.sibling}}function ts(a,c,d){for(d=d&&(c.subtreeFlags&8772)!==0,c=c.child;c!==null;){var p=c.alternate,v=a,w=c,T=w.flags;switch(w.tag){case 0:case 11:case 15:ts(v,w,d),fu(4,w);break;case 1:if(ts(v,w,d),p=w,v=p.stateNode,typeof v.componentDidMount=="function")try{v.componentDidMount()}catch(X){St(p,p.return,X)}if(p=w,v=p.updateQueue,v!==null){var N=p.stateNode;try{var V=v.shared.hiddenCallbacks;if(V!==null)for(v.shared.hiddenCallbacks=null,v=0;v<V.length;v++)gC(V[v],N)}catch(X){St(p,p.return,X)}}d&&T&64&&_1(w),hu(w,w.return);break;case 27:N1(w);case 26:case 5:ts(v,w,d),d&&p===null&&T&4&&R1(w),hu(w,w.return);break;case 12:ts(v,w,d);break;case 31:ts(v,w,d),d&&T&4&&L1(v,w);break;case 13:ts(v,w,d),d&&T&4&&P1(v,w);break;case 22:w.memoizedState===null&&ts(v,w,d),hu(w,w.return);break;case 30:break;default:ts(v,w,d)}c=c.sibling}}function db(a,c){var d=null;a!==null&&a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(d=a.memoizedState.cachePool.pool),a=null,c.memoizedState!==null&&c.memoizedState.cachePool!==null&&(a=c.memoizedState.cachePool.pool),a!==d&&(a!=null&&a.refCount++,d!=null&&Qc(d))}function fb(a,c){a=null,c.alternate!==null&&(a=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==a&&(c.refCount++,a!=null&&Qc(a))}function ri(a,c,d,p){if(c.subtreeFlags&10256)for(c=c.child;c!==null;)B1(a,c,d,p),c=c.sibling}function B1(a,c,d,p){var v=c.flags;switch(c.tag){case 0:case 11:case 15:ri(a,c,d,p),v&2048&&fu(9,c);break;case 1:ri(a,c,d,p);break;case 3:ri(a,c,d,p),v&2048&&(a=null,c.alternate!==null&&(a=c.alternate.memoizedState.cache),c=c.memoizedState.cache,c!==a&&(c.refCount++,a!=null&&Qc(a)));break;case 12:if(v&2048){ri(a,c,d,p),a=c.stateNode;try{var w=c.memoizedProps,T=w.id,N=w.onPostCommit;typeof N=="function"&&N(T,c.alternate===null?"mount":"update",a.passiveEffectDuration,-0)}catch(V){St(c,c.return,V)}}else ri(a,c,d,p);break;case 31:ri(a,c,d,p);break;case 13:ri(a,c,d,p);break;case 23:break;case 22:w=c.stateNode,T=c.alternate,c.memoizedState!==null?w._visibility&2?ri(a,c,d,p):pu(a,c):w._visibility&2?ri(a,c,d,p):(w._visibility|=2,Al(a,c,d,p,(c.subtreeFlags&10256)!==0||!1)),v&2048&&db(T,c);break;case 24:ri(a,c,d,p),v&2048&&fb(c.alternate,c);break;default:ri(a,c,d,p)}}function Al(a,c,d,p,v){for(v=v&&((c.subtreeFlags&10256)!==0||!1),c=c.child;c!==null;){var w=a,T=c,N=d,V=p,X=T.flags;switch(T.tag){case 0:case 11:case 15:Al(w,T,N,V,v),fu(8,T);break;case 23:break;case 22:var oe=T.stateNode;T.memoizedState!==null?oe._visibility&2?Al(w,T,N,V,v):pu(w,T):(oe._visibility|=2,Al(w,T,N,V,v)),v&&X&2048&&db(T.alternate,T);break;case 24:Al(w,T,N,V,v),v&&X&2048&&fb(T.alternate,T);break;default:Al(w,T,N,V,v)}c=c.sibling}}function pu(a,c){if(c.subtreeFlags&10256)for(c=c.child;c!==null;){var d=a,p=c,v=p.flags;switch(p.tag){case 22:pu(d,p),v&2048&&db(p.alternate,p);break;case 24:pu(d,p),v&2048&&fb(p.alternate,p);break;default:pu(d,p)}c=c.sibling}}var mu=8192;function Rl(a,c,d){if(a.subtreeFlags&mu)for(a=a.child;a!==null;)V1(a,c,d),a=a.sibling}function V1(a,c,d){switch(a.tag){case 26:Rl(a,c,d),a.flags&mu&&a.memoizedState!==null&&vz(d,ni,a.memoizedState,a.memoizedProps);break;case 5:Rl(a,c,d);break;case 3:case 4:var p=ni;ni=lh(a.stateNode.containerInfo),Rl(a,c,d),ni=p;break;case 22:a.memoizedState===null&&(p=a.alternate,p!==null&&p.memoizedState!==null?(p=mu,mu=16777216,Rl(a,c,d),mu=p):Rl(a,c,d));break;default:Rl(a,c,d)}}function H1(a){var c=a.alternate;if(c!==null&&(a=c.child,a!==null)){c.child=null;do c=a.sibling,a.sibling=null,a=c;while(a!==null)}}function gu(a){var c=a.deletions;if((a.flags&16)!==0){if(c!==null)for(var d=0;d<c.length;d++){var p=c[d];vn=p,F1(p,a)}H1(a)}if(a.subtreeFlags&10256)for(a=a.child;a!==null;)U1(a),a=a.sibling}function U1(a){switch(a.tag){case 0:case 11:case 15:gu(a),a.flags&2048&&Zs(9,a,a.return);break;case 3:gu(a);break;case 12:gu(a);break;case 22:var c=a.stateNode;a.memoizedState!==null&&c._visibility&2&&(a.return===null||a.return.tag!==13)?(c._visibility&=-3,Zf(a)):gu(a);break;default:gu(a)}}function Zf(a){var c=a.deletions;if((a.flags&16)!==0){if(c!==null)for(var d=0;d<c.length;d++){var p=c[d];vn=p,F1(p,a)}H1(a)}for(a=a.child;a!==null;){switch(c=a,c.tag){case 0:case 11:case 15:Zs(8,c,c.return),Zf(c);break;case 22:d=c.stateNode,d._visibility&2&&(d._visibility&=-3,Zf(c));break;default:Zf(c)}a=a.sibling}}function F1(a,c){for(;vn!==null;){var d=vn;switch(d.tag){case 0:case 11:case 15:Zs(8,d,c);break;case 23:case 22:if(d.memoizedState!==null&&d.memoizedState.cachePool!==null){var p=d.memoizedState.cachePool.pool;p!=null&&p.refCount++}break;case 24:Qc(d.memoizedState.cache)}if(p=d.child,p!==null)p.return=d,vn=p;else e:for(d=a;vn!==null;){p=vn;var v=p.sibling,w=p.return;if(I1(p),p===d){vn=null;break e}if(v!==null){v.return=w,vn=v;break e}vn=w}}}var IP={getCacheForType:function(a){var c=Rn(sn),d=c.data.get(a);return d===void 0&&(d=a(),c.data.set(a,d)),d},cacheSignal:function(){return Rn(sn).controller.signal}},jP=typeof WeakMap=="function"?WeakMap:Map,bt=0,Mt=null,st=null,at=0,wt=0,Sr=null,Ys=!1,Ml=!1,hb=!1,ns=0,Zt=0,Xs=0,ma=0,pb=0,kr=0,Nl=0,yu=null,fr=null,mb=!1,Yf=0,q1=0,Xf=1/0,Jf=null,Js=null,gn=0,Qs=null,Ol=null,rs=0,gb=0,yb=null,G1=null,bu=0,bb=null;function Cr(){return(bt&2)!==0&&at!==0?at&-at:z.T!==null?Cb():lk()}function W1(){if(kr===0)if((at&536870912)===0||ut){var a=F;F<<=1,(F&3932160)===0&&(F=262144),kr=a}else kr=536870912;return a=xr.current,a!==null&&(a.flags|=32),kr}function hr(a,c,d){(a===Mt&&(wt===2||wt===9)||a.cancelPendingCommit!==null)&&(Dl(a,0),eo(a,at,kr,!1)),Ps(a,d),((bt&2)===0||a!==Mt)&&(a===Mt&&((bt&2)===0&&(ma|=d),Zt===4&&eo(a,at,kr,!1)),Ei(a))}function K1(a,c,d){if((bt&6)!==0)throw Error(r(327));var p=!d&&(c&127)===0&&(c&a.expiredLanes)===0||Dt(a,c),v=p?zP(a,c):xb(a,c,!0),w=p;do{if(v===0){Ml&&!p&&eo(a,c,0,!1);break}else{if(d=a.current.alternate,w&&!LP(d)){v=xb(a,c,!1),w=!1;continue}if(v===2){if(w=c,a.errorRecoveryDisabledLanes&w)var T=0;else T=a.pendingLanes&-536870913,T=T!==0?T:T&536870912?536870912:0;if(T!==0){c=T;e:{var N=a;v=yu;var V=N.current.memoizedState.isDehydrated;if(V&&(Dl(N,T).flags|=256),T=xb(N,T,!1),T!==2){if(hb&&!V){N.errorRecoveryDisabledLanes|=w,ma|=w,v=4;break e}w=fr,fr=v,w!==null&&(fr===null?fr=w:fr.push.apply(fr,w))}v=T}if(w=!1,v!==2)continue}}if(v===1){Dl(a,0),eo(a,c,0,!0);break}e:{switch(p=a,w=v,w){case 0:case 1:throw Error(r(345));case 4:if((c&4194048)!==c)break;case 6:eo(p,c,kr,!Ys);break e;case 2:fr=null;break;case 3:case 5:break;default:throw Error(r(329))}if((c&62914560)===c&&(v=Yf+300-Ht(),10<v)){if(eo(p,c,kr,!Ys),Ge(p,0,!0)!==0)break e;rs=c,p.timeoutHandle=EE(Z1.bind(null,p,d,fr,Jf,mb,c,kr,ma,Nl,Ys,w,"Throttled",-0,0),v);break e}Z1(p,d,fr,Jf,mb,c,kr,ma,Nl,Ys,w,null,-0,0)}}break}while(!0);Ei(a)}function Z1(a,c,d,p,v,w,T,N,V,X,oe,ue,J,te){if(a.timeoutHandle=-1,ue=c.subtreeFlags,ue&8192||(ue&16785408)===16785408){ue={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Hi},V1(c,w,ue);var Oe=(w&62914560)===w?Yf-Ht():(w&4194048)===w?q1-Ht():0;if(Oe=xz(ue,Oe),Oe!==null){rs=w,a.cancelPendingCommit=Oe(rE.bind(null,a,c,w,d,p,v,T,N,V,oe,ue,null,J,te)),eo(a,w,T,!X);return}}rE(a,c,w,d,p,v,T,N,V)}function LP(a){for(var c=a;;){var d=c.tag;if((d===0||d===11||d===15)&&c.flags&16384&&(d=c.updateQueue,d!==null&&(d=d.stores,d!==null)))for(var p=0;p<d.length;p++){var v=d[p],w=v.getSnapshot;v=v.value;try{if(!br(w(),v))return!1}catch{return!1}}if(d=c.child,c.subtreeFlags&16384&&d!==null)d.return=c,c=d;else{if(c===a)break;for(;c.sibling===null;){if(c.return===null||c.return===a)return!0;c=c.return}c.sibling.return=c.return,c=c.sibling}}return!0}function eo(a,c,d,p){c&=~pb,c&=~ma,a.suspendedLanes|=c,a.pingedLanes&=~c,p&&(a.warmLanes|=c),p=a.expirationTimes;for(var v=c;0<v;){var w=31-be(v),T=1<<w;p[w]=-1,v&=~T}d!==0&&sk(a,d,c)}function Qf(){return(bt&6)===0?(vu(0),!1):!0}function vb(){if(st!==null){if(wt===0)var a=st.return;else a=st,Gi=oa=null,jy(a),kl=null,tu=0,a=st;for(;a!==null;)T1(a.alternate,a),a=a.return;st=null}}function Dl(a,c){var d=a.timeoutHandle;d!==-1&&(a.timeoutHandle=-1,nz(d)),d=a.cancelPendingCommit,d!==null&&(a.cancelPendingCommit=null,d()),rs=0,vb(),Mt=a,st=d=Fi(a.current,null),at=c,wt=0,Sr=null,Ys=!1,Ml=Dt(a,c),hb=!1,Nl=kr=pb=ma=Xs=Zt=0,fr=yu=null,mb=!1,(c&8)!==0&&(c|=c&32);var p=a.entangledLanes;if(p!==0)for(a=a.entanglements,p&=c;0<p;){var v=31-be(p),w=1<<v;c|=a[v],p&=~w}return ns=c,xf(),d}function Y1(a,c){tt=null,z.H=cu,c===Sl||c===Af?(c=fC(),wt=3):c===ky?(c=fC(),wt=4):wt=c===Xy?8:c!==null&&typeof c=="object"&&typeof c.then=="function"?6:1,Sr=c,st===null&&(Zt=1,Hf(a,zr(c,a.current)))}function X1(){var a=xr.current;return a===null?!0:(at&4194048)===at?Hr===null:(at&62914560)===at||(at&536870912)!==0?a===Hr:!1}function J1(){var a=z.H;return z.H=cu,a===null?cu:a}function Q1(){var a=z.A;return z.A=IP,a}function eh(){Zt=4,Ys||(at&4194048)!==at&&xr.current!==null||(Ml=!0),(Xs&134217727)===0&&(ma&134217727)===0||Mt===null||eo(Mt,at,kr,!1)}function xb(a,c,d){var p=bt;bt|=2;var v=J1(),w=Q1();(Mt!==a||at!==c)&&(Jf=null,Dl(a,c)),c=!1;var T=Zt;e:do try{if(wt!==0&&st!==null){var N=st,V=Sr;switch(wt){case 8:vb(),T=6;break e;case 3:case 2:case 9:case 6:xr.current===null&&(c=!0);var X=wt;if(wt=0,Sr=null,Il(a,N,V,X),d&&Ml){T=0;break e}break;default:X=wt,wt=0,Sr=null,Il(a,N,V,X)}}PP(),T=Zt;break}catch(oe){Y1(a,oe)}while(!0);return c&&a.shellSuspendCounter++,Gi=oa=null,bt=p,z.H=v,z.A=w,st===null&&(Mt=null,at=0,xf()),T}function PP(){for(;st!==null;)eE(st)}function zP(a,c){var d=bt;bt|=2;var p=J1(),v=Q1();Mt!==a||at!==c?(Jf=null,Xf=Ht()+500,Dl(a,c)):Ml=Dt(a,c);e:do try{if(wt!==0&&st!==null){c=st;var w=Sr;t:switch(wt){case 1:wt=0,Sr=null,Il(a,c,w,1);break;case 2:case 9:if(uC(w)){wt=0,Sr=null,tE(c);break}c=function(){wt!==2&&wt!==9||Mt!==a||(wt=7),Ei(a)},w.then(c,c);break e;case 3:wt=7;break e;case 4:wt=5;break e;case 7:uC(w)?(wt=0,Sr=null,tE(c)):(wt=0,Sr=null,Il(a,c,w,7));break;case 5:var T=null;switch(st.tag){case 26:T=st.memoizedState;case 5:case 27:var N=st;if(T?BE(T):N.stateNode.complete){wt=0,Sr=null;var V=N.sibling;if(V!==null)st=V;else{var X=N.return;X!==null?(st=X,th(X)):st=null}break t}}wt=0,Sr=null,Il(a,c,w,5);break;case 6:wt=0,Sr=null,Il(a,c,w,6);break;case 8:vb(),Zt=6;break e;default:throw Error(r(462))}}$P();break}catch(oe){Y1(a,oe)}while(!0);return Gi=oa=null,z.H=p,z.A=v,bt=d,st!==null?0:(Mt=null,at=0,xf(),Zt)}function $P(){for(;st!==null&&!sr();)eE(st)}function eE(a){var c=C1(a.alternate,a,ns);a.memoizedProps=a.pendingProps,c===null?th(a):st=c}function tE(a){var c=a,d=c.alternate;switch(c.tag){case 15:case 0:c=b1(d,c,c.pendingProps,c.type,void 0,at);break;case 11:c=b1(d,c,c.pendingProps,c.type.render,c.ref,at);break;case 5:jy(c);default:T1(d,c),c=st=Qk(c,ns),c=C1(d,c,ns)}a.memoizedProps=a.pendingProps,c===null?th(a):st=c}function Il(a,c,d,p){Gi=oa=null,jy(c),kl=null,tu=0;var v=c.return;try{if(_P(a,v,c,d,at)){Zt=1,Hf(a,zr(d,a.current)),st=null;return}}catch(w){if(v!==null)throw st=v,w;Zt=1,Hf(a,zr(d,a.current)),st=null;return}c.flags&32768?(ut||p===1?a=!0:Ml||(at&536870912)!==0?a=!1:(Ys=a=!0,(p===2||p===9||p===3||p===6)&&(p=xr.current,p!==null&&p.tag===13&&(p.flags|=16384))),nE(c,a)):th(c)}function th(a){var c=a;do{if((c.flags&32768)!==0){nE(c,Ys);return}a=c.return;var d=MP(c.alternate,c,ns);if(d!==null){st=d;return}if(c=c.sibling,c!==null){st=c;return}st=c=a}while(c!==null);Zt===0&&(Zt=5)}function nE(a,c){do{var d=NP(a.alternate,a);if(d!==null){d.flags&=32767,st=d;return}if(d=a.return,d!==null&&(d.flags|=32768,d.subtreeFlags=0,d.deletions=null),!c&&(a=a.sibling,a!==null)){st=a;return}st=a=d}while(a!==null);Zt=6,st=null}function rE(a,c,d,p,v,w,T,N,V){a.cancelPendingCommit=null;do nh();while(gn!==0);if((bt&6)!==0)throw Error(r(327));if(c!==null){if(c===a.current)throw Error(r(177));if(w=c.lanes|c.childLanes,w|=ly,$c(a,d,w,T,N,V),a===Mt&&(st=Mt=null,at=0),Ol=c,Qs=a,rs=d,gb=w,yb=v,G1=p,(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?(a.callbackNode=null,a.callbackPriority=0,UP(Bn,function(){return lE(),null})):(a.callbackNode=null,a.callbackPriority=0),p=(c.flags&13878)!==0,(c.subtreeFlags&13878)!==0||p){p=z.T,z.T=null,v=L.p,L.p=2,T=bt,bt|=4;try{OP(a,c,d)}finally{bt=T,L.p=v,z.T=p}}gn=1,iE(),sE(),oE()}}function iE(){if(gn===1){gn=0;var a=Qs,c=Ol,d=(c.flags&13878)!==0;if((c.subtreeFlags&13878)!==0||d){d=z.T,z.T=null;var p=L.p;L.p=2;var v=bt;bt|=4;try{z1(c,a);var w=Ob,T=Fk(a.containerInfo),N=w.focusedElem,V=w.selectionRange;if(T!==N&&N&&N.ownerDocument&&Uk(N.ownerDocument.documentElement,N)){if(V!==null&&ry(N)){var X=V.start,oe=V.end;if(oe===void 0&&(oe=X),"selectionStart"in N)N.selectionStart=X,N.selectionEnd=Math.min(oe,N.value.length);else{var ue=N.ownerDocument||document,J=ue&&ue.defaultView||window;if(J.getSelection){var te=J.getSelection(),Oe=N.textContent.length,Fe=Math.min(V.start,Oe),_t=V.end===void 0?Fe:Math.min(V.end,Oe);!te.extend&&Fe>_t&&(T=_t,_t=Fe,Fe=T);var W=Hk(N,Fe),q=Hk(N,_t);if(W&&q&&(te.rangeCount!==1||te.anchorNode!==W.node||te.anchorOffset!==W.offset||te.focusNode!==q.node||te.focusOffset!==q.offset)){var Y=ue.createRange();Y.setStart(W.node,W.offset),te.removeAllRanges(),Fe>_t?(te.addRange(Y),te.extend(q.node,q.offset)):(Y.setEnd(q.node,q.offset),te.addRange(Y))}}}}for(ue=[],te=N;te=te.parentNode;)te.nodeType===1&&ue.push({element:te,left:te.scrollLeft,top:te.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;N<ue.length;N++){var ce=ue[N];ce.element.scrollLeft=ce.left,ce.element.scrollTop=ce.top}}ph=!!Nb,Ob=Nb=null}finally{bt=v,L.p=p,z.T=d}}a.current=c,gn=2}}function sE(){if(gn===2){gn=0;var a=Qs,c=Ol,d=(c.flags&8772)!==0;if((c.subtreeFlags&8772)!==0||d){d=z.T,z.T=null;var p=L.p;L.p=2;var v=bt;bt|=4;try{D1(a,c.alternate,c)}finally{bt=v,L.p=p,z.T=d}}gn=3}}function oE(){if(gn===4||gn===3){gn=0,Ir();var a=Qs,c=Ol,d=rs,p=G1;(c.subtreeFlags&10256)!==0||(c.flags&10256)!==0?gn=5:(gn=0,Ol=Qs=null,aE(a,a.pendingLanes));var v=a.pendingLanes;if(v===0&&(Js=null),zg(d),c=c.stateNode,ie&&typeof ie.onCommitFiberRoot=="function")try{ie.onCommitFiberRoot(U,c,void 0,(c.current.flags&128)===128)}catch{}if(p!==null){c=z.T,v=L.p,L.p=2,z.T=null;try{for(var w=a.onRecoverableError,T=0;T<p.length;T++){var N=p[T];w(N.value,{componentStack:N.stack})}}finally{z.T=c,L.p=v}}(rs&3)!==0&&nh(),Ei(a),v=a.pendingLanes,(d&261930)!==0&&(v&42)!==0?a===bb?bu++:(bu=0,bb=a):bu=0,vu(0)}}function aE(a,c){(a.pooledCacheLanes&=c)===0&&(c=a.pooledCache,c!=null&&(a.pooledCache=null,Qc(c)))}function nh(){return iE(),sE(),oE(),lE()}function lE(){if(gn!==5)return!1;var a=Qs,c=gb;gb=0;var d=zg(rs),p=z.T,v=L.p;try{L.p=32>d?32:d,z.T=null,d=yb,yb=null;var w=Qs,T=rs;if(gn=0,Ol=Qs=null,rs=0,(bt&6)!==0)throw Error(r(331));var N=bt;if(bt|=4,U1(w.current),B1(w,w.current,T,d),bt=N,vu(0,!1),ie&&typeof ie.onPostCommitFiberRoot=="function")try{ie.onPostCommitFiberRoot(U,w)}catch{}return!0}finally{L.p=v,z.T=p,aE(a,c)}}function cE(a,c,d){c=zr(d,c),c=Yy(a.stateNode,c,2),a=Gs(a,c,2),a!==null&&(Ps(a,2),Ei(a))}function St(a,c,d){if(a.tag===3)cE(a,a,d);else for(;c!==null;){if(c.tag===3){cE(c,a,d);break}else if(c.tag===1){var p=c.stateNode;if(typeof c.type.getDerivedStateFromError=="function"||typeof p.componentDidCatch=="function"&&(Js===null||!Js.has(p))){a=zr(d,a),d=u1(2),p=Gs(c,d,2),p!==null&&(d1(d,p,c,a),Ps(p,2),Ei(p));break}}c=c.return}}function wb(a,c,d){var p=a.pingCache;if(p===null){p=a.pingCache=new jP;var v=new Set;p.set(c,v)}else v=p.get(c),v===void 0&&(v=new Set,p.set(c,v));v.has(d)||(hb=!0,v.add(d),a=BP.bind(null,a,c,d),c.then(a,a))}function BP(a,c,d){var p=a.pingCache;p!==null&&p.delete(c),a.pingedLanes|=a.suspendedLanes&d,a.warmLanes&=~d,Mt===a&&(at&d)===d&&(Zt===4||Zt===3&&(at&62914560)===at&&300>Ht()-Yf?(bt&2)===0&&Dl(a,0):pb|=d,Nl===at&&(Nl=0)),Ei(a)}function uE(a,c){c===0&&(c=or()),a=ra(a,c),a!==null&&(Ps(a,c),Ei(a))}function VP(a){var c=a.memoizedState,d=0;c!==null&&(d=c.retryLane),uE(a,d)}function HP(a,c){var d=0;switch(a.tag){case 31:case 13:var p=a.stateNode,v=a.memoizedState;v!==null&&(d=v.retryLane);break;case 19:p=a.stateNode;break;case 22:p=a.stateNode._retryCache;break;default:throw Error(r(314))}p!==null&&p.delete(c),uE(a,d)}function UP(a,c){return $n(a,c)}var rh=null,jl=null,Sb=!1,ih=!1,kb=!1,to=0;function Ei(a){a!==jl&&a.next===null&&(jl===null?rh=jl=a:jl=jl.next=a),ih=!0,Sb||(Sb=!0,qP())}function vu(a,c){if(!kb&&ih){kb=!0;do for(var d=!1,p=rh;p!==null;){if(a!==0){var v=p.pendingLanes;if(v===0)var w=0;else{var T=p.suspendedLanes,N=p.pingedLanes;w=(1<<31-be(42|a)+1)-1,w&=v&~(T&~N),w=w&201326741?w&201326741|1:w?w|2:0}w!==0&&(d=!0,pE(p,w))}else w=at,w=Ge(p,p===Mt?w:0,p.cancelPendingCommit!==null||p.timeoutHandle!==-1),(w&3)===0||Dt(p,w)||(d=!0,pE(p,w));p=p.next}while(d);kb=!1}}function FP(){dE()}function dE(){ih=Sb=!1;var a=0;to!==0&&tz()&&(a=to);for(var c=Ht(),d=null,p=rh;p!==null;){var v=p.next,w=fE(p,c);w===0?(p.next=null,d===null?rh=v:d.next=v,v===null&&(jl=d)):(d=p,(a!==0||(w&3)!==0)&&(ih=!0)),p=v}gn!==0&&gn!==5||vu(a),to!==0&&(to=0)}function fE(a,c){for(var d=a.suspendedLanes,p=a.pingedLanes,v=a.expirationTimes,w=a.pendingLanes&-62914561;0<w;){var T=31-be(w),N=1<<T,V=v[T];V===-1?((N&d)===0||(N&p)!==0)&&(v[T]=Zn(N,c)):V<=c&&(a.expiredLanes|=N),w&=~N}if(c=Mt,d=at,d=Ge(a,a===c?d:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p=a.callbackNode,d===0||a===c&&(wt===2||wt===9)||a.cancelPendingCommit!==null)return p!==null&&p!==null&&Dr(p),a.callbackNode=null,a.callbackPriority=0;if((d&3)===0||Dt(a,d)){if(c=d&-d,c===a.callbackPriority)return c;switch(p!==null&&Dr(p),zg(d)){case 2:case 8:d=ei;break;case 32:d=Bn;break;case 268435456:d=Ne;break;default:d=Bn}return p=hE.bind(null,a),d=$n(d,p),a.callbackPriority=c,a.callbackNode=d,c}return p!==null&&p!==null&&Dr(p),a.callbackPriority=2,a.callbackNode=null,2}function hE(a,c){if(gn!==0&&gn!==5)return a.callbackNode=null,a.callbackPriority=0,null;var d=a.callbackNode;if(nh()&&a.callbackNode!==d)return null;var p=at;return p=Ge(a,a===Mt?p:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),p===0?null:(K1(a,p,c),fE(a,Ht()),a.callbackNode!=null&&a.callbackNode===d?hE.bind(null,a):null)}function pE(a,c){if(nh())return null;K1(a,c,!0)}function qP(){rz(function(){(bt&6)!==0?$n(yr,FP):dE()})}function Cb(){if(to===0){var a=xl;a===0&&(a=se,se<<=1,(se&261888)===0&&(se=256)),to=a}return to}function mE(a){return a==null||typeof a=="symbol"||typeof a=="boolean"?null:typeof a=="function"?a:ff(""+a)}function gE(a,c){var d=c.ownerDocument.createElement("input");return d.name=c.name,d.value=c.value,a.id&&d.setAttribute("form",a.id),c.parentNode.insertBefore(d,c),a=new FormData(a),d.parentNode.removeChild(d),a}function GP(a,c,d,p,v){if(c==="submit"&&d&&d.stateNode===v){var w=mE((v[ar]||null).action),T=p.submitter;T&&(c=(c=T[ar]||null)?mE(c.formAction):T.getAttribute("formAction"),c!==null&&(w=c,T=null));var N=new gf("action","action",null,p,v);a.push({event:N,listeners:[{instance:null,listener:function(){if(p.defaultPrevented){if(to!==0){var V=T?gE(v,T):new FormData(v);Fy(d,{pending:!0,data:V,method:v.method,action:w},null,V)}}else typeof w=="function"&&(N.preventDefault(),V=T?gE(v,T):new FormData(v),Fy(d,{pending:!0,data:V,method:v.method,action:w},w,V))},currentTarget:v}]})}}for(var Eb=0;Eb<ay.length;Eb++){var Tb=ay[Eb],WP=Tb.toLowerCase(),KP=Tb[0].toUpperCase()+Tb.slice(1);ti(WP,"on"+KP)}ti(Wk,"onAnimationEnd"),ti(Kk,"onAnimationIteration"),ti(Zk,"onAnimationStart"),ti("dblclick","onDoubleClick"),ti("focusin","onFocus"),ti("focusout","onBlur"),ti(uP,"onTransitionRun"),ti(dP,"onTransitionStart"),ti(fP,"onTransitionCancel"),ti(Yk,"onTransitionEnd"),ol("onMouseEnter",["mouseout","mouseover"]),ol("onMouseLeave",["mouseout","mouseover"]),ol("onPointerEnter",["pointerout","pointerover"]),ol("onPointerLeave",["pointerout","pointerover"]),Qo("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Qo("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Qo("onBeforeInput",["compositionend","keypress","textInput","paste"]),Qo("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Qo("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Qo("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var xu="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(" "),ZP=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(xu));function yE(a,c){c=(c&4)!==0;for(var d=0;d<a.length;d++){var p=a[d],v=p.event;p=p.listeners;e:{var w=void 0;if(c)for(var T=p.length-1;0<=T;T--){var N=p[T],V=N.instance,X=N.currentTarget;if(N=N.listener,V!==w&&v.isPropagationStopped())break e;w=N,v.currentTarget=X;try{w(v)}catch(oe){vf(oe)}v.currentTarget=null,w=V}else for(T=0;T<p.length;T++){if(N=p[T],V=N.instance,X=N.currentTarget,N=N.listener,V!==w&&v.isPropagationStopped())break e;w=N,v.currentTarget=X;try{w(v)}catch(oe){vf(oe)}v.currentTarget=null,w=V}}}}function ot(a,c){var d=c[$g];d===void 0&&(d=c[$g]=new Set);var p=a+"__bubble";d.has(p)||(bE(c,a,2,!1),d.add(p))}function _b(a,c,d){var p=0;c&&(p|=4),bE(d,a,p,c)}var sh="_reactListening"+Math.random().toString(36).slice(2);function Ab(a){if(!a[sh]){a[sh]=!0,dk.forEach(function(d){d!=="selectionchange"&&(ZP.has(d)||_b(d,!1,a),_b(d,!0,a))});var c=a.nodeType===9?a:a.ownerDocument;c===null||c[sh]||(c[sh]=!0,_b("selectionchange",!1,c))}}function bE(a,c,d,p){switch(WE(c)){case 2:var v=kz;break;case 8:v=Cz;break;default:v=Ub}d=v.bind(null,c,d,a),v=void 0,!Kg||c!=="touchstart"&&c!=="touchmove"&&c!=="wheel"||(v=!0),p?v!==void 0?a.addEventListener(c,d,{capture:!0,passive:v}):a.addEventListener(c,d,!0):v!==void 0?a.addEventListener(c,d,{passive:v}):a.addEventListener(c,d,!1)}function Rb(a,c,d,p,v){var w=p;if((c&1)===0&&(c&2)===0&&p!==null)e:for(;;){if(p===null)return;var T=p.tag;if(T===3||T===4){var N=p.stateNode.containerInfo;if(N===v)break;if(T===4)for(T=p.return;T!==null;){var V=T.tag;if((V===3||V===4)&&T.stateNode.containerInfo===v)return;T=T.return}for(;N!==null;){if(T=rl(N),T===null)return;if(V=T.tag,V===5||V===6||V===26||V===27){p=w=T;continue e}N=N.parentNode}}p=p.return}kk(function(){var X=w,oe=Gg(d),ue=[];e:{var J=Xk.get(a);if(J!==void 0){var te=gf,Oe=a;switch(a){case"keypress":if(pf(d)===0)break e;case"keydown":case"keyup":te=H2;break;case"focusin":Oe="focus",te=Jg;break;case"focusout":Oe="blur",te=Jg;break;case"beforeblur":case"afterblur":te=Jg;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":te=Tk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":te=M2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":te=q2;break;case Wk:case Kk:case Zk:te=D2;break;case Yk:te=W2;break;case"scroll":case"scrollend":te=A2;break;case"wheel":te=Z2;break;case"copy":case"cut":case"paste":te=j2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":te=Ak;break;case"toggle":case"beforetoggle":te=X2}var Fe=(c&4)!==0,_t=!Fe&&(a==="scroll"||a==="scrollend"),W=Fe?J!==null?J+"Capture":null:J;Fe=[];for(var q=X,Y;q!==null;){var ce=q;if(Y=ce.stateNode,ce=ce.tag,ce!==5&&ce!==26&&ce!==27||Y===null||W===null||(ce=Hc(q,W),ce!=null&&Fe.push(wu(q,ce,Y))),_t)break;q=q.return}0<Fe.length&&(J=new te(J,Oe,null,d,oe),ue.push({event:J,listeners:Fe}))}}if((c&7)===0){e:{if(J=a==="mouseover"||a==="pointerover",te=a==="mouseout"||a==="pointerout",J&&d!==qg&&(Oe=d.relatedTarget||d.fromElement)&&(rl(Oe)||Oe[nl]))break e;if((te||J)&&(J=oe.window===oe?oe:(J=oe.ownerDocument)?J.defaultView||J.parentWindow:window,te?(Oe=d.relatedTarget||d.toElement,te=X,Oe=Oe?rl(Oe):null,Oe!==null&&(_t=s(Oe),Fe=Oe.tag,Oe!==_t||Fe!==5&&Fe!==27&&Fe!==6)&&(Oe=null)):(te=null,Oe=X),te!==Oe)){if(Fe=Tk,ce="onMouseLeave",W="onMouseEnter",q="mouse",(a==="pointerout"||a==="pointerover")&&(Fe=Ak,ce="onPointerLeave",W="onPointerEnter",q="pointer"),_t=te==null?J:Vc(te),Y=Oe==null?J:Vc(Oe),J=new Fe(ce,q+"leave",te,d,oe),J.target=_t,J.relatedTarget=Y,ce=null,rl(oe)===X&&(Fe=new Fe(W,q+"enter",Oe,d,oe),Fe.target=Y,Fe.relatedTarget=_t,ce=Fe),_t=ce,te&&Oe)t:{for(Fe=YP,W=te,q=Oe,Y=0,ce=W;ce;ce=Fe(ce))Y++;ce=0;for(var Ve=q;Ve;Ve=Fe(Ve))ce++;for(;0<Y-ce;)W=Fe(W),Y--;for(;0<ce-Y;)q=Fe(q),ce--;for(;Y--;){if(W===q||q!==null&&W===q.alternate){Fe=W;break t}W=Fe(W),q=Fe(q)}Fe=null}else Fe=null;te!==null&&vE(ue,J,te,Fe,!1),Oe!==null&&_t!==null&&vE(ue,_t,Oe,Fe,!0)}}e:{if(J=X?Vc(X):window,te=J.nodeName&&J.nodeName.toLowerCase(),te==="select"||te==="input"&&J.type==="file")var ht=Lk;else if(Ik(J))if(Pk)ht=aP;else{ht=sP;var Le=iP}else te=J.nodeName,!te||te.toLowerCase()!=="input"||J.type!=="checkbox"&&J.type!=="radio"?X&&Fg(X.elementType)&&(ht=Lk):ht=oP;if(ht&&(ht=ht(a,X))){jk(ue,ht,d,oe);break e}Le&&Le(a,J,X),a==="focusout"&&X&&J.type==="number"&&X.memoizedProps.value!=null&&Ug(J,"number",J.value)}switch(Le=X?Vc(X):window,a){case"focusin":(Ik(Le)||Le.contentEditable==="true")&&(fl=Le,iy=X,Yc=null);break;case"focusout":Yc=iy=fl=null;break;case"mousedown":sy=!0;break;case"contextmenu":case"mouseup":case"dragend":sy=!1,qk(ue,d,oe);break;case"selectionchange":if(cP)break;case"keydown":case"keyup":qk(ue,d,oe)}var nt;if(ey)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else dl?Ok(a,d)&&(lt="onCompositionEnd"):a==="keydown"&&d.keyCode===229&&(lt="onCompositionStart");lt&&(Rk&&d.locale!=="ko"&&(dl||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&dl&&(nt=Ck()):($s=oe,Zg="value"in $s?$s.value:$s.textContent,dl=!0)),Le=oh(X,lt),0<Le.length&&(lt=new _k(lt,a,null,d,oe),ue.push({event:lt,listeners:Le}),nt?lt.data=nt:(nt=Dk(d),nt!==null&&(lt.data=nt)))),(nt=Q2?eP(a,d):tP(a,d))&&(lt=oh(X,"onBeforeInput"),0<lt.length&&(Le=new _k("onBeforeInput","beforeinput",null,d,oe),ue.push({event:Le,listeners:lt}),Le.data=nt)),GP(ue,a,X,d,oe)}yE(ue,c)})}function wu(a,c,d){return{instance:a,listener:c,currentTarget:d}}function oh(a,c){for(var d=c+"Capture",p=[];a!==null;){var v=a,w=v.stateNode;if(v=v.tag,v!==5&&v!==26&&v!==27||w===null||(v=Hc(a,d),v!=null&&p.unshift(wu(a,v,w)),v=Hc(a,c),v!=null&&p.push(wu(a,v,w))),a.tag===3)return p;a=a.return}return[]}function YP(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5&&a.tag!==27);return a||null}function vE(a,c,d,p,v){for(var w=c._reactName,T=[];d!==null&&d!==p;){var N=d,V=N.alternate,X=N.stateNode;if(N=N.tag,V!==null&&V===p)break;N!==5&&N!==26&&N!==27||X===null||(V=X,v?(X=Hc(d,w),X!=null&&T.unshift(wu(d,X,V))):v||(X=Hc(d,w),X!=null&&T.push(wu(d,X,V)))),d=d.return}T.length!==0&&a.push({event:c,listeners:T})}var XP=/\r\n?/g,JP=/\u0000|\uFFFD/g;function xE(a){return(typeof a=="string"?a:""+a).replace(XP,`
|
|
9
|
+
`).replace(JP,"")}function wE(a,c){return c=xE(c),xE(a)===c}function Tt(a,c,d,p,v,w){switch(d){case"children":typeof p=="string"?c==="body"||c==="textarea"&&p===""||ll(a,p):(typeof p=="number"||typeof p=="bigint")&&c!=="body"&&ll(a,""+p);break;case"className":uf(a,"class",p);break;case"tabIndex":uf(a,"tabindex",p);break;case"dir":case"role":case"viewBox":case"width":case"height":uf(a,d,p);break;case"style":wk(a,p,w);break;case"data":if(c!=="object"){uf(a,"data",p);break}case"src":case"href":if(p===""&&(c!=="a"||d!=="href")){a.removeAttribute(d);break}if(p==null||typeof p=="function"||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(d);break}p=ff(""+p),a.setAttribute(d,p);break;case"action":case"formAction":if(typeof p=="function"){a.setAttribute(d,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof w=="function"&&(d==="formAction"?(c!=="input"&&Tt(a,c,"name",v.name,v,null),Tt(a,c,"formEncType",v.formEncType,v,null),Tt(a,c,"formMethod",v.formMethod,v,null),Tt(a,c,"formTarget",v.formTarget,v,null)):(Tt(a,c,"encType",v.encType,v,null),Tt(a,c,"method",v.method,v,null),Tt(a,c,"target",v.target,v,null)));if(p==null||typeof p=="symbol"||typeof p=="boolean"){a.removeAttribute(d);break}p=ff(""+p),a.setAttribute(d,p);break;case"onClick":p!=null&&(a.onclick=Hi);break;case"onScroll":p!=null&&ot("scroll",a);break;case"onScrollEnd":p!=null&&ot("scrollend",a);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(r(61));if(d=p.__html,d!=null){if(v.children!=null)throw Error(r(60));a.innerHTML=d}}break;case"multiple":a.multiple=p&&typeof p!="function"&&typeof p!="symbol";break;case"muted":a.muted=p&&typeof p!="function"&&typeof p!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(p==null||typeof p=="function"||typeof p=="boolean"||typeof p=="symbol"){a.removeAttribute("xlink:href");break}d=ff(""+p),a.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",d);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":p!=null&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(d,""+p):a.removeAttribute(d);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":p&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(d,""):a.removeAttribute(d);break;case"capture":case"download":p===!0?a.setAttribute(d,""):p!==!1&&p!=null&&typeof p!="function"&&typeof p!="symbol"?a.setAttribute(d,p):a.removeAttribute(d);break;case"cols":case"rows":case"size":case"span":p!=null&&typeof p!="function"&&typeof p!="symbol"&&!isNaN(p)&&1<=p?a.setAttribute(d,p):a.removeAttribute(d);break;case"rowSpan":case"start":p==null||typeof p=="function"||typeof p=="symbol"||isNaN(p)?a.removeAttribute(d):a.setAttribute(d,p);break;case"popover":ot("beforetoggle",a),ot("toggle",a),cf(a,"popover",p);break;case"xlinkActuate":Vi(a,"http://www.w3.org/1999/xlink","xlink:actuate",p);break;case"xlinkArcrole":Vi(a,"http://www.w3.org/1999/xlink","xlink:arcrole",p);break;case"xlinkRole":Vi(a,"http://www.w3.org/1999/xlink","xlink:role",p);break;case"xlinkShow":Vi(a,"http://www.w3.org/1999/xlink","xlink:show",p);break;case"xlinkTitle":Vi(a,"http://www.w3.org/1999/xlink","xlink:title",p);break;case"xlinkType":Vi(a,"http://www.w3.org/1999/xlink","xlink:type",p);break;case"xmlBase":Vi(a,"http://www.w3.org/XML/1998/namespace","xml:base",p);break;case"xmlLang":Vi(a,"http://www.w3.org/XML/1998/namespace","xml:lang",p);break;case"xmlSpace":Vi(a,"http://www.w3.org/XML/1998/namespace","xml:space",p);break;case"is":cf(a,"is",p);break;case"innerText":case"textContent":break;default:(!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(d=T2.get(d)||d,cf(a,d,p))}}function Mb(a,c,d,p,v,w){switch(d){case"style":wk(a,p,w);break;case"dangerouslySetInnerHTML":if(p!=null){if(typeof p!="object"||!("__html"in p))throw Error(r(61));if(d=p.__html,d!=null){if(v.children!=null)throw Error(r(60));a.innerHTML=d}}break;case"children":typeof p=="string"?ll(a,p):(typeof p=="number"||typeof p=="bigint")&&ll(a,""+p);break;case"onScroll":p!=null&&ot("scroll",a);break;case"onScrollEnd":p!=null&&ot("scrollend",a);break;case"onClick":p!=null&&(a.onclick=Hi);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!fk.hasOwnProperty(d))e:{if(d[0]==="o"&&d[1]==="n"&&(v=d.endsWith("Capture"),c=d.slice(2,v?d.length-7:void 0),w=a[ar]||null,w=w!=null?w[d]:null,typeof w=="function"&&a.removeEventListener(c,w,v),typeof p=="function")){typeof w!="function"&&w!==null&&(d in a?a[d]=null:a.hasAttribute(d)&&a.removeAttribute(d)),a.addEventListener(c,p,v);break e}d in a?a[d]=p:p===!0?a.setAttribute(d,""):cf(a,d,p)}}}function Nn(a,c,d){switch(c){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":ot("error",a),ot("load",a);var p=!1,v=!1,w;for(w in d)if(d.hasOwnProperty(w)){var T=d[w];if(T!=null)switch(w){case"src":p=!0;break;case"srcSet":v=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,c));default:Tt(a,c,w,T,d,null)}}v&&Tt(a,c,"srcSet",d.srcSet,d,null),p&&Tt(a,c,"src",d.src,d,null);return;case"input":ot("invalid",a);var N=w=T=v=null,V=null,X=null;for(p in d)if(d.hasOwnProperty(p)){var oe=d[p];if(oe!=null)switch(p){case"name":v=oe;break;case"type":T=oe;break;case"checked":V=oe;break;case"defaultChecked":X=oe;break;case"value":w=oe;break;case"defaultValue":N=oe;break;case"children":case"dangerouslySetInnerHTML":if(oe!=null)throw Error(r(137,c));break;default:Tt(a,c,p,oe,d,null)}}yk(a,w,N,V,X,T,v,!1);return;case"select":ot("invalid",a),p=T=w=null;for(v in d)if(d.hasOwnProperty(v)&&(N=d[v],N!=null))switch(v){case"value":w=N;break;case"defaultValue":T=N;break;case"multiple":p=N;default:Tt(a,c,v,N,d,null)}c=w,d=T,a.multiple=!!p,c!=null?al(a,!!p,c,!1):d!=null&&al(a,!!p,d,!0);return;case"textarea":ot("invalid",a),w=v=p=null;for(T in d)if(d.hasOwnProperty(T)&&(N=d[T],N!=null))switch(T){case"value":p=N;break;case"defaultValue":v=N;break;case"children":w=N;break;case"dangerouslySetInnerHTML":if(N!=null)throw Error(r(91));break;default:Tt(a,c,T,N,d,null)}vk(a,p,v,w);return;case"option":for(V in d)d.hasOwnProperty(V)&&(p=d[V],p!=null)&&(V==="selected"?a.selected=p&&typeof p!="function"&&typeof p!="symbol":Tt(a,c,V,p,d,null));return;case"dialog":ot("beforetoggle",a),ot("toggle",a),ot("cancel",a),ot("close",a);break;case"iframe":case"object":ot("load",a);break;case"video":case"audio":for(p=0;p<xu.length;p++)ot(xu[p],a);break;case"image":ot("error",a),ot("load",a);break;case"details":ot("toggle",a);break;case"embed":case"source":case"link":ot("error",a),ot("load",a);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(X in d)if(d.hasOwnProperty(X)&&(p=d[X],p!=null))switch(X){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,c));default:Tt(a,c,X,p,d,null)}return;default:if(Fg(c)){for(oe in d)d.hasOwnProperty(oe)&&(p=d[oe],p!==void 0&&Mb(a,c,oe,p,d,void 0));return}}for(N in d)d.hasOwnProperty(N)&&(p=d[N],p!=null&&Tt(a,c,N,p,d,null))}function QP(a,c,d,p){switch(c){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var v=null,w=null,T=null,N=null,V=null,X=null,oe=null;for(te in d){var ue=d[te];if(d.hasOwnProperty(te)&&ue!=null)switch(te){case"checked":break;case"value":break;case"defaultValue":V=ue;default:p.hasOwnProperty(te)||Tt(a,c,te,null,p,ue)}}for(var J in p){var te=p[J];if(ue=d[J],p.hasOwnProperty(J)&&(te!=null||ue!=null))switch(J){case"type":w=te;break;case"name":v=te;break;case"checked":X=te;break;case"defaultChecked":oe=te;break;case"value":T=te;break;case"defaultValue":N=te;break;case"children":case"dangerouslySetInnerHTML":if(te!=null)throw Error(r(137,c));break;default:te!==ue&&Tt(a,c,J,te,p,ue)}}Hg(a,T,N,V,X,oe,w,v);return;case"select":te=T=N=J=null;for(w in d)if(V=d[w],d.hasOwnProperty(w)&&V!=null)switch(w){case"value":break;case"multiple":te=V;default:p.hasOwnProperty(w)||Tt(a,c,w,null,p,V)}for(v in p)if(w=p[v],V=d[v],p.hasOwnProperty(v)&&(w!=null||V!=null))switch(v){case"value":J=w;break;case"defaultValue":N=w;break;case"multiple":T=w;default:w!==V&&Tt(a,c,v,w,p,V)}c=N,d=T,p=te,J!=null?al(a,!!d,J,!1):!!p!=!!d&&(c!=null?al(a,!!d,c,!0):al(a,!!d,d?[]:"",!1));return;case"textarea":te=J=null;for(N in d)if(v=d[N],d.hasOwnProperty(N)&&v!=null&&!p.hasOwnProperty(N))switch(N){case"value":break;case"children":break;default:Tt(a,c,N,null,p,v)}for(T in p)if(v=p[T],w=d[T],p.hasOwnProperty(T)&&(v!=null||w!=null))switch(T){case"value":J=v;break;case"defaultValue":te=v;break;case"children":break;case"dangerouslySetInnerHTML":if(v!=null)throw Error(r(91));break;default:v!==w&&Tt(a,c,T,v,p,w)}bk(a,J,te);return;case"option":for(var Oe in d)J=d[Oe],d.hasOwnProperty(Oe)&&J!=null&&!p.hasOwnProperty(Oe)&&(Oe==="selected"?a.selected=!1:Tt(a,c,Oe,null,p,J));for(V in p)J=p[V],te=d[V],p.hasOwnProperty(V)&&J!==te&&(J!=null||te!=null)&&(V==="selected"?a.selected=J&&typeof J!="function"&&typeof J!="symbol":Tt(a,c,V,J,p,te));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Fe in d)J=d[Fe],d.hasOwnProperty(Fe)&&J!=null&&!p.hasOwnProperty(Fe)&&Tt(a,c,Fe,null,p,J);for(X in p)if(J=p[X],te=d[X],p.hasOwnProperty(X)&&J!==te&&(J!=null||te!=null))switch(X){case"children":case"dangerouslySetInnerHTML":if(J!=null)throw Error(r(137,c));break;default:Tt(a,c,X,J,p,te)}return;default:if(Fg(c)){for(var _t in d)J=d[_t],d.hasOwnProperty(_t)&&J!==void 0&&!p.hasOwnProperty(_t)&&Mb(a,c,_t,void 0,p,J);for(oe in p)J=p[oe],te=d[oe],!p.hasOwnProperty(oe)||J===te||J===void 0&&te===void 0||Mb(a,c,oe,J,p,te);return}}for(var W in d)J=d[W],d.hasOwnProperty(W)&&J!=null&&!p.hasOwnProperty(W)&&Tt(a,c,W,null,p,J);for(ue in p)J=p[ue],te=d[ue],!p.hasOwnProperty(ue)||J===te||J==null&&te==null||Tt(a,c,ue,J,p,te)}function SE(a){switch(a){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function ez(){if(typeof performance.getEntriesByType=="function"){for(var a=0,c=0,d=performance.getEntriesByType("resource"),p=0;p<d.length;p++){var v=d[p],w=v.transferSize,T=v.initiatorType,N=v.duration;if(w&&N&&SE(T)){for(T=0,N=v.responseEnd,p+=1;p<d.length;p++){var V=d[p],X=V.startTime;if(X>N)break;var oe=V.transferSize,ue=V.initiatorType;oe&&SE(ue)&&(V=V.responseEnd,T+=oe*(V<N?1:(N-X)/(V-X)))}if(--p,c+=8*(w+T)/(v.duration/1e3),a++,10<a)break}}if(0<a)return c/a/1e6}return navigator.connection&&(a=navigator.connection.downlink,typeof a=="number")?a:5}var Nb=null,Ob=null;function ah(a){return a.nodeType===9?a:a.ownerDocument}function kE(a){switch(a){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function CE(a,c){if(a===0)switch(c){case"svg":return 1;case"math":return 2;default:return 0}return a===1&&c==="foreignObject"?0:a}function Db(a,c){return a==="textarea"||a==="noscript"||typeof c.children=="string"||typeof c.children=="number"||typeof c.children=="bigint"||typeof c.dangerouslySetInnerHTML=="object"&&c.dangerouslySetInnerHTML!==null&&c.dangerouslySetInnerHTML.__html!=null}var Ib=null;function tz(){var a=window.event;return a&&a.type==="popstate"?a===Ib?!1:(Ib=a,!0):(Ib=null,!1)}var EE=typeof setTimeout=="function"?setTimeout:void 0,nz=typeof clearTimeout=="function"?clearTimeout:void 0,TE=typeof Promise=="function"?Promise:void 0,rz=typeof queueMicrotask=="function"?queueMicrotask:typeof TE<"u"?function(a){return TE.resolve(null).then(a).catch(iz)}:EE;function iz(a){setTimeout(function(){throw a})}function no(a){return a==="head"}function _E(a,c){var d=c,p=0;do{var v=d.nextSibling;if(a.removeChild(d),v&&v.nodeType===8)if(d=v.data,d==="/$"||d==="/&"){if(p===0){a.removeChild(v),$l(c);return}p--}else if(d==="$"||d==="$?"||d==="$~"||d==="$!"||d==="&")p++;else if(d==="html")Su(a.ownerDocument.documentElement);else if(d==="head"){d=a.ownerDocument.head,Su(d);for(var w=d.firstChild;w;){var T=w.nextSibling,N=w.nodeName;w[Bc]||N==="SCRIPT"||N==="STYLE"||N==="LINK"&&w.rel.toLowerCase()==="stylesheet"||d.removeChild(w),w=T}}else d==="body"&&Su(a.ownerDocument.body);d=v}while(d);$l(c)}function AE(a,c){var d=a;a=0;do{var p=d.nextSibling;if(d.nodeType===1?c?(d._stashedDisplay=d.style.display,d.style.display="none"):(d.style.display=d._stashedDisplay||"",d.getAttribute("style")===""&&d.removeAttribute("style")):d.nodeType===3&&(c?(d._stashedText=d.nodeValue,d.nodeValue=""):d.nodeValue=d._stashedText||""),p&&p.nodeType===8)if(d=p.data,d==="/$"){if(a===0)break;a--}else d!=="$"&&d!=="$?"&&d!=="$~"&&d!=="$!"||a++;d=p}while(d)}function jb(a){var c=a.firstChild;for(c&&c.nodeType===10&&(c=c.nextSibling);c;){var d=c;switch(c=c.nextSibling,d.nodeName){case"HTML":case"HEAD":case"BODY":jb(d),Bg(d);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(d.rel.toLowerCase()==="stylesheet")continue}a.removeChild(d)}}function sz(a,c,d,p){for(;a.nodeType===1;){var v=d;if(a.nodeName.toLowerCase()!==c.toLowerCase()){if(!p&&(a.nodeName!=="INPUT"||a.type!=="hidden"))break}else if(p){if(!a[Bc])switch(c){case"meta":if(!a.hasAttribute("itemprop"))break;return a;case"link":if(w=a.getAttribute("rel"),w==="stylesheet"&&a.hasAttribute("data-precedence"))break;if(w!==v.rel||a.getAttribute("href")!==(v.href==null||v.href===""?null:v.href)||a.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin)||a.getAttribute("title")!==(v.title==null?null:v.title))break;return a;case"style":if(a.hasAttribute("data-precedence"))break;return a;case"script":if(w=a.getAttribute("src"),(w!==(v.src==null?null:v.src)||a.getAttribute("type")!==(v.type==null?null:v.type)||a.getAttribute("crossorigin")!==(v.crossOrigin==null?null:v.crossOrigin))&&w&&a.hasAttribute("async")&&!a.hasAttribute("itemprop"))break;return a;default:return a}}else if(c==="input"&&a.type==="hidden"){var w=v.name==null?null:""+v.name;if(v.type==="hidden"&&a.getAttribute("name")===w)return a}else return a;if(a=Ur(a.nextSibling),a===null)break}return null}function oz(a,c,d){if(c==="")return null;for(;a.nodeType!==3;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!d||(a=Ur(a.nextSibling),a===null))return null;return a}function RE(a,c){for(;a.nodeType!==8;)if((a.nodeType!==1||a.nodeName!=="INPUT"||a.type!=="hidden")&&!c||(a=Ur(a.nextSibling),a===null))return null;return a}function Lb(a){return a.data==="$?"||a.data==="$~"}function Pb(a){return a.data==="$!"||a.data==="$?"&&a.ownerDocument.readyState!=="loading"}function az(a,c){var d=a.ownerDocument;if(a.data==="$~")a._reactRetry=c;else if(a.data!=="$?"||d.readyState!=="loading")c();else{var p=function(){c(),d.removeEventListener("DOMContentLoaded",p)};d.addEventListener("DOMContentLoaded",p),a._reactRetry=p}}function Ur(a){for(;a!=null;a=a.nextSibling){var c=a.nodeType;if(c===1||c===3)break;if(c===8){if(c=a.data,c==="$"||c==="$!"||c==="$?"||c==="$~"||c==="&"||c==="F!"||c==="F")break;if(c==="/$"||c==="/&")return null}}return a}var zb=null;function ME(a){a=a.nextSibling;for(var c=0;a;){if(a.nodeType===8){var d=a.data;if(d==="/$"||d==="/&"){if(c===0)return Ur(a.nextSibling);c--}else d!=="$"&&d!=="$!"&&d!=="$?"&&d!=="$~"&&d!=="&"||c++}a=a.nextSibling}return null}function NE(a){a=a.previousSibling;for(var c=0;a;){if(a.nodeType===8){var d=a.data;if(d==="$"||d==="$!"||d==="$?"||d==="$~"||d==="&"){if(c===0)return a;c--}else d!=="/$"&&d!=="/&"||c++}a=a.previousSibling}return null}function OE(a,c,d){switch(c=ah(d),a){case"html":if(a=c.documentElement,!a)throw Error(r(452));return a;case"head":if(a=c.head,!a)throw Error(r(453));return a;case"body":if(a=c.body,!a)throw Error(r(454));return a;default:throw Error(r(451))}}function Su(a){for(var c=a.attributes;c.length;)a.removeAttributeNode(c[0]);Bg(a)}var Fr=new Map,DE=new Set;function lh(a){return typeof a.getRootNode=="function"?a.getRootNode():a.nodeType===9?a:a.ownerDocument}var is=L.d;L.d={f:lz,r:cz,D:uz,C:dz,L:fz,m:hz,X:mz,S:pz,M:gz};function lz(){var a=is.f(),c=Qf();return a||c}function cz(a){var c=il(a);c!==null&&c.tag===5&&c.type==="form"?YC(c):is.r(a)}var Ll=typeof document>"u"?null:document;function IE(a,c,d){var p=Ll;if(p&&typeof c=="string"&&c){var v=Lr(c);v='link[rel="'+a+'"][href="'+v+'"]',typeof d=="string"&&(v+='[crossorigin="'+d+'"]'),DE.has(v)||(DE.add(v),a={rel:a,crossOrigin:d,href:c},p.querySelector(v)===null&&(c=p.createElement("link"),Nn(c,"link",a),bn(c),p.head.appendChild(c)))}}function uz(a){is.D(a),IE("dns-prefetch",a,null)}function dz(a,c){is.C(a,c),IE("preconnect",a,c)}function fz(a,c,d){is.L(a,c,d);var p=Ll;if(p&&a&&c){var v='link[rel="preload"][as="'+Lr(c)+'"]';c==="image"&&d&&d.imageSrcSet?(v+='[imagesrcset="'+Lr(d.imageSrcSet)+'"]',typeof d.imageSizes=="string"&&(v+='[imagesizes="'+Lr(d.imageSizes)+'"]')):v+='[href="'+Lr(a)+'"]';var w=v;switch(c){case"style":w=Pl(a);break;case"script":w=zl(a)}Fr.has(w)||(a=m({rel:"preload",href:c==="image"&&d&&d.imageSrcSet?void 0:a,as:c},d),Fr.set(w,a),p.querySelector(v)!==null||c==="style"&&p.querySelector(ku(w))||c==="script"&&p.querySelector(Cu(w))||(c=p.createElement("link"),Nn(c,"link",a),bn(c),p.head.appendChild(c)))}}function hz(a,c){is.m(a,c);var d=Ll;if(d&&a){var p=c&&typeof c.as=="string"?c.as:"script",v='link[rel="modulepreload"][as="'+Lr(p)+'"][href="'+Lr(a)+'"]',w=v;switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":w=zl(a)}if(!Fr.has(w)&&(a=m({rel:"modulepreload",href:a},c),Fr.set(w,a),d.querySelector(v)===null)){switch(p){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(d.querySelector(Cu(w)))return}p=d.createElement("link"),Nn(p,"link",a),bn(p),d.head.appendChild(p)}}}function pz(a,c,d){is.S(a,c,d);var p=Ll;if(p&&a){var v=sl(p).hoistableStyles,w=Pl(a);c=c||"default";var T=v.get(w);if(!T){var N={loading:0,preload:null};if(T=p.querySelector(ku(w)))N.loading=5;else{a=m({rel:"stylesheet",href:a,"data-precedence":c},d),(d=Fr.get(w))&&$b(a,d);var V=T=p.createElement("link");bn(V),Nn(V,"link",a),V._p=new Promise(function(X,oe){V.onload=X,V.onerror=oe}),V.addEventListener("load",function(){N.loading|=1}),V.addEventListener("error",function(){N.loading|=2}),N.loading|=4,ch(T,c,p)}T={type:"stylesheet",instance:T,count:1,state:N},v.set(w,T)}}}function mz(a,c){is.X(a,c);var d=Ll;if(d&&a){var p=sl(d).hoistableScripts,v=zl(a),w=p.get(v);w||(w=d.querySelector(Cu(v)),w||(a=m({src:a,async:!0},c),(c=Fr.get(v))&&Bb(a,c),w=d.createElement("script"),bn(w),Nn(w,"link",a),d.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},p.set(v,w))}}function gz(a,c){is.M(a,c);var d=Ll;if(d&&a){var p=sl(d).hoistableScripts,v=zl(a),w=p.get(v);w||(w=d.querySelector(Cu(v)),w||(a=m({src:a,async:!0,type:"module"},c),(c=Fr.get(v))&&Bb(a,c),w=d.createElement("script"),bn(w),Nn(w,"link",a),d.head.appendChild(w)),w={type:"script",instance:w,count:1,state:null},p.set(v,w))}}function jE(a,c,d,p){var v=(v=Re.current)?lh(v):null;if(!v)throw Error(r(446));switch(a){case"meta":case"title":return null;case"style":return typeof d.precedence=="string"&&typeof d.href=="string"?(c=Pl(d.href),d=sl(v).hoistableStyles,p=d.get(c),p||(p={type:"style",instance:null,count:0,state:null},d.set(c,p)),p):{type:"void",instance:null,count:0,state:null};case"link":if(d.rel==="stylesheet"&&typeof d.href=="string"&&typeof d.precedence=="string"){a=Pl(d.href);var w=sl(v).hoistableStyles,T=w.get(a);if(T||(v=v.ownerDocument||v,T={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},w.set(a,T),(w=v.querySelector(ku(a)))&&!w._p&&(T.instance=w,T.state.loading=5),Fr.has(a)||(d={rel:"preload",as:"style",href:d.href,crossOrigin:d.crossOrigin,integrity:d.integrity,media:d.media,hrefLang:d.hrefLang,referrerPolicy:d.referrerPolicy},Fr.set(a,d),w||yz(v,a,d,T.state))),c&&p===null)throw Error(r(528,""));return T}if(c&&p!==null)throw Error(r(529,""));return null;case"script":return c=d.async,d=d.src,typeof d=="string"&&c&&typeof c!="function"&&typeof c!="symbol"?(c=zl(d),d=sl(v).hoistableScripts,p=d.get(c),p||(p={type:"script",instance:null,count:0,state:null},d.set(c,p)),p):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,a))}}function Pl(a){return'href="'+Lr(a)+'"'}function ku(a){return'link[rel="stylesheet"]['+a+"]"}function LE(a){return m({},a,{"data-precedence":a.precedence,precedence:null})}function yz(a,c,d,p){a.querySelector('link[rel="preload"][as="style"]['+c+"]")?p.loading=1:(c=a.createElement("link"),p.preload=c,c.addEventListener("load",function(){return p.loading|=1}),c.addEventListener("error",function(){return p.loading|=2}),Nn(c,"link",d),bn(c),a.head.appendChild(c))}function zl(a){return'[src="'+Lr(a)+'"]'}function Cu(a){return"script[async]"+a}function PE(a,c,d){if(c.count++,c.instance===null)switch(c.type){case"style":var p=a.querySelector('style[data-href~="'+Lr(d.href)+'"]');if(p)return c.instance=p,bn(p),p;var v=m({},d,{"data-href":d.href,"data-precedence":d.precedence,href:null,precedence:null});return p=(a.ownerDocument||a).createElement("style"),bn(p),Nn(p,"style",v),ch(p,d.precedence,a),c.instance=p;case"stylesheet":v=Pl(d.href);var w=a.querySelector(ku(v));if(w)return c.state.loading|=4,c.instance=w,bn(w),w;p=LE(d),(v=Fr.get(v))&&$b(p,v),w=(a.ownerDocument||a).createElement("link"),bn(w);var T=w;return T._p=new Promise(function(N,V){T.onload=N,T.onerror=V}),Nn(w,"link",p),c.state.loading|=4,ch(w,d.precedence,a),c.instance=w;case"script":return w=zl(d.src),(v=a.querySelector(Cu(w)))?(c.instance=v,bn(v),v):(p=d,(v=Fr.get(w))&&(p=m({},d),Bb(p,v)),a=a.ownerDocument||a,v=a.createElement("script"),bn(v),Nn(v,"link",p),a.head.appendChild(v),c.instance=v);case"void":return null;default:throw Error(r(443,c.type))}else c.type==="stylesheet"&&(c.state.loading&4)===0&&(p=c.instance,c.state.loading|=4,ch(p,d.precedence,a));return c.instance}function ch(a,c,d){for(var p=d.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),v=p.length?p[p.length-1]:null,w=v,T=0;T<p.length;T++){var N=p[T];if(N.dataset.precedence===c)w=N;else if(w!==v)break}w?w.parentNode.insertBefore(a,w.nextSibling):(c=d.nodeType===9?d.head:d,c.insertBefore(a,c.firstChild))}function $b(a,c){a.crossOrigin==null&&(a.crossOrigin=c.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=c.referrerPolicy),a.title==null&&(a.title=c.title)}function Bb(a,c){a.crossOrigin==null&&(a.crossOrigin=c.crossOrigin),a.referrerPolicy==null&&(a.referrerPolicy=c.referrerPolicy),a.integrity==null&&(a.integrity=c.integrity)}var uh=null;function zE(a,c,d){if(uh===null){var p=new Map,v=uh=new Map;v.set(d,p)}else v=uh,p=v.get(d),p||(p=new Map,v.set(d,p));if(p.has(a))return p;for(p.set(a,null),d=d.getElementsByTagName(a),v=0;v<d.length;v++){var w=d[v];if(!(w[Bc]||w[_n]||a==="link"&&w.getAttribute("rel")==="stylesheet")&&w.namespaceURI!=="http://www.w3.org/2000/svg"){var T=w.getAttribute(c)||"";T=a+T;var N=p.get(T);N?N.push(w):p.set(T,[w])}}return p}function $E(a,c,d){a=a.ownerDocument||a,a.head.insertBefore(d,c==="title"?a.querySelector("head > title"):null)}function bz(a,c,d){if(d===1||c.itemProp!=null)return!1;switch(a){case"meta":case"title":return!0;case"style":if(typeof c.precedence!="string"||typeof c.href!="string"||c.href==="")break;return!0;case"link":if(typeof c.rel!="string"||typeof c.href!="string"||c.href===""||c.onLoad||c.onError)break;return c.rel==="stylesheet"?(a=c.disabled,typeof c.precedence=="string"&&a==null):!0;case"script":if(c.async&&typeof c.async!="function"&&typeof c.async!="symbol"&&!c.onLoad&&!c.onError&&c.src&&typeof c.src=="string")return!0}return!1}function BE(a){return!(a.type==="stylesheet"&&(a.state.loading&3)===0)}function vz(a,c,d,p){if(d.type==="stylesheet"&&(typeof p.media!="string"||matchMedia(p.media).matches!==!1)&&(d.state.loading&4)===0){if(d.instance===null){var v=Pl(p.href),w=c.querySelector(ku(v));if(w){c=w._p,c!==null&&typeof c=="object"&&typeof c.then=="function"&&(a.count++,a=dh.bind(a),c.then(a,a)),d.state.loading|=4,d.instance=w,bn(w);return}w=c.ownerDocument||c,p=LE(p),(v=Fr.get(v))&&$b(p,v),w=w.createElement("link"),bn(w);var T=w;T._p=new Promise(function(N,V){T.onload=N,T.onerror=V}),Nn(w,"link",p),d.instance=w}a.stylesheets===null&&(a.stylesheets=new Map),a.stylesheets.set(d,c),(c=d.state.preload)&&(d.state.loading&3)===0&&(a.count++,d=dh.bind(a),c.addEventListener("load",d),c.addEventListener("error",d))}}var Vb=0;function xz(a,c){return a.stylesheets&&a.count===0&&hh(a,a.stylesheets),0<a.count||0<a.imgCount?function(d){var p=setTimeout(function(){if(a.stylesheets&&hh(a,a.stylesheets),a.unsuspend){var w=a.unsuspend;a.unsuspend=null,w()}},6e4+c);0<a.imgBytes&&Vb===0&&(Vb=62500*ez());var v=setTimeout(function(){if(a.waitingForImages=!1,a.count===0&&(a.stylesheets&&hh(a,a.stylesheets),a.unsuspend)){var w=a.unsuspend;a.unsuspend=null,w()}},(a.imgBytes>Vb?50:800)+c);return a.unsuspend=d,function(){a.unsuspend=null,clearTimeout(p),clearTimeout(v)}}:null}function dh(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)hh(this,this.stylesheets);else if(this.unsuspend){var a=this.unsuspend;this.unsuspend=null,a()}}}var fh=null;function hh(a,c){a.stylesheets=null,a.unsuspend!==null&&(a.count++,fh=new Map,c.forEach(wz,a),fh=null,dh.call(a))}function wz(a,c){if(!(c.state.loading&4)){var d=fh.get(a);if(d)var p=d.get(null);else{d=new Map,fh.set(a,d);for(var v=a.querySelectorAll("link[data-precedence],style[data-precedence]"),w=0;w<v.length;w++){var T=v[w];(T.nodeName==="LINK"||T.getAttribute("media")!=="not all")&&(d.set(T.dataset.precedence,T),p=T)}p&&d.set(null,p)}v=c.instance,T=v.getAttribute("data-precedence"),w=d.get(T)||p,w===p&&d.set(null,v),d.set(T,v),this.count++,p=dh.bind(this),v.addEventListener("load",p),v.addEventListener("error",p),w?w.parentNode.insertBefore(v,w.nextSibling):(a=a.nodeType===9?a.head:a,a.insertBefore(v,a.firstChild)),c.state.loading|=4}}var Eu={$$typeof:R,Provider:null,Consumer:null,_currentValue:G,_currentValue2:G,_threadCount:0};function Sz(a,c,d,p,v,w,T,N,V){this.tag=1,this.containerInfo=a,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=wi(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=wi(0),this.hiddenUpdates=wi(null),this.identifierPrefix=p,this.onUncaughtError=v,this.onCaughtError=w,this.onRecoverableError=T,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=V,this.incompleteTransitions=new Map}function VE(a,c,d,p,v,w,T,N,V,X,oe,ue){return a=new Sz(a,c,d,T,V,X,oe,ue,N),c=1,w===!0&&(c|=24),w=vr(3,null,null,c),a.current=w,w.stateNode=a,c=xy(),c.refCount++,a.pooledCache=c,c.refCount++,w.memoizedState={element:p,isDehydrated:d,cache:c},Cy(w),a}function HE(a){return a?(a=ml,a):ml}function UE(a,c,d,p,v,w){v=HE(v),p.context===null?p.context=v:p.pendingContext=v,p=qs(c),p.payload={element:d},w=w===void 0?null:w,w!==null&&(p.callback=w),d=Gs(a,p,c),d!==null&&(hr(d,a,c),ru(d,a,c))}function FE(a,c){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var d=a.retryLane;a.retryLane=d!==0&&d<c?d:c}}function Hb(a,c){FE(a,c),(a=a.alternate)&&FE(a,c)}function qE(a){if(a.tag===13||a.tag===31){var c=ra(a,67108864);c!==null&&hr(c,a,67108864),Hb(a,67108864)}}function GE(a){if(a.tag===13||a.tag===31){var c=Cr();c=Pg(c);var d=ra(a,c);d!==null&&hr(d,a,c),Hb(a,c)}}var ph=!0;function kz(a,c,d,p){var v=z.T;z.T=null;var w=L.p;try{L.p=2,Ub(a,c,d,p)}finally{L.p=w,z.T=v}}function Cz(a,c,d,p){var v=z.T;z.T=null;var w=L.p;try{L.p=8,Ub(a,c,d,p)}finally{L.p=w,z.T=v}}function Ub(a,c,d,p){if(ph){var v=Fb(p);if(v===null)Rb(a,c,p,mh,d),KE(a,p);else if(Tz(v,a,c,d,p))p.stopPropagation();else if(KE(a,p),c&4&&-1<Ez.indexOf(a)){for(;v!==null;){var w=il(v);if(w!==null)switch(w.tag){case 3:if(w=w.stateNode,w.current.memoizedState.isDehydrated){var T=Ce(w.pendingLanes);if(T!==0){var N=w;for(N.pendingLanes|=2,N.entangledLanes|=2;T;){var V=1<<31-be(T);N.entanglements[1]|=V,T&=~V}Ei(w),(bt&6)===0&&(Xf=Ht()+500,vu(0))}}break;case 31:case 13:N=ra(w,2),N!==null&&hr(N,w,2),Qf(),Hb(w,2)}if(w=Fb(p),w===null&&Rb(a,c,p,mh,d),w===v)break;v=w}v!==null&&p.stopPropagation()}else Rb(a,c,p,null,d)}}function Fb(a){return a=Gg(a),qb(a)}var mh=null;function qb(a){if(mh=null,a=rl(a),a!==null){var c=s(a);if(c===null)a=null;else{var d=c.tag;if(d===13){if(a=o(c),a!==null)return a;a=null}else if(d===31){if(a=l(c),a!==null)return a;a=null}else if(d===3){if(c.stateNode.current.memoizedState.isDehydrated)return c.tag===3?c.stateNode.containerInfo:null;a=null}else c!==a&&(a=null)}}return mh=a,null}function WE(a){switch(a){case"beforetoggle":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"toggle":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 2;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"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(xi()){case yr:return 2;case ei:return 8;case Bn:case ge:return 32;case Ne:return 268435456;default:return 32}default:return 32}}var Gb=!1,ro=null,io=null,so=null,Tu=new Map,_u=new Map,oo=[],Ez="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".split(" ");function KE(a,c){switch(a){case"focusin":case"focusout":ro=null;break;case"dragenter":case"dragleave":io=null;break;case"mouseover":case"mouseout":so=null;break;case"pointerover":case"pointerout":Tu.delete(c.pointerId);break;case"gotpointercapture":case"lostpointercapture":_u.delete(c.pointerId)}}function Au(a,c,d,p,v,w){return a===null||a.nativeEvent!==w?(a={blockedOn:c,domEventName:d,eventSystemFlags:p,nativeEvent:w,targetContainers:[v]},c!==null&&(c=il(c),c!==null&&qE(c)),a):(a.eventSystemFlags|=p,c=a.targetContainers,v!==null&&c.indexOf(v)===-1&&c.push(v),a)}function Tz(a,c,d,p,v){switch(c){case"focusin":return ro=Au(ro,a,c,d,p,v),!0;case"dragenter":return io=Au(io,a,c,d,p,v),!0;case"mouseover":return so=Au(so,a,c,d,p,v),!0;case"pointerover":var w=v.pointerId;return Tu.set(w,Au(Tu.get(w)||null,a,c,d,p,v)),!0;case"gotpointercapture":return w=v.pointerId,_u.set(w,Au(_u.get(w)||null,a,c,d,p,v)),!0}return!1}function ZE(a){var c=rl(a.target);if(c!==null){var d=s(c);if(d!==null){if(c=d.tag,c===13){if(c=o(d),c!==null){a.blockedOn=c,ck(a.priority,function(){GE(d)});return}}else if(c===31){if(c=l(d),c!==null){a.blockedOn=c,ck(a.priority,function(){GE(d)});return}}else if(c===3&&d.stateNode.current.memoizedState.isDehydrated){a.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}a.blockedOn=null}function gh(a){if(a.blockedOn!==null)return!1;for(var c=a.targetContainers;0<c.length;){var d=Fb(a.nativeEvent);if(d===null){d=a.nativeEvent;var p=new d.constructor(d.type,d);qg=p,d.target.dispatchEvent(p),qg=null}else return c=il(d),c!==null&&qE(c),a.blockedOn=d,!1;c.shift()}return!0}function YE(a,c,d){gh(a)&&d.delete(c)}function _z(){Gb=!1,ro!==null&&gh(ro)&&(ro=null),io!==null&&gh(io)&&(io=null),so!==null&&gh(so)&&(so=null),Tu.forEach(YE),_u.forEach(YE)}function yh(a,c){a.blockedOn===c&&(a.blockedOn=null,Gb||(Gb=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,_z)))}var bh=null;function XE(a){bh!==a&&(bh=a,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){bh===a&&(bh=null);for(var c=0;c<a.length;c+=3){var d=a[c],p=a[c+1],v=a[c+2];if(typeof p!="function"){if(qb(p||d)===null)continue;break}var w=il(d);w!==null&&(a.splice(c,3),c-=3,Fy(w,{pending:!0,data:v,method:d.method,action:p},p,v))}}))}function $l(a){function c(V){return yh(V,a)}ro!==null&&yh(ro,a),io!==null&&yh(io,a),so!==null&&yh(so,a),Tu.forEach(c),_u.forEach(c);for(var d=0;d<oo.length;d++){var p=oo[d];p.blockedOn===a&&(p.blockedOn=null)}for(;0<oo.length&&(d=oo[0],d.blockedOn===null);)ZE(d),d.blockedOn===null&&oo.shift();if(d=(a.ownerDocument||a).$$reactFormReplay,d!=null)for(p=0;p<d.length;p+=3){var v=d[p],w=d[p+1],T=v[ar]||null;if(typeof w=="function")T||XE(d);else if(T){var N=null;if(w&&w.hasAttribute("formAction")){if(v=w,T=w[ar]||null)N=T.formAction;else if(qb(v)!==null)continue}else N=T.action;typeof N=="function"?d[p+1]=N:(d.splice(p,3),p-=3),XE(d)}}}function JE(){function a(w){w.canIntercept&&w.info==="react-transition"&&w.intercept({handler:function(){return new Promise(function(T){return v=T})},focusReset:"manual",scroll:"manual"})}function c(){v!==null&&(v(),v=null),p||setTimeout(d,20)}function d(){if(!p&&!navigation.transition){var w=navigation.currentEntry;w&&w.url!=null&&navigation.navigate(w.url,{state:w.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var p=!1,v=null;return navigation.addEventListener("navigate",a),navigation.addEventListener("navigatesuccess",c),navigation.addEventListener("navigateerror",c),setTimeout(d,100),function(){p=!0,navigation.removeEventListener("navigate",a),navigation.removeEventListener("navigatesuccess",c),navigation.removeEventListener("navigateerror",c),v!==null&&(v(),v=null)}}}function Wb(a){this._internalRoot=a}vh.prototype.render=Wb.prototype.render=function(a){var c=this._internalRoot;if(c===null)throw Error(r(409));var d=c.current,p=Cr();UE(d,p,a,c,null,null)},vh.prototype.unmount=Wb.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var c=a.containerInfo;UE(a.current,2,null,a,null,null),Qf(),c[nl]=null}};function vh(a){this._internalRoot=a}vh.prototype.unstable_scheduleHydration=function(a){if(a){var c=lk();a={blockedOn:null,target:a,priority:c};for(var d=0;d<oo.length&&c!==0&&c<oo[d].priority;d++);oo.splice(d,0,a),d===0&&ZE(a)}};var QE=e.version;if(QE!=="19.2.8")throw Error(r(527,QE,"19.2.8"));L.findDOMNode=function(a){var c=a._reactInternals;if(c===void 0)throw typeof a.render=="function"?Error(r(188)):(a=Object.keys(a).join(","),Error(r(268,a)));return a=f(c),a=a!==null?h(a):null,a=a===null?null:a.stateNode,a};var Az={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var xh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!xh.isDisabled&&xh.supportsFiber)try{U=xh.inject(Az),ie=xh}catch{}}return Mu.createRoot=function(a,c){if(!i(a))throw Error(r(299));var d=!1,p="",v=o1,w=a1,T=l1;return c!=null&&(c.unstable_strictMode===!0&&(d=!0),c.identifierPrefix!==void 0&&(p=c.identifierPrefix),c.onUncaughtError!==void 0&&(v=c.onUncaughtError),c.onCaughtError!==void 0&&(w=c.onCaughtError),c.onRecoverableError!==void 0&&(T=c.onRecoverableError)),c=VE(a,1,!1,null,null,d,p,null,v,w,T,JE),a[nl]=c.current,Ab(a),new Wb(c)},Mu.hydrateRoot=function(a,c,d){if(!i(a))throw Error(r(299));var p=!1,v="",w=o1,T=a1,N=l1,V=null;return d!=null&&(d.unstable_strictMode===!0&&(p=!0),d.identifierPrefix!==void 0&&(v=d.identifierPrefix),d.onUncaughtError!==void 0&&(w=d.onUncaughtError),d.onCaughtError!==void 0&&(T=d.onCaughtError),d.onRecoverableError!==void 0&&(N=d.onRecoverableError),d.formState!==void 0&&(V=d.formState)),c=VE(a,1,!0,c,d??null,p,v,V,w,T,N,JE),c.context=HE(null),d=c.current,p=Cr(),p=Pg(p),v=qs(p),v.callback=null,Gs(d,v,p),d=p,c.current.lanes=d,Ps(c,d),Ei(c),a[nl]=c.current,Ab(a),new vh(c)},Mu.version="19.2.8",Mu}var fT;function zz(){if(fT)return Xb.exports;fT=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(),Xb.exports=Pz(),Xb.exports}var $z=zz();const Bz=()=>{};var hT={};const AM=function(t){const e=[];let n=0;for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e[n++]=i:i<2048?(e[n++]=i>>6|192,e[n++]=i&63|128):(i&64512)===55296&&r+1<t.length&&(t.charCodeAt(r+1)&64512)===56320?(i=65536+((i&1023)<<10)+(t.charCodeAt(++r)&1023),e[n++]=i>>18|240,e[n++]=i>>12&63|128,e[n++]=i>>6&63|128,e[n++]=i&63|128):(e[n++]=i>>12|224,e[n++]=i>>6&63|128,e[n++]=i&63|128)}return e},Vz=function(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n++];if(i<128)e[r++]=String.fromCharCode(i);else if(i>191&&i<224){const s=t[n++];e[r++]=String.fromCharCode((i&31)<<6|s&63)}else if(i>239&&i<365){const s=t[n++],o=t[n++],l=t[n++],u=((i&7)<<18|(s&63)<<12|(o&63)<<6|l&63)-65536;e[r++]=String.fromCharCode(55296+(u>>10)),e[r++]=String.fromCharCode(56320+(u&1023))}else{const s=t[n++],o=t[n++];e[r++]=String.fromCharCode((i&15)<<12|(s&63)<<6|o&63)}}return e.join("")},RM={byteToCharMap_:null,charToByteMap_:null,byteToCharMapWebSafe_:null,charToByteMapWebSafe_:null,ENCODED_VALS_BASE:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",get ENCODED_VALS(){return this.ENCODED_VALS_BASE+"+/="},get ENCODED_VALS_WEBSAFE(){return this.ENCODED_VALS_BASE+"-_."},HAS_NATIVE_SUPPORT:typeof atob=="function",encodeByteArray(t,e){if(!Array.isArray(t))throw Error("encodeByteArray takes an array as a parameter");this.init_();const n=e?this.byteToCharMapWebSafe_:this.byteToCharMap_,r=[];for(let i=0;i<t.length;i+=3){const s=t[i],o=i+1<t.length,l=o?t[i+1]:0,u=i+2<t.length,f=u?t[i+2]:0,h=s>>2,m=(s&3)<<4|l>>4;let g=(l&15)<<2|f>>6,b=f&63;u||(b=64,o||(g=64)),r.push(n[h],n[m],n[g],n[b])}return r.join("")},encodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?btoa(t):this.encodeByteArray(AM(t),e)},decodeString(t,e){return this.HAS_NATIVE_SUPPORT&&!e?atob(t):Vz(this.decodeStringToByteArray(t,e))},decodeStringToByteArray(t,e){this.init_();const n=e?this.charToByteMapWebSafe_:this.charToByteMap_,r=[];for(let i=0;i<t.length;){const s=n[t.charAt(i++)],l=i<t.length?n[t.charAt(i)]:0;++i;const f=i<t.length?n[t.charAt(i)]:64;++i;const m=i<t.length?n[t.charAt(i)]:64;if(++i,s==null||l==null||f==null||m==null)throw new Hz;const g=s<<2|l>>4;if(r.push(g),f!==64){const b=l<<4&240|f>>2;if(r.push(b),m!==64){const x=f<<6&192|m;r.push(x)}}}return r},init_(){if(!this.byteToCharMap_){this.byteToCharMap_={},this.charToByteMap_={},this.byteToCharMapWebSafe_={},this.charToByteMapWebSafe_={};for(let t=0;t<this.ENCODED_VALS.length;t++)this.byteToCharMap_[t]=this.ENCODED_VALS.charAt(t),this.charToByteMap_[this.byteToCharMap_[t]]=t,this.byteToCharMapWebSafe_[t]=this.ENCODED_VALS_WEBSAFE.charAt(t),this.charToByteMapWebSafe_[this.byteToCharMapWebSafe_[t]]=t,t>=this.ENCODED_VALS_BASE.length&&(this.charToByteMap_[this.ENCODED_VALS_WEBSAFE.charAt(t)]=t,this.charToByteMapWebSafe_[this.ENCODED_VALS.charAt(t)]=t)}}};class Hz extends Error{constructor(){super(...arguments),this.name="DecodeBase64StringError"}}const Uz=function(t){const e=AM(t);return RM.encodeByteArray(e,!0)},MM=function(t){return Uz(t).replace(/\./g,"")},NM=function(t){try{return RM.decodeString(t,!0)}catch(e){console.error("base64Decode failed: ",e)}return null};function Fz(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("Unable to locate global object.")}const qz=()=>Fz().__FIREBASE_DEFAULTS__,Gz=()=>{if(typeof process>"u"||typeof hT>"u")return;const t=hT.__FIREBASE_DEFAULTS__;if(t)return JSON.parse(t)},Wz=()=>{if(typeof document>"u")return;let t;try{t=document.cookie.match(/__FIREBASE_DEFAULTS__=([^;]+)/)}catch{return}const e=t&&NM(t[1]);return e&&JSON.parse(e)},Qx=()=>{try{return Bz()||qz()||Gz()||Wz()}catch(t){console.info(`Unable to get __FIREBASE_DEFAULTS__ due to: ${t}`);return}},Kz=t=>Qx()?.emulatorHosts?.[t],OM=()=>Qx()?.config,DM=t=>Qx()?.[`_${t}`];class IM{constructor(){this.reject=()=>{},this.resolve=()=>{},this.promise=new Promise((e,n)=>{this.resolve=e,this.reject=n})}wrapCallback(e){return(n,r)=>{n?this.reject(n):this.resolve(r),typeof e=="function"&&(this.promise.catch(()=>{}),e.length===1?e(n):e(n,r))}}}function nr(){return typeof navigator<"u"&&typeof navigator.userAgent=="string"?navigator.userAgent:""}function Zz(){return typeof window<"u"&&!!(window.cordova||window.phonegap||window.PhoneGap)&&/ios|iphone|ipod|ipad|android|blackberry|iemobile/i.test(nr())}function Yz(){return typeof navigator<"u"&&navigator.userAgent==="Cloudflare-Workers"}function Xz(){const t=typeof chrome=="object"?chrome.runtime:typeof browser=="object"?browser.runtime:void 0;return typeof t=="object"&&t.id!==void 0}function Jz(){return typeof navigator=="object"&&navigator.product==="ReactNative"}function Qz(){const t=nr();return t.indexOf("MSIE ")>=0||t.indexOf("Trident/")>=0}function e$(){try{return typeof indexedDB=="object"}catch{return!1}}function t$(){return new Promise((t,e)=>{try{let n=!0;const r="validate-browser-context-for-indexeddb-analytics-module",i=self.indexedDB.open(r);i.onsuccess=()=>{i.result.close(),n||self.indexedDB.deleteDatabase(r),t(!0)},i.onupgradeneeded=()=>{n=!1},i.onerror=()=>{e(i.error?.message||"")}}catch(n){e(n)}})}const n$="FirebaseError";class Go extends Error{constructor(e,n,r){super(n),this.code=e,this.customData=r,this.name=n$,Object.setPrototypeOf(this,Go.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,Ud.prototype.create)}}class Ud{constructor(e,n,r){this.service=e,this.serviceName=n,this.errors=r}create(e,...n){const r=n[0]||{},i=`${this.service}/${e}`,s=this.errors[e],o=s?r$(s,r):"Error",l=`${this.serviceName}: ${o} (${i}).`;return new Go(i,l,r)}}function r$(t,e){try{let n=0,r="";for(;n<t.length;){const i=t.indexOf("{$",n);if(i===-1){r+=t.substring(n);break}const s=t.indexOf("}",i+2);if(s===-1){r+=t.substring(n);break}const o=t.substring(i+2,s),l=e[o];r+=t.substring(n,i)+(l!=null?String(l):`<${o}?>`),n=s+1}return r}catch{return t}}function i$(t){for(const e in t)if(Object.prototype.hasOwnProperty.call(t,e))return!1;return!0}function uc(t,e){if(t===e)return!0;const n=Object.keys(t),r=Object.keys(e);for(const i of n){if(!r.includes(i))return!1;const s=t[i],o=e[i];if(pT(s)&&pT(o)){if(!uc(s,o))return!1}else if(s!==o)return!1}for(const i of r)if(!n.includes(i))return!1;return!0}function pT(t){return t!==null&&typeof t=="object"}function Fd(t){const e=[];for(const[n,r]of Object.entries(t))Array.isArray(r)?r.forEach(i=>{e.push(encodeURIComponent(n)+"="+encodeURIComponent(i))}):e.push(encodeURIComponent(n)+"="+encodeURIComponent(r));return e.length?"&"+e.join("&"):""}function Fu(t){const e={};return t.replace(/^\?/,"").split("&").forEach(r=>{if(r){const[i,s]=r.split("=");e[decodeURIComponent(i)]=decodeURIComponent(s)}}),e}function qu(t){const e=t.indexOf("?");if(!e)return"";const n=t.indexOf("#",e);return t.substring(e,n>0?n:void 0)}function s$(t,e){const n=new o$(t,e);return n.subscribe.bind(n)}class o${constructor(e,n){this.observers=[],this.unsubscribes=[],this.observerCount=0,this.task=Promise.resolve(),this.finalized=!1,this.onNoObservers=n,this.task.then(()=>{e(this)}).catch(r=>{this.error(r)})}next(e){this.forEachObserver(n=>{n.next(e)})}error(e){this.forEachObserver(n=>{n.error(e)}),this.close(e)}complete(){this.forEachObserver(e=>{e.complete()}),this.close()}subscribe(e,n,r){let i;if(e===void 0&&n===void 0&&r===void 0)throw new Error("Missing Observer.");a$(e,["next","error","complete"])?i=e:i={next:e,error:n,complete:r},i.next===void 0&&(i.next=tv),i.error===void 0&&(i.error=tv),i.complete===void 0&&(i.complete=tv);const s=this.unsubscribeOne.bind(this,this.observers.length);return this.finalized&&this.task.then(()=>{try{this.finalError?i.error(this.finalError):i.complete()}catch{}}),this.observers.push(i),s}unsubscribeOne(e){this.observers===void 0||this.observers[e]===void 0||(delete this.observers[e],this.observerCount-=1,this.observerCount===0&&this.onNoObservers!==void 0&&this.onNoObservers(this))}forEachObserver(e){if(!this.finalized)for(let n=0;n<this.observers.length;n++)this.sendOne(n,e)}sendOne(e,n){this.task.then(()=>{if(this.observers!==void 0&&this.observers[e]!==void 0)try{n(this.observers[e])}catch(r){typeof console<"u"&&console.error&&console.error(r)}})}close(e){this.finalized||(this.finalized=!0,e!==void 0&&(this.finalError=e),this.task.then(()=>{this.observers=void 0,this.onNoObservers=void 0}))}}function a$(t,e){if(typeof t!="object"||t===null)return!1;for(const n of e)if(n in t&&typeof t[n]=="function")return!0;return!1}function tv(){}function Is(t){return t&&t._delegate?t._delegate:t}function ew(t){try{return(t.startsWith("http://")||t.startsWith("https://")?new URL(t).hostname:t).endsWith(".cloudworkstations.dev")}catch{return!1}}async function l$(t){return(await fetch(t,{credentials:"include"})).ok}class dc{constructor(e,n,r){this.name=e,this.instanceFactory=n,this.type=r,this.multipleInstances=!1,this.serviceProps={},this.instantiationMode="LAZY",this.onInstanceCreated=null}setInstantiationMode(e){return this.instantiationMode=e,this}setMultipleInstances(e){return this.multipleInstances=e,this}setServiceProps(e){return this.serviceProps=e,this}setInstanceCreatedCallback(e){return this.onInstanceCreated=e,this}}const ya="[DEFAULT]";class c${constructor(e,n){this.name=e,this.container=n,this.component=null,this.instances=new Map,this.instancesDeferred=new Map,this.instancesOptions=new Map,this.onInitCallbacks=new Map}get(e){const n=this.normalizeInstanceIdentifier(e);if(!this.instancesDeferred.has(n)){const r=new IM;if(this.instancesDeferred.set(n,r),this.isInitialized(n)||this.shouldAutoInitialize())try{const i=this.getOrInitializeService({instanceIdentifier:n});i&&r.resolve(i)}catch{}}return this.instancesDeferred.get(n).promise}getImmediate(e){const n=this.normalizeInstanceIdentifier(e?.identifier),r=e?.optional??!1;if(this.isInitialized(n)||this.shouldAutoInitialize())try{return this.getOrInitializeService({instanceIdentifier:n})}catch(i){if(r)return null;throw i}else{if(r)return null;throw Error(`Service ${this.name} is not available`)}}getComponent(){return this.component}setComponent(e){if(e.name!==this.name)throw Error(`Mismatching Component ${e.name} for Provider ${this.name}.`);if(this.component)throw Error(`Component for ${this.name} has already been provided`);if(this.component=e,!!this.shouldAutoInitialize()){if(d$(e))try{this.getOrInitializeService({instanceIdentifier:ya})}catch{}for(const[n,r]of this.instancesDeferred.entries()){const i=this.normalizeInstanceIdentifier(n);try{const s=this.getOrInitializeService({instanceIdentifier:i});r.resolve(s)}catch{}}}}clearInstance(e=ya){this.instancesDeferred.delete(e),this.instancesOptions.delete(e),this.instances.delete(e)}async delete(){const e=Array.from(this.instances.values());await Promise.all([...e.filter(n=>"INTERNAL"in n).map(n=>n.INTERNAL.delete()),...e.filter(n=>"_delete"in n).map(n=>n._delete())])}isComponentSet(){return this.component!=null}isInitialized(e=ya){return this.instances.has(e)}getOptions(e=ya){return this.instancesOptions.get(e)||{}}initialize(e={}){const{options:n={}}=e,r=this.normalizeInstanceIdentifier(e.instanceIdentifier);if(this.isInitialized(r))throw Error(`${this.name}(${r}) has already been initialized`);if(!this.isComponentSet())throw Error(`Component ${this.name} has not been registered yet`);const i=this.getOrInitializeService({instanceIdentifier:r,options:n});for(const[s,o]of this.instancesDeferred.entries()){const l=this.normalizeInstanceIdentifier(s);r===l&&o.resolve(i)}return i}onInit(e,n){const r=this.normalizeInstanceIdentifier(n),i=this.onInitCallbacks.get(r)??new Set;i.add(e),this.onInitCallbacks.set(r,i);const s=this.instances.get(r);return s&&e(s,r),()=>{i.delete(e)}}invokeOnInitCallbacks(e,n){const r=this.onInitCallbacks.get(n);if(r)for(const i of r)try{i(e,n)}catch{}}getOrInitializeService({instanceIdentifier:e,options:n={}}){let r=this.instances.get(e);if(!r&&this.component&&(r=this.component.instanceFactory(this.container,{instanceIdentifier:u$(e),options:n}),this.instances.set(e,r),this.instancesOptions.set(e,n),this.invokeOnInitCallbacks(r,e),this.component.onInstanceCreated))try{this.component.onInstanceCreated(this.container,e,r)}catch{}return r||null}normalizeInstanceIdentifier(e=ya){return this.component?this.component.multipleInstances?e:ya:e}shouldAutoInitialize(){return!!this.component&&this.component.instantiationMode!=="EXPLICIT"}}function u$(t){return t===ya?void 0:t}function d$(t){return t.instantiationMode==="EAGER"}class f${constructor(e){this.name=e,this.providers=new Map}addComponent(e){const n=this.getProvider(e.name);if(n.isComponentSet())throw new Error(`Component ${e.name} has already been registered with ${this.name}`);n.setComponent(e)}addOrOverwriteComponent(e){this.getProvider(e.name).isComponentSet()&&this.providers.delete(e.name),this.addComponent(e)}getProvider(e){if(this.providers.has(e))return this.providers.get(e);const n=new c$(e,this);return this.providers.set(e,n),n}getProviders(){return Array.from(this.providers.values())}}var Nt;(function(t){t[t.DEBUG=0]="DEBUG",t[t.VERBOSE=1]="VERBOSE",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.ERROR=4]="ERROR",t[t.SILENT=5]="SILENT"})(Nt||(Nt={}));const h$={debug:Nt.DEBUG,verbose:Nt.VERBOSE,info:Nt.INFO,warn:Nt.WARN,error:Nt.ERROR,silent:Nt.SILENT},p$=Nt.INFO,m$={[Nt.DEBUG]:"log",[Nt.VERBOSE]:"log",[Nt.INFO]:"info",[Nt.WARN]:"warn",[Nt.ERROR]:"error"},g$=(t,e,...n)=>{if(e<t.logLevel)return;const r=new Date().toISOString(),i=m$[e];if(i)console[i](`[${r}] ${t.name}:`,...n);else throw new Error(`Attempted to log a message with an invalid logType (value: ${e})`)};class jM{constructor(e){this.name=e,this._logLevel=p$,this._logHandler=g$,this._userLogHandler=null}get logLevel(){return this._logLevel}set logLevel(e){if(!(e in Nt))throw new TypeError(`Invalid value "${e}" assigned to \`logLevel\``);this._logLevel=e}setLogLevel(e){this._logLevel=typeof e=="string"?h$[e]:e}get logHandler(){return this._logHandler}set logHandler(e){if(typeof e!="function")throw new TypeError("Value assigned to `logHandler` must be a function");this._logHandler=e}get userLogHandler(){return this._userLogHandler}set userLogHandler(e){this._userLogHandler=e}debug(...e){this._userLogHandler&&this._userLogHandler(this,Nt.DEBUG,...e),this._logHandler(this,Nt.DEBUG,...e)}log(...e){this._userLogHandler&&this._userLogHandler(this,Nt.VERBOSE,...e),this._logHandler(this,Nt.VERBOSE,...e)}info(...e){this._userLogHandler&&this._userLogHandler(this,Nt.INFO,...e),this._logHandler(this,Nt.INFO,...e)}warn(...e){this._userLogHandler&&this._userLogHandler(this,Nt.WARN,...e),this._logHandler(this,Nt.WARN,...e)}error(...e){this._userLogHandler&&this._userLogHandler(this,Nt.ERROR,...e),this._logHandler(this,Nt.ERROR,...e)}}const y$=(t,e)=>e.some(n=>t instanceof n);let mT,gT;function b$(){return mT||(mT=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function v$(){return gT||(gT=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}const LM=new WeakMap,y0=new WeakMap,PM=new WeakMap,nv=new WeakMap,tw=new WeakMap;function x$(t){const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("success",s),t.removeEventListener("error",o)},s=()=>{n(Ao(t.result)),i()},o=()=>{r(t.error),i()};t.addEventListener("success",s),t.addEventListener("error",o)});return e.then(n=>{n instanceof IDBCursor&&LM.set(n,t)}).catch(()=>{}),tw.set(e,t),e}function w$(t){if(y0.has(t))return;const e=new Promise((n,r)=>{const i=()=>{t.removeEventListener("complete",s),t.removeEventListener("error",o),t.removeEventListener("abort",o)},s=()=>{n(),i()},o=()=>{r(t.error||new DOMException("AbortError","AbortError")),i()};t.addEventListener("complete",s),t.addEventListener("error",o),t.addEventListener("abort",o)});y0.set(t,e)}let b0={get(t,e,n){if(t instanceof IDBTransaction){if(e==="done")return y0.get(t);if(e==="objectStoreNames")return t.objectStoreNames||PM.get(t);if(e==="store")return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Ao(t[e])},set(t,e,n){return t[e]=n,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function S$(t){b0=t(b0)}function k$(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...n){const r=t.call(rv(this),e,...n);return PM.set(r,e.sort?e.sort():[e]),Ao(r)}:v$().includes(t)?function(...e){return t.apply(rv(this),e),Ao(LM.get(this))}:function(...e){return Ao(t.apply(rv(this),e))}}function C$(t){return typeof t=="function"?k$(t):(t instanceof IDBTransaction&&w$(t),y$(t,b$())?new Proxy(t,b0):t)}function Ao(t){if(t instanceof IDBRequest)return x$(t);if(nv.has(t))return nv.get(t);const e=C$(t);return e!==t&&(nv.set(t,e),tw.set(e,t)),e}const rv=t=>tw.get(t);function E$(t,e,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(t,e),l=Ao(o);return r&&o.addEventListener("upgradeneeded",u=>{r(Ao(o.result),u.oldVersion,u.newVersion,Ao(o.transaction),u)}),n&&o.addEventListener("blocked",u=>n(u.oldVersion,u.newVersion,u)),l.then(u=>{s&&u.addEventListener("close",()=>s()),i&&u.addEventListener("versionchange",f=>i(f.oldVersion,f.newVersion,f))}).catch(()=>{}),l}const T$=["get","getKey","getAll","getAllKeys","count"],_$=["put","add","delete","clear"],iv=new Map;function yT(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(iv.get(e))return iv.get(e);const n=e.replace(/FromIndex$/,""),r=e!==n,i=_$.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||T$.includes(n)))return;const s=async function(o,...l){const u=this.transaction(o,i?"readwrite":"readonly");let f=u.store;return r&&(f=f.index(l.shift())),(await Promise.all([f[n](...l),i&&u.done]))[0]};return iv.set(e,s),s}S$(t=>({...t,get:(e,n,r)=>yT(e,n)||t.get(e,n,r),has:(e,n)=>!!yT(e,n)||t.has(e,n)}));class A${constructor(e){this.container=e}getPlatformInfoString(){return this.container.getProviders().map(n=>{if(R$(n)){const r=n.getImmediate();return`${r.library}/${r.version}`}else return null}).filter(n=>n).join(" ")}}function R$(t){return t.getComponent()?.type==="VERSION"}const v0="@firebase/app",bT="0.16.0";const Rs=new jM("@firebase/app"),M$="@firebase/app-compat",N$="@firebase/analytics-compat",O$="@firebase/analytics",D$="@firebase/app-check-compat",I$="@firebase/app-check",j$="@firebase/auth",L$="@firebase/auth-compat",P$="@firebase/database",z$="@firebase/data-connect",$$="@firebase/database-compat",B$="@firebase/functions",V$="@firebase/functions-compat",H$="@firebase/installations",U$="@firebase/installations-compat",F$="@firebase/messaging",q$="@firebase/messaging-compat",G$="@firebase/performance",W$="@firebase/performance-compat",K$="@firebase/remote-config",Z$="@firebase/remote-config-compat",Y$="@firebase/storage",X$="@firebase/storage-compat",J$="@firebase/firestore",Q$="@firebase/ai",eB="@firebase/firestore-compat",tB="firebase",nB="12.17.0";const x0="[DEFAULT]",rB={[v0]:"fire-core",[M$]:"fire-core-compat",[O$]:"fire-analytics",[N$]:"fire-analytics-compat",[I$]:"fire-app-check",[D$]:"fire-app-check-compat",[j$]:"fire-auth",[L$]:"fire-auth-compat",[P$]:"fire-rtdb",[z$]:"fire-data-connect",[$$]:"fire-rtdb-compat",[B$]:"fire-fn",[V$]:"fire-fn-compat",[H$]:"fire-iid",[U$]:"fire-iid-compat",[F$]:"fire-fcm",[q$]:"fire-fcm-compat",[G$]:"fire-perf",[W$]:"fire-perf-compat",[K$]:"fire-rc",[Z$]:"fire-rc-compat",[Y$]:"fire-gcs",[X$]:"fire-gcs-compat",[J$]:"fire-fst",[eB]:"fire-fst-compat",[Q$]:"fire-vertex","fire-js":"fire-js",[tB]:"fire-js-all"};const vd=new Map,iB=new Map,w0=new Map;function vT(t,e){try{t.container.addComponent(e)}catch(n){Rs.debug(`Component ${e.name} failed to register with FirebaseApp ${t.name}`,n)}}function xd(t){const e=t.name;if(w0.has(e))return Rs.debug(`There were multiple attempts to register component ${e}.`),!1;w0.set(e,t);for(const n of vd.values())vT(n,t);for(const n of iB.values())vT(n,t);return!0}function zM(t,e){const n=t.container.getProvider("heartbeat").getImmediate({optional:!0});return n&&n.triggerHeartbeat(),t.container.getProvider(e)}function ui(t){return t==null?!1:t.settings!==void 0}const sB={"no-app":"No Firebase App '{$appName}' has been created - call initializeApp() first","bad-app-name":"Illegal App name: '{$appName}'","duplicate-app":"Firebase App named '{$appName}' already exists with different {$mismatchedParam}. Existing: '{$oldValue}'. New: '{$newValue}'.","app-deleted":"Firebase App named '{$appName}' already deleted","server-app-deleted":"Firebase Server App has been deleted","no-options":"Need to provide options, when not being deployed to hosting via source.","invalid-app-argument":"firebase.{$appName}() takes either no argument or a Firebase App instance.","invalid-log-argument":"First argument to `onLog` must be null or a function.","idb-open":"Error thrown when opening IndexedDB. Original error: {$originalErrorMessage}.","idb-get":"Error thrown when reading from IndexedDB. Original error: {$originalErrorMessage}.","idb-set":"Error thrown when writing to IndexedDB. Original error: {$originalErrorMessage}.","idb-delete":"Error thrown when deleting from IndexedDB. Original error: {$originalErrorMessage}.","finalization-registry-not-supported":"FirebaseServerApp deleteOnDeref field defined but the JS runtime does not support FinalizationRegistry.","invalid-server-app-environment":"FirebaseServerApp is not for use in browser environments."},ys=new Ud("app","Firebase",sB);class oB{constructor(e,n,r){this._isDeleted=!1,this._options={...e},this._config={...n},this._name=n.name,this._automaticDataCollectionEnabled=n.automaticDataCollectionEnabled,this._container=r,this.container.addComponent(new dc("app",()=>this,"PUBLIC"))}get automaticDataCollectionEnabled(){return this.checkDestroyed(),this._automaticDataCollectionEnabled}set automaticDataCollectionEnabled(e){this.checkDestroyed(),this._automaticDataCollectionEnabled=e}get name(){return this.checkDestroyed(),this._name}get options(){return this.checkDestroyed(),this._options}get config(){return this.checkDestroyed(),this._config}get container(){return this._container}get isDeleted(){return this._isDeleted}set isDeleted(e){this._isDeleted=e}checkDestroyed(){if(this.isDeleted)throw ys.create("app-deleted",{appName:this._name})}}const qd=nB;function $M(t,e={}){let n=t;typeof e!="object"&&(e={name:e});const r={name:x0,automaticDataCollectionEnabled:!0,...e},i=r.name;if(typeof i!="string"||!i)throw ys.create("bad-app-name",{appName:String(i)});if(n||(n=OM()),!n)throw ys.create("no-options");const s=vd.get(i);if(s)if(uc(n,s.options)){if(uc(r,s.config))return s;throw ys.create("duplicate-app",{appName:i,mismatchedParam:"config",oldValue:JSON.stringify(s.config),newValue:JSON.stringify(r)})}else throw ys.create("duplicate-app",{appName:i,mismatchedParam:"options",oldValue:JSON.stringify(s.options),newValue:JSON.stringify(n)});const o=new f$(i);for(const u of w0.values())o.addComponent(u);const l=new oB(n,r,o);return vd.set(i,l),l}function BM(t=x0){const e=vd.get(t);if(!e&&t===x0&&OM())return $M();if(!e)throw ys.create("no-app",{appName:t});return e}function aB(){return Array.from(vd.values())}function nc(t,e,n){let r=rB[t]??t;n&&(r+=`-${n}`);const i=r.match(/\s|\//),s=e.match(/\s|\//);if(i||s){const o=[`Unable to register library "${r}" with version "${e}":`];i&&o.push(`library name "${r}" contains illegal characters (whitespace or "/")`),i&&s&&o.push("and"),s&&o.push(`version name "${e}" contains illegal characters (whitespace or "/")`),Rs.warn(o.join(" "));return}xd(new dc(`${r}-version`,()=>({library:r,version:e}),"VERSION"))}const lB="firebase-heartbeat-database",cB=1,wd="firebase-heartbeat-store";let sv=null;function VM(){return sv||(sv=E$(lB,cB,{upgrade:(t,e)=>{switch(e){case 0:try{t.createObjectStore(wd)}catch(n){console.warn(n)}}}}).catch(t=>{throw ys.create("idb-open",{originalErrorMessage:t.message})})),sv}async function uB(t){try{const n=(await VM()).transaction(wd),r=await n.objectStore(wd).get(HM(t));return await n.done,r}catch(e){if(e instanceof Go)Rs.warn(e.message);else{const n=ys.create("idb-get",{originalErrorMessage:e?.message});Rs.warn(n.message)}}}async function xT(t,e){try{const r=(await VM()).transaction(wd,"readwrite");await r.objectStore(wd).put(e,HM(t)),await r.done}catch(n){if(n instanceof Go)Rs.warn(n.message);else{const r=ys.create("idb-set",{originalErrorMessage:n?.message});Rs.warn(r.message)}}}function HM(t){return`${t.name}!${t.options.appId}`}const dB=1024,fB=30;class hB{constructor(e){this.container=e,this._heartbeatsCache=null;const n=this.container.getProvider("app").getImmediate();this._storage=new mB(n),this._heartbeatsCachePromise=this._storage.read().then(r=>(this._heartbeatsCache=r,r))}async triggerHeartbeat(){try{const n=this.container.getProvider("platform-logger").getImmediate().getPlatformInfoString(),r=wT();if(this._heartbeatsCache?.heartbeats==null&&(this._heartbeatsCache=await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null)||this._heartbeatsCache.lastSentHeartbeatDate===r||this._heartbeatsCache.heartbeats.some(i=>i.date===r))return;if(this._heartbeatsCache.heartbeats.push({date:r,agent:n}),this._heartbeatsCache.heartbeats.length>fB){const i=gB(this._heartbeatsCache.heartbeats);this._heartbeatsCache.heartbeats.splice(i,1)}return this._storage.overwrite(this._heartbeatsCache)}catch(e){Rs.warn(e)}}async getHeartbeatsHeader(){try{if(this._heartbeatsCache===null&&await this._heartbeatsCachePromise,this._heartbeatsCache?.heartbeats==null||this._heartbeatsCache.heartbeats.length===0)return"";const e=wT(),{heartbeatsToSend:n,unsentEntries:r}=pB(this._heartbeatsCache.heartbeats),i=MM(JSON.stringify({version:2,heartbeats:n}));return this._heartbeatsCache.lastSentHeartbeatDate=e,r.length>0?(this._heartbeatsCache.heartbeats=r,await this._storage.overwrite(this._heartbeatsCache)):(this._heartbeatsCache.heartbeats=[],this._storage.overwrite(this._heartbeatsCache)),i}catch(e){return Rs.warn(e),""}}}function wT(){return new Date().toISOString().substring(0,10)}function pB(t,e=dB){const n=[];let r=t.slice();for(const i of t){const s=n.find(o=>o.agent===i.agent);if(s){if(s.dates.push(i.date),ST(n)>e){s.dates.pop();break}}else if(n.push({agent:i.agent,dates:[i.date]}),ST(n)>e){n.pop();break}r=r.slice(1)}return{heartbeatsToSend:n,unsentEntries:r}}class mB{constructor(e){this.app=e,this._canUseIndexedDBPromise=this.runIndexedDBEnvironmentCheck()}async runIndexedDBEnvironmentCheck(){return e$()?t$().then(()=>!0).catch(()=>!1):!1}async read(){if(await this._canUseIndexedDBPromise){const n=await uB(this.app);return n?.heartbeats?n:{heartbeats:[]}}else return{heartbeats:[]}}async overwrite(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return xT(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:e.heartbeats})}else return}async add(e){if(await this._canUseIndexedDBPromise){const r=await this.read();return xT(this.app,{lastSentHeartbeatDate:e.lastSentHeartbeatDate??r.lastSentHeartbeatDate,heartbeats:[...r.heartbeats,...e.heartbeats]})}else return}}function ST(t){return MM(JSON.stringify({version:2,heartbeats:t})).length}function gB(t){if(t.length===0)return-1;let e=0,n=t[0].date;for(let r=1;r<t.length;r++)t[r].date<n&&(n=t[r].date,e=r);return e}function yB(t){xd(new dc("platform-logger",e=>new A$(e),"PRIVATE")),xd(new dc("heartbeat",e=>new hB(e),"PRIVATE")),nc(v0,bT,t),nc(v0,bT,"esm2020"),nc("fire-js","")}yB("");var bB="firebase",vB="12.17.1";nc(bB,vB,"app");function UM(){return{"dependent-sdk-initialized-before-auth":"Another Firebase SDK was initialized and is trying to use Auth before Auth is initialized. Please be sure to call `initializeAuth` or `getAuth` before starting any other Firebase SDK."}}const xB=UM,FM=new Ud("auth","Firebase",UM());const kp=new jM("@firebase/auth");function qM(t,...e){kp.logLevel<=Nt.WARN&&kp.warn(`Auth (${qd}): ${t}`,...e)}function ip(t,...e){kp.logLevel<=Nt.ERROR&&kp.error(`Auth (${qd}): ${t}`,...e)}function Jr(t,...e){throw rw(t,...e)}function mi(t,...e){return rw(t,...e)}function nw(t,e,n){const r={...xB(),[e]:n};return new Ud("auth","Firebase",r).create(e,{appName:t.name})}function Ro(t){return nw(t,"operation-not-supported-in-this-environment","Operations that alter the current user are not supported in conjunction with FirebaseServerApp")}function wB(t,e,n){const r=n;if(!(e instanceof r))throw r.name!==e.constructor.name&&Jr(t,"argument-error"),nw(t,"argument-error",`Type of ${e.constructor.name} does not match expected instance.Did you pass a reference from a different Auth SDK?`)}function rw(t,...e){if(typeof t!="string"){const n=e[0],r=[...e.slice(1)];return r[0]&&(r[0].appName=t.name),t._errorFactory.create(n,...r)}return FM.create(t,...e)}function We(t,e,...n){if(!t)throw rw(e,...n)}function bs(t){const e="INTERNAL ASSERTION FAILED: "+t;throw ip(e),new Error(e)}function Ms(t,e){t||bs(e)}function S0(){return typeof self<"u"&&self.location?.href||""}function SB(){return kT()==="http:"||kT()==="https:"}function kT(){return typeof self<"u"&&self.location?.protocol||null}function kB(){return typeof navigator<"u"&&navigator&&"onLine"in navigator&&typeof navigator.onLine=="boolean"&&(SB()||Xz()||"connection"in navigator)?navigator.onLine:!0}function CB(){if(typeof navigator>"u")return null;const t=navigator;return t.languages&&t.languages[0]||t.language||null}class Gd{constructor(e,n){this.shortDelay=e,this.longDelay=n,Ms(n>e,"Short delay should be less than long delay!"),this.isMobile=Zz()||Jz()}get(){return kB()?this.isMobile?this.longDelay:this.shortDelay:Math.min(5e3,this.shortDelay)}}function iw(t,e){Ms(t.emulator,"Emulator should always be set here");const{url:n}=t.emulator;return e?`${n}${e.startsWith("/")?e.slice(1):e}`:n}class GM{static initialize(e,n,r){this.fetchImpl=e,n&&(this.headersImpl=n),r&&(this.responseImpl=r)}static fetch(){if(this.fetchImpl)return this.fetchImpl;if(typeof self<"u"&&"fetch"in self)return self.fetch;if(typeof globalThis<"u"&&globalThis.fetch)return globalThis.fetch;if(typeof fetch<"u")return fetch;bs("Could not find fetch implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static headers(){if(this.headersImpl)return this.headersImpl;if(typeof self<"u"&&"Headers"in self)return self.Headers;if(typeof globalThis<"u"&&globalThis.Headers)return globalThis.Headers;if(typeof Headers<"u")return Headers;bs("Could not find Headers implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}static response(){if(this.responseImpl)return this.responseImpl;if(typeof self<"u"&&"Response"in self)return self.Response;if(typeof globalThis<"u"&&globalThis.Response)return globalThis.Response;if(typeof Response<"u")return Response;bs("Could not find Response implementation, make sure you call FetchProvider.initialize() with an appropriate polyfill")}}const EB={CREDENTIAL_MISMATCH:"custom-token-mismatch",MISSING_CUSTOM_TOKEN:"internal-error",INVALID_IDENTIFIER:"invalid-email",MISSING_CONTINUE_URI:"internal-error",INVALID_PASSWORD:"wrong-password",MISSING_PASSWORD:"missing-password",INVALID_LOGIN_CREDENTIALS:"invalid-credential",EMAIL_EXISTS:"email-already-in-use",PASSWORD_LOGIN_DISABLED:"operation-not-allowed",INVALID_IDP_RESPONSE:"invalid-credential",INVALID_PENDING_TOKEN:"invalid-credential",FEDERATED_USER_ID_ALREADY_LINKED:"credential-already-in-use",MISSING_REQ_TYPE:"internal-error",EMAIL_NOT_FOUND:"user-not-found",RESET_PASSWORD_EXCEED_LIMIT:"too-many-requests",EXPIRED_OOB_CODE:"expired-action-code",INVALID_OOB_CODE:"invalid-action-code",MISSING_OOB_CODE:"internal-error",CREDENTIAL_TOO_OLD_LOGIN_AGAIN:"requires-recent-login",INVALID_ID_TOKEN:"invalid-user-token",TOKEN_EXPIRED:"user-token-expired",USER_NOT_FOUND:"user-token-expired",TOO_MANY_ATTEMPTS_TRY_LATER:"too-many-requests",PASSWORD_DOES_NOT_MEET_REQUIREMENTS:"password-does-not-meet-requirements",INVALID_CODE:"invalid-verification-code",INVALID_SESSION_INFO:"invalid-verification-id",INVALID_TEMPORARY_PROOF:"invalid-credential",MISSING_SESSION_INFO:"missing-verification-id",SESSION_EXPIRED:"code-expired",MISSING_ANDROID_PACKAGE_NAME:"missing-android-pkg-name",UNAUTHORIZED_DOMAIN:"unauthorized-continue-uri",INVALID_OAUTH_CLIENT_ID:"invalid-oauth-client-id",ADMIN_ONLY_OPERATION:"admin-restricted-operation",INVALID_MFA_PENDING_CREDENTIAL:"invalid-multi-factor-session",MFA_ENROLLMENT_NOT_FOUND:"multi-factor-info-not-found",MISSING_MFA_ENROLLMENT_ID:"missing-multi-factor-info",MISSING_MFA_PENDING_CREDENTIAL:"missing-multi-factor-session",SECOND_FACTOR_EXISTS:"second-factor-already-in-use",SECOND_FACTOR_LIMIT_EXCEEDED:"maximum-second-factor-count-exceeded",BLOCKING_FUNCTION_ERROR_RESPONSE:"internal-error",RECAPTCHA_NOT_ENABLED:"recaptcha-not-enabled",MISSING_RECAPTCHA_TOKEN:"missing-recaptcha-token",INVALID_RECAPTCHA_TOKEN:"invalid-recaptcha-token",INVALID_RECAPTCHA_ACTION:"invalid-recaptcha-action",MISSING_CLIENT_TYPE:"missing-client-type",MISSING_RECAPTCHA_VERSION:"missing-recaptcha-version",INVALID_RECAPTCHA_VERSION:"invalid-recaptcha-version",INVALID_REQ_TYPE:"invalid-req-type"};const TB=["/v1/accounts:signInWithCustomToken","/v1/accounts:signInWithEmailLink","/v1/accounts:signInWithIdp","/v1/accounts:signInWithPassword","/v1/accounts:signInWithPhoneNumber","/v1/token"],_B=new Gd(3e4,6e4);function Ka(t,e){return t.tenantId&&!e.tenantId?{...e,tenantId:t.tenantId}:e}async function Wo(t,e,n,r,i={}){return WM(t,i,async()=>{let s={},o={};r&&(e==="GET"?o=r:s={body:JSON.stringify(r)});const l=Fd({...o,key:t.config.apiKey}).slice(1),u=await t._getAdditionalHeaders();u["Content-Type"]="application/json",t.languageCode&&(u["X-Firebase-Locale"]=t.languageCode);const f={method:e,headers:u,...s};return Yz()||(f.referrerPolicy="strict-origin-when-cross-origin"),t.emulatorConfig&&ew(t.emulatorConfig.host)&&(f.credentials="include"),GM.fetch()(await KM(t,t.config.apiHost,n,l),f)})}async function WM(t,e,n){t._canInitEmulator=!1;const r={...EB,...e};try{const i=new RB(t),s=await Promise.race([n(),i.promise]);i.clearNetworkTimeout();const o=await s.json();if("needConfirmation"in o)throw wh(t,"account-exists-with-different-credential",o);if(s.ok&&!("errorMessage"in o))return o;{const l=s.ok?o.errorMessage:o.error.message,[u,f]=l.split(" : ");if(u==="FEDERATED_USER_ID_ALREADY_LINKED")throw wh(t,"credential-already-in-use",o);if(u==="EMAIL_EXISTS")throw wh(t,"email-already-in-use",o);if(u==="USER_DISABLED")throw wh(t,"user-disabled",o);const h=r[u]||u.toLowerCase().replace(/[_\s]+/g,"-");if(f)throw nw(t,h,f);Jr(t,h)}}catch(i){if(i instanceof Go)throw i;Jr(t,"network-request-failed",{message:String(i)})}}async function Bm(t,e,n,r,i={}){const s=await Wo(t,e,n,r,i);return"mfaPendingCredential"in s&&Jr(t,"multi-factor-auth-required",{_serverResponse:s}),s}async function KM(t,e,n,r){const i=`${e}${n}?${r}`,s=t,o=s.config.emulator?iw(t.config,i):`${t.config.apiScheme}://${i}`;return TB.includes(n)&&(await s._persistenceManagerAvailable,s._getPersistenceType()==="COOKIE")?s._getPersistence()._getFinalTarget(o).toString():o}function AB(t){switch(t){case"ENFORCE":return"ENFORCE";case"AUDIT":return"AUDIT";case"OFF":return"OFF";default:return"ENFORCEMENT_STATE_UNSPECIFIED"}}class RB{clearNetworkTimeout(){clearTimeout(this.timer)}constructor(e){this.auth=e,this.timer=null,this.promise=new Promise((n,r)=>{this.timer=setTimeout(()=>r(mi(this.auth,"network-request-failed")),_B.get())})}}function wh(t,e,n){const r={appName:t.name};n.email&&(r.email=n.email),n.phoneNumber&&(r.phoneNumber=n.phoneNumber);const i=mi(t,e,r);return i.customData._tokenResponse=n,i}function CT(t){return t!==void 0&&t.enterprise!==void 0}class MB{constructor(e){if(this.siteKey="",this.recaptchaEnforcementState=[],e.recaptchaKey===void 0)throw new Error("recaptchaKey undefined");this.siteKey=e.recaptchaKey.split("/")[3],this.recaptchaEnforcementState=e.recaptchaEnforcementState}getProviderEnforcementState(e){if(!this.recaptchaEnforcementState||this.recaptchaEnforcementState.length===0)return null;for(const n of this.recaptchaEnforcementState)if(n.provider&&n.provider===e)return AB(n.enforcementState);return null}isProviderEnabled(e){return this.getProviderEnforcementState(e)==="ENFORCE"||this.getProviderEnforcementState(e)==="AUDIT"}isAnyProviderEnabled(){return this.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")||this.isProviderEnabled("PHONE_PROVIDER")}}async function NB(t,e){return Wo(t,"GET","/v2/recaptchaConfig",Ka(t,e))}async function OB(t,e){return Wo(t,"POST","/v1/accounts:delete",e)}async function Cp(t,e){return Wo(t,"POST","/v1/accounts:lookup",e)}function td(t){if(t)try{const e=new Date(Number(t));if(!isNaN(e.getTime()))return e.toUTCString()}catch{}}async function DB(t,e=!1){const n=Is(t),r=await n.getIdToken(e),i=sw(r);We(i&&i.exp&&i.auth_time&&i.iat,n.auth,"internal-error");const s=typeof i.firebase=="object"?i.firebase:void 0,o=s?.sign_in_provider;return{claims:i,token:r,authTime:td(ov(i.auth_time)),issuedAtTime:td(ov(i.iat)),expirationTime:td(ov(i.exp)),signInProvider:o||null,signInSecondFactor:s?.sign_in_second_factor||null}}function ov(t){return Number(t)*1e3}function sw(t){const[e,n,r]=t.split(".");if(e===void 0||n===void 0||r===void 0)return ip("JWT malformed, contained fewer than 3 sections"),null;try{const i=NM(n);return i?JSON.parse(i):(ip("Failed to decode base64 JWT payload"),null)}catch(i){return ip("Caught error parsing JWT payload as JSON",i?.toString()),null}}function ET(t){const e=sw(t);return We(e,"internal-error"),We(typeof e.exp<"u","internal-error"),We(typeof e.iat<"u","internal-error"),Number(e.exp)-Number(e.iat)}async function Sd(t,e,n=!1){if(n)return e;try{return await e}catch(r){throw r instanceof Go&&IB(r)&&t.auth.currentUser===t&&await t.auth.signOut(),r}}function IB({code:t}){return t==="auth/user-disabled"||t==="auth/user-token-expired"}class jB{constructor(e){this.user=e,this.isRunning=!1,this.timerId=null,this.errorBackoff=3e4}_start(){this.isRunning||(this.isRunning=!0,this.schedule())}_stop(){this.isRunning&&(this.isRunning=!1,this.timerId!==null&&clearTimeout(this.timerId))}getInterval(e){if(e){const n=this.errorBackoff;return this.errorBackoff=Math.min(this.errorBackoff*2,96e4),n}else{this.errorBackoff=3e4;const r=(this.user.stsTokenManager.expirationTime??0)-Date.now()-3e5;return Math.max(0,r)}}schedule(e=!1){if(!this.isRunning)return;const n=this.getInterval(e);this.timerId=setTimeout(async()=>{await this.iteration()},n)}async iteration(){try{await this.user.getIdToken(!0)}catch(e){e?.code==="auth/network-request-failed"&&this.schedule(!0);return}this.schedule()}}class k0{constructor(e,n){this.createdAt=e,this.lastLoginAt=n,this._initializeTime()}_initializeTime(){this.lastSignInTime=td(this.lastLoginAt),this.creationTime=td(this.createdAt)}_copy(e){this.createdAt=e.createdAt,this.lastLoginAt=e.lastLoginAt,this._initializeTime()}toJSON(){return{createdAt:this.createdAt,lastLoginAt:this.lastLoginAt}}}async function Ep(t){const e=t.auth,n=await t.getIdToken(),r=await Sd(t,Cp(e,{idToken:n}));We(r?.users.length,e,"internal-error");const i=r.users[0];t._notifyReloadListener(i);const s=i.providerUserInfo?.length?ZM(i.providerUserInfo):[],o=PB(t.providerData,s),l=t.isAnonymous,u=!(t.email&&i.passwordHash)&&!o?.length,f=l?u:!1,h={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:o,metadata:new k0(i.createdAt,i.lastLoginAt),isAnonymous:f};Object.assign(t,h)}async function LB(t){const e=Is(t);await Ep(e),await e.auth._persistUserIfCurrent(e),e.auth._notifyListenersIfCurrent(e)}function PB(t,e){return[...t.filter(r=>!e.some(i=>i.providerId===r.providerId)),...e]}function ZM(t){return t.map(({providerId:e,...n})=>({providerId:e,uid:n.rawId||"",displayName:n.displayName||null,email:n.email||null,phoneNumber:n.phoneNumber||null,photoURL:n.photoUrl||null}))}async function zB(t,e){const n=await WM(t,{},async()=>{const r=Fd({grant_type:"refresh_token",refresh_token:e}).slice(1),{tokenApiHost:i,apiKey:s}=t.config,o=await KM(t,i,"/v1/token",`key=${s}`),l=await t._getAdditionalHeaders();l["Content-Type"]="application/x-www-form-urlencoded";const u={method:"POST",headers:l,body:r};return t.emulatorConfig&&ew(t.emulatorConfig.host)&&(u.credentials="include"),GM.fetch()(o,u)});return{accessToken:n.access_token,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async function $B(t,e){return Wo(t,"POST","/v2/accounts:revokeToken",Ka(t,e))}class rc{constructor(){this.refreshToken=null,this.accessToken=null,this.expirationTime=null}get isExpired(){return!this.expirationTime||Date.now()>this.expirationTime-3e4}updateFromServerResponse(e){We(e.idToken,"internal-error"),We(typeof e.idToken<"u","internal-error"),We(typeof e.refreshToken<"u","internal-error");const n="expiresIn"in e&&typeof e.expiresIn<"u"?Number(e.expiresIn):ET(e.idToken);this.updateTokensAndExpiration(e.idToken,e.refreshToken,n)}updateFromIdToken(e){We(e.length!==0,"internal-error");const n=ET(e);this.updateTokensAndExpiration(e,null,n)}async getToken(e,n=!1){return!n&&this.accessToken&&!this.isExpired?this.accessToken:(We(this.refreshToken,e,"user-token-expired"),this.refreshToken?(await this.refresh(e,this.refreshToken),this.accessToken):null)}clearRefreshToken(){this.refreshToken=null}async refresh(e,n){const{accessToken:r,refreshToken:i,expiresIn:s}=await zB(e,n);this.updateTokensAndExpiration(r,i,Number(s))}updateTokensAndExpiration(e,n,r){this.refreshToken=n||null,this.accessToken=e||null,this.expirationTime=Date.now()+r*1e3}static fromJSON(e,n){const{refreshToken:r,accessToken:i,expirationTime:s}=n,o=new rc;return r&&(We(typeof r=="string","internal-error",{appName:e}),o.refreshToken=r),i&&(We(typeof i=="string","internal-error",{appName:e}),o.accessToken=i),s&&(We(typeof s=="number","internal-error",{appName:e}),o.expirationTime=s),o}toJSON(){return{refreshToken:this.refreshToken,accessToken:this.accessToken,expirationTime:this.expirationTime}}_assign(e){this.accessToken=e.accessToken,this.refreshToken=e.refreshToken,this.expirationTime=e.expirationTime}_clone(){return Object.assign(new rc,this.toJSON())}_performRefresh(){return bs("not implemented")}}function lo(t,e){We(typeof t=="string"||typeof t>"u","internal-error",{appName:e})}class hi{constructor({uid:e,auth:n,stsTokenManager:r,...i}){this.providerId="firebase",this.proactiveRefresh=new jB(this),this.reloadUserInfo=null,this.reloadListener=null,this.uid=e,this.auth=n,this.stsTokenManager=r,this.accessToken=r.accessToken,this.displayName=i.displayName||null,this.email=i.email||null,this.emailVerified=i.emailVerified||!1,this.phoneNumber=i.phoneNumber||null,this.photoURL=i.photoURL||null,this.isAnonymous=i.isAnonymous||!1,this.tenantId=i.tenantId||null,this.providerData=i.providerData?[...i.providerData]:[],this.metadata=new k0(i.createdAt||void 0,i.lastLoginAt||void 0)}async getIdToken(e){const n=await Sd(this,this.stsTokenManager.getToken(this.auth,e));return We(n,this.auth,"internal-error"),this.accessToken!==n&&(this.accessToken=n,await this.auth._persistUserIfCurrent(this),this.auth._notifyListenersIfCurrent(this)),n}getIdTokenResult(e){return DB(this,e)}reload(){return LB(this)}_assign(e){this!==e&&(We(this.uid===e.uid,this.auth,"internal-error"),this.displayName=e.displayName,this.photoURL=e.photoURL,this.email=e.email,this.emailVerified=e.emailVerified,this.phoneNumber=e.phoneNumber,this.isAnonymous=e.isAnonymous,this.tenantId=e.tenantId,this.providerData=e.providerData.map(n=>({...n})),this.metadata._copy(e.metadata),this.stsTokenManager._assign(e.stsTokenManager))}_clone(e){const n=new hi({...this,auth:e,stsTokenManager:this.stsTokenManager._clone()});return n.metadata._copy(this.metadata),n}_onReload(e){We(!this.reloadListener,this.auth,"internal-error"),this.reloadListener=e,this.reloadUserInfo&&(this._notifyReloadListener(this.reloadUserInfo),this.reloadUserInfo=null)}_notifyReloadListener(e){this.reloadListener?this.reloadListener(e):this.reloadUserInfo=e}_startProactiveRefresh(){this.proactiveRefresh._start()}_stopProactiveRefresh(){this.proactiveRefresh._stop()}async _updateTokensIfNecessary(e,n=!1){let r=!1;e.idToken&&e.idToken!==this.stsTokenManager.accessToken&&(this.stsTokenManager.updateFromServerResponse(e),r=!0),n&&await Ep(this),await this.auth._persistUserIfCurrent(this),r&&this.auth._notifyListenersIfCurrent(this)}async delete(){if(ui(this.auth.app))return Promise.reject(Ro(this.auth));const e=await this.getIdToken();return await Sd(this,OB(this.auth,{idToken:e})),this.stsTokenManager.clearRefreshToken(),this.auth.signOut()}toJSON(){return{uid:this.uid,email:this.email||void 0,emailVerified:this.emailVerified,displayName:this.displayName||void 0,isAnonymous:this.isAnonymous,photoURL:this.photoURL||void 0,phoneNumber:this.phoneNumber||void 0,tenantId:this.tenantId||void 0,providerData:this.providerData.map(e=>({...e})),stsTokenManager:this.stsTokenManager.toJSON(),_redirectEventId:this._redirectEventId,...this.metadata.toJSON(),apiKey:this.auth.config.apiKey,appName:this.auth.name}}get refreshToken(){return this.stsTokenManager.refreshToken||""}static _fromJSON(e,n){const r=n.displayName??void 0,i=n.email??void 0,s=n.phoneNumber??void 0,o=n.photoURL??void 0,l=n.tenantId??void 0,u=n._redirectEventId??void 0,f=n.createdAt??void 0,h=n.lastLoginAt??void 0,{uid:m,emailVerified:g,isAnonymous:b,providerData:x,stsTokenManager:S}=n;We(m&&S,e,"internal-error");const k=rc.fromJSON(this.name,S);We(typeof m=="string",e,"internal-error"),lo(r,e.name),lo(i,e.name),We(typeof g=="boolean",e,"internal-error"),We(typeof b=="boolean",e,"internal-error"),lo(s,e.name),lo(o,e.name),lo(l,e.name),lo(u,e.name),lo(f,e.name),lo(h,e.name);const C=new hi({uid:m,auth:e,email:i,emailVerified:g,displayName:r,isAnonymous:b,photoURL:o,phoneNumber:s,tenantId:l,stsTokenManager:k,createdAt:f,lastLoginAt:h});return x&&Array.isArray(x)&&(C.providerData=x.map(A=>({...A}))),u&&(C._redirectEventId=u),C}static async _fromIdTokenResponse(e,n,r=!1){const i=new rc;i.updateFromServerResponse(n);const s=new hi({uid:n.localId,auth:e,stsTokenManager:i,isAnonymous:r});return await Ep(s),s}static async _fromGetAccountInfoResponse(e,n,r){const i=n.users[0];We(i.localId!==void 0,"internal-error");const s=i.providerUserInfo!==void 0?ZM(i.providerUserInfo):[],o=!(i.email&&i.passwordHash)&&!s?.length,l=new rc;l.updateFromIdToken(r);const u=new hi({uid:i.localId,auth:e,stsTokenManager:l,isAnonymous:o}),f={uid:i.localId,displayName:i.displayName||null,photoURL:i.photoUrl||null,email:i.email||null,emailVerified:i.emailVerified||!1,phoneNumber:i.phoneNumber||null,tenantId:i.tenantId||null,providerData:s,metadata:new k0(i.createdAt,i.lastLoginAt),isAnonymous:!(i.email&&i.passwordHash)&&!s?.length};return Object.assign(u,f),u}}const TT=new Map;function vs(t){Ms(t instanceof Function,"Expected a class definition");let e=TT.get(t);return e?(Ms(e instanceof t,"Instance stored in cache mismatched with class"),e):(e=new t,TT.set(t,e),e)}class YM{constructor(){this.type="NONE",this.storage={}}async _isAvailable(){return!0}async _set(e,n){this.storage[e]=n}async _get(e){const n=this.storage[e];return n===void 0?null:n}async _remove(e){delete this.storage[e]}_addListener(e,n){}_removeListener(e,n){}}YM.type="NONE";const _T=YM;function sp(t,e,n){return`firebase:${t}:${e}:${n}`}class ic{constructor(e,n,r){this.persistence=e,this.auth=n,this.userKey=r;const{config:i,name:s}=this.auth;this.fullUserKey=sp(this.userKey,i.apiKey,s),this.fullPersistenceKey=sp("persistence",i.apiKey,s),this.boundEventHandler=n._onStorageEvent.bind(n),this.persistence._addListener(this.fullUserKey,this.boundEventHandler)}setCurrentUser(e){return this.persistence._set(this.fullUserKey,e.toJSON())}async getCurrentUser(){const e=await this.persistence._get(this.fullUserKey);if(!e)return null;if(typeof e=="string"){const n=await Cp(this.auth,{idToken:e}).catch(()=>{});return n?hi._fromGetAccountInfoResponse(this.auth,n,e):null}return hi._fromJSON(this.auth,e)}removeCurrentUser(){return this.persistence._remove(this.fullUserKey)}savePersistenceForRedirect(){return this.persistence._set(this.fullPersistenceKey,this.persistence.type)}async setPersistence(e){if(this.persistence===e)return;const n=await this.getCurrentUser();if(await this.removeCurrentUser(),this.persistence=e,n)return this.setCurrentUser(n)}delete(){this.persistence._removeListener(this.fullUserKey,this.boundEventHandler)}static async create(e,n,r="authUser"){if(!n.length)return new ic(vs(_T),e,r);const i=(await Promise.all(n.map(async f=>{if(await f._isAvailable())return f}))).filter(f=>f);let s=i[0]||vs(_T);const o=sp(r,e.config.apiKey,e.name);let l=null;for(const f of n)try{const h=await f._get(o);if(h){let m;if(typeof h=="string"){const g=await Cp(e,{idToken:h}).catch(()=>{});if(!g)break;m=await hi._fromGetAccountInfoResponse(e,g,h)}else m=hi._fromJSON(e,h);f!==s&&(l=m),s=f;break}}catch{}const u=i.filter(f=>f._shouldAllowMigration);return!s._shouldAllowMigration||!u.length?new ic(s,e,r):(s=u[0],l&&await s._set(o,l.toJSON()),await Promise.all(n.map(async f=>{if(f!==s)try{await f._remove(o)}catch{}})),new ic(s,e,r))}}function AT(t){const e=t.toLowerCase();if(e.includes("opera/")||e.includes("opr/")||e.includes("opios/"))return"Opera";if(eN(e))return"IEMobile";if(e.includes("msie")||e.includes("trident/"))return"IE";if(e.includes("edge/"))return"Edge";if(XM(e))return"Firefox";if(e.includes("silk/"))return"Silk";if(nN(e))return"Blackberry";if(rN(e))return"Webos";if(JM(e))return"Safari";if((e.includes("chrome/")||QM(e))&&!e.includes("edge/"))return"Chrome";if(tN(e))return"Android";{const n=/([a-zA-Z\d\.]+)\/[a-zA-Z\d\.]*$/,r=t.match(n);if(r?.length===2)return r[1]}return"Other"}function XM(t=nr()){return/firefox\//i.test(t)}function JM(t=nr()){const e=t.toLowerCase();return e.includes("safari/")&&!e.includes("chrome/")&&!e.includes("crios/")&&!e.includes("android")}function QM(t=nr()){return/crios\//i.test(t)}function eN(t=nr()){return/iemobile/i.test(t)}function tN(t=nr()){return/android/i.test(t)}function nN(t=nr()){return/blackberry/i.test(t)}function rN(t=nr()){return/webos/i.test(t)}function ow(t=nr()){return/iphone|ipad|ipod/i.test(t)||/macintosh/i.test(t)&&/mobile/i.test(t)}function BB(t=nr()){return ow(t)&&!!window.navigator?.standalone}function VB(){return Qz()&&document.documentMode===10}function iN(t=nr()){return ow(t)||tN(t)||rN(t)||nN(t)||/windows phone/i.test(t)||eN(t)}function sN(t,e=[]){let n;switch(t){case"Browser":n=AT(nr());break;case"Worker":n=`${AT(nr())}-${t}`;break;default:n=t}const r=e.length?e.join(","):"FirebaseCore-web";return`${n}/JsCore/${qd}/${r}`}class HB{constructor(e){this.auth=e,this.queue=[]}pushCallback(e,n){const r=s=>new Promise((o,l)=>{try{const u=e(s);o(u)}catch(u){l(u)}});r.onAbort=n,this.queue.push(r);const i=this.queue.length-1;return()=>{this.queue[i]=()=>Promise.resolve()}}async runMiddleware(e){if(this.auth.currentUser===e)return;const n=[];try{for(const r of this.queue)await r(e),r.onAbort&&n.push(r.onAbort)}catch(r){n.reverse();for(const i of n)try{i()}catch{}throw this.auth._errorFactory.create("login-blocked",{originalMessage:r?.message})}}}async function UB(t,e={}){return Wo(t,"GET","/v2/passwordPolicy",Ka(t,e))}const FB=6;class qB{constructor(e){const n=e.customStrengthOptions;this.customStrengthOptions={},this.customStrengthOptions.minPasswordLength=n.minPasswordLength??FB,n.maxPasswordLength&&(this.customStrengthOptions.maxPasswordLength=n.maxPasswordLength),n.containsLowercaseCharacter!==void 0&&(this.customStrengthOptions.containsLowercaseLetter=n.containsLowercaseCharacter),n.containsUppercaseCharacter!==void 0&&(this.customStrengthOptions.containsUppercaseLetter=n.containsUppercaseCharacter),n.containsNumericCharacter!==void 0&&(this.customStrengthOptions.containsNumericCharacter=n.containsNumericCharacter),n.containsNonAlphanumericCharacter!==void 0&&(this.customStrengthOptions.containsNonAlphanumericCharacter=n.containsNonAlphanumericCharacter),this.enforcementState=e.enforcementState,this.enforcementState==="ENFORCEMENT_STATE_UNSPECIFIED"&&(this.enforcementState="OFF"),this.allowedNonAlphanumericCharacters=e.allowedNonAlphanumericCharacters?.join("")??"",this.forceUpgradeOnSignin=e.forceUpgradeOnSignin??!1,this.schemaVersion=e.schemaVersion}validatePassword(e){const n={isValid:!0,passwordPolicy:this};return this.validatePasswordLengthOptions(e,n),this.validatePasswordCharacterOptions(e,n),n.isValid&&(n.isValid=n.meetsMinPasswordLength??!0),n.isValid&&(n.isValid=n.meetsMaxPasswordLength??!0),n.isValid&&(n.isValid=n.containsLowercaseLetter??!0),n.isValid&&(n.isValid=n.containsUppercaseLetter??!0),n.isValid&&(n.isValid=n.containsNumericCharacter??!0),n.isValid&&(n.isValid=n.containsNonAlphanumericCharacter??!0),n}validatePasswordLengthOptions(e,n){const r=this.customStrengthOptions.minPasswordLength,i=this.customStrengthOptions.maxPasswordLength;r&&(n.meetsMinPasswordLength=e.length>=r),i&&(n.meetsMaxPasswordLength=e.length<=i)}validatePasswordCharacterOptions(e,n){this.updatePasswordCharacterOptionsStatuses(n,!1,!1,!1,!1);let r;for(let i=0;i<e.length;i++)r=e.charAt(i),this.updatePasswordCharacterOptionsStatuses(n,r>="a"&&r<="z",r>="A"&&r<="Z",r>="0"&&r<="9",this.allowedNonAlphanumericCharacters.includes(r))}updatePasswordCharacterOptionsStatuses(e,n,r,i,s){this.customStrengthOptions.containsLowercaseLetter&&(e.containsLowercaseLetter||(e.containsLowercaseLetter=n)),this.customStrengthOptions.containsUppercaseLetter&&(e.containsUppercaseLetter||(e.containsUppercaseLetter=r)),this.customStrengthOptions.containsNumericCharacter&&(e.containsNumericCharacter||(e.containsNumericCharacter=i)),this.customStrengthOptions.containsNonAlphanumericCharacter&&(e.containsNonAlphanumericCharacter||(e.containsNonAlphanumericCharacter=s))}}class GB{constructor(e,n,r,i){this.app=e,this.heartbeatServiceProvider=n,this.appCheckServiceProvider=r,this.config=i,this.currentUser=null,this.emulatorConfig=null,this.operations=Promise.resolve(),this.authStateSubscription=new RT(this),this.idTokenSubscription=new RT(this),this.beforeStateQueue=new HB(this),this.redirectUser=null,this.isProactiveRefreshEnabled=!1,this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION=1,this._canInitEmulator=!0,this._isInitialized=!1,this._deleted=!1,this._initializationPromise=null,this._popupRedirectResolver=null,this._errorFactory=FM,this._agentRecaptchaConfig=null,this._tenantRecaptchaConfigs={},this._projectPasswordPolicy=null,this._tenantPasswordPolicies={},this._resolvePersistenceManagerAvailable=void 0,this.lastNotifiedUid=void 0,this.languageCode=null,this.tenantId=null,this.settings={appVerificationDisabledForTesting:!1},this.frameworks=[],this.name=e.name,this.clientVersion=i.sdkClientVersion,this._persistenceManagerAvailable=new Promise(s=>this._resolvePersistenceManagerAvailable=s)}_initializeWithPersistence(e,n){return n&&(this._popupRedirectResolver=vs(n)),this._initializationPromise=this.queue(async()=>{if(!this._deleted&&(this.persistenceManager=await ic.create(this,e),this._resolvePersistenceManagerAvailable?.(),!this._deleted)){if(this._popupRedirectResolver?._shouldInitProactively)try{await this._popupRedirectResolver._initialize(this)}catch{}await this.initializeCurrentUser(n),this.lastNotifiedUid=this.currentUser?.uid||null,!this._deleted&&(this._isInitialized=!0)}}),this._initializationPromise}async _onStorageEvent(){if(this._deleted)return;const e=await this.assertedPersistence.getCurrentUser();if(!(!this.currentUser&&!e)){if(this.currentUser&&e&&this.currentUser.uid===e.uid){this._currentUser._assign(e),await this.currentUser.getIdToken();return}await this._updateCurrentUser(e,!0)}}async initializeCurrentUserFromIdToken(e){try{const n=await Cp(this,{idToken:e}),r=await hi._fromGetAccountInfoResponse(this,n,e);await this.directlySetCurrentUser(r)}catch(n){console.warn("FirebaseServerApp could not login user with provided authIdToken: ",n),await this.directlySetCurrentUser(null)}}async initializeCurrentUser(e){if(ui(this.app)){const s=this.app.settings.authIdToken;return s?new Promise(o=>{setTimeout(()=>this.initializeCurrentUserFromIdToken(s).then(o,o))}):this.directlySetCurrentUser(null)}const n=await this.assertedPersistence.getCurrentUser();let r=n,i=!1;if(e&&this.config.authDomain){await this.getOrInitRedirectPersistenceManager();const s=this.redirectUser?._redirectEventId,o=r?._redirectEventId,l=await this.tryRedirectSignIn(e);(!s||s===o)&&l?.user&&(r=l.user,i=!0)}if(!r)return this.directlySetCurrentUser(null);if(!r._redirectEventId){if(i)try{await this.beforeStateQueue.runMiddleware(r)}catch(s){r=n,this._popupRedirectResolver._overrideRedirectResult(this,()=>Promise.reject(s))}return r?this.reloadAndSetCurrentUserOrClear(r):this.directlySetCurrentUser(null)}return We(this._popupRedirectResolver,this,"argument-error"),await this.getOrInitRedirectPersistenceManager(),this.redirectUser&&this.redirectUser._redirectEventId===r._redirectEventId?this.directlySetCurrentUser(r):this.reloadAndSetCurrentUserOrClear(r)}async tryRedirectSignIn(e){let n=null;try{n=await this._popupRedirectResolver._completeRedirectFn(this,e,!0)}catch{await this._setRedirectUser(null)}return n}async reloadAndSetCurrentUserOrClear(e){try{await Ep(e)}catch(n){if(n?.code!=="auth/network-request-failed")return this.directlySetCurrentUser(null)}return this.directlySetCurrentUser(e)}useDeviceLanguage(){this.languageCode=CB()}async _delete(){this._deleted=!0}async updateCurrentUser(e){if(ui(this.app))return Promise.reject(Ro(this));const n=e?Is(e):null;return n&&We(n.auth.config.apiKey===this.config.apiKey,this,"invalid-user-token"),this._updateCurrentUser(n&&n._clone(this))}async _updateCurrentUser(e,n=!1){if(!this._deleted)return e&&We(this.tenantId===e.tenantId,this,"tenant-id-mismatch"),n||await this.beforeStateQueue.runMiddleware(e),this.queue(async()=>{await this.directlySetCurrentUser(e),this.notifyAuthListeners()})}async signOut(){return ui(this.app)?Promise.reject(Ro(this)):(await this.beforeStateQueue.runMiddleware(null),(this.redirectPersistenceManager||this._popupRedirectResolver)&&await this._setRedirectUser(null),this._updateCurrentUser(null,!0))}setPersistence(e){return ui(this.app)?Promise.reject(Ro(this)):this.queue(async()=>{await this.assertedPersistence.setPersistence(vs(e))})}_getRecaptchaConfig(){return this.tenantId==null?this._agentRecaptchaConfig:this._tenantRecaptchaConfigs[this.tenantId]}async validatePassword(e){this._getPasswordPolicyInternal()||await this._updatePasswordPolicy();const n=this._getPasswordPolicyInternal();return n.schemaVersion!==this.EXPECTED_PASSWORD_POLICY_SCHEMA_VERSION?Promise.reject(this._errorFactory.create("unsupported-password-policy-schema-version",{})):n.validatePassword(e)}_getPasswordPolicyInternal(){return this.tenantId===null?this._projectPasswordPolicy:this._tenantPasswordPolicies[this.tenantId]}async _updatePasswordPolicy(){const e=await UB(this),n=new qB(e);this.tenantId===null?this._projectPasswordPolicy=n:this._tenantPasswordPolicies[this.tenantId]=n}_getPersistenceType(){return this.assertedPersistence.persistence.type}_getPersistence(){return this.assertedPersistence.persistence}_updateErrorMap(e){this._errorFactory=new Ud("auth","Firebase",e())}onAuthStateChanged(e,n,r){return this.registerStateListener(this.authStateSubscription,e,n,r)}beforeAuthStateChanged(e,n){return this.beforeStateQueue.pushCallback(e,n)}onIdTokenChanged(e,n,r){return this.registerStateListener(this.idTokenSubscription,e,n,r)}authStateReady(){return new Promise((e,n)=>{if(this.currentUser)e();else{const r=this.onAuthStateChanged(()=>{r(),e()},n)}})}async revokeAccessToken(e){if(this.currentUser){const n=await this.currentUser.getIdToken(),r={providerId:"apple.com",tokenType:"ACCESS_TOKEN",token:e,idToken:n};this.tenantId!=null&&(r.tenantId=this.tenantId),await $B(this,r)}}toJSON(){return{apiKey:this.config.apiKey,authDomain:this.config.authDomain,appName:this.name,currentUser:this._currentUser?.toJSON()}}async _setRedirectUser(e,n){const r=await this.getOrInitRedirectPersistenceManager(n);return e===null?r.removeCurrentUser():r.setCurrentUser(e)}async getOrInitRedirectPersistenceManager(e){if(!this.redirectPersistenceManager){const n=e&&vs(e)||this._popupRedirectResolver;We(n,this,"argument-error"),this.redirectPersistenceManager=await ic.create(this,[vs(n._redirectPersistence)],"redirectUser"),this.redirectUser=await this.redirectPersistenceManager.getCurrentUser()}return this.redirectPersistenceManager}async _redirectUserForId(e){return this._isInitialized&&await this.queue(async()=>{}),this._currentUser?._redirectEventId===e?this._currentUser:this.redirectUser?._redirectEventId===e?this.redirectUser:null}async _persistUserIfCurrent(e){if(e===this.currentUser)return this.queue(async()=>this.directlySetCurrentUser(e))}_notifyListenersIfCurrent(e){e===this.currentUser&&this.notifyAuthListeners()}_key(){return`${this.config.authDomain}:${this.config.apiKey}:${this.name}`}_startProactiveRefresh(){this.isProactiveRefreshEnabled=!0,this.currentUser&&this._currentUser._startProactiveRefresh()}_stopProactiveRefresh(){this.isProactiveRefreshEnabled=!1,this.currentUser&&this._currentUser._stopProactiveRefresh()}get _currentUser(){return this.currentUser}notifyAuthListeners(){if(!this._isInitialized)return;this.idTokenSubscription.next(this.currentUser);const e=this.currentUser?.uid??null;this.lastNotifiedUid!==e&&(this.lastNotifiedUid=e,this.authStateSubscription.next(this.currentUser))}registerStateListener(e,n,r,i){if(this._deleted)return()=>{};const s=typeof n=="function"?n:n.next.bind(n);let o=!1;const l=this._isInitialized?Promise.resolve():this._initializationPromise;if(We(l,this,"internal-error"),l.then(()=>{o||s(this.currentUser)}),typeof n=="function"){const u=e.addObserver(n,r,i);return()=>{o=!0,u()}}else{const u=e.addObserver(n);return()=>{o=!0,u()}}}async directlySetCurrentUser(e){this.currentUser&&this.currentUser!==e&&this._currentUser._stopProactiveRefresh(),e&&this.isProactiveRefreshEnabled&&e._startProactiveRefresh(),this.currentUser=e,e?await this.assertedPersistence.setCurrentUser(e):await this.assertedPersistence.removeCurrentUser()}queue(e){return this.operations=this.operations.then(e,e),this.operations}get assertedPersistence(){return We(this.persistenceManager,this,"internal-error"),this.persistenceManager}_logFramework(e){!e||this.frameworks.includes(e)||(this.frameworks.push(e),this.frameworks.sort(),this.clientVersion=sN(this.config.clientPlatform,this._getFrameworks()))}_getFrameworks(){return this.frameworks}async _getAdditionalHeaders(){const e={"X-Client-Version":this.clientVersion};this.app.options.appId&&(e["X-Firebase-gmpid"]=this.app.options.appId);const n=await this.heartbeatServiceProvider.getImmediate({optional:!0})?.getHeartbeatsHeader();n&&(e["X-Firebase-Client"]=n);const r=await this._getAppCheckToken();return r&&(e["X-Firebase-AppCheck"]=r),e}async _getAppCheckToken(){if(ui(this.app)&&this.app.settings.appCheckToken)return this.app.settings.appCheckToken;const e=await this.appCheckServiceProvider.getImmediate({optional:!0})?.getToken();return e?.error&&qM(`Error while retrieving App Check token: ${e.error}`),e?.token}}function Za(t){return Is(t)}class RT{constructor(e){this.auth=e,this.observer=null,this.addObserver=s$(n=>this.observer=n)}get next(){return We(this.observer,this.auth,"internal-error"),this.observer.next.bind(this.observer)}}let Vm={async loadJS(){throw new Error("Unable to load external scripts")},recaptchaV2Script:"",recaptchaEnterpriseScript:"",gapiScript:""};function WB(t){Vm=t}function oN(t){return Vm.loadJS(t)}function KB(){return Vm.recaptchaEnterpriseScript}function ZB(){return Vm.gapiScript}function YB(t){return`__${t}${Math.floor(Math.random()*1e6)}`}class XB{constructor(){this.enterprise=new JB}ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}class JB{ready(e){e()}execute(e,n){return Promise.resolve("token")}render(e,n){return""}}const QB="recaptcha-enterprise",aN="NO_RECAPTCHA",MT="onFirebaseAuthREInstanceReady";class yo{constructor(e){this.type=QB,this.auth=Za(e)}async verify(e="verify",n=!1){async function r(s){if(!n){if(s.tenantId==null&&s._agentRecaptchaConfig!=null)return s._agentRecaptchaConfig.siteKey;if(s.tenantId!=null&&s._tenantRecaptchaConfigs[s.tenantId]!==void 0)return s._tenantRecaptchaConfigs[s.tenantId].siteKey}return new Promise(async(o,l)=>{NB(s,{clientType:"CLIENT_TYPE_WEB",version:"RECAPTCHA_ENTERPRISE"}).then(u=>{if(u.recaptchaKey===void 0)l(new Error("recaptcha Enterprise site key undefined"));else{const f=new MB(u);return s.tenantId==null?s._agentRecaptchaConfig=f:s._tenantRecaptchaConfigs[s.tenantId]=f,o(f.siteKey)}}).catch(u=>{l(u)})})}function i(s,o,l){const u=window.grecaptcha;CT(u)?u.enterprise.ready(()=>{u.enterprise.execute(s,{action:e}).then(f=>{o(f)}).catch(()=>{o(aN)})}):l(Error("No reCAPTCHA enterprise script loaded."))}return this.auth.settings.appVerificationDisabledForTesting?new XB().execute("siteKey",{action:"verify"}):new Promise((s,o)=>{r(this.auth).then(async l=>{if(!n&&CT(window.grecaptcha)&&yo.scriptInjectionDeferred)await yo.scriptInjectionDeferred.promise,i(l,s,o);else{if(typeof window>"u"){o(new Error("RecaptchaVerifier is only supported in browser"));return}let u=KB();u.length!==0&&(u+=l+`&onload=${MT}`),yo.scriptInjectionDeferred=new IM,window[MT]=()=>{yo.scriptInjectionDeferred?.resolve()},oN(u).then(()=>yo.scriptInjectionDeferred?.promise).then(()=>{i(l,s,o)}).catch(f=>{o(f)})}}).catch(l=>{o(l)})})}}yo.scriptInjectionDeferred=null;async function NT(t,e,n,r=!1,i=!1){const s=new yo(t);let o;if(i)o=aN;else try{o=await s.verify(n)}catch{o=await s.verify(n,!0)}const l={...e};if(n==="mfaSmsEnrollment"||n==="mfaSmsSignIn"){if("phoneEnrollmentInfo"in l){const u=l.phoneEnrollmentInfo.phoneNumber,f=l.phoneEnrollmentInfo.recaptchaToken;Object.assign(l,{phoneEnrollmentInfo:{phoneNumber:u,recaptchaToken:f,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}else if("phoneSignInInfo"in l){const u=l.phoneSignInInfo.recaptchaToken;Object.assign(l,{phoneSignInInfo:{recaptchaToken:u,captchaResponse:o,clientType:"CLIENT_TYPE_WEB",recaptchaVersion:"RECAPTCHA_ENTERPRISE"}})}return l}return r?Object.assign(l,{captchaResp:o}):Object.assign(l,{captchaResponse:o}),Object.assign(l,{clientType:"CLIENT_TYPE_WEB"}),Object.assign(l,{recaptchaVersion:"RECAPTCHA_ENTERPRISE"}),l}async function OT(t,e,n,r,i){if(t._getRecaptchaConfig()?.isProviderEnabled("EMAIL_PASSWORD_PROVIDER")){const s=await NT(t,e,n,n==="getOobCode");return r(t,s)}else return r(t,e).catch(async s=>{if(s.code==="auth/missing-recaptcha-token"){console.log(`${n} is protected by reCAPTCHA Enterprise for this project. Automatically triggering the reCAPTCHA flow and restarting the flow.`);const o=await NT(t,e,n,n==="getOobCode");return r(t,o)}else return Promise.reject(s)})}function e3(t,e){const n=zM(t,"auth");if(n.isInitialized()){const i=n.getImmediate(),s=n.getOptions();if(uc(s,e??{}))return i;Jr(i,"already-initialized")}return n.initialize({options:e})}function t3(t,e){const n=e?.persistence||[],r=(Array.isArray(n)?n:[n]).map(vs);e?.errorMap&&t._updateErrorMap(e.errorMap),t._initializeWithPersistence(r,e?.popupRedirectResolver)}function n3(t,e,n){const r=Za(t);We(/^https?:\/\//.test(e),r,"invalid-emulator-scheme");const i=!1,s=lN(e),{host:o,port:l}=r3(e),u=l===null?"":`:${l}`,f={url:`${s}//${o}${u}/`},h=Object.freeze({host:o,port:l,protocol:s.replace(":",""),options:Object.freeze({disableWarnings:i})});if(!r._canInitEmulator){We(r.config.emulator&&r.emulatorConfig,r,"emulator-config-failed"),We(uc(f,r.config.emulator)&&uc(h,r.emulatorConfig),r,"emulator-config-failed");return}r.config.emulator=f,r.emulatorConfig=h,r.settings.appVerificationDisabledForTesting=!0,ew(o)?l$(`${s}//${o}${u}`):i3()}function lN(t){const e=t.indexOf(":");return e<0?"":t.substr(0,e+1)}function r3(t){const e=lN(t),n=/(\/\/)?([^?#/]+)/.exec(t.substr(e.length));if(!n)return{host:"",port:null};const r=n[2].split("@").pop()||"",i=/^(\[[^\]]+\])(:|$)/.exec(r);if(i){const s=i[1];return{host:s,port:DT(r.substr(s.length+1))}}else{const[s,o]=r.split(":");return{host:s,port:DT(o)}}}function DT(t){if(!t)return null;const e=Number(t);return isNaN(e)?null:e}function i3(){function t(){const e=document.createElement("p"),n=e.style;e.innerText="Running in emulator mode. Do not use with production credentials.",n.position="fixed",n.width="100%",n.backgroundColor="#ffffff",n.border=".1em solid #000000",n.color="#b50000",n.bottom="0px",n.left="0px",n.margin="0px",n.zIndex="10000",n.textAlign="center",e.classList.add("firebase-emulator-warning"),document.body.appendChild(e)}typeof console<"u"&&typeof console.info=="function"&&console.info("WARNING: You are using the Auth Emulator, which is intended for local testing only. Do not use with production credentials."),typeof window<"u"&&typeof document<"u"&&(document.readyState==="loading"?window.addEventListener("DOMContentLoaded",t):t())}class aw{constructor(e,n){this.providerId=e,this.signInMethod=n}toJSON(){return bs("not implemented")}_getIdTokenResponse(e){return bs("not implemented")}_linkToIdToken(e,n){return bs("not implemented")}_getReauthenticationResolver(e){return bs("not implemented")}}async function s3(t,e){return Wo(t,"POST","/v1/accounts:signUp",e)}async function o3(t,e){return Bm(t,"POST","/v1/accounts:signInWithPassword",Ka(t,e))}async function a3(t,e){return Bm(t,"POST","/v1/accounts:signInWithEmailLink",Ka(t,e))}async function l3(t,e){return Bm(t,"POST","/v1/accounts:signInWithEmailLink",Ka(t,e))}class kd extends aw{constructor(e,n,r,i=null){super("password",r),this._email=e,this._password=n,this._tenantId=i}static _fromEmailAndPassword(e,n){return new kd(e,n,"password")}static _fromEmailAndCode(e,n,r=null){return new kd(e,n,"emailLink",r)}toJSON(){return{email:this._email,password:this._password,signInMethod:this.signInMethod,tenantId:this._tenantId}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e;if(n?.email&&n?.password){if(n.signInMethod==="password")return this._fromEmailAndPassword(n.email,n.password);if(n.signInMethod==="emailLink")return this._fromEmailAndCode(n.email,n.password,n.tenantId)}return null}async _getIdTokenResponse(e){switch(this.signInMethod){case"password":const n={returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return OT(e,n,"signInWithPassword",o3);case"emailLink":return a3(e,{email:this._email,oobCode:this._password});default:Jr(e,"internal-error")}}async _linkToIdToken(e,n){switch(this.signInMethod){case"password":const r={idToken:n,returnSecureToken:!0,email:this._email,password:this._password,clientType:"CLIENT_TYPE_WEB"};return OT(e,r,"signUpPassword",s3);case"emailLink":return l3(e,{idToken:n,email:this._email,oobCode:this._password});default:Jr(e,"internal-error")}}_getReauthenticationResolver(e){return this._getIdTokenResponse(e)}}async function sc(t,e){return Bm(t,"POST","/v1/accounts:signInWithIdp",Ka(t,e))}const c3="http://localhost";class Da extends aw{constructor(){super(...arguments),this.pendingToken=null}static _fromParams(e){const n=new Da(e.providerId,e.signInMethod);return e.idToken||e.accessToken?(e.idToken&&(n.idToken=e.idToken),e.accessToken&&(n.accessToken=e.accessToken),e.nonce&&!e.pendingToken&&(n.nonce=e.nonce),e.pendingToken&&(n.pendingToken=e.pendingToken)):e.oauthToken&&e.oauthTokenSecret?(n.accessToken=e.oauthToken,n.secret=e.oauthTokenSecret):Jr("argument-error"),n}toJSON(){return{idToken:this.idToken,accessToken:this.accessToken,secret:this.secret,nonce:this.nonce,pendingToken:this.pendingToken,providerId:this.providerId,signInMethod:this.signInMethod}}static fromJSON(e){const n=typeof e=="string"?JSON.parse(e):e,{providerId:r,signInMethod:i,...s}=n;if(!r||!i)return null;const o=new Da(r,i);return o.idToken=s.idToken||void 0,o.accessToken=s.accessToken||void 0,o.secret=s.secret,o.nonce=s.nonce,o.pendingToken=s.pendingToken||null,o}_getIdTokenResponse(e){const n=this.buildRequest();return sc(e,n)}_linkToIdToken(e,n){const r=this.buildRequest();return r.idToken=n,sc(e,r)}_getReauthenticationResolver(e){const n=this.buildRequest();return n.autoCreate=!1,sc(e,n)}buildRequest(){const e={requestUri:c3,returnSecureToken:!0};if(this.pendingToken)e.pendingToken=this.pendingToken;else{const n={};this.idToken&&(n.id_token=this.idToken),this.accessToken&&(n.access_token=this.accessToken),this.secret&&(n.oauth_token_secret=this.secret),n.providerId=this.providerId,this.nonce&&!this.pendingToken&&(n.nonce=this.nonce),e.postBody=Fd(n)}return e}}function u3(t){switch(t){case"recoverEmail":return"RECOVER_EMAIL";case"resetPassword":return"PASSWORD_RESET";case"signIn":return"EMAIL_SIGNIN";case"verifyEmail":return"VERIFY_EMAIL";case"verifyAndChangeEmail":return"VERIFY_AND_CHANGE_EMAIL";case"revertSecondFactorAddition":return"REVERT_SECOND_FACTOR_ADDITION";default:return null}}function d3(t){const e=Fu(qu(t)).link,n=e?Fu(qu(e)).deep_link_id:null,r=Fu(qu(t)).deep_link_id;return(r?Fu(qu(r)).link:null)||r||n||e||t}class lw{constructor(e){const n=Fu(qu(e)),r=n.apiKey??null,i=n.oobCode??null,s=u3(n.mode??null);We(r&&i&&s,"argument-error"),this.apiKey=r,this.operation=s,this.code=i,this.continueUrl=n.continueUrl??null,this.languageCode=n.lang??null,this.tenantId=n.tenantId??null}static parseLink(e){const n=d3(e);try{return new lw(n)}catch{return null}}}class Mc{constructor(){this.providerId=Mc.PROVIDER_ID}static credential(e,n){return kd._fromEmailAndPassword(e,n)}static credentialWithLink(e,n){const r=lw.parseLink(n);return We(r,"argument-error"),kd._fromEmailAndCode(e,r.code,r.tenantId)}}Mc.PROVIDER_ID="password";Mc.EMAIL_PASSWORD_SIGN_IN_METHOD="password";Mc.EMAIL_LINK_SIGN_IN_METHOD="emailLink";class cw{constructor(e){this.providerId=e,this.defaultLanguageCode=null,this.customParameters={}}setDefaultLanguage(e){this.defaultLanguageCode=e}setCustomParameters(e){return this.customParameters=e,this}getCustomParameters(){return this.customParameters}}class Wd extends cw{constructor(){super(...arguments),this.scopes=[]}addScope(e){return this.scopes.includes(e)||this.scopes.push(e),this}getScopes(){return[...this.scopes]}}class bo extends Wd{constructor(){super("facebook.com")}static credential(e){return Da._fromParams({providerId:bo.PROVIDER_ID,signInMethod:bo.FACEBOOK_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return bo.credentialFromTaggedObject(e)}static credentialFromError(e){return bo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return bo.credential(e.oauthAccessToken)}catch{return null}}}bo.FACEBOOK_SIGN_IN_METHOD="facebook.com";bo.PROVIDER_ID="facebook.com";class gs extends Wd{constructor(){super("google.com"),this.addScope("profile")}static credential(e,n){return Da._fromParams({providerId:gs.PROVIDER_ID,signInMethod:gs.GOOGLE_SIGN_IN_METHOD,idToken:e,accessToken:n})}static credentialFromResult(e){return gs.credentialFromTaggedObject(e)}static credentialFromError(e){return gs.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthIdToken:n,oauthAccessToken:r}=e;if(!n&&!r)return null;try{return gs.credential(n,r)}catch{return null}}}gs.GOOGLE_SIGN_IN_METHOD="google.com";gs.PROVIDER_ID="google.com";class vo extends Wd{constructor(){super("github.com")}static credential(e){return Da._fromParams({providerId:vo.PROVIDER_ID,signInMethod:vo.GITHUB_SIGN_IN_METHOD,accessToken:e})}static credentialFromResult(e){return vo.credentialFromTaggedObject(e)}static credentialFromError(e){return vo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e||!("oauthAccessToken"in e)||!e.oauthAccessToken)return null;try{return vo.credential(e.oauthAccessToken)}catch{return null}}}vo.GITHUB_SIGN_IN_METHOD="github.com";vo.PROVIDER_ID="github.com";class xo extends Wd{constructor(){super("twitter.com")}static credential(e,n){return Da._fromParams({providerId:xo.PROVIDER_ID,signInMethod:xo.TWITTER_SIGN_IN_METHOD,oauthToken:e,oauthTokenSecret:n})}static credentialFromResult(e){return xo.credentialFromTaggedObject(e)}static credentialFromError(e){return xo.credentialFromTaggedObject(e.customData||{})}static credentialFromTaggedObject({_tokenResponse:e}){if(!e)return null;const{oauthAccessToken:n,oauthTokenSecret:r}=e;if(!n||!r)return null;try{return xo.credential(n,r)}catch{return null}}}xo.TWITTER_SIGN_IN_METHOD="twitter.com";xo.PROVIDER_ID="twitter.com";class fc{constructor(e){this.user=e.user,this.providerId=e.providerId,this._tokenResponse=e._tokenResponse,this.operationType=e.operationType}static async _fromIdTokenResponse(e,n,r,i=!1){const s=await hi._fromIdTokenResponse(e,r,i),o=IT(r);return new fc({user:s,providerId:o,_tokenResponse:r,operationType:n})}static async _forOperation(e,n,r){await e._updateTokensIfNecessary(r,!0);const i=IT(r);return new fc({user:e,providerId:i,_tokenResponse:r,operationType:n})}}function IT(t){return t.providerId?t.providerId:"phoneNumber"in t?"phone":null}class Tp extends Go{constructor(e,n,r,i){super(n.code,n.message),this.operationType=r,this.user=i,Object.setPrototypeOf(this,Tp.prototype),this.customData={appName:e.name,tenantId:e.tenantId??void 0,_serverResponse:n.customData._serverResponse,operationType:r}}static _fromErrorAndOperation(e,n,r,i){return new Tp(e,n,r,i)}}function cN(t,e,n,r){return(e==="reauthenticate"?n._getReauthenticationResolver(t):n._getIdTokenResponse(t)).catch(s=>{throw s.code==="auth/multi-factor-auth-required"?Tp._fromErrorAndOperation(t,s,e,r):s})}async function f3(t,e,n=!1){const r=await Sd(t,e._linkToIdToken(t.auth,await t.getIdToken()),n);return fc._forOperation(t,"link",r)}async function h3(t,e,n=!1){const{auth:r}=t;if(ui(r.app))return Promise.reject(Ro(r));const i="reauthenticate";try{const s=await Sd(t,cN(r,i,e,t),n);We(s.idToken,r,"internal-error");const o=sw(s.idToken);We(o,r,"internal-error");const{sub:l}=o;return We(t.uid===l,r,"user-mismatch"),fc._forOperation(t,i,s)}catch(s){throw s?.code==="auth/user-not-found"&&Jr(r,"user-mismatch"),s}}async function uN(t,e,n=!1){if(ui(t.app))return Promise.reject(Ro(t));const r="signIn",i=await cN(t,r,e),s=await fc._fromIdTokenResponse(t,r,i);return n||await t._updateCurrentUser(s.user),s}async function p3(t,e){return uN(Za(t),e)}async function m3(t){const e=Za(t);e._getPasswordPolicyInternal()&&await e._updatePasswordPolicy()}function g3(t,e,n){return ui(t.app)?Promise.reject(Ro(t)):p3(Is(t),Mc.credential(e,n)).catch(async r=>{throw r.code==="auth/password-does-not-meet-requirements"&&m3(t),r})}function y3(t,e,n,r){return Is(t).onIdTokenChanged(e,n,r)}function b3(t,e,n){return Is(t).beforeAuthStateChanged(e,n)}function v3(t,e,n,r){return Is(t).onAuthStateChanged(e,n,r)}function jT(t){return Is(t).signOut()}const _p="__sak";class dN{constructor(e,n){this.storageRetriever=e,this.type=n}_isAvailable(){try{return this.storage?(this.storage.setItem(_p,"1"),this.storage.removeItem(_p),Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}_set(e,n){return this.storage.setItem(e,JSON.stringify(n)),Promise.resolve()}_get(e){const n=this.storage.getItem(e);return Promise.resolve(n?JSON.parse(n):null)}_remove(e){return this.storage.removeItem(e),Promise.resolve()}get storage(){return this.storageRetriever()}}const x3=1e3,w3=10;class fN extends dN{constructor(){super(()=>window.localStorage,"LOCAL"),this.boundEventHandler=(e,n)=>this.onStorageEvent(e,n),this.listeners={},this.localCache={},this.pollTimer=null,this.fallbackToPolling=iN(),this._shouldAllowMigration=!0}forAllChangedKeys(e){for(const n of Object.keys(this.listeners)){const r=this.storage.getItem(n),i=this.localCache[n];r!==i&&e(n,i,r)}}onStorageEvent(e,n=!1){if(!e.key){this.forAllChangedKeys((o,l,u)=>{this.notifyListeners(o,u)});return}const r=e.key;n?this.detachListener():this.stopPolling();const i=()=>{const o=this.storage.getItem(r);!n&&this.localCache[r]===o||this.notifyListeners(r,o)},s=this.storage.getItem(r);VB()&&s!==e.newValue&&e.newValue!==e.oldValue?setTimeout(i,w3):i()}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const i of Array.from(r))i(n&&JSON.parse(n))}startPolling(){this.stopPolling(),this.pollTimer=setInterval(()=>{this.forAllChangedKeys((e,n,r)=>{this.onStorageEvent(new StorageEvent("storage",{key:e,oldValue:n,newValue:r}),!0)})},x3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}attachListener(){window.addEventListener("storage",this.boundEventHandler)}detachListener(){window.removeEventListener("storage",this.boundEventHandler)}_addListener(e,n){Object.keys(this.listeners).length===0&&(this.fallbackToPolling?this.startPolling():this.attachListener()),this.listeners[e]||(this.listeners[e]=new Set,this.localCache[e]=this.storage.getItem(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.detachListener(),this.stopPolling())}async _set(e,n){await super._set(e,n),this.localCache[e]=JSON.stringify(n)}async _get(e){const n=await super._get(e);return this.localCache[e]=JSON.stringify(n),n}async _remove(e){await super._remove(e),delete this.localCache[e]}}fN.type="LOCAL";const S3=fN;class hN extends dN{constructor(){super(()=>window.sessionStorage,"SESSION")}_addListener(e,n){}_removeListener(e,n){}}hN.type="SESSION";const pN=hN;function k3(t){return Promise.all(t.map(async e=>{try{return{fulfilled:!0,value:await e}}catch(n){return{fulfilled:!1,reason:n}}}))}class Hm{constructor(e){this.eventTarget=e,this.handlersMap={},this.boundEventHandler=this.handleEvent.bind(this)}static _getInstance(e){const n=this.receivers.find(i=>i.isListeningto(e));if(n)return n;const r=new Hm(e);return this.receivers.push(r),r}isListeningto(e){return this.eventTarget===e}async handleEvent(e){const n=e,{eventId:r,eventType:i,data:s}=n.data,o=this.handlersMap[i];if(!o?.size)return;n.ports[0].postMessage({status:"ack",eventId:r,eventType:i});const l=Array.from(o).map(async f=>f(n.origin,s)),u=await k3(l);n.ports[0].postMessage({status:"done",eventId:r,eventType:i,response:u})}_subscribe(e,n){Object.keys(this.handlersMap).length===0&&this.eventTarget.addEventListener("message",this.boundEventHandler),this.handlersMap[e]||(this.handlersMap[e]=new Set),this.handlersMap[e].add(n)}_unsubscribe(e,n){this.handlersMap[e]&&n&&this.handlersMap[e].delete(n),(!n||this.handlersMap[e].size===0)&&delete this.handlersMap[e],Object.keys(this.handlersMap).length===0&&this.eventTarget.removeEventListener("message",this.boundEventHandler)}}Hm.receivers=[];function uw(t="",e=10){let n="";for(let r=0;r<e;r++)n+=Math.floor(Math.random()*10);return t+n}class C3{constructor(e){this.target=e,this.handlers=new Set}removeMessageHandler(e){e.messageChannel&&(e.messageChannel.port1.removeEventListener("message",e.onMessage),e.messageChannel.port1.close()),this.handlers.delete(e)}async _send(e,n,r=50){const i=typeof MessageChannel<"u"?new MessageChannel:null;if(!i)throw new Error("connection_unavailable");let s,o;return new Promise((l,u)=>{const f=uw("",20);i.port1.start();const h=setTimeout(()=>{u(new Error("unsupported_event"))},r);o={messageChannel:i,onMessage(m){const g=m;if(g.data.eventId===f)switch(g.data.status){case"ack":clearTimeout(h),s=setTimeout(()=>{u(new Error("timeout"))},3e3);break;case"done":clearTimeout(s),l(g.data.response);break;default:clearTimeout(h),clearTimeout(s),u(new Error("invalid_response"));break}}},this.handlers.add(o),i.port1.addEventListener("message",o.onMessage),this.target.postMessage({eventType:e,eventId:f,data:n},[i.port2])}).finally(()=>{o&&this.removeMessageHandler(o)})}}function Ii(){return window}function E3(t){Ii().location.href=t}function mN(){return typeof Ii().WorkerGlobalScope<"u"&&typeof Ii().importScripts=="function"}async function T3(){if(!navigator?.serviceWorker)return null;try{return(await navigator.serviceWorker.ready).active}catch{return null}}function _3(){return navigator?.serviceWorker?.controller||null}function A3(){return mN()?self:null}const gN="firebaseLocalStorageDb",R3=1,Ap="firebaseLocalStorage",yN="fbase_key";class Kd{constructor(e){this.request=e}toPromise(){return new Promise((e,n)=>{this.request.addEventListener("success",()=>{e(this.request.result)}),this.request.addEventListener("error",()=>{n(this.request.error)})})}}function Um(t,e){return t.transaction([Ap],e?"readwrite":"readonly").objectStore(Ap)}function M3(){const t=indexedDB.deleteDatabase(gN);return new Kd(t).toPromise()}function bN(){const t=indexedDB.open(gN,R3);return new Promise((e,n)=>{t.addEventListener("error",()=>{n(t.error)}),t.addEventListener("upgradeneeded",()=>{const r=t.result;try{r.createObjectStore(Ap,{keyPath:yN})}catch(i){n(i)}}),t.addEventListener("success",async()=>{const r=t.result;r.objectStoreNames.contains(Ap)?e(r):(r.close(),await M3(),e(await bN()))})})}async function LT(t,e,n){const r=Um(t,!0).put({[yN]:e,value:n});return new Kd(r).toPromise()}async function N3(t,e){const n=Um(t,!1).get(e),r=await new Kd(n).toPromise();return r===void 0?null:r.value}function PT(t,e){const n=Um(t,!0).delete(e);return new Kd(n).toPromise()}const O3=800,D3=3;class vN{registerLifecycleListeners(){typeof window<"u"&&typeof window.addEventListener=="function"&&(window.addEventListener("pagehide",this.onPageHide),window.addEventListener("pageshow",this.onPageShow)),typeof document<"u"&&typeof document.addEventListener=="function"&&document.addEventListener("visibilitychange",this.onVisibilityChange)}unregisterLifecycleListeners(){typeof window<"u"&&typeof window.removeEventListener=="function"&&(window.removeEventListener("pagehide",this.onPageHide),window.removeEventListener("pageshow",this.onPageShow)),typeof document<"u"&&typeof document.removeEventListener=="function"&&document.removeEventListener("visibilitychange",this.onVisibilityChange)}constructor(){this.type="LOCAL",this.dbPromise=null,this._shouldAllowMigration=!0,this.listeners={},this.localCache={},this.pollTimer=null,this.isHiding=!1,this.pendingWrites=0,this.receiver=null,this.sender=null,this.serviceWorkerReceiverAvailable=!1,this.activeServiceWorker=null,this.onPageHide=()=>{this.isHiding=!0,this.stopPolling(),this.dbPromise&&(this.dbPromise.then(e=>e.close()).catch(()=>{}),this.dbPromise=null)},this.onPageShow=()=>{this.isHiding&&(this.isHiding=!1,Object.keys(this.listeners).length>0&&this.startPolling())},this.onVisibilityChange=()=>{typeof document<"u"&&(document.visibilityState==="hidden"?this.onPageHide():document.visibilityState==="visible"&&this.onPageShow())},this._workerInitializationPromise=this.initializeServiceWorkerMessaging().then(()=>{},()=>{})}async _openDb(){if(this.isHiding)throw new Error("Database is closing/hidden");return this.dbPromise?this.dbPromise:(this.dbPromise=bN(),this.dbPromise.catch(()=>{this.dbPromise=null}),this.dbPromise)}async _withRetries(e){let n=0;for(;;)try{const r=await this._openDb();return await e(r)}catch(r){if(this.isHiding||n++>D3)throw r;this.dbPromise&&((await this.dbPromise).close(),this.dbPromise=null)}}async initializeServiceWorkerMessaging(){return mN()?this.initializeReceiver():this.initializeSender()}async initializeReceiver(){this.receiver=Hm._getInstance(A3()),this.receiver._subscribe("keyChanged",async(e,n)=>({keyProcessed:(await this._poll()).includes(n.key)})),this.receiver._subscribe("ping",async(e,n)=>["keyChanged"])}async initializeSender(){if(this.activeServiceWorker=await T3(),!this.activeServiceWorker)return;this.sender=new C3(this.activeServiceWorker);const e=await this.sender._send("ping",{},800);e&&e[0]?.fulfilled&&e[0]?.value.includes("keyChanged")&&(this.serviceWorkerReceiverAvailable=!0)}async notifyServiceWorker(e){if(!(!this.sender||!this.activeServiceWorker||_3()!==this.activeServiceWorker))try{await this.sender._send("keyChanged",{key:e},this.serviceWorkerReceiverAvailable?800:50)}catch{}}async _isAvailable(){try{return indexedDB?(await this._withRetries(async e=>{await LT(e,_p,"1"),await PT(e,_p)}),!0):!1}catch{}return!1}async _withPendingWrite(e){this.pendingWrites++;try{await e()}finally{this.pendingWrites--}}async _set(e,n){return this._withPendingWrite(async()=>(await this._withRetries(r=>LT(r,e,n)),this.localCache[e]=n,this.notifyServiceWorker(e)))}async _get(e){const n=await this._withRetries(r=>N3(r,e));return this.localCache[e]=n,n}async _remove(e){return this._withPendingWrite(async()=>(await this._withRetries(n=>PT(n,e)),delete this.localCache[e],this.notifyServiceWorker(e)))}async _poll(){if(this.isHiding)return[];try{const e=await this._withRetries(i=>{const s=Um(i,!1).getAll();return new Kd(s).toPromise()});if(this.isHiding)return[];if(!e)return[];if(this.pendingWrites!==0)return[];const n=[],r=new Set;if(e.length!==0)for(const{fbase_key:i,value:s}of e)r.add(i),JSON.stringify(this.localCache[i])!==JSON.stringify(s)&&(this.notifyListeners(i,s),n.push(i));for(const i of Object.keys(this.localCache))this.localCache[i]&&!r.has(i)&&(this.notifyListeners(i,null),n.push(i));return n}catch(e){return this.isHiding||qM(`Firebase Auth cross-tab polling failed with error: ${e}`),[]}}notifyListeners(e,n){this.localCache[e]=n;const r=this.listeners[e];if(r)for(const i of Array.from(r))i(n)}startPolling(){this.stopPolling(),this.pollTimer=setInterval(async()=>this._poll(),O3)}stopPolling(){this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)}_addListener(e,n){Object.keys(this.listeners).length===0&&(this.startPolling(),this.registerLifecycleListeners()),this.listeners[e]||(this.listeners[e]=new Set,this._get(e)),this.listeners[e].add(n)}_removeListener(e,n){this.listeners[e]&&(this.listeners[e].delete(n),this.listeners[e].size===0&&delete this.listeners[e]),Object.keys(this.listeners).length===0&&(this.stopPolling(),this.unregisterLifecycleListeners())}}vN.type="LOCAL";const I3=vN;new Gd(3e4,6e4);function xN(t,e){return e?vs(e):(We(t._popupRedirectResolver,t,"argument-error"),t._popupRedirectResolver)}class dw extends aw{constructor(e){super("custom","custom"),this.params=e}_getIdTokenResponse(e){return sc(e,this._buildIdpRequest())}_linkToIdToken(e,n){return sc(e,this._buildIdpRequest(n))}_getReauthenticationResolver(e){return sc(e,this._buildIdpRequest())}_buildIdpRequest(e){const n={requestUri:this.params.requestUri,sessionId:this.params.sessionId,postBody:this.params.postBody,tenantId:this.params.tenantId,pendingToken:this.params.pendingToken,returnSecureToken:!0,returnIdpCredential:!0};return e&&(n.idToken=e),n}}function j3(t){return uN(t.auth,new dw(t),t.bypassAuthState)}function L3(t){const{auth:e,user:n}=t;return We(n,e,"internal-error"),h3(n,new dw(t),t.bypassAuthState)}async function P3(t){const{auth:e,user:n}=t;return We(n,e,"internal-error"),f3(n,new dw(t),t.bypassAuthState)}class wN{constructor(e,n,r,i,s=!1){this.auth=e,this.resolver=r,this.user=i,this.bypassAuthState=s,this.pendingPromise=null,this.eventManager=null,this.filter=Array.isArray(n)?n:[n]}execute(){return new Promise(async(e,n)=>{this.pendingPromise={resolve:e,reject:n};try{this.eventManager=await this.resolver._initialize(this.auth),await this.onExecution(),this.eventManager.registerConsumer(this)}catch(r){this.reject(r)}})}async onAuthEvent(e){const{urlResponse:n,sessionId:r,postBody:i,tenantId:s,error:o,type:l}=e;if(o){this.reject(o);return}const u={auth:this.auth,requestUri:n,sessionId:r,tenantId:s||void 0,postBody:i||void 0,user:this.user,bypassAuthState:this.bypassAuthState};try{this.resolve(await this.getIdpTask(l)(u))}catch(f){this.reject(f)}}onError(e){this.reject(e)}getIdpTask(e){switch(e){case"signInViaPopup":case"signInViaRedirect":return j3;case"linkViaPopup":case"linkViaRedirect":return P3;case"reauthViaPopup":case"reauthViaRedirect":return L3;default:Jr(this.auth,"internal-error")}}resolve(e){Ms(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.resolve(e),this.unregisterAndCleanUp()}reject(e){Ms(this.pendingPromise,"Pending promise was never set"),this.pendingPromise.reject(e),this.unregisterAndCleanUp()}unregisterAndCleanUp(){this.eventManager&&this.eventManager.unregisterConsumer(this),this.pendingPromise=null,this.cleanUp()}}const z3=new Gd(2e3,1e4);async function $3(t,e,n){if(ui(t.app))return Promise.reject(mi(t,"operation-not-supported-in-this-environment"));const r=Za(t);wB(t,e,cw);const i=xN(r,n);return new wa(r,"signInViaPopup",e,i).executeNotNull()}class wa extends wN{constructor(e,n,r,i,s){super(e,n,i,s),this.provider=r,this.authWindow=null,this.pollId=null,wa.currentPopupAction&&wa.currentPopupAction.cancel(),wa.currentPopupAction=this}async executeNotNull(){const e=await this.execute();return We(e,this.auth,"internal-error"),e}async onExecution(){Ms(this.filter.length===1,"Popup operations only handle one event");const e=uw();this.authWindow=await this.resolver._openPopup(this.auth,this.provider,this.filter[0],e),this.authWindow.associatedEvent=e,this.resolver._originValidation(this.auth).catch(n=>{this.reject(n)}),this.resolver._isIframeWebStorageSupported(this.auth,n=>{n||this.reject(mi(this.auth,"web-storage-unsupported"))}),this.pollUserCancellation()}get eventId(){return this.authWindow?.associatedEvent||null}cancel(){this.reject(mi(this.auth,"cancelled-popup-request"))}cleanUp(){this.authWindow&&this.authWindow.close(),this.pollId&&window.clearTimeout(this.pollId),this.authWindow=null,this.pollId=null,wa.currentPopupAction=null}pollUserCancellation(){const e=()=>{if(this.authWindow?.window?.closed){this.pollId=window.setTimeout(()=>{this.pollId=null,this.reject(mi(this.auth,"popup-closed-by-user"))},8e3);return}this.pollId=window.setTimeout(e,z3.get())};e()}}wa.currentPopupAction=null;const B3="pendingRedirect",op=new Map;class V3 extends wN{constructor(e,n,r=!1){super(e,["signInViaRedirect","linkViaRedirect","reauthViaRedirect","unknown"],n,void 0,r),this.eventId=null}async execute(){let e=op.get(this.auth._key());if(!e){try{const r=await H3(this.resolver,this.auth)?await super.execute():null;e=()=>Promise.resolve(r)}catch(n){e=()=>Promise.reject(n)}op.set(this.auth._key(),e)}return this.bypassAuthState||op.set(this.auth._key(),()=>Promise.resolve(null)),e()}async onAuthEvent(e){if(e.type==="signInViaRedirect")return super.onAuthEvent(e);if(e.type==="unknown"){this.resolve(null);return}if(e.eventId){const n=await this.auth._redirectUserForId(e.eventId);if(n)return this.user=n,super.onAuthEvent(e);this.resolve(null)}}async onExecution(){}cleanUp(){}}async function H3(t,e){const n=q3(e),r=F3(t);if(!await r._isAvailable())return!1;const i=await r._get(n)==="true";return await r._remove(n),i}function U3(t,e){op.set(t._key(),e)}function F3(t){return vs(t._redirectPersistence)}function q3(t){return sp(B3,t.config.apiKey,t.name)}async function G3(t,e,n=!1){if(ui(t.app))return Promise.reject(Ro(t));const r=Za(t),i=xN(r,e),o=await new V3(r,i,n).execute();return o&&!n&&(delete o.user._redirectEventId,await r._persistUserIfCurrent(o.user),await r._setRedirectUser(null,e)),o}const W3=600*1e3;class K3{constructor(e){this.auth=e,this.cachedEventUids=new Set,this.consumers=new Set,this.queuedRedirectEvent=null,this.hasHandledPotentialRedirect=!1,this.lastProcessedEventTime=Date.now()}registerConsumer(e){this.consumers.add(e),this.queuedRedirectEvent&&this.isEventForConsumer(this.queuedRedirectEvent,e)&&(this.sendToConsumer(this.queuedRedirectEvent,e),this.saveEventToCache(this.queuedRedirectEvent),this.queuedRedirectEvent=null)}unregisterConsumer(e){this.consumers.delete(e)}onEvent(e){if(this.hasEventBeenHandled(e))return!1;let n=!1;return this.consumers.forEach(r=>{this.isEventForConsumer(e,r)&&(n=!0,this.sendToConsumer(e,r),this.saveEventToCache(e))}),this.hasHandledPotentialRedirect||!Z3(e)||(this.hasHandledPotentialRedirect=!0,n||(this.queuedRedirectEvent=e,n=!0)),n}sendToConsumer(e,n){if(e.error&&!SN(e)){const r=e.error.code?.split("auth/")[1]||"internal-error";n.onError(mi(this.auth,r))}else n.onAuthEvent(e)}isEventForConsumer(e,n){const r=n.eventId===null||!!e.eventId&&e.eventId===n.eventId;return n.filter.includes(e.type)&&r}hasEventBeenHandled(e){return Date.now()-this.lastProcessedEventTime>=W3&&this.cachedEventUids.clear(),this.cachedEventUids.has(zT(e))}saveEventToCache(e){this.cachedEventUids.add(zT(e)),this.lastProcessedEventTime=Date.now()}}function zT(t){return[t.type,t.eventId,t.sessionId,t.tenantId].filter(e=>e).join("-")}function SN({type:t,error:e}){return t==="unknown"&&e?.code==="auth/no-auth-event"}function Z3(t){switch(t.type){case"signInViaRedirect":case"linkViaRedirect":case"reauthViaRedirect":return!0;case"unknown":return SN(t);default:return!1}}async function Y3(t,e={}){return Wo(t,"GET","/v1/projects",e)}const X3=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,J3=/^https?/;async function Q3(t){if(t.config.emulator)return;const{authorizedDomains:e}=await Y3(t);for(const n of e)try{if(eV(n))return}catch{}Jr(t,"unauthorized-domain")}function eV(t){const e=S0(),{protocol:n,hostname:r}=new URL(e);if(t.startsWith("chrome-extension://")){const o=new URL(t);return o.hostname===""&&r===""?n==="chrome-extension:"&&t.replace("chrome-extension://","")===e.replace("chrome-extension://",""):n==="chrome-extension:"&&o.hostname===r}if(!J3.test(n))return!1;if(X3.test(t))return r===t;const i=t.replace(/\./g,"\\.");return new RegExp("^(.+\\."+i+"|"+i+")$","i").test(r)}const tV=new Gd(3e4,6e4);function $T(){const t=Ii().___jsl;if(t?.H){for(const e of Object.keys(t.H))if(t.H[e].r=t.H[e].r||[],t.H[e].L=t.H[e].L||[],t.H[e].r=[...t.H[e].L],t.CP)for(let n=0;n<t.CP.length;n++)t.CP[n]=null}}function nV(t){return new Promise((e,n)=>{function r(){$T(),gapi.load("gapi.iframes",{callback:()=>{e(gapi.iframes.getContext())},ontimeout:()=>{$T(),n(mi(t,"network-request-failed"))},timeout:tV.get()})}if(Ii().gapi?.iframes?.Iframe)e(gapi.iframes.getContext());else if(Ii().gapi?.load)r();else{const i=YB("iframefcb");return Ii()[i]=()=>{gapi.load?r():n(mi(t,"network-request-failed"))},oN(`${ZB()}?onload=${i}`).catch(s=>n(s))}}).catch(e=>{throw ap=null,e})}let ap=null;function rV(t){return ap=ap||nV(t),ap}const iV=new Gd(5e3,15e3),sV="__/auth/iframe",oV="emulator/auth/iframe",aV={style:{position:"absolute",top:"-100px",width:"1px",height:"1px"},"aria-hidden":"true",tabindex:"-1"},lV=new Map([["identitytoolkit.googleapis.com","p"],["staging-identitytoolkit.sandbox.googleapis.com","s"],["test-identitytoolkit.sandbox.googleapis.com","t"]]);function cV(t){const e=t.config;We(e.authDomain,t,"auth-domain-config-required");const n=e.emulator?iw(e,oV):`https://${t.config.authDomain}/${sV}`,r={apiKey:e.apiKey,appName:t.name,v:qd},i=lV.get(t.config.apiHost);i&&(r.eid=i);const s=t._getFrameworks();return s.length&&(r.fw=s.join(",")),`${n}?${Fd(r).slice(1)}`}async function uV(t){const e=await rV(t),n=Ii().gapi;return We(n,t,"internal-error"),e.open({where:document.body,url:cV(t),messageHandlersFilter:n.iframes.CROSS_ORIGIN_IFRAMES_FILTER,attributes:aV,dontclear:!0},r=>new Promise(async(i,s)=>{await r.restyle({setHideOnLeave:!1});const o=mi(t,"network-request-failed"),l=Ii().setTimeout(()=>{s(o)},iV.get());function u(){Ii().clearTimeout(l),i(r)}r.ping(u).then(u,()=>{s(o)})}))}const dV={location:"yes",resizable:"yes",statusbar:"yes",toolbar:"no"},fV=500,hV=600,pV="_blank",mV="http://localhost";class BT{constructor(e){this.window=e,this.associatedEvent=null}close(){if(this.window)try{this.window.close()}catch{}}}function gV(t,e,n,r=fV,i=hV){const s=Math.max((window.screen.availHeight-i)/2,0).toString(),o=Math.max((window.screen.availWidth-r)/2,0).toString();let l="";const u={...dV,width:r.toString(),height:i.toString(),top:s,left:o},f=nr().toLowerCase();n&&(l=QM(f)?pV:n),XM(f)&&(e=e||mV,u.scrollbars="yes");const h=Object.entries(u).reduce((g,[b,x])=>`${g}${b}=${x},`,"");if(BB(f)&&l!=="_self")return yV(e||"",l),new BT(null);const m=window.open(e||"",l,h);We(m,t,"popup-blocked");try{m.focus()}catch{}return new BT(m)}function yV(t,e){const n=document.createElement("a");n.href=t,n.target=e;const r=document.createEvent("MouseEvent");r.initMouseEvent("click",!0,!0,window,1,0,0,0,0,!1,!1,!1,!1,1,null),n.dispatchEvent(r)}const bV="__/auth/handler",vV="emulator/auth/handler",xV=encodeURIComponent("fac");async function VT(t,e,n,r,i,s){We(t.config.authDomain,t,"auth-domain-config-required"),We(t.config.apiKey,t,"invalid-api-key");const o={apiKey:t.config.apiKey,appName:t.name,authType:n,redirectUrl:r,v:qd,eventId:i};if(e instanceof cw){e.setDefaultLanguage(t.languageCode),o.providerId=e.providerId||"",i$(e.getCustomParameters())||(o.customParameters=JSON.stringify(e.getCustomParameters()));for(const[h,m]of Object.entries({}))o[h]=m}if(e instanceof Wd){const h=e.getScopes().filter(m=>m!=="");h.length>0&&(o.scopes=h.join(","))}t.tenantId&&(o.tid=t.tenantId);const l=o;for(const h of Object.keys(l))l[h]===void 0&&delete l[h];const u=await t._getAppCheckToken(),f=u?`#${xV}=${encodeURIComponent(u)}`:"";return`${wV(t)}?${Fd(l).slice(1)}${f}`}function wV({config:t}){return t.emulator?iw(t,vV):`https://${t.authDomain}/${bV}`}const av="webStorageSupport";class SV{constructor(){this.eventManagers={},this.iframes={},this.originValidationPromises={},this._redirectPersistence=pN,this._completeRedirectFn=G3,this._overrideRedirectResult=U3}async _openPopup(e,n,r,i){Ms(this.eventManagers[e._key()]?.manager,"_initialize() not called before _openPopup()");const s=await VT(e,n,r,S0(),i);return gV(e,s,uw())}async _openRedirect(e,n,r,i){await this._originValidation(e);const s=await VT(e,n,r,S0(),i);return E3(s),new Promise(()=>{})}_initialize(e){const n=e._key();if(this.eventManagers[n]){const{manager:i,promise:s}=this.eventManagers[n];return i?Promise.resolve(i):(Ms(s,"If manager is not set, promise should be"),s)}const r=this.initAndGetManager(e);return this.eventManagers[n]={promise:r},r.catch(()=>{delete this.eventManagers[n]}),r}async initAndGetManager(e){const n=await uV(e),r=new K3(e);return n.register("authEvent",i=>(We(i?.authEvent,e,"invalid-auth-event"),{status:r.onEvent(i.authEvent)?"ACK":"ERROR"}),gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER),this.eventManagers[e._key()]={manager:r},this.iframes[e._key()]=n,r}_isIframeWebStorageSupported(e,n){this.iframes[e._key()].send(av,{type:av},i=>{const s=i?.[0]?.[av];s!==void 0&&n(!!s),Jr(e,"internal-error")},gapi.iframes.CROSS_ORIGIN_IFRAMES_FILTER)}_originValidation(e){const n=e._key();return this.originValidationPromises[n]||(this.originValidationPromises[n]=Q3(e)),this.originValidationPromises[n]}get _shouldInitProactively(){return iN()||JM()||ow()}}const kV=SV;var HT="@firebase/auth",UT="1.13.4";class CV{constructor(e){this.auth=e,this.internalListeners=new Map}getUid(){return this.assertAuthConfigured(),this.auth.currentUser?.uid||null}async getToken(e){return this.assertAuthConfigured(),await this.auth._initializationPromise,this.auth.currentUser?{accessToken:await this.auth.currentUser.getIdToken(e)}:null}addAuthTokenListener(e){if(this.assertAuthConfigured(),this.internalListeners.has(e))return;const n=this.auth.onIdTokenChanged(r=>{e(r?.stsTokenManager.accessToken||null)});this.internalListeners.set(e,n),this.updateProactiveRefresh()}removeAuthTokenListener(e){this.assertAuthConfigured();const n=this.internalListeners.get(e);n&&(this.internalListeners.delete(e),n(),this.updateProactiveRefresh())}assertAuthConfigured(){We(this.auth._initializationPromise,"dependent-sdk-initialized-before-auth")}updateProactiveRefresh(){this.internalListeners.size>0?this.auth._startProactiveRefresh():this.auth._stopProactiveRefresh()}}function EV(t){switch(t){case"Node":return"node";case"ReactNative":return"rn";case"Worker":return"webworker";case"Cordova":return"cordova";case"WebExtension":return"web-extension";default:return}}function TV(t){xd(new dc("auth",(e,{options:n})=>{const r=e.getProvider("app").getImmediate(),i=e.getProvider("heartbeat"),s=e.getProvider("app-check-internal"),{apiKey:o,authDomain:l}=r.options;We(o&&!o.includes(":"),"invalid-api-key",{appName:r.name});const u={apiKey:o,authDomain:l,clientPlatform:t,apiHost:"identitytoolkit.googleapis.com",tokenApiHost:"securetoken.googleapis.com",apiScheme:"https",sdkClientVersion:sN(t)},f=new GB(r,i,s,u);return t3(f,n),f},"PUBLIC").setInstantiationMode("EXPLICIT").setInstanceCreatedCallback((e,n,r)=>{e.getProvider("auth-internal").initialize()})),xd(new dc("auth-internal",e=>{const n=Za(e.getProvider("auth").getImmediate());return(r=>new CV(r))(n)},"PRIVATE").setInstantiationMode("EXPLICIT")),nc(HT,UT,EV(t)),nc(HT,UT,"esm2020")}const _V=300,AV=DM("authIdTokenMaxAge")||_V;let FT=null;const RV=t=>async e=>{const n=e&&await e.getIdTokenResult(),r=n&&(new Date().getTime()-Date.parse(n.issuedAtTime))/1e3;if(r&&r>AV)return;const i=n?.token;FT!==i&&(FT=i,await fetch(t,{method:i?"POST":"DELETE",headers:i?{Authorization:`Bearer ${i}`}:{}}))};function MV(t=BM()){const e=zM(t,"auth");if(e.isInitialized())return e.getImmediate();const n=e3(t,{popupRedirectResolver:kV,persistence:[I3,S3,pN]}),r=DM("authTokenSyncURL");if(r&&typeof isSecureContext=="boolean"&&isSecureContext){const s=new URL(r,location.origin);if(location.origin===s.origin){const o=RV(s.toString());b3(n,o,()=>o(n.currentUser)),y3(n,l=>o(l))}}const i=Kz("auth");return i&&n3(n,`http://${i}`),n}function NV(){return document.getElementsByTagName("head")?.[0]??document}WB({loadJS(t){return new Promise((e,n)=>{const r=document.createElement("script");r.setAttribute("src",t),r.onload=e,r.onerror=i=>{const s=mi("internal-error");s.customData=i,n(s)},r.type="text/javascript",r.charset="UTF-8",NV().appendChild(r)})},gapiScript:"https://apis.google.com/js/api.js",recaptchaV2Script:"https://www.google.com/recaptcha/api.js",recaptchaEnterpriseScript:"https://www.google.com/recaptcha/enterprise.js?render="});TV("Browser");function OV(t=6e4){const e=new Map,n=new Map;function r(o,l,u){if(!u?.fresh){const h=e.get(o);if(h&&Date.now()-h.at<t)return Promise.resolve(h.value);const m=n.get(o);if(m)return m}const f=l().then(h=>(e.set(o,{value:h,at:Date.now()}),n.delete(o),h)).catch(h=>{throw n.delete(o),h});return n.set(o,f),f}function i(o,l){e.set(o,{value:l,at:Date.now()})}function s(o){if(!o){e.clear(),n.clear();return}for(const l of[...e.keys()])(l===o||l.startsWith(`${o}:`))&&e.delete(l);for(const l of[...n.keys()])(l===o||l.startsWith(`${o}:`))&&n.delete(l)}return{get:r,set:i,invalidate:s}}const DV="x-vertebr-env";async function Nu(t,e){const n=await t.arrayBuffer(),r=new Uint8Array(n);let i="";const s=32768;for(let l=0;l<r.length;l+=s)i+=String.fromCharCode(...r.subarray(l,l+s));return{name:e||typeof File<"u"&&t instanceof File&&t.name||"upload",type:t.type||"application/octet-stream",data:btoa(i)}}function C0(t,e){const n=typeof t=="string"?{apiBase:t,getEnvironment:(()=>"")}:t,r=n.apiBase.replace(/\/$/,""),i=OV(n.cacheTtlMs??6e4);async function s(o,l,u){const f=n.getEnvironment().trim(),m=(await n.getAccessToken?.())?.trim(),g=await fetch(`${r}${o}`,{...l,headers:{Accept:"application/json","Content-Type":"application/json",...f?{[DV]:f}:{},...u?.auth!==!1&&m?{Authorization:`Bearer ${m}`}:{},...l?.headers??{}}});if(!g.ok){const b=await g.text();let x=b||`Request failed (${g.status})`;try{const S=JSON.parse(b);typeof S.error=="string"&&S.error.trim()?x=S.error:S.error&&typeof S.error=="object"&&typeof S.error.message=="string"&&S.error.message.trim()?x=S.error.message:typeof S.message=="string"&&S.message.trim()&&(x=S.message)}catch{}throw new Error(x)}return await g.json()}return{getBootstrap:o=>i.get("bootstrap",()=>s("/bootstrap",void 0,{auth:!1}),o),getCatalog:o=>i.get("catalog",()=>s(""),o),getMetrics:o=>{const l=o?.range?.trim()||"14d";return i.get(`metrics:${l}`,()=>s(`/metrics?range=${encodeURIComponent(l)}`),o)},getPublicControls:o=>i.get("controls",async()=>(await s("/public/controls",void 0,{auth:!1})).configs??{},o),getPublicResource:(o,l)=>i.get(`public-resource:${o}`,()=>s(`/public/resources/${encodeURIComponent(o)}`,void 0,{auth:!1}),l),listResource:(o,l)=>i.get(`resource:${o}`,()=>s(`/resources/${encodeURIComponent(o)}`),l),createResource:async(o,l)=>{const u=await s(`/resources/${encodeURIComponent(o)}`,{method:"POST",body:JSON.stringify(l)});return i.invalidate(`resource:${o}`),i.invalidate(`public-resource:${o}`),u},updateResource:async(o,l,u)=>{const f=await s(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,{method:"PUT",body:JSON.stringify(u)});return i.invalidate(`resource:${o}`),i.invalidate(`public-resource:${o}`),f},deleteResource:async(o,l)=>{const u=await s(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}`,{method:"DELETE"});return i.invalidate(`resource:${o}`),i.invalidate(`public-resource:${o}`),u},runResourceAction:async(o,l,u,f)=>{const h=await s(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}/actions/${encodeURIComponent(u)}`,{method:"POST",body:JSON.stringify(f??{})});return i.invalidate(`resource:${o}`),i.invalidate(`public-resource:${o}`),h},runCollectionAction:async(o,l,u)=>{const f=await s(`/resources/${encodeURIComponent(o)}/collection-actions/${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(u??{})});return i.invalidate(`resource:${o}`),i.invalidate(`public-resource:${o}`),f},previewResourceMail:async(o,l,u,f)=>s(`/resources/${encodeURIComponent(o)}/${encodeURIComponent(l)}/mail/${encodeURIComponent(u)}/preview`,{method:"POST",body:JSON.stringify(f??{})}),getEmails:o=>i.get("emails",()=>s("/emails"),o),previewEmails:async o=>s("/emails/preview",{method:"POST",body:JSON.stringify(o)}),sendEmails:async o=>{const l=await s("/emails/send",{method:"POST",body:JSON.stringify(o)});return i.invalidate("emails"),i.invalidate(`resource:${o.resourceId}`),l},scheduleEmails:async o=>{const l=await s("/emails/schedule",{method:"POST",body:JSON.stringify(o)});return i.invalidate("emails"),l},cancelEmailCampaign:async o=>{const l=await s(`/emails/campaigns/${encodeURIComponent(o)}`,{method:"DELETE"});return i.invalidate("emails"),l},saveEmailLibraryTemplate:async o=>{const l=await s("/emails/library",{method:"POST",body:JSON.stringify(o)});return i.invalidate("emails"),l},deleteEmailLibraryTemplate:async o=>{const l=await s(`/emails/library/${encodeURIComponent(o)}`,{method:"DELETE"});return i.invalidate("emails"),l},uploadResourceFile:async(o,l,u,f)=>{const h=await Nu(u,f);return s(`/resources/${encodeURIComponent(o)}/uploads/${encodeURIComponent(l)}`,{method:"POST",body:JSON.stringify(h)})},uploadResourceFiles:async(o,l,u)=>{const f={files:await Promise.all(u.map(h=>Nu(h)))};return s(`/resources/${encodeURIComponent(o)}/uploads/${encodeURIComponent(l)}/bulk`,{method:"POST",body:JSON.stringify(f)})},getGallery:o=>i.get("gallery",()=>s("/gallery"),o),uploadGalleryFile:async(o,l)=>{const u=await Nu(o,l),f=await s("/gallery/upload",{method:"POST",body:JSON.stringify(u)});return i.invalidate("gallery"),f},uploadGalleryFiles:async o=>{const l={files:await Promise.all(o.map(f=>Nu(f)))},u=await s("/gallery/upload/bulk",{method:"POST",body:JSON.stringify(l)});return i.invalidate("gallery"),u},deleteGalleryItem:async o=>{const l=await s(`/gallery/${encodeURIComponent(o)}`,{method:"DELETE"});return i.invalidate("gallery"),l},getFonts:o=>i.get("fonts",()=>s("/fonts"),o),getPublicFonts:async o=>(await i.get("public:fonts",()=>s("/public/fonts"),o)).items,uploadFontFile:async(o,l,u)=>{const f={...await Nu(o,u),...l?.family?{family:l.family}:{},...l?.label?{label:l.label}:{},...l?.weight!=null?{weight:l.weight}:{}},h=await s("/fonts/upload",{method:"POST",body:JSON.stringify(f)});return i.invalidate("fonts"),i.invalidate("public:fonts"),h},importGoogleFont:async o=>{const l=await s("/fonts/import-google",{method:"POST",body:JSON.stringify(o)});return i.invalidate("fonts"),i.invalidate("public:fonts"),l},deleteFontItem:async o=>{const l=await s(`/fonts/${encodeURIComponent(o)}`,{method:"DELETE"});return i.invalidate("fonts"),i.invalidate("public:fonts"),l},getConfig:(o,l)=>i.get(`config:${o}`,()=>s(`/configs/${encodeURIComponent(o)}`),l),setConfig:async(o,l)=>{const u=await s(`/configs/${encodeURIComponent(o)}`,{method:"PUT",body:JSON.stringify(l)}),f={id:u.id,label:u.label,schema:u.schema??{},environment:u.environment,value:u.value};return i.set(`config:${o}`,f),i.invalidate("controls"),f},invalidateCache:o=>i.invalidate(o)}}function fw(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ya=fw();function kN(t){Ya=t}var nd={exec:()=>null};function xt(t,e=""){let n=typeof t=="string"?t:t.source;const r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Jn.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var Jn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i")},IV=/^(?:[ \t]*(?:\n|$))+/,jV=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,LV=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Zd=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,PV=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hw=/(?:[*+-]|\d{1,9}[.)])/,CN=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,EN=xt(CN).replace(/bull/g,hw).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),zV=xt(CN).replace(/bull/g,hw).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),pw=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,$V=/^[^\n]+/,mw=/(?!\s*\])(?:\\.|[^\[\]\\])+/,BV=xt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",mw).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),VV=xt(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,hw).getRegex(),Fm="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",gw=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,HV=xt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",gw).replace("tag",Fm).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),TN=xt(pw).replace("hr",Zd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fm).getRegex(),UV=xt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",TN).getRegex(),yw={blockquote:UV,code:jV,def:BV,fences:LV,heading:PV,hr:Zd,html:HV,lheading:EN,list:VV,newline:IV,paragraph:TN,table:nd,text:$V},qT=xt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Zd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fm).getRegex(),FV={...yw,lheading:zV,table:qT,paragraph:xt(pw).replace("hr",Zd).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",qT).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Fm).getRegex()},qV={...yw,html:xt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",gw).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:nd,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:xt(pw).replace("hr",Zd).replace("heading",` *#{1,6} *[^
|
|
10
|
+
]`).replace("lheading",EN).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},GV=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,WV=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,_N=/^( {2,}|\\)\n(?!\s*$)/,KV=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,qm=/[\p{P}\p{S}]/u,bw=/[\s\p{P}\p{S}]/u,AN=/[^\s\p{P}\p{S}]/u,ZV=xt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,bw).getRegex(),RN=/(?!~)[\p{P}\p{S}]/u,YV=/(?!~)[\s\p{P}\p{S}]/u,XV=/(?:[^\s\p{P}\p{S}]|~)/u,JV=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,MN=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,QV=xt(MN,"u").replace(/punct/g,qm).getRegex(),eH=xt(MN,"u").replace(/punct/g,RN).getRegex(),NN="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",tH=xt(NN,"gu").replace(/notPunctSpace/g,AN).replace(/punctSpace/g,bw).replace(/punct/g,qm).getRegex(),nH=xt(NN,"gu").replace(/notPunctSpace/g,XV).replace(/punctSpace/g,YV).replace(/punct/g,RN).getRegex(),rH=xt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,AN).replace(/punctSpace/g,bw).replace(/punct/g,qm).getRegex(),iH=xt(/\\(punct)/,"gu").replace(/punct/g,qm).getRegex(),sH=xt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),oH=xt(gw).replace("(?:-->|$)","-->").getRegex(),aH=xt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",oH).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rp=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,lH=xt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",Rp).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ON=xt(/^!?\[(label)\]\[(ref)\]/).replace("label",Rp).replace("ref",mw).getRegex(),DN=xt(/^!?\[(ref)\](?:\[\])?/).replace("ref",mw).getRegex(),cH=xt("reflink|nolink(?!\\()","g").replace("reflink",ON).replace("nolink",DN).getRegex(),vw={_backpedal:nd,anyPunctuation:iH,autolink:sH,blockSkip:JV,br:_N,code:WV,del:nd,emStrongLDelim:QV,emStrongRDelimAst:tH,emStrongRDelimUnd:rH,escape:GV,link:lH,nolink:DN,punctuation:ZV,reflink:ON,reflinkSearch:cH,tag:aH,text:KV,url:nd},uH={...vw,link:xt(/^!?\[(label)\]\((.*?)\)/).replace("label",Rp).getRegex(),reflink:xt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rp).getRegex()},E0={...vw,emStrongRDelimAst:nH,emStrongLDelim:eH,url:xt(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},dH={...E0,br:xt(_N).replace("{2,}","*").getRegex(),text:xt(E0.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Sh={normal:yw,gfm:FV,pedantic:qV},Ou={normal:vw,gfm:E0,breaks:dH,pedantic:uH},fH={"&":"&","<":"<",">":">",'"':""","'":"'"},GT=t=>fH[t];function Ti(t,e){if(e){if(Jn.escapeTest.test(t))return t.replace(Jn.escapeReplace,GT)}else if(Jn.escapeTestNoEncode.test(t))return t.replace(Jn.escapeReplaceNoEncode,GT);return t}function WT(t){try{t=encodeURI(t).replace(Jn.percentDecode,"%")}catch{return null}return t}function KT(t,e){const n=t.replace(Jn.findPipe,(s,o,l)=>{let u=!1,f=o;for(;--f>=0&&l[f]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Jn.splitPipe);let i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Jn.slashPipe,"|");return r}function Du(t,e,n){const r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function hH(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function ZT(t,e,n,r,i){const s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;const u={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,u}function pH(t,e,n){const r=t.match(n.other.indentCodeCompensation);if(r===null)return e;const i=r[1];return e.split(`
|
|
11
|
+
`).map(s=>{const o=s.match(n.other.beginningSpace);if(o===null)return s;const[l]=o;return l.length>=i.length?s.slice(i.length):s}).join(`
|
|
12
|
+
`)}var Mp=class{options;rules;lexer;constructor(t){this.options=t||Ya}space(t){const e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){const e=this.rules.block.code.exec(t);if(e){const n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Du(n,`
|
|
13
|
+
`)}}}fences(t){const e=this.rules.block.fences.exec(t);if(e){const n=e[0],r=pH(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){const e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){const r=Du(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){const e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Du(e[0],`
|
|
14
|
+
`)}}blockquote(t){const e=this.rules.block.blockquote.exec(t);if(e){let n=Du(e[0],`
|
|
15
|
+
`).split(`
|
|
16
|
+
`),r="",i="";const s=[];for(;n.length>0;){let o=!1;const l=[];let u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))l.push(n[u]),o=!0;else if(!o)l.push(n[u]);else break;n=n.slice(u);const f=l.join(`
|
|
17
|
+
`),h=f.replace(this.rules.other.blockquoteSetextReplace,`
|
|
18
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
19
|
+
${f}`:f,i=i?`${i}
|
|
20
|
+
${h}`:h;const m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=m,n.length===0)break;const g=s.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){const b=g,x=b.raw+`
|
|
21
|
+
`+n.join(`
|
|
22
|
+
`),S=this.blockquote(x);s[s.length-1]=S,r=r.substring(0,r.length-b.raw.length)+S.raw,i=i.substring(0,i.length-b.text.length)+S.text;break}else if(g?.type==="list"){const b=g,x=b.raw+`
|
|
23
|
+
`+n.join(`
|
|
24
|
+
`),S=this.list(x);s[s.length-1]=S,r=r.substring(0,r.length-g.raw.length)+S.raw,i=i.substring(0,i.length-b.raw.length)+S.raw,n=x.substring(s.at(-1).raw.length).split(`
|
|
25
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim();const r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");const s=this.rules.other.listItemRegex(n);let o=!1;for(;t;){let u=!1,f="",h="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=e[2].split(`
|
|
26
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,C=>" ".repeat(3*C.length)),g=t.split(`
|
|
27
|
+
`,1)[0],b=!m.trim(),x=0;if(this.options.pedantic?(x=2,h=m.trimStart()):b?x=e[1].length+1:(x=e[2].search(this.rules.other.nonSpaceChar),x=x>4?1:x,h=m.slice(x),x+=e[1].length),b&&this.rules.other.blankLine.test(g)&&(f+=g+`
|
|
28
|
+
`,t=t.substring(g.length+1),u=!0),!u){const C=this.rules.other.nextBulletRegex(x),A=this.rules.other.hrRegex(x),R=this.rules.other.fencesBeginRegex(x),_=this.rules.other.headingBeginRegex(x),M=this.rules.other.htmlBeginRegex(x);for(;t;){const O=t.split(`
|
|
29
|
+
`,1)[0];let D;if(g=O,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),D=g):D=g.replace(this.rules.other.tabCharGlobal," "),R.test(g)||_.test(g)||M.test(g)||C.test(g)||A.test(g))break;if(D.search(this.rules.other.nonSpaceChar)>=x||!g.trim())h+=`
|
|
30
|
+
`+D.slice(x);else{if(b||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(m)||_.test(m)||A.test(m))break;h+=`
|
|
31
|
+
`+g}!b&&!g.trim()&&(b=!0),f+=O+`
|
|
32
|
+
`,t=t.substring(O.length+1),m=D.slice(x)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(o=!0));let S=null,k;this.options.gfm&&(S=this.rules.other.listIsTask.exec(h),S&&(k=S[0]!=="[ ] ",h=h.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:f,task:!!S,checked:k,loose:!1,text:h,tokens:[]}),i.raw+=f}const l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let u=0;u<i.items.length;u++)if(this.lexer.state.top=!1,i.items[u].tokens=this.lexer.blockTokens(i.items[u].text,[]),!i.loose){const f=i.items[u].tokens.filter(m=>m.type==="space"),h=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));i.loose=h}if(i.loose)for(let u=0;u<i.items.length;u++)i.items[u].loose=!0;return i}}html(t){const e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){const e=this.rules.block.def.exec(t);if(e){const n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){const e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;const n=KT(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
33
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(const o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(const o of i)s.rows.push(KT(o,s.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[u]})));return s}}lheading(t){const e=this.rules.block.lheading.exec(t);if(e)return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:e[1],tokens:this.lexer.inline(e[1])}}paragraph(t){const e=this.rules.block.paragraph.exec(t);if(e){const n=e[1].charAt(e[1].length-1)===`
|
|
34
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){const e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){const e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){const e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){const e=this.rules.inline.link.exec(t);if(e){const n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;const s=Du(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{const s=hH(e[2],"()");if(s===-2)return;if(s>-1){const l=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){const s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),ZT(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){const r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){const s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return ZT(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(r[1]||r[2]||"")||!n||this.rules.inline.punctuation.exec(n)){const s=[...r[0]].length-1;let o,l,u=s,f=0;const h=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+s);(r=h.exec(e))!=null;){if(o=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!o)continue;if(l=[...o].length,r[3]||r[4]){u+=l;continue}else if((r[5]||r[6])&&s%3&&!((s+l)%3)){f+=l;continue}if(u-=l,u>0)continue;l=Math.min(l,l+u+f);const m=[...r[0]][0].length,g=t.slice(0,s+r.index+m+l);if(Math.min(s,l)%2){const x=g.slice(1,-1);return{type:"em",raw:g,text:x,tokens:this.lexer.inlineTokens(x)}}const b=g.slice(2,-2);return{type:"strong",raw:g,text:b,tokens:this.lexer.inlineTokens(b)}}}}codespan(t){const e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," ");const r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){const e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t){const e=this.rules.inline.del.exec(t);if(e)return{type:"del",raw:e[0],text:e[2],tokens:this.lexer.inlineTokens(e[2])}}autolink(t){const e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){const e=this.rules.inline.text.exec(t);if(e){const n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},xs=class T0{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||Ya,this.options.tokenizer=this.options.tokenizer||new Mp,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};const n={other:Jn,block:Sh.normal,inline:Ou.normal};this.options.pedantic?(n.block=Sh.pedantic,n.inline=Ou.pedantic):this.options.gfm&&(n.block=Sh.gfm,this.options.breaks?n.inline=Ou.breaks:n.inline=Ou.gfm),this.tokenizer.rules=n}static get rules(){return{block:Sh,inline:Ou}}static lex(e,n){return new T0(n).lex(e)}static lexInline(e,n){return new T0(n).inlineTokens(e)}lex(e){e=e.replace(Jn.carriageReturn,`
|
|
35
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){const r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.options.pedantic&&(e=e.replace(Jn.tabCharGlobal," ").replace(Jn.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);const o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
36
|
+
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);const o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
|
|
37
|
+
`+i.raw,o.text+=`
|
|
38
|
+
`+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);const o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=`
|
|
39
|
+
`+i.raw,o.text+=`
|
|
40
|
+
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title});continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let o=1/0;const l=e.slice(1);let u;this.options.extensions.startBlock.forEach(f=>{u=f.call({lexer:this},l),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(s=e.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){const o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=`
|
|
41
|
+
`+i.raw,o.text+=`
|
|
42
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),r=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);const o=n.at(-1);o?.type==="text"?(o.raw+=`
|
|
43
|
+
`+i.raw,o.text+=`
|
|
44
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(e){const o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){let r=e,i=null;if(this.tokens.links){const l=Object.keys(this.tokens.links);if(l.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!=null;)l.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!=null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!=null;)r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let s=!1,o="";for(;e;){s||(o=""),s=!1;let l;if(this.options.extensions?.inline?.some(f=>(l=f.call({lexer:this},e,n))?(e=e.substring(l.raw.length),n.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);const f=n.at(-1);l.type==="text"&&f?.type==="text"?(f.raw+=l.raw,f.text+=l.text):n.push(l);continue}if(l=this.tokenizer.emStrong(e,r,o)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.del(e)){e=e.substring(l.raw.length),n.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),n.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),n.push(l);continue}let u=e;if(this.options.extensions?.startInline){let f=1/0;const h=e.slice(1);let m;this.options.extensions.startInline.forEach(g=>{m=g.call({lexer:this},h),typeof m=="number"&&m>=0&&(f=Math.min(f,m))}),f<1/0&&f>=0&&(u=e.substring(0,f+1))}if(l=this.tokenizer.inlineText(u)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),s=!0;const f=n.at(-1);f?.type==="text"?(f.raw+=l.raw,f.text+=l.text):n.push(l);continue}if(e){const f="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(f);break}else throw new Error(f)}}return n}},Cd=class{options;parser;constructor(t){this.options=t||Ya}space(t){return""}code({text:t,lang:e,escaped:n}){const r=(e||"").match(Jn.notSpaceStart)?.[0],i=t.replace(Jn.endingNewline,"")+`
|
|
45
|
+
`;return r?'<pre><code class="language-'+Ti(r)+'">'+(n?i:Ti(i,!0))+`</code></pre>
|
|
46
|
+
`:"<pre><code>"+(n?i:Ti(i,!0))+`</code></pre>
|
|
47
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
48
|
+
${this.parser.parse(t)}</blockquote>
|
|
49
|
+
`}html({text:t}){return t}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
50
|
+
`}hr(t){return`<hr>
|
|
51
|
+
`}list(t){const e=t.ordered,n=t.start;let r="";for(let o=0;o<t.items.length;o++){const l=t.items[o];r+=this.listitem(l)}const i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
52
|
+
`+r+"</"+i+`>
|
|
53
|
+
`}listitem(t){let e="";if(t.task){const n=this.checkbox({checked:!!t.checked});t.loose?t.tokens[0]?.type==="paragraph"?(t.tokens[0].text=n+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&t.tokens[0].tokens[0].type==="text"&&(t.tokens[0].tokens[0].text=n+" "+Ti(t.tokens[0].tokens[0].text),t.tokens[0].tokens[0].escaped=!0)):t.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):e+=n+" "}return e+=this.parser.parse(t.tokens,!!t.loose),`<li>${e}</li>
|
|
54
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox">'}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
55
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){const s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
56
|
+
<thead>
|
|
57
|
+
`+e+`</thead>
|
|
58
|
+
`+r+`</table>
|
|
59
|
+
`}tablerow({text:t}){return`<tr>
|
|
60
|
+
${t}</tr>
|
|
61
|
+
`}tablecell(t){const e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
62
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ti(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){const r=this.parser.parseInline(n),i=WT(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+Ti(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));const i=WT(t);if(i===null)return Ti(n);t=i;let s=`<img src="${t}" alt="${n}"`;return e&&(s+=` title="${Ti(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ti(t.text)}},xw=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}},ws=class _0{options;renderer;textRenderer;constructor(e){this.options=e||Ya,this.options.renderer=this.options.renderer||new Cd,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new xw}static parse(e,n){return new _0(n).parse(e)}static parseInline(e,n){return new _0(n).parseInline(e)}parse(e,n=!0){let r="";for(let i=0;i<e.length;i++){const s=e[i];if(this.options.extensions?.renderers?.[s.type]){const l=s,u=this.options.extensions.renderers[l.type].call({parser:this},l);if(u!==!1||!["space","hr","heading","code","table","blockquote","list","html","paragraph","text"].includes(l.type)){r+=u||"";continue}}const o=s;switch(o.type){case"space":{r+=this.renderer.space(o);continue}case"hr":{r+=this.renderer.hr(o);continue}case"heading":{r+=this.renderer.heading(o);continue}case"code":{r+=this.renderer.code(o);continue}case"table":{r+=this.renderer.table(o);continue}case"blockquote":{r+=this.renderer.blockquote(o);continue}case"list":{r+=this.renderer.list(o);continue}case"html":{r+=this.renderer.html(o);continue}case"paragraph":{r+=this.renderer.paragraph(o);continue}case"text":{let l=o,u=this.renderer.text(l);for(;i+1<e.length&&e[i+1].type==="text";)l=e[++i],u+=`
|
|
63
|
+
`+this.renderer.text(l);n?r+=this.renderer.paragraph({type:"paragraph",raw:u,text:u,tokens:[{type:"text",raw:u,text:u,escaped:!0}]}):r+=u;continue}default:{const l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}parseInline(e,n=this.renderer){let r="";for(let i=0;i<e.length;i++){const s=e[i];if(this.options.extensions?.renderers?.[s.type]){const l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=l||"";continue}}const o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{const l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},lp=class{options;block;constructor(t){this.options=t||Ya}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}provideLexer(){return this.block?xs.lex:xs.lexInline}provideParser(){return this.block?ws.parse:ws.parseInline}},IN=class{defaults=fw();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ws;Renderer=Cd;TextRenderer=xw;Lexer=xs;Tokenizer=Mp;Hooks=lp;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(const r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{const i=r;for(const s of i.header)n=n.concat(this.walkTokens(s.tokens,e));for(const s of i.rows)for(const o of s)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{const i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{const i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{const o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){const e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{const r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){const s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");const s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){const i=this.defaults.renderer||new Cd(this.defaults);for(const s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;const o=s,l=n.renderer[o],u=i[o];i[o]=(...f)=>{let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h||""}}r.renderer=i}if(n.tokenizer){const i=this.defaults.tokenizer||new Mp(this.defaults);for(const s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;const o=s,l=n.tokenizer[o],u=i[o];i[o]=(...f)=>{let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h}}r.tokenizer=i}if(n.hooks){const i=this.defaults.hooks||new lp;for(const s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;const o=s,l=n.hooks[o],u=i[o];lp.passThroughHooks.has(s)?i[o]=f=>{if(this.defaults.async)return Promise.resolve(l.call(i,f)).then(m=>u.call(i,m));const h=l.call(i,f);return u.call(i,h)}:i[o]=(...f)=>{let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h}}r.hooks=i}if(n.walkTokens){const i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(s.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return xs.lex(t,e??this.defaults)}parser(t,e){return ws.parse(t,e??this.defaults)}parseMarkdown(t){return(n,r)=>{const i={...r},s={...this.defaults,...i},o=this.onError(!!s.silent,!!s.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));s.hooks&&(s.hooks.options=s,s.hooks.block=t);const l=s.hooks?s.hooks.provideLexer():t?xs.lex:xs.lexInline,u=s.hooks?s.hooks.provideParser():t?ws.parse:ws.parseInline;if(s.async)return Promise.resolve(s.hooks?s.hooks.preprocess(n):n).then(f=>l(f,s)).then(f=>s.hooks?s.hooks.processAllTokens(f):f).then(f=>s.walkTokens?Promise.all(this.walkTokens(f,s.walkTokens)).then(()=>f):f).then(f=>u(f,s)).then(f=>s.hooks?s.hooks.postprocess(f):f).catch(o);try{s.hooks&&(n=s.hooks.preprocess(n));let f=l(n,s);s.hooks&&(f=s.hooks.processAllTokens(f)),s.walkTokens&&this.walkTokens(f,s.walkTokens);let h=u(f,s);return s.hooks&&(h=s.hooks.postprocess(h)),h}catch(f){return o(f)}}}onError(t,e){return n=>{if(n.message+=`
|
|
64
|
+
Please report this to https://github.com/markedjs/marked.`,t){const r="<p>An error occurred:</p><pre>"+Ti(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ia=new IN;function At(t,e){return Ia.parse(t,e)}At.options=At.setOptions=function(t){return Ia.setOptions(t),At.defaults=Ia.defaults,kN(At.defaults),At};At.getDefaults=fw;At.defaults=Ya;At.use=function(...t){return Ia.use(...t),At.defaults=Ia.defaults,kN(At.defaults),At};At.walkTokens=function(t,e){return Ia.walkTokens(t,e)};At.parseInline=Ia.parseInline;At.Parser=ws;At.parser=ws.parse;At.Renderer=Cd;At.TextRenderer=xw;At.Lexer=xs;At.lexer=xs.lex;At.Tokenizer=Mp;At.Hooks=lp;At.parse=At;At.options;At.setOptions;At.use;At.walkTokens;At.parseInline;ws.parse;xs.lex;function Iu(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function YT(t){const e=t.trim();return e?e.startsWith("//")?`https:${e}`:/^(https?:|mailto:|\/|#)/i.test(e)?e:null:null}class mH extends Cd{html(){return""}link({href:e,title:n,tokens:r}){const i=this.parser.parseInline(r),s=YT(e);if(!s)return i;const o=n?` title="${Iu(n)}"`:"";return`<a href="${Iu(s)}"${o} rel="noopener noreferrer">${i}</a>`}image({href:e,title:n,text:r}){const i=YT(e);if(!i)return"";const s=n?` title="${Iu(n)}"`:"";return`<img src="${Iu(i)}" alt="${Iu(r)}"${s} loading="lazy" />`}}new IN({gfm:!0,breaks:!1,renderer:new mH});const gH="vertebrPreview",yH="vertebrControl",jN="vertebr",bH="vertebr:preview-draft",vH="vertebr:preview-ready";function xH(t,e={}){const n=e.origin??(typeof window<"u"?window.location.origin:""),r=t.trim()||"/",i=new URL((r.startsWith("http"),r),n||"http://localhost");return i.searchParams.set(gH,"1"),e.controlId?.trim()&&i.searchParams.set(yH,e.controlId.trim()),n?i.toString():`${i.pathname}${i.search}${i.hash}`}function wH(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function SH(t){return wH(t)?t.source===jN&&t.type===vH:!1}function kH(t,e,n,r="*"){if(!t||!e)return;const i={source:jN,type:bH,controlId:e,value:n};t.postMessage(i,r)}function CH(t,e={}){if(typeof window>"u")return()=>{};const n=e.allowedOrigins?.filter(Boolean)??[],r=i=>{n.length>0&&!n.includes(i.origin)||SH(i.data)&&t(i.source)};return window.addEventListener("message",r),()=>window.removeEventListener("message",r)}const XT=[{family:"Manrope",category:"sans-serif",weights:[400,500,600,700]},{family:"Syne",category:"display",weights:[600,700,800]},{family:"Inter",category:"sans-serif",weights:[400,500,600,700]},{family:"Roboto",category:"sans-serif",weights:[400,500,700]},{family:"Open Sans",category:"sans-serif",weights:[400,600,700]},{family:"Lato",category:"sans-serif",weights:[400,700]},{family:"Montserrat",category:"sans-serif",weights:[400,600,700]},{family:"Poppins",category:"sans-serif",weights:[400,600,700]},{family:"Nunito",category:"sans-serif",weights:[400,600,700]},{family:"Work Sans",category:"sans-serif",weights:[400,600,700]},{family:"DM Sans",category:"sans-serif",weights:[400,500,700]},{family:"Plus Jakarta Sans",category:"sans-serif",weights:[400,600,700]},{family:"Outfit",category:"sans-serif",weights:[400,600,700]},{family:"Space Grotesk",category:"sans-serif",weights:[400,600,700]},{family:"Playfair Display",category:"serif",weights:[400,600,700]},{family:"Merriweather",category:"serif",weights:[400,700]},{family:"Libre Baskerville",category:"serif",weights:[400,700]},{family:"Cormorant Garamond",category:"serif",weights:[400,600,700]},{family:"Fraunces",category:"serif",weights:[400,600,700]},{family:"Bebas Neue",category:"display",weights:[400]},{family:"Oswald",category:"display",weights:[400,600,700]},{family:"Archivo Black",category:"display",weights:[400]},{family:"Anton",category:"display",weights:[400]},{family:"Barlow Condensed",category:"sans-serif",weights:[400,600,700]},{family:"JetBrains Mono",category:"monospace",weights:[400,600,700]},{family:"IBM Plex Mono",category:"monospace",weights:[400,600,700]},{family:"Source Serif 4",category:"serif",weights:[400,600,700]},{family:"Instrument Serif",category:"serif",weights:[400,600]},{family:"Sora",category:"sans-serif",weights:[400,600,700]},{family:"Rubik",category:"sans-serif",weights:[400,600,700]}];function EH(t){switch(t){case"woff2":return"woff2";case"woff":return"woff";default:return"truetype"}}function LN(t){return(t.files??[]).map(e=>`@font-face{font-family:"${t.family.replace(/"/g,'\\"')}";src:url("${e.url}") format("${EH(e.format)}");font-weight:${e.weight};font-style:${e.style};font-display:swap;}`).join("")}function TH(t){switch(t){case"woff2":return"woff2";case"woff":return"woff";default:return"ttf"}}function _H(t,e,n){const r=t.replace(/\/$/,""),i=n.style==="italic"?"-italic":"",s=TH(n.format);return`${r}/public/fonts/${encodeURIComponent(e)}/${n.weight}${i}.${s}`}function AH(t,e){return t.map(n=>({...n,files:(n.files??[]).map(r=>({...r,url:_H(e,n.id,r)}))}))}const RH="vertebr:theme";function MH(t){try{const e=localStorage.getItem(t);if(e==="light"||e==="dark")return e}catch{}return null}function NH(t,e){try{localStorage.setItem(t,e)}catch{}}function OH(t){document.documentElement.setAttribute("data-vb-theme",t)}function DH(t=RH){const[e,n]=E.useState(()=>MH(t)??"dark");E.useEffect(()=>{OH(e),NH(t,e)},[e,t]);const r=E.useCallback(s=>{n(s)},[]),i=E.useCallback(()=>{n(s=>s==="dark"?"light":"dark")},[]);return{theme:e,setTheme:r,toggleTheme:i}}const PN=[{id:"7d",label:"Last 7 days"},{id:"14d",label:"Last 14 days"},{id:"30d",label:"Last 30 days"},{id:"this_month",label:"This month"},{id:"last_month",label:"Last month"}],IH="14d",jH=new Set(PN.map(t=>t.id));function LH(t){return t&&jH.has(t)?t:IH}var Yd=t=>t.type==="checkbox",Gm=t=>t.type==="file",ko=t=>t instanceof Date,In=t=>t==null;const ww=t=>typeof t=="object";var Gt=t=>!In(t)&&!Array.isArray(t)&&ww(t)&&!ko(t),A0=t=>Gt(t)&&t.target?Yd(t.target)?t.target.checked:Gm(t.target)?t.target.files:t.target.value:t,zN=(t,e)=>e.split(".").some((n,r,i)=>!isNaN(Number(n))&&t.has(i.slice(0,r).join("."))),$N=t=>{const e=t.constructor&&t.constructor.prototype;return Gt(e)&&e.hasOwnProperty("isPrototypeOf")},Wm=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function qt(t){if(t instanceof Date)return new Date(t);const e=typeof FileList<"u"&&t instanceof FileList;if(Wm&&(t instanceof Blob||e))return t;const n=Array.isArray(t);if(!n&&!(Gt(t)&&$N(t)))return t;const r=n?[]:Object.create(Object.getPrototypeOf(t));for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&(r[i]=qt(t[i]));return r}const fo={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},di={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},si={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},BN="root",Sw=["__proto__","constructor","prototype"],PH=/^\w*$/;var Xd=t=>PH.test(t),Vt=t=>t===void 0;const zH=/[.[\]'"]/;var Km=t=>t.split(zH).filter(Boolean),Se=(t,e,n)=>{if(!e||!Gt(t))return n;const r=Xd(e)?[e]:Km(e);if(r.some(s=>Sw.includes(s)))return n;const i=r.reduce((s,o)=>In(s)?void 0:s[o],t);return Vt(i)||i===t?Vt(t[e])?n:t[e]:i},Tr=t=>typeof t=="boolean",qn=t=>typeof t=="function",vt=(t,e,n)=>{let r=-1;const i=Xd(e)?[e]:Km(e),s=i.length,o=s-1;for(;++r<s;){const l=i[r];let u=n;if(r!==o){const f=t[l];u=Gt(f)||Array.isArray(f)?f:isNaN(+i[r+1])?{}:[]}if(Sw.includes(l))return;t[l]=u,t=t[l]}};const VN=qe.createContext(null);VN.displayName="HookFormControlContext";const kw=()=>qe.useContext(VN);var HN=(t,e,n,r=!0)=>{const i={};for(const s in t)Object.defineProperty(i,s,{get:()=>{const o=s;return e._proxyFormState[o]!==di.all&&(e._proxyFormState[o]=!r||di.all),n&&(n[o]=!0),t[o]}});return i};const Cw=Wm?qe.useLayoutEffect:qe.useEffect;function $H(t){const e=kw(),{control:n=e,disabled:r,name:i,exact:s}=t||{},[o,l]=qe.useState(()=>({...n._formState,defaultValues:n._defaultValues})),u=qe.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Cw(()=>n._subscribe({name:i,formState:u.current,exact:s,callback:f=>{!r&&l({...n._formState,...f,defaultValues:n._defaultValues})}}),[i,r,s]),qe.useEffect(()=>{u.current.isValid&&n._setValid(!0)},[n]),qe.useMemo(()=>HN(o,n,u.current,!1),[o,n])}var jn=t=>typeof t=="string",R0=(t,e,n,r,i)=>jn(t)?(r&&e.watch.add(t),Se(n,t,i)):Array.isArray(t)?t.map(s=>(r&&e.watch.add(s),Se(n,s))):(r&&(e.watchAll=!0),n),M0=t=>In(t)||!ww(t);const JT=(t,e)=>e.length===0&&!Array.isArray(t)&&!$N(t);function _r(t,e,n=new WeakMap){if(t===e)return!0;if(M0(t)||M0(e))return Object.is(t,e);if(ko(t)&&ko(e))return Object.is(t.getTime(),e.getTime());const r=Object.keys(t),i=Object.keys(e);if(r.length!==i.length)return!1;if(JT(t,r)||JT(e,i))return Object.is(t,e);if(!r.length&&Array.isArray(t)!==Array.isArray(e))return!1;const s=n.get(t);if(s&&s.has(e))return!0;if(s)s.add(e);else{const o=new WeakSet;o.add(e),n.set(t,o)}for(const o of r){const l=t[o];if(!(o in e))return!1;if(o!=="ref"){const u=e[o];if(ko(l)&&ko(u)||(Gt(l)||Array.isArray(l))&&(Gt(u)||Array.isArray(u))?!_r(l,u,n):!Object.is(l,u))return!1}}return!0}function UN(t){const e=kw(),{control:n=e,name:r,defaultValue:i,disabled:s,exact:o,compute:l}=t||{},u=qe.useRef(i),f=qe.useRef(l),h=qe.useRef(void 0),m=qe.useRef(n),g=qe.useRef(r);f.current=l;const[b,x]=qe.useState(()=>{const _=n._getWatch(r,u.current);return f.current?f.current(_):_}),S=qe.useCallback(_=>{const M=R0(r,n._names,_||n._formValues,!1,u.current);return f.current?f.current(M):M},[n._formValues,n._names,r]),k=qe.useCallback(_=>{if(!s){const M=R0(r,n._names,_||n._formValues,!1,u.current);if(f.current){const O=f.current(M);_r(O,h.current)||(x(O),h.current=O)}else x(M)}},[n._formValues,n._names,s,r]);Cw(()=>((m.current!==n||!_r(g.current,r))&&(m.current=n,g.current=r,k()),n._subscribe({name:r,formState:{values:!0},exact:o,callback:_=>{k(_.values)}})),[n,o,r,k]),qe.useEffect(()=>n._removeUnmounted());const C=m.current!==n,A=g.current,R=qe.useMemo(()=>{if(s)return null;const _=!C&&!_r(A,r);return C||_?S():null},[s,C,r,A,S]);return R!==null?R:b}function BH(t){const e=kw(),{name:n,disabled:r,control:i=e,shouldUnregister:s,defaultValue:o,exact:l=!0}=t,u=zN(i._names.array,n),f=qe.useMemo(()=>Se(i._formValues,n,Se(i._defaultValues,n,o)),[i,n,o]),h=UN({control:i,name:n,defaultValue:f,exact:l}),m=$H({control:i,name:n,exact:l}),g=qe.useRef(t),b=qe.useRef(null),x=qe.useRef(i.register(n,{...t.rules,value:h,...Tr(t.disabled)?{disabled:t.disabled}:{}}));g.current=t;const S=qe.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!Se(m.errors,n)},isDirty:{enumerable:!0,get:()=>!!Se(m.dirtyFields,n)},isTouched:{enumerable:!0,get:()=>!!Se(m.touchedFields,n)},isValidating:{enumerable:!0,get:()=>!!Se(m.validatingFields,n)},error:{enumerable:!0,get:()=>Se(m.errors,n)}}),[m,n]),k=qe.useCallback(_=>{const M=A0(_);return Se(i._fields,n)||(x.current=i.register(n,{...g.current.rules,value:M})),x.current.onChange({target:{value:A0(_),name:n},type:fo.CHANGE})},[n,i]),C=qe.useCallback(()=>x.current.onBlur({target:{value:Se(i._formValues,n),name:n},type:fo.BLUR}),[n,i._formValues]),A=qe.useCallback(_=>{_&&(b.current={focus:()=>qn(_.focus)&&_.focus(),select:()=>qn(_.select)&&_.select(),setCustomValidity:O=>qn(_.setCustomValidity)&&_.setCustomValidity(O),reportValidity:()=>qn(_.reportValidity)&&_.reportValidity()});const M=Se(i._fields,n);M&&M._f&&_&&(M._f.ref=b.current)},[i._fields,n]),R=qe.useMemo(()=>({name:n,value:h,...Tr(r)||m.disabled?{disabled:m.disabled||r}:{},onChange:k,onBlur:C,ref:A}),[n,r,m.disabled,k,C,A,h]);return qe.useEffect(()=>{const _=i._options.shouldUnregister||s;x.current=i.register(n,{...g.current.rules,...Tr(g.current.disabled)?{disabled:g.current.disabled}:{}});const M=(O,D)=>{const I=Se(i._fields,O);I&&I._f&&(I._f.mount=D)};if(M(n,!0),_){const O=qt(Se(s?i._defaultValues:i._options.values||i._defaultValues,n,Se(i._options.defaultValues,n,g.current.defaultValue)));vt(i._defaultValues,n,O),Vt(Se(i._formValues,n))&&vt(i._formValues,n,O)}if(!u&&i.register(n),b.current){const O=Se(i._fields,n);O&&O._f&&(O._f.ref=b.current)}return()=>{(u?_&&!i._state.action:_)?i.unregister(n):M(n,!1)}},[n,i,u,s]),qe.useEffect(()=>{i._setDisabledField({disabled:r,name:n})},[r,n,i]),qe.useMemo(()=>({field:R,formState:m,fieldState:S}),[R,m,S])}const ss=t=>t.render(BH(t));var kh=t=>({isOnSubmit:!t||t===di.onSubmit,isOnBlur:t===di.onBlur,isOnChange:t===di.onChange,isOnAll:t===di.all,isOnTouch:t===di.onTouched}),lv=(t,e,n)=>{if(n)return!1;if(e.watchAll||e.watch.has(t))return!0;for(const r of e.watch)if(t.startsWith(r)&&t.charAt(r.length)===".")return!0;return!1};const rd=(t,e,n,r)=>{for(const i of n||Object.keys(t)){if(i==="_f")continue;const s=n?Se(t,i):t[i];if(s){const{_f:o}=s;if(o){if(o.refs&&o.refs[0]&&e(o.refs[0],i)&&!r)return!0;if(o.ref&&e(o.ref,o.name)&&!r)return!0;if(rd(s,e))break}else if((Gt(s)||Array.isArray(s))&&rd(s,e))break}}};var QT=(t,e,n)=>{const r=Se(t,n),i=Array.isArray(r)?r:[];return vt(i,BN,e[n]),vt(t,n,i),t},On=t=>Gt(t)&&!Object.keys(t).length,Np=t=>{if(!Wm)return!1;const e=t?t.ownerDocument:0;return t instanceof(e&&e.defaultView?e.defaultView.HTMLElement:HTMLElement)},Ew=t=>t.type==="radio",Op=t=>t instanceof RegExp,Tw=(t,e,n,r,i)=>e?{...n[t],types:{...n[t]&&n[t].types?n[t].types:{},[r]:i||!0}}:{};const e_={value:!1,isValid:!1},t_={value:!0,isValid:!0};var FN=t=>{if(Array.isArray(t)){if(t.length>1){const e=t.filter(n=>n&&n.checked&&!n.disabled).map(n=>n.value);return{value:e,isValid:!!e.length}}return t[0].checked&&!t[0].disabled?t[0].attributes&&!Vt(t[0].attributes.value)?Vt(t[0].value)||t[0].value===""?t_:{value:t[0].value,isValid:!0}:t_:e_}return e_};const n_={isValid:!1,value:null};var qN=t=>Array.isArray(t)?t.reduce((e,n)=>n&&n.checked&&!n.disabled?{isValid:!0,value:n.value}:e,n_):n_;function r_(t,e,n="validate"){if(jn(t)||Array.isArray(t)&&t.every(jn)||Tr(t)&&!t)return{type:n,message:jn(t)?t:"",ref:e}}var Bl=t=>Gt(t)&&!Op(t)?t:{value:t,message:""},i_=async(t,e,n,r,i,s)=>{const{ref:o,refs:l,required:u,maxLength:f,minLength:h,min:m,max:g,pattern:b,validate:x,name:S,valueAsNumber:k,mount:C}=t._f,A=Se(n,S);if(!C||e.has(S))return{};const R=l?l[0]:o,_=K=>{if(i&&R.reportValidity){const ee=Tr(K)?"":K||"";l?l.forEach(Q=>Q.setCustomValidity(ee)):R.setCustomValidity(ee),R.reportValidity()}},M={},O=Ew(o),D=Yd(o),I=O||D,P=(k||Gm(o))&&Vt(o.value)&&Vt(A)||Np(o)&&o.value===""||A===""||Array.isArray(A)&&!A.length,B=Tw.bind(null,S,r,M),re=(K,ee,Q,fe=si.maxLength,z=si.minLength)=>{const L=K?ee:Q;M[S]={type:K?fe:z,message:L,ref:o,...B(K?fe:z,L)}};if(s?!Array.isArray(A)||!A.length:u&&(!I&&(P||In(A))||Tr(A)&&!A||D&&!FN(l).isValid||O&&!qN(l).isValid)){const{value:K,message:ee}=jn(u)?{value:!!u,message:u}:Bl(u);if(K&&(M[S]={type:si.required,message:ee,ref:R,...B(si.required,ee)},!r))return _(ee),M}if(!P&&(!In(m)||!In(g))){let K,ee;const Q=Bl(g),fe=Bl(m);if(!In(A)&&!isNaN(A)){const z=o.valueAsNumber||A&&+A;In(Q.value)||(K=z>Q.value),In(fe.value)||(ee=z<fe.value)}else{const z=o.valueAsDate||new Date(A),L=ke=>new Date(new Date().toDateString()+" "+ke),G=o.type=="time",he=o.type=="week";jn(Q.value)&&A&&(K=G?L(A)>L(Q.value):he?A>Q.value:z>new Date(Q.value)),jn(fe.value)&&A&&(ee=G?L(A)<L(fe.value):he?A<fe.value:z<new Date(fe.value))}if((K||ee)&&(re(!!K,Q.message,fe.message,si.max,si.min),!r))return _(M[S].message),M}if((f||h)&&!P&&(jn(A)||s&&Array.isArray(A))){const K=Bl(f),ee=Bl(h),Q=!In(K.value)&&A.length>+K.value,fe=!In(ee.value)&&A.length<+ee.value;if((Q||fe)&&(re(Q,K.message,ee.message),!r))return _(M[S].message),M}if(b&&!P&&jn(A)){const{value:K,message:ee}=Bl(b);if(Op(K)&&!A.match(K)&&(M[S]={type:si.pattern,message:ee,ref:o,...B(si.pattern,ee)},!r))return _(ee),M}if(x){if(qn(x)){const K=await x(A,n),ee=r_(K,R);if(ee&&(M[S]={...ee,...B(si.validate,ee.message)},!r))return _(ee.message),M}else if(Gt(x)){let K={};for(const ee in x){if(!On(K)&&!r)break;const Q=r_(await x[ee](A,n),R,ee);Q&&(K={...Q,...B(ee,Q.message)},_(Q.message),r&&(M[S]=K))}if(!On(K)&&(M[S]={ref:R,...K},!r))return M}}return _(!0),M},cp=t=>Array.isArray(t)?t:[t],GN=t=>Array.isArray(t)?t.filter(Boolean):[];function VH(t,e){const n=e.length-1;let r=0;for(;r<n;){if(In(t)){t=void 0;break}t=t[e[r]],r++}return t}function HH(t){for(const e in t)if(t.hasOwnProperty(e)&&!Vt(t[e]))return!1;return!0}function nn(t,e){if(jn(e)&&Object.prototype.hasOwnProperty.call(t,e))return delete t[e],t;const n=Array.isArray(e)?e:Xd(e)?[e]:Km(e);if(n.some(o=>Sw.includes(String(o))))return t;const r=n.length===1?t:VH(t,n),i=n.length-1,s=n[i];return r&&delete r[s],i!==0&&(Gt(r)&&On(r)||Array.isArray(r)&&HH(r))&&nn(t,n.slice(0,-1)),t}const WN=t=>{const e={};for(const n of Object.keys(t))if(ww(t[n])&&t[n]!==null&&!ko(t[n])){const r=WN(t[n]);for(const i of Object.keys(r))e[`${n}.${i}`]=r[i]}else e[n]=t[n];return e},UH=qe.createContext(null);UH.displayName="HookFormContext";var s_=()=>{let t=[];return{get observers(){return t},next:i=>{for(const s of t)s.next&&s.next(i)},subscribe:i=>(t.push(i),{unsubscribe:()=>{t=t.filter(s=>s!==i)}}),unsubscribe:()=>{t=[]}}};function KN(t,e){const n={};for(const r in t)if(t.hasOwnProperty(r)){const i=t[r],s=e[r];if(i&&Gt(i)&&s){const o=KN(i,s);Gt(o)&&(n[r]=o)}else t[r]&&(n[r]=s)}return n}var ZN=t=>t.type==="select-multiple",FH=t=>Ew(t)||Yd(t),cv=t=>Np(t)&&t.isConnected;function o_(t){return Array.isArray(t)||Gt(t)}function YN(t,e,n="",r=[]){for(const i in t){const s=n?`${n}.${i}`:i,o=t[i];o_(o)&&o_(Se(e,s))?YN(o,e,s,r):r.push(s)}return r}var qH=t=>{for(const e in t)if(qn(t[e]))return!0;return!1};function XN(t){return Array.isArray(t)||Gt(t)&&!qH(t)}function JN(t){return!!(t&&"_f"in t)}function QN(t){return Array.isArray(t)?!t.some(e=>!Vt(e)):!Object.keys(t).length}function N0(t,e){Array.isArray(t)?t[e]=void 0:delete t[e]}function O0(t,e={},n){for(const r in t){const i=t[r],s=n&&n[r];XN(i)&&(!Array.isArray(i)||!JN(s))?(e[r]=Array.isArray(i)?[]:{},O0(i,e[r],s),QN(e[r])&&N0(e,r)):Vt(i)||(e[r]=!0)}return e}function ba(t,e,n,r){n||(n=O0(e,{},r));for(const i in t){const s=t[i],o=r&&r[i];XN(s)&&(!Array.isArray(s)||!JN(o))?(Vt(e)||M0(n[i])?n[i]=O0(s,Array.isArray(s)?[]:{},o):ba(s,In(e)?{}:e[i],n[i],o),QN(n[i])&&N0(n,i)):_r(s,e[i])?N0(n,i):n[i]=!0}return n}var eO=(t,{valueAsNumber:e,valueAsDate:n,setValueAs:r})=>Vt(t)?t:e?t===""?NaN:t&&+t:n&&jn(t)?new Date(t):r?r(t):t;function a_(t){const e=t.ref;return Gm(e)?e.files:Ew(e)?qN(t.refs).value:ZN(e)?[...e.selectedOptions].map(({value:n})=>n):Yd(e)?FN(t.refs).value:eO(e.value,t)}var GH=(t,e,n,r)=>{const i={};for(const s of t){const o=Se(e,s);o&&vt(i,s,o._f)}return{criteriaMode:n,names:[...t],fields:i,shouldUseNativeValidation:r}},ju=t=>Vt(t)?t:Op(t)?t.source:Gt(t)?Op(t.value)?t.value.source:t.value:t;const l_="AsyncFunction";var WH=t=>{if(!t||!t.validate)return!1;if(qn(t.validate))return t.validate.constructor.name===l_;if(Gt(t.validate)){for(const e in t.validate)if(t.validate[e].constructor.name===l_)return!0}return!1},KH=t=>t.mount&&(t.required||t.min||t.max||t.maxLength||t.minLength||t.pattern||t.validate);function c_(t,e,n){const r=Se(t,n);if(r||Xd(n))return{error:r,name:n};const i=n.split(".");for(;i.length;){const s=i.join("."),o=Se(e,s),l=Se(t,s);if(o&&!Array.isArray(o)&&n!==s)return{name:n};if(l&&l.type)return{name:s,error:l};if(l&&l.root&&l.root.type)return{name:`${s}.root`,error:l.root};i.pop()}return{name:n}}var ZH=(t,e,n,r)=>{n(t);const i=Object.keys(t).filter(s=>s!=="name");return!i.length||r&&i.length>=Object.keys(e).length||i.find(s=>e[s]===(!r||di.all))},YH=(t,e,n)=>!t||!e||t===e||cp(t).some(r=>r&&(n?r===e||r.startsWith(e+"."):r.startsWith(e)||e.startsWith(r))),XH=(t,e,n,r,i)=>i.isOnAll?!1:!n&&i.isOnTouch?!(e||t):(n?r.isOnBlur:i.isOnBlur)?!t:(n?r.isOnChange:i.isOnChange)?t:!0,JH=(t,e)=>!GN(Se(t,e)).length&&nn(t,e);const QH={mode:di.onSubmit,reValidateMode:di.onChange,shouldFocusError:!0},uv="form",eU=(t,e)=>{for(const n in t)n in e||delete t[n];Object.assign(t,e)},tO={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function tU(t={}){let e={...QH,...t},n={...qt(tO),isLoading:qn(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1},r={},i=Gt(e.defaultValues)||Gt(e.values)?qt(e.defaultValues||e.values)||{}:{},s=e.shouldUnregister?{}:qt(i),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},l={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set};const u={},f={};let h=0,m=kh(e.mode),g=kh(e.reValidateMode);const b={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},x={...b};let S={...x};const k={array:s_(),state:s_()};let C=0;const A=e.criteriaMode===di.all,R=(j,$)=>U=>{clearTimeout(f[j]),f[j]=setTimeout($,U)},_=async j=>{if(!o.keepIsValid&&!e.disabled&&(x.isValid||S.isValid||j)){const $=++C;let U;e.resolver?(U=On((await Q()).errors),$===C&&M()):U=await L({fields:r,onlyCheckValid:!0,eventType:fo.VALID}),$===C&&U!==n.isValid&&k.state.next({isValid:U})}},M=(j,$)=>{!e.disabled&&(x.isValidating||x.validatingFields||S.isValidating||S.validatingFields)&&((j||Array.from(l.mount)).forEach(U=>{U&&($?vt(n.validatingFields,U,$):nn(n.validatingFields,U))}),k.state.next({validatingFields:n.validatingFields,isValidating:!On(n.validatingFields)}))},O=()=>{n.dirtyFields=ba(i,s,void 0,r)},D=(j,$=[],U,ie,le=!0,be=!0)=>{if(ie&&U&&!e.disabled){if(o.action=!0,be&&Array.isArray(Se(r,j))){const we=U(Se(r,j),ie.argA,ie.argB);le&&vt(r,j,we)}if(be&&Array.isArray(Se(n.errors,j))){const we=U(Se(n.errors,j),ie.argA,ie.argB);le&&vt(n.errors,j,we),JH(n.errors,j)}if((x.touchedFields||S.touchedFields)&&be&&Array.isArray(Se(n.touchedFields,j))){const we=U(Se(n.touchedFields,j),ie.argA,ie.argB);le&&vt(n.touchedFields,j,we)}(x.dirtyFields||S.dirtyFields)&&O(),k.state.next({name:j,isDirty:he(j,$),dirtyFields:n.dirtyFields,errors:n.errors,isValid:n.isValid})}else vt(s,j,$)},I=(j,$)=>{vt(n.errors,j,$),n.errors={...n.errors},k.state.next({errors:n.errors})},P=j=>{n.errors=j,k.state.next({errors:n.errors,isValid:!1})},B=j=>{const $=Xd(j)?[j]:Km(j);let U=s,ie=i;for(let le=0;le<$.length-1;le++){const be=$[le];if(U=In(U)?U:U[be],ie=In(ie)?ie:ie[be],U===null&&ie!==null)return!0}return!1},re=(j,$,U,ie)=>{const le=Se(r,j);if(le){if(B(j))return;const be=Vt(Se(s,j)),we=Se(s,j,Vt(U)?Se(i,j):U);Vt(we)||ie&&ie.defaultChecked||$?vt(s,j,$?we:a_(le._f)):Z(j,we),o.mount&&!o.action&&(_(),be&&n.isDirty&&(x.isDirty||S.isDirty)&&(he()||(n.isDirty=!1,k.state.next({...n}))),t.shouldUnregister&&be&&!Vt(Se(s,j))&&lv(j,l)&&(o.watch=!0))}},K=(j,$,U,ie,le)=>{let be=!1,we=!1;const Te={name:j};if(!e.disabled||ie===!0){if(!U||ie){const Be=_r(Se(i,j),$);(x.isDirty||S.isDirty)&&(we=n.isDirty,n.isDirty=Te.isDirty=!Be||he(),be=we!==Te.isDirty),we=!!Se(n.dirtyFields,j),Be!==n.isDirty?eU(n.dirtyFields,ba(i,s,void 0,r)):Be?nn(n.dirtyFields,j):vt(n.dirtyFields,j,!0),Te.dirtyFields=n.dirtyFields,be=be||(x.dirtyFields||S.dirtyFields)&&we!==!Be}if(U){const Be=Se(n.touchedFields,j);Be||(vt(n.touchedFields,j,U),Te.touchedFields=n.touchedFields,be=be||(x.touchedFields||S.touchedFields)&&Be!==U)}be&&le&&k.state.next(Te)}return be?Te:{}},ee=(j,$,U,ie)=>{const le=Se(n.errors,j),be=(x.isValid||S.isValid)&&Tr($)&&n.isValid!==$;if(e.delayError&&U?(u[j]=R(j,()=>I(j,U)),u[j](e.delayError)):(clearTimeout(f[j]),delete u[j],U?vt(n.errors,j,U):nn(n.errors,j),n.errors={...n.errors}),(U?!_r(le,U):le)||!On(ie)||be){const we={...ie,...be&&Tr($)?{isValid:$}:{},errors:n.errors,name:j};n={...n,...we},k.state.next(we)}},Q=async j=>(M(j,!0),await e.resolver(s,e.context,GH(j||l.mount,r,e.criteriaMode,e.shouldUseNativeValidation))),fe=async j=>{const{errors:$}=await Q(j);if(M(j),j){for(const U of j){const ie=Se($,U);ie?l.array.has(U)&&Gt(ie)&&!Object.keys(ie).some(le=>!Number.isNaN(Number(le)))?QT(n.errors,{[U]:ie},U):vt(n.errors,U,ie):nn(n.errors,U)}n.errors={...n.errors}}else n.errors=$;return $},z=async({name:j,eventType:$})=>{if(t.validate){const U=await t.validate({formValues:s,formState:n,name:j,eventType:$});if(Gt(U))for(const ie in U){const le=U[ie];le&&Ze(`${uv}.${ie}`,{message:jn(le.message)?le.message:"",type:le.type||si.validate})}else jn(U)||!U?Ze(uv,{message:U||"",type:si.validate}):Ue(uv);return U}return!0},L=async({fields:j,onlyCheckValid:$,name:U,eventType:ie,context:le={valid:!0,runRootValidation:!1}})=>{if(t.validate&&(le.runRootValidation=!0,!await z({name:U,eventType:ie})&&(le.valid=!1,$)))return le.valid;for(const be in j){const we=j[be];if(we){const{_f:Te,...Be}=we;if(Te){const se=l.array.has(Te.name),F=we._f&&WH(we._f),ne=x.validatingFields||x.isValidating||S.validatingFields||S.isValidating;F&&ne&&M([Te.name],!0);const Ce=await i_(we,l.disabled,s,A,e.shouldUseNativeValidation&&!$,se);if(F&&ne&&M([Te.name]),Ce[Te.name]&&(le.valid=!1,$)||(!$&&(Se(Ce,Te.name)?se?QT(n.errors,Ce,Te.name):vt(n.errors,Te.name,Ce[Te.name]):nn(n.errors,Te.name)),t.shouldUseNativeValidation&&Ce[Te.name]))break}!On(Be)&&await L({context:le,onlyCheckValid:$,fields:Be,name:be,eventType:ie})}}return le.valid},G=()=>{for(const j of l.unMount){const $=Se(r,j);$&&($._f.refs?$._f.refs.every(U=>!cv(U)):!cv($._f.ref))&&mn(j)}l.unMount=new Set},he=(j,$)=>(j&&$&&vt(s,j,$),!_r(o.mount?s:i,i)),ke=(j,$,U)=>R0(j,l,{...o.mount?s:Vt($)?i:jn(j)?{[j]:$}:$},U,$),H=j=>GN(Se(o.mount?s:i,j,e.shouldUnregister?Se(i,j,[]):[])),Z=(j,$,U={},ie=!1,le=!1)=>{const be=Se(r,j);let we=$;if(be){const Te=be._f;Te&&(!Te.disabled&&vt(s,j,eO($,Te)),we=Np(Te.ref)&&In($)?"":$,ZN(Te.ref)?[...Te.ref.options].forEach(Be=>Be.selected=we.includes(Be.value)):Te.refs?Yd(Te.ref)?Te.refs.forEach(Be=>{(!Be.defaultChecked||!Be.disabled)&&(Array.isArray(we)?Be.checked=!!we.find(se=>se===Be.value):Be.checked=we===Be.value||!!we)}):Te.refs.forEach(Be=>Be.checked=Be.value===we):Gm(Te.ref)?Te.ref.value="":(Te.ref.value=we,!Te.ref.type&&!le&&k.state.next({name:j,values:ie?s:qt(s)})))}(U.shouldDirty||U.shouldTouch)&&K(j,we,U.shouldTouch,U.shouldDirty,!le),U.shouldValidate&&ae(j,{delayError:U.delayError})},pe=(j,$,U,ie=!1,le=!1)=>{l.array.has(j)&&k.array.next({name:j,values:ie?s:qt(s)});for(const be in $){if(!$.hasOwnProperty(be))return;const we=$[be],Te=j+"."+be,Be=Se(r,Te);(l.array.has(j)||Gt(we)||Be&&!Be._f)&&!ko(we)?pe(Te,we,U,ie,le):Z(Te,we,U,ie,le)}},ve=(j,$,U,ie,le=!1)=>{const be=Se(r,j),we=l.array.has(j),Te=ie?$:qt($),Be=Se(s,j),se=_r(Be,Te);if(se||vt(s,j,Te),we)k.array.next({name:j,values:ie?s:qt(s)}),(x.isDirty||x.dirtyFields||S.isDirty||S.dirtyFields)&&U.shouldDirty&&(O(),le||k.state.next({name:j,dirtyFields:n.dirtyFields,isDirty:he(j,Te)}));else{const F=Array.isArray(Te)&&!Te.length||On(Te);!be||be._f||In(Te)||F?Z(j,Te,U,ie,le):pe(j,Te,U,ie,le)}if(!se&&!le){const F=lv(j,l),ne=ie?s:qt(s);k.state.next({...F&&n,name:o.mount||F?j:void 0,values:ne})}},Ae=(j,$,U={})=>ve(j,$,U,!1),Re=(j,$={})=>{const U=qn(j)?j(s):j;if(!_r(s,U)){s={...s,...U};const ie=WN(U);for(const le of l.mount)le in ie&&ve(le,ie[le],$,!0,!0);k.state.next({...n,name:void 0,type:void 0,...h?{values:s}:{}}),$.shouldValidate&&_()}},$e=async j=>{o.mount=!0;const $=j.target;let U=$.name,ie=!0;const le=Se(r,U),be=we=>{ie=Number.isNaN(we)||ko(we)&&isNaN(we.getTime())||_r(we,Se(s,U,we))};if(le){let we,Te;const Be=$.type?a_(le._f):A0(j),se=j.type===fo.BLUR||j.type===fo.FOCUS_OUT,F=!KH(le._f)&&!t.validate&&!e.resolver&&!Se(n.errors,U)&&!le._f.deps,ne=F||XH(se,Se(n.touchedFields,U),n.isSubmitted,g,m),Ce=lv(U,l,se);if(vt(s,U,Be),se){if(!$||!$.readOnly){le._f.onBlur&&le._f.onBlur(j);const Zn=u[U];Zn&&Zn(0)}}else le._f.onChange&&le._f.onChange(j);const Ge=K(U,Be,se),Dt=!On(Ge)||Ce;if(!se&&k.state.next({name:U,type:j.type,...h?{values:qt(s)}:{}}),ne)return(!F||!n.isValid)&&(x.isValid||S.isValid)&&(e.mode==="onBlur"?se&&_():se||_()),Dt&&k.state.next({name:U,...Ce?{}:Ge});if(!e.resolver&&t.validate&&await z({name:U,eventType:j.type}),!se&&Ce&&k.state.next({...n}),e.resolver){const{errors:Zn}=await Q([U]);if(M([U]),be(Be),!ie){!On(Ge)&&k.state.next(Ge);return}const or=c_(n.errors,r,U),wi=c_(Zn,r,or.name||U);we=wi.error,U=wi.name,Te=On(Zn)}else M([U],!0),we=(await i_(le,l.disabled,s,A,e.shouldUseNativeValidation))[U],M([U]),be(Be),ie&&(we?Te=!1:(x.isValid||S.isValid)&&(Te=await L({fields:r,onlyCheckValid:!0,name:U,eventType:j.type})));ie&&(le._f.deps&&(!Array.isArray(le._f.deps)||le._f.deps.length>0)&&ae(le._f.deps),ee(U,Te,we,Ge))}},_e=(j,$)=>{if(Se(n.errors,$)&&j.focus)return j.focus(),1},ae=async(j,$={})=>{let U,ie;const le=cp(j);if(e.resolver){const be=await fe(Vt(j)?j:le);U=On(be),ie=j?!le.some(we=>Se(be,we)):U}else j?(ie=(await Promise.all(le.map(async be=>{const we=Se(r,be);return await L({fields:we&&we._f?{[be]:we}:we,eventType:fo.TRIGGER})}))).every(Boolean),!(!ie&&!n.isValid)&&_()):ie=U=await L({fields:r,name:j,eventType:fo.TRIGGER});if($.delayError&&e.delayError&&jn(j)){const be=Se(n.errors,j);be?(nn(n.errors,j),u[j]=R(j,()=>I(j,be)),u[j](e.delayError)):(clearTimeout(f[j]),delete u[j])}return k.state.next({...!jn(j)||(x.isValid||S.isValid)&&U!==n.isValid?{}:{name:j},...e.resolver||!j?{isValid:U}:{},errors:n.errors}),$.shouldFocus&&!ie&&rd(r,_e,j?le:l.mount),ie},me=(j,$)=>{let U={...o.mount?s:i};return $&&(U=KN($.dirtyFields?n.dirtyFields:n.touchedFields,U)),Vt(j)?U:jn(j)?Se(U,j):j.map(ie=>Se(U,ie))},Ie=(j,$)=>({invalid:!!Se(($||n).errors,j),isDirty:!!Se(($||n).dirtyFields,j),error:Se(($||n).errors,j),isValidating:!!Se(n.validatingFields,j),isTouched:!!Se(($||n).touchedFields,j)}),Ue=j=>{const $=j?cp(j):void 0;$?.forEach(U=>nn(n.errors,U)),$?$.forEach(U=>{k.state.next({name:U,errors:n.errors})}):(n.errors={},k.state.next({errors:n.errors}))},Ze=(j,$,U)=>{const ie=(Se(r,j,{_f:{}})._f||{}).ref,le=Se(n.errors,j)||{},{ref:be,message:we,type:Te,...Be}=le;vt(n.errors,j,{...Be,...$,ref:ie}),k.state.next({name:j,errors:n.errors,isValid:!1}),U&&U.shouldFocus&&ie&&ie.focus&&ie.focus()},ct=(j,$)=>{if(qn(j)){h++;const{unsubscribe:U}=k.state.subscribe({next:le=>"values"in le&&j(le.values||ke(void 0,$),le)});let ie=!1;return{unsubscribe:()=>{ie||(ie=!0,h--,U())}}}return ke(j,$,!0)},yt=j=>{var $;const U=!!(!(($=j.formState)===null||$===void 0)&&$.values);U&&h++;const{unsubscribe:ie}=k.state.subscribe({next:be=>{if(YH(j.name,be.name,j.exact)&&ZH(be,j.formState||x,ei,j.reRenderRoot)){const we={...s};j.callback({values:we,...n,...be,defaultValues:i})}}});if(!U)return ie;let le=!1;return()=>{le||(le=!0,h--,ie())}},Pt=j=>(o.mount=!0,S={...S,...j.formState},yt({...j,formState:{...b,...j.formState}})),mn=(j,$={})=>{for(const U of j?cp(j):l.mount)l.mount.delete(U),l.array.delete(U),$.keepValue||(nn(r,U),nn(s,U)),!$.keepError&&nn(n.errors,U),!$.keepDirty&&nn(n.dirtyFields,U),!$.keepTouched&&nn(n.touchedFields,U),!$.keepIsValidating&&nn(n.validatingFields,U),!e.shouldUnregister&&!$.keepDefaultValue&&nn(i,U);k.state.next({values:qt(s)}),k.state.next({...n,...$.keepDirty?{isDirty:he()}:{}}),!$.keepIsValid&&_()},Wt=({disabled:j,name:$})=>{if(Tr(j)&&o.mount||j||l.disabled.has($)){const le=l.disabled.has($)!==!!j;j?l.disabled.add($):l.disabled.delete($),le&&o.mount&&!o.action&&_()}},yn=(j,$={})=>{let U=Se(r,j);const ie=Tr($.disabled)||Tr(e.disabled),le=!l.registerName.has(j)&&U&&U._f&&!U._f.mount;return vt(r,j,{...U||{},_f:{...U&&U._f?U._f:{ref:{name:j}},name:j,mount:!0,...$}}),l.mount.add(j),U&&!le?Wt({disabled:Tr($.disabled)?$.disabled:e.disabled,name:j}):re(j,!0,$.value),{...ie?{disabled:$.disabled||e.disabled}:{},...e.progressive?{required:!!$.required,min:ju($.min),max:ju($.max),minLength:ju($.minLength),maxLength:ju($.maxLength),pattern:ju($.pattern)}:{},name:j,onChange:$e,onBlur:$e,ref:be=>{if(be){l.registerName.add(j),yn(j,$),l.registerName.delete(j),U=Se(r,j);const we=Vt(be.value)&&be.querySelectorAll&&be.querySelectorAll("input,select,textarea")[0]||be,Te=FH(we),Be=U._f.refs||[];if(Te?Be.find(F=>F===we):we===U._f.ref)return;const se={...U._f};Te?(se.refs=[...Be.filter(cv),we,...Array.isArray(Se(i,j))?[{}]:[]],se.ref={type:we.type,name:j}):(se.ref=we,delete se.refs),vt(r,j,{_f:se}),re(j,!1,void 0,we)}else U=Se(r,j,{}),U._f&&(U._f.mount=!1),(e.shouldUnregister||$.shouldUnregister)&&!(zN(l.array,j)&&o.action)&&l.unMount.add(j)}}},$n=()=>e.shouldFocusError&&!e.shouldUseNativeValidation&&rd(r,_e,l.mount),Dr=j=>{Tr(j)&&(k.state.next({disabled:j}),rd(r,($,U)=>{const ie=Se(r,U);ie&&($.disabled=ie._f.disabled||j,Array.isArray(ie._f.refs)&&ie._f.refs.forEach(le=>{le.disabled=ie._f.disabled||j}))},0,!1))},sr=(j,$)=>async U=>{let ie,le;U&&(U.preventDefault&&U.preventDefault(),U.persist&&U.persist());let be=qt(s);if(k.state.next({isSubmitting:!0}),e.resolver){const{errors:we,values:Te}=await Q();M(),n.errors=we,be=qt(Te)}else await L({fields:r,eventType:fo.SUBMIT});if(l.disabled.size)for(const we of l.disabled)nn(be,we);if(nn(n.errors,BN),On(n.errors)){k.state.next({errors:{}});try{ie=await j(be,U)}catch(we){le=we}}else $&&await $({...n.errors},U),$n(),setTimeout($n);if(k.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:On(n.errors)&&!le,submitCount:n.submitCount+1,errors:n.errors}),le)throw le;return ie},Ir=(j,$={})=>{Se(r,j)&&(Vt($.defaultValue)?Ae(j,qt(Se(i,j))):(Ae(j,$.defaultValue),vt(i,j,qt($.defaultValue))),$.keepTouched||nn(n.touchedFields,j),$.keepDirty||(nn(n.dirtyFields,j),n.isDirty=$.defaultValue?he(j,qt(Se(i,j))):he()),$.keepError||(nn(n.errors,j),x.isValid&&_()),k.state.next({...n}))},Ht=(j,$={})=>{const U=j?qt(j):i,ie=qt(U),le=On(j),be=ie,we=r;if($.keepDefaultValues||(i=U),!$.keepValues){if($.keepDirtyValues){const Te=new Set([...l.mount,...YN(ba(i,s,void 0,we),n.dirtyFields)]);for(const Be of Array.from(Te)){const se=Se(n.dirtyFields,Be),F=Se(s,Be),ne=Se(be,Be);se&&!Vt(F)?vt(be,Be,F):!se&&!Vt(ne)&&Ae(Be,ne)}}else{if(Wm&&Vt(j))for(const Te of l.mount){const Be=Se(r,Te);if(Be&&Be._f){const se=Array.isArray(Be._f.refs)?Be._f.refs[0]:Be._f.ref;if(Np(se)){const F=se.closest("form");if(F){F.reset();break}}}}if($.keepFieldsRef)for(const Te of l.mount)Ae(Te,Se(be,Te));else r={}}if(e.shouldUnregister){if(s=$.keepDefaultValues?qt(i):{},$.keepFieldsRef)for(const Te of l.mount)vt(s,Te,Se(be,Te))}else s=qt(be);k.array.next({values:{...be}}),k.state.next({name:void 0,type:void 0,values:{...be}})}l={mount:$.keepDirtyValues?l.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!x.isValid||!!$.keepIsValid||!!$.keepDirtyValues||!e.shouldUnregister&&!On(be),o.watch=!!e.shouldUnregister,o.keepIsValid=!!$.keepIsValid,o.action=!1,$.keepErrors||(n.errors={}),k.state.next({submitCount:$.keepSubmitCount?n.submitCount:0,isDirty:le?!1:$.keepDirty?n.isDirty:$.keepValues?he():!!($.keepDefaultValues&&!_r(j,i)),isSubmitted:$.keepIsSubmitted?n.isSubmitted:!1,dirtyFields:le?{}:$.keepDirtyValues?$.keepDefaultValues&&s?ba(i,s,void 0,we):n.dirtyFields:$.keepDefaultValues&&j?ba(i,j,void 0,we):$.keepDirty?n.dirtyFields:{},touchedFields:$.keepTouched?n.touchedFields:{},errors:$.keepErrors?n.errors:{},isSubmitSuccessful:$.keepIsSubmitSuccessful?n.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:i})},xi=(j,$)=>Ht(qn(j)?j(s):j,{...e.resetOptions,...$}),yr=(j,$={})=>{const U=Se(r,j),ie=U&&U._f;if(ie){const le=ie.refs?ie.refs[0]:ie.ref;le.focus&&setTimeout(()=>{le.focus(),$.shouldSelect&&qn(le.select)&&le.select()})}},ei=j=>{const{name:$,type:U,values:ie,...le}=j;n={...n,...le}},Ne={control:{register:yn,unregister:mn,getFieldState:Ie,handleSubmit:sr,setError:Ze,_subscribe:yt,_runSchema:Q,_updateIsValidating:M,_focusError:$n,_getWatch:ke,_getDirty:he,_setValid:_,_setFieldArray:D,_setDisabledField:Wt,_setErrors:P,_getFieldArray:H,_reset:Ht,_resetDefaultValues:()=>qn(e.defaultValues)&&e.defaultValues().then(j=>{xi(j,e.resetOptions),k.state.next({isLoading:!1})}),_removeUnmounted:G,_disableForm:Dr,_subjects:k,_proxyFormState:x,get _fields(){return r},get _formValues(){return s},get _state(){return o},set _state(j){o=j},get _defaultValues(){return i},get _names(){return l},set _names(j){l=j},get _formState(){return n},get _options(){return e},set _options(j){e={...e,...j},m=kh(e.mode),g=kh(e.reValidateMode)}},subscribe:Pt,trigger:ae,register:yn,handleSubmit:sr,watch:ct,setValue:Ae,setValues:Re,getValues:me,reset:xi,resetField:Ir,resetDefaultValues:(j,$={})=>{if(i=qt(j),!$.keepDirty){const U=ba(i,s,void 0,r);n.dirtyFields=U,n.isDirty=!On(U)}$.keepIsValid||_(),k.state.next({...n,defaultValues:i})},clearErrors:Ue,unregister:mn,setError:Ze,setFocus:yr,getFieldState:Ie};return{...Ne,formControl:Ne}}function nU(t={}){const e=qe.useRef(void 0),n=qe.useRef(void 0),r=qe.useRef(t.formControl),[i,s]=qe.useState(()=>({...qt(tO),isLoading:qn(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1,defaultValues:qn(t.defaultValues)?void 0:t.defaultValues}));if(!e.current||t.formControl&&r.current!==t.formControl)if(r.current=t.formControl,t.formControl)e.current={...t.formControl,formState:i},t.defaultValues&&!qn(t.defaultValues)&&t.formControl.reset(t.defaultValues,t.resetOptions);else{const{formControl:l,...u}=tU(t);e.current={...u,formState:i}}const o=e.current.control;return o._options=t,Cw(()=>{const l=o._subscribe({formState:o._proxyFormState,callback:()=>s({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return s(u=>({...u,isReady:!0})),o._formState.isReady=!0,l},[o]),qe.useEffect(()=>o._disableForm(t.disabled),[o,t.disabled]),qe.useEffect(()=>{t.mode&&(o._options.mode=t.mode),t.reValidateMode&&(o._options.reValidateMode=t.reValidateMode)},[o,t.mode,t.reValidateMode]),qe.useEffect(()=>{t.errors&&(o._setErrors(t.errors),o._focusError())},[o,t.errors]),qe.useEffect(()=>{t.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,t.shouldUnregister]),qe.useEffect(()=>{if(o._proxyFormState.isDirty){const l=o._getDirty();l!==i.isDirty&&o._subjects.state.next({isDirty:l})}},[o,i.isDirty]),qe.useEffect(()=>{var l;t.values&&!_r(t.values,n.current)?(o._reset(t.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((l=o._options.resetOptions)===null||l===void 0)&&l.keepIsValid||o._setValid(),n.current=t.values,s(u=>({...u}))):o._resetDefaultValues()},[o,t.values]),qe.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),e.current.formState=qe.useMemo(()=>HN(i,o),[o,i]),e.current}const u_=(t,e,n)=>{if(t&&"reportValidity"in t){const r=Se(n,e);t.setCustomValidity(r&&r.message||""),t.reportValidity()}},D0=(t,e)=>{for(const n in e.fields){const r=e.fields[n];r&&r.ref&&"reportValidity"in r.ref?u_(r.ref,n,t):r&&r.refs&&r.refs.forEach(i=>u_(i,n,t))}},d_=(t,e)=>{e.shouldUseNativeValidation&&D0(t,e);const n={};for(const r in t){const i=Se(e.fields,r),s=Object.assign(t[r]||{},{ref:i&&i.refs?i.refs[0]:i&&i.ref});if(rU(e.names||Object.keys(t),r)){const o=Object.assign({},Se(n,r));vt(o,"root",s),vt(n,r,o)}else vt(n,r,s)}return n},rU=(t,e)=>{const n=f_(e).replace(/[.*+?^${}()|\\]/g,"\\$&");return t.some(r=>f_(r).match(`^${n}\\.\\d+`))};function f_(t){return t.replace(/[\[\]]/g,"")}function I0(){return I0=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},I0.apply(null,arguments)}function h_(t,e){try{var n=t()}catch(r){return e(r)}return n&&n.then?n.then(void 0,e):n}function iU(t,e){for(var n=Object.create(null);t.length;){var r=t[0],i=r.code,s=r.message,o=r.path.join(".");if(!n[o])if("unionErrors"in r){var l,u,f=r.unionErrors.reduce(function(g,b){return b.errors.length<g.errors.length?b:g}).errors[0];n[o]={message:(l=f?.message)!=null?l:s,type:(u=f?.code)!=null?u:i}}else n[o]={message:s,type:i};if("unionErrors"in r&&r.unionErrors.forEach(function(g){return g.errors.forEach(function(b){return t.push(b)})}),e){var h=n[o].types,m=h&&h[r.code];n[o]=Tw(o,e,n,i,m?[].concat(m,r.message):r.message)}t.shift()}return n}function sU(t,e){for(var n=Object.create(null),r=function(){var i=t[0],s=i.code,o=i.message,l=i.path.join(".");if(!n[l])if(i.code==="invalid_union"&&i.errors.length>0){var u,f,h=i.errors.reduce(function(b,x){return x.length<b.length?x:b})[0];n[l]={message:(u=h?.message)!=null?u:o,type:(f=h?.code)!=null?f:s}}else n[l]={message:o,type:s};if(i.code==="invalid_union"&&i.errors.forEach(function(b){return b.forEach(function(x){return t.push(I0({},x,{path:[].concat(i.path,x.path)}))})}),e){var m=n[l].types,g=m&&m[i.code];n[l]=Tw(l,e,n,s,g?[].concat(g,i.message):i.message)}t.shift()};t.length;)r();return n}function oU(t,e,n){if(n===void 0&&(n={}),(function(r){return"_zod"in r&&typeof r._zod=="object"})(t))return function(r,i,s){try{return Promise.resolve(h_(function(){function o(u){return s.shouldUseNativeValidation&&D0({},s),{errors:{},values:n.raw?Object.assign({},r):u}}var l=t;return n.mode==="sync"?o(l.parse(r,e)):Promise.resolve(l.parseAsync(r,e)).then(o)},function(o){if((function(l){var u;return!(l==null||(u=l._zod)==null||(u=u.traits)==null||!u.has("$ZodError"))})(o))return{values:{},errors:d_(sU(o.issues,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};if((function(r){return"_def"in r&&typeof r._def=="object"})(t))return function(r,i,s){try{return Promise.resolve(h_(function(){return Promise.resolve(t[n.mode==="sync"?"parse":"parseAsync"](r,e)).then(function(o){return s.shouldUseNativeValidation&&D0({},s),{errors:{},values:n.raw?Object.assign({},r):o}})},function(o){if((function(l){return Array.isArray(l?.issues)})(o))return{values:{},errors:d_(iU(o.errors,!s.shouldUseNativeValidation&&s.criteriaMode==="all"),s)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}var gt;(function(t){t.assertEqual=i=>{};function e(i){}t.assertIs=e;function n(i){throw new Error}t.assertNever=n,t.arrayToEnum=i=>{const s={};for(const o of i)s[o]=o;return s},t.getValidEnumValues=i=>{const s=t.objectKeys(i).filter(l=>typeof i[i[l]]!="number"),o={};for(const l of s)o[l]=i[l];return t.objectValues(o)},t.objectValues=i=>t.objectKeys(i).map(function(s){return i[s]}),t.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{const s=[];for(const o in i)Object.prototype.hasOwnProperty.call(i,o)&&s.push(o);return s},t.find=(i,s)=>{for(const o of i)if(s(o))return o},t.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function r(i,s=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(s)}t.joinValues=r,t.jsonStringifyReplacer=(i,s)=>typeof s=="bigint"?s.toString():s})(gt||(gt={}));var p_;(function(t){t.mergeShapes=(e,n)=>({...e,...n})})(p_||(p_={}));const je=gt.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ho=t=>{switch(typeof t){case"undefined":return je.undefined;case"string":return je.string;case"number":return Number.isNaN(t)?je.nan:je.number;case"boolean":return je.boolean;case"function":return je.function;case"bigint":return je.bigint;case"symbol":return je.symbol;case"object":return Array.isArray(t)?je.array:t===null?je.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?je.promise:typeof Map<"u"&&t instanceof Map?je.map:typeof Set<"u"&&t instanceof Set?je.set:typeof Date<"u"&&t instanceof Date?je.date:je.object;default:return je.unknown}},xe=gt.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class Ns extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=r=>{this.issues=[...this.issues,r]},this.addIssues=(r=[])=>{this.issues=[...this.issues,...r]};const n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e}format(e){const n=e||function(s){return s.message},r={_errors:[]},i=s=>{for(const o of s.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)r._errors.push(n(o));else{let l=r,u=0;for(;u<o.path.length;){const f=o.path[u];u===o.path.length-1?(l[f]=l[f]||{_errors:[]},l[f]._errors.push(n(o))):l[f]=l[f]||{_errors:[]},l=l[f],u++}}};return i(this),r}static assert(e){if(!(e instanceof Ns))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,gt.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){const n={},r=[];for(const i of this.issues)if(i.path.length>0){const s=i.path[0];n[s]=n[s]||[],n[s].push(e(i))}else r.push(e(i));return{formErrors:r,fieldErrors:n}}get formErrors(){return this.flatten()}}Ns.create=t=>new Ns(t);const j0=(t,e)=>{let n;switch(t.code){case xe.invalid_type:t.received===je.undefined?n="Required":n=`Expected ${t.expected}, received ${t.received}`;break;case xe.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(t.expected,gt.jsonStringifyReplacer)}`;break;case xe.unrecognized_keys:n=`Unrecognized key(s) in object: ${gt.joinValues(t.keys,", ")}`;break;case xe.invalid_union:n="Invalid input";break;case xe.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${gt.joinValues(t.options)}`;break;case xe.invalid_enum_value:n=`Invalid enum value. Expected ${gt.joinValues(t.options)}, received '${t.received}'`;break;case xe.invalid_arguments:n="Invalid function arguments";break;case xe.invalid_return_type:n="Invalid function return type";break;case xe.invalid_date:n="Invalid date";break;case xe.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(n=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(n=`${n} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?n=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?n=`Invalid input: must end with "${t.validation.endsWith}"`:gt.assertNever(t.validation):t.validation!=="regex"?n=`Invalid ${t.validation}`:n="Invalid";break;case xe.too_small:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?n=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:n="Invalid input";break;case xe.too_big:t.type==="array"?n=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?n=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?n=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?n=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?n=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:n="Invalid input";break;case xe.custom:n="Invalid input";break;case xe.invalid_intersection_types:n="Intersection results could not be merged";break;case xe.not_multiple_of:n=`Number must be a multiple of ${t.multipleOf}`;break;case xe.not_finite:n="Number must be finite";break;default:n=e.defaultError,gt.assertNever(t)}return{message:n}};let aU=j0;function lU(){return aU}const cU=t=>{const{data:e,path:n,errorMaps:r,issueData:i}=t,s=[...n,...i.path||[]],o={...i,path:s};if(i.message!==void 0)return{...i,path:s,message:i.message};let l="";const u=r.filter(f=>!!f).slice().reverse();for(const f of u)l=f(o,{data:e,defaultError:l}).message;return{...i,path:s,message:l}};function Me(t,e){const n=lU(),r=cU({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,n,n===j0?void 0:j0].filter(i=>!!i)});t.common.issues.push(r)}class Nr{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,n){const r=[];for(const i of n){if(i.status==="aborted")return Qe;i.status==="dirty"&&e.dirty(),r.push(i.value)}return{status:e.value,value:r}}static async mergeObjectAsync(e,n){const r=[];for(const i of n){const s=await i.key,o=await i.value;r.push({key:s,value:o})}return Nr.mergeObjectSync(e,r)}static mergeObjectSync(e,n){const r={};for(const i of n){const{key:s,value:o}=i;if(s.status==="aborted"||o.status==="aborted")return Qe;s.status==="dirty"&&e.dirty(),o.status==="dirty"&&e.dirty(),s.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(r[s.value]=o.value)}return{status:e.value,value:r}}}const Qe=Object.freeze({status:"aborted"}),Gu=t=>({status:"dirty",value:t}),Qr=t=>({status:"valid",value:t}),m_=t=>t.status==="aborted",g_=t=>t.status==="dirty",hc=t=>t.status==="valid",Dp=t=>typeof Promise<"u"&&t instanceof Promise;var Pe;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(Pe||(Pe={}));class Po{constructor(e,n,r,i){this._cachedPath=[],this.parent=e,this.data=n,this._path=r,this._key=i}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const y_=(t,e)=>{if(hc(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const n=new Ns(t.common.issues);return this._error=n,this._error}}};function it(t){if(!t)return{};const{errorMap:e,invalid_type_error:n,required_error:r,description:i}=t;if(e&&(n||r))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:i}:{errorMap:(o,l)=>{const{message:u}=t;return o.code==="invalid_enum_value"?{message:u??l.defaultError}:typeof l.data>"u"?{message:u??r??l.defaultError}:o.code!=="invalid_type"?{message:l.defaultError}:{message:u??n??l.defaultError}},description:i}}class ft{get description(){return this._def.description}_getType(e){return ho(e.data)}_getOrReturnCtx(e,n){return n||{common:e.parent.common,data:e.data,parsedType:ho(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Nr,ctx:{common:e.parent.common,data:e.data,parsedType:ho(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const n=this._parse(e);if(Dp(n))throw new Error("Synchronous parse encountered promise.");return n}_parseAsync(e){const n=this._parse(e);return Promise.resolve(n)}parse(e,n){const r=this.safeParse(e,n);if(r.success)return r.data;throw r.error}safeParse(e,n){const r={common:{issues:[],async:n?.async??!1,contextualErrorMap:n?.errorMap},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ho(e)},i=this._parseSync({data:e,path:r.path,parent:r});return y_(r,i)}"~validate"(e){const n={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ho(e)};if(!this["~standard"].async)try{const r=this._parseSync({data:e,path:[],parent:n});return hc(r)?{value:r.value}:{issues:n.common.issues}}catch(r){r?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),n.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:n}).then(r=>hc(r)?{value:r.value}:{issues:n.common.issues})}async parseAsync(e,n){const r=await this.safeParseAsync(e,n);if(r.success)return r.data;throw r.error}async safeParseAsync(e,n){const r={common:{issues:[],contextualErrorMap:n?.errorMap,async:!0},path:n?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ho(e)},i=this._parse({data:e,path:r.path,parent:r}),s=await(Dp(i)?i:Promise.resolve(i));return y_(r,s)}refine(e,n){const r=i=>typeof n=="string"||typeof n>"u"?{message:n}:typeof n=="function"?n(i):n;return this._refinement((i,s)=>{const o=e(i),l=()=>s.addIssue({code:xe.custom,...r(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?!0:(l(),!1)):o?!0:(l(),!1)})}refinement(e,n){return this._refinement((r,i)=>e(r)?!0:(i.addIssue(typeof n=="function"?n(r,i):n),!1))}_refinement(e){return new gc({schema:this,typeName:et.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:n=>this["~validate"](n)}}optional(){return Mo.create(this,this._def)}nullable(){return yc.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ji.create(this)}promise(){return Pp.create(this,this._def)}or(e){return jp.create([this,e],this._def)}and(e){return Lp.create(this,e,this._def)}transform(e){return new gc({...it(this._def),schema:this,typeName:et.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const n=typeof e=="function"?e:()=>e;return new z0({...it(this._def),innerType:this,defaultValue:n,typeName:et.ZodDefault})}brand(){return new OU({typeName:et.ZodBranded,type:this,...it(this._def)})}catch(e){const n=typeof e=="function"?e:()=>e;return new $0({...it(this._def),innerType:this,catchValue:n,typeName:et.ZodCatch})}describe(e){const n=this.constructor;return new n({...this._def,description:e})}pipe(e){return _w.create(this,e)}readonly(){return B0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const uU=/^c[^\s-]{8,}$/i,dU=/^[0-9a-z]+$/,fU=/^[0-9A-HJKMNP-TV-Z]{26}$/i,hU=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,pU=/^[a-z0-9_-]{21}$/i,mU=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,gU=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,yU=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bU="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let dv;const vU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,xU=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,wU=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,SU=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kU=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,CU=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nO="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",EU=new RegExp(`^${nO}$`);function rO(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const n=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${n}`}function TU(t){return new RegExp(`^${rO(t)}$`)}function _U(t){let e=`${nO}T${rO(t)}`;const n=[];return n.push(t.local?"Z?":"Z"),t.offset&&n.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${n.join("|")})`,new RegExp(`^${e}$`)}function AU(t,e){return!!((e==="v4"||!e)&&vU.test(t)||(e==="v6"||!e)&&wU.test(t))}function RU(t,e){if(!mU.test(t))return!1;try{const[n]=t.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),i=JSON.parse(atob(r));return!(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||e&&i.alg!==e)}catch{return!1}}function MU(t,e){return!!((e==="v4"||!e)&&xU.test(t)||(e==="v6"||!e)&&SU.test(t))}class Co extends ft{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==je.string){const s=this._getOrReturnCtx(e);return Me(s,{code:xe.invalid_type,expected:je.string,received:s.parsedType}),Qe}const r=new Nr;let i;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="max")e.data.length>s.value&&(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),r.dirty());else if(s.kind==="length"){const o=e.data.length>s.value,l=e.data.length<s.value;(o||l)&&(i=this._getOrReturnCtx(e,i),o?Me(i,{code:xe.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):l&&Me(i,{code:xe.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),r.dirty())}else if(s.kind==="email")yU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"email",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="emoji")dv||(dv=new RegExp(bU,"u")),dv.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"emoji",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="uuid")hU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"uuid",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="nanoid")pU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"nanoid",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid")uU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"cuid",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="cuid2")dU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"cuid2",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="ulid")fU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"ulid",code:xe.invalid_string,message:s.message}),r.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{i=this._getOrReturnCtx(e,i),Me(i,{validation:"url",code:xe.invalid_string,message:s.message}),r.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"regex",code:xe.invalid_string,message:s.message}),r.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),r.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:{startsWith:s.value},message:s.message}),r.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:{endsWith:s.value},message:s.message}),r.dirty()):s.kind==="datetime"?_U(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:"datetime",message:s.message}),r.dirty()):s.kind==="date"?EU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:"date",message:s.message}),r.dirty()):s.kind==="time"?TU(s).test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.invalid_string,validation:"time",message:s.message}),r.dirty()):s.kind==="duration"?gU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"duration",code:xe.invalid_string,message:s.message}),r.dirty()):s.kind==="ip"?AU(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"ip",code:xe.invalid_string,message:s.message}),r.dirty()):s.kind==="jwt"?RU(e.data,s.alg)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"jwt",code:xe.invalid_string,message:s.message}),r.dirty()):s.kind==="cidr"?MU(e.data,s.version)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"cidr",code:xe.invalid_string,message:s.message}),r.dirty()):s.kind==="base64"?kU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"base64",code:xe.invalid_string,message:s.message}),r.dirty()):s.kind==="base64url"?CU.test(e.data)||(i=this._getOrReturnCtx(e,i),Me(i,{validation:"base64url",code:xe.invalid_string,message:s.message}),r.dirty()):gt.assertNever(s);return{status:r.value,value:e.data}}_regex(e,n,r){return this.refinement(i=>e.test(i),{validation:n,code:xe.invalid_string,...Pe.errToObj(r)})}_addCheck(e){return new Co({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Pe.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Pe.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Pe.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Pe.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...Pe.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Pe.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Pe.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Pe.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...Pe.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...Pe.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...Pe.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Pe.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...Pe.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...Pe.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...Pe.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...Pe.errToObj(e)})}regex(e,n){return this._addCheck({kind:"regex",regex:e,...Pe.errToObj(n)})}includes(e,n){return this._addCheck({kind:"includes",value:e,position:n?.position,...Pe.errToObj(n?.message)})}startsWith(e,n){return this._addCheck({kind:"startsWith",value:e,...Pe.errToObj(n)})}endsWith(e,n){return this._addCheck({kind:"endsWith",value:e,...Pe.errToObj(n)})}min(e,n){return this._addCheck({kind:"min",value:e,...Pe.errToObj(n)})}max(e,n){return this._addCheck({kind:"max",value:e,...Pe.errToObj(n)})}length(e,n){return this._addCheck({kind:"length",value:e,...Pe.errToObj(n)})}nonempty(e){return this.min(1,Pe.errToObj(e))}trim(){return new Co({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Co({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Co({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxLength(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Co.create=t=>new Co({checks:[],typeName:et.ZodString,coerce:t?.coerce??!1,...it(t)});function NU(t,e){const n=(t.toString().split(".")[1]||"").length,r=(e.toString().split(".")[1]||"").length,i=n>r?n:r,s=Number.parseInt(t.toFixed(i).replace(".","")),o=Number.parseInt(e.toFixed(i).replace(".",""));return s%o/10**i}class pc extends ft{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==je.number){const s=this._getOrReturnCtx(e);return Me(s,{code:xe.invalid_type,expected:je.number,received:s.parsedType}),Qe}let r;const i=new Nr;for(const s of this._def.checks)s.kind==="int"?gt.isInteger(e.data)||(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.invalid_type,expected:"integer",received:"float",message:s.message}),i.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),i.dirty()):s.kind==="multipleOf"?NU(e.data,s.value)!==0&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.not_finite,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}gte(e,n){return this.setLimit("min",e,!0,Pe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Pe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Pe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Pe.toString(n))}setLimit(e,n,r,i){return new pc({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Pe.toString(i)}]})}_addCheck(e){return new pc({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Pe.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Pe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Pe.toString(n)})}finite(e){return this._addCheck({kind:"finite",message:Pe.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Pe.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Pe.toString(e)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&>.isInteger(e.value))}get isFinite(){let e=null,n=null;for(const r of this._def.checks){if(r.kind==="finite"||r.kind==="int"||r.kind==="multipleOf")return!0;r.kind==="min"?(n===null||r.value>n)&&(n=r.value):r.kind==="max"&&(e===null||r.value<e)&&(e=r.value)}return Number.isFinite(n)&&Number.isFinite(e)}}pc.create=t=>new pc({checks:[],typeName:et.ZodNumber,coerce:t?.coerce||!1,...it(t)});class Ed extends ft{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==je.bigint)return this._getInvalidInput(e);let r;const i=new Nr;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),i.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(r=this._getOrReturnCtx(e,r),Me(r,{code:xe.not_multiple_of,multipleOf:s.value,message:s.message}),i.dirty()):gt.assertNever(s);return{status:i.value,value:e.data}}_getInvalidInput(e){const n=this._getOrReturnCtx(e);return Me(n,{code:xe.invalid_type,expected:je.bigint,received:n.parsedType}),Qe}gte(e,n){return this.setLimit("min",e,!0,Pe.toString(n))}gt(e,n){return this.setLimit("min",e,!1,Pe.toString(n))}lte(e,n){return this.setLimit("max",e,!0,Pe.toString(n))}lt(e,n){return this.setLimit("max",e,!1,Pe.toString(n))}setLimit(e,n,r,i){return new Ed({...this._def,checks:[...this._def.checks,{kind:e,value:n,inclusive:r,message:Pe.toString(i)}]})}_addCheck(e){return new Ed({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Pe.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Pe.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Pe.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Pe.toString(e)})}multipleOf(e,n){return this._addCheck({kind:"multipleOf",value:e,message:Pe.toString(n)})}get minValue(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e}get maxValue(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e}}Ed.create=t=>new Ed({checks:[],typeName:et.ZodBigInt,coerce:t?.coerce??!1,...it(t)});class L0 extends ft{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==je.boolean){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.boolean,received:r.parsedType}),Qe}return Qr(e.data)}}L0.create=t=>new L0({typeName:et.ZodBoolean,coerce:t?.coerce||!1,...it(t)});class Ip extends ft{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==je.date){const s=this._getOrReturnCtx(e);return Me(s,{code:xe.invalid_type,expected:je.date,received:s.parsedType}),Qe}if(Number.isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return Me(s,{code:xe.invalid_date}),Qe}const r=new Nr;let i;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),r.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(i=this._getOrReturnCtx(e,i),Me(i,{code:xe.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),r.dirty()):gt.assertNever(s);return{status:r.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ip({...this._def,checks:[...this._def.checks,e]})}min(e,n){return this._addCheck({kind:"min",value:e.getTime(),message:Pe.toString(n)})}max(e,n){return this._addCheck({kind:"max",value:e.getTime(),message:Pe.toString(n)})}get minDate(){let e=null;for(const n of this._def.checks)n.kind==="min"&&(e===null||n.value>e)&&(e=n.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const n of this._def.checks)n.kind==="max"&&(e===null||n.value<e)&&(e=n.value);return e!=null?new Date(e):null}}Ip.create=t=>new Ip({checks:[],coerce:t?.coerce||!1,typeName:et.ZodDate,...it(t)});class b_ extends ft{_parse(e){if(this._getType(e)!==je.symbol){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.symbol,received:r.parsedType}),Qe}return Qr(e.data)}}b_.create=t=>new b_({typeName:et.ZodSymbol,...it(t)});class v_ extends ft{_parse(e){if(this._getType(e)!==je.undefined){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.undefined,received:r.parsedType}),Qe}return Qr(e.data)}}v_.create=t=>new v_({typeName:et.ZodUndefined,...it(t)});class x_ extends ft{_parse(e){if(this._getType(e)!==je.null){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.null,received:r.parsedType}),Qe}return Qr(e.data)}}x_.create=t=>new x_({typeName:et.ZodNull,...it(t)});class w_ extends ft{constructor(){super(...arguments),this._any=!0}_parse(e){return Qr(e.data)}}w_.create=t=>new w_({typeName:et.ZodAny,...it(t)});class S_ extends ft{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Qr(e.data)}}S_.create=t=>new S_({typeName:et.ZodUnknown,...it(t)});class zo extends ft{_parse(e){const n=this._getOrReturnCtx(e);return Me(n,{code:xe.invalid_type,expected:je.never,received:n.parsedType}),Qe}}zo.create=t=>new zo({typeName:et.ZodNever,...it(t)});class k_ extends ft{_parse(e){if(this._getType(e)!==je.undefined){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.void,received:r.parsedType}),Qe}return Qr(e.data)}}k_.create=t=>new k_({typeName:et.ZodVoid,...it(t)});class ji extends ft{_parse(e){const{ctx:n,status:r}=this._processInputParams(e),i=this._def;if(n.parsedType!==je.array)return Me(n,{code:xe.invalid_type,expected:je.array,received:n.parsedType}),Qe;if(i.exactLength!==null){const o=n.data.length>i.exactLength.value,l=n.data.length<i.exactLength.value;(o||l)&&(Me(n,{code:o?xe.too_big:xe.too_small,minimum:l?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),r.dirty())}if(i.minLength!==null&&n.data.length<i.minLength.value&&(Me(n,{code:xe.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),r.dirty()),i.maxLength!==null&&n.data.length>i.maxLength.value&&(Me(n,{code:xe.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),r.dirty()),n.common.async)return Promise.all([...n.data].map((o,l)=>i.type._parseAsync(new Po(n,o,n.path,l)))).then(o=>Nr.mergeArray(r,o));const s=[...n.data].map((o,l)=>i.type._parseSync(new Po(n,o,n.path,l)));return Nr.mergeArray(r,s)}get element(){return this._def.type}min(e,n){return new ji({...this._def,minLength:{value:e,message:Pe.toString(n)}})}max(e,n){return new ji({...this._def,maxLength:{value:e,message:Pe.toString(n)}})}length(e,n){return new ji({...this._def,exactLength:{value:e,message:Pe.toString(n)}})}nonempty(e){return this.min(1,e)}}ji.create=(t,e)=>new ji({type:t,minLength:null,maxLength:null,exactLength:null,typeName:et.ZodArray,...it(e)});function Xl(t){if(t instanceof un){const e={};for(const n in t.shape){const r=t.shape[n];e[n]=Mo.create(Xl(r))}return new un({...t._def,shape:()=>e})}else return t instanceof ji?new ji({...t._def,type:Xl(t.element)}):t instanceof Mo?Mo.create(Xl(t.unwrap())):t instanceof yc?yc.create(Xl(t.unwrap())):t instanceof ja?ja.create(t.items.map(e=>Xl(e))):t}class un extends ft{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),n=gt.objectKeys(e);return this._cached={shape:e,keys:n},this._cached}_parse(e){if(this._getType(e)!==je.object){const f=this._getOrReturnCtx(e);return Me(f,{code:xe.invalid_type,expected:je.object,received:f.parsedType}),Qe}const{status:r,ctx:i}=this._processInputParams(e),{shape:s,keys:o}=this._getCached(),l=[];if(!(this._def.catchall instanceof zo&&this._def.unknownKeys==="strip"))for(const f in i.data)o.includes(f)||l.push(f);const u=[];for(const f of o){const h=s[f],m=i.data[f];u.push({key:{status:"valid",value:f},value:h._parse(new Po(i,m,i.path,f)),alwaysSet:f in i.data})}if(this._def.catchall instanceof zo){const f=this._def.unknownKeys;if(f==="passthrough")for(const h of l)u.push({key:{status:"valid",value:h},value:{status:"valid",value:i.data[h]}});else if(f==="strict")l.length>0&&(Me(i,{code:xe.unrecognized_keys,keys:l}),r.dirty());else if(f!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const f=this._def.catchall;for(const h of l){const m=i.data[h];u.push({key:{status:"valid",value:h},value:f._parse(new Po(i,m,i.path,h)),alwaysSet:h in i.data})}}return i.common.async?Promise.resolve().then(async()=>{const f=[];for(const h of u){const m=await h.key,g=await h.value;f.push({key:m,value:g,alwaysSet:h.alwaysSet})}return f}).then(f=>Nr.mergeObjectSync(r,f)):Nr.mergeObjectSync(r,u)}get shape(){return this._def.shape()}strict(e){return Pe.errToObj,new un({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(n,r)=>{const i=this._def.errorMap?.(n,r).message??r.defaultError;return n.code==="unrecognized_keys"?{message:Pe.errToObj(e).message??i}:{message:i}}}:{}})}strip(){return new un({...this._def,unknownKeys:"strip"})}passthrough(){return new un({...this._def,unknownKeys:"passthrough"})}extend(e){return new un({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new un({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:et.ZodObject})}setKey(e,n){return this.augment({[e]:n})}catchall(e){return new un({...this._def,catchall:e})}pick(e){const n={};for(const r of gt.objectKeys(e))e[r]&&this.shape[r]&&(n[r]=this.shape[r]);return new un({...this._def,shape:()=>n})}omit(e){const n={};for(const r of gt.objectKeys(this.shape))e[r]||(n[r]=this.shape[r]);return new un({...this._def,shape:()=>n})}deepPartial(){return Xl(this)}partial(e){const n={};for(const r of gt.objectKeys(this.shape)){const i=this.shape[r];e&&!e[r]?n[r]=i:n[r]=i.optional()}return new un({...this._def,shape:()=>n})}required(e){const n={};for(const r of gt.objectKeys(this.shape))if(e&&!e[r])n[r]=this.shape[r];else{let s=this.shape[r];for(;s instanceof Mo;)s=s._def.innerType;n[r]=s}return new un({...this._def,shape:()=>n})}keyof(){return iO(gt.objectKeys(this.shape))}}un.create=(t,e)=>new un({shape:()=>t,unknownKeys:"strip",catchall:zo.create(),typeName:et.ZodObject,...it(e)});un.strictCreate=(t,e)=>new un({shape:()=>t,unknownKeys:"strict",catchall:zo.create(),typeName:et.ZodObject,...it(e)});un.lazycreate=(t,e)=>new un({shape:t,unknownKeys:"strip",catchall:zo.create(),typeName:et.ZodObject,...it(e)});class jp extends ft{_parse(e){const{ctx:n}=this._processInputParams(e),r=this._def.options;function i(s){for(const l of s)if(l.result.status==="valid")return l.result;for(const l of s)if(l.result.status==="dirty")return n.common.issues.push(...l.ctx.common.issues),l.result;const o=s.map(l=>new Ns(l.ctx.common.issues));return Me(n,{code:xe.invalid_union,unionErrors:o}),Qe}if(n.common.async)return Promise.all(r.map(async s=>{const o={...n,common:{...n.common,issues:[]},parent:null};return{result:await s._parseAsync({data:n.data,path:n.path,parent:o}),ctx:o}})).then(i);{let s;const o=[];for(const u of r){const f={...n,common:{...n.common,issues:[]},parent:null},h=u._parseSync({data:n.data,path:n.path,parent:f});if(h.status==="valid")return h;h.status==="dirty"&&!s&&(s={result:h,ctx:f}),f.common.issues.length&&o.push(f.common.issues)}if(s)return n.common.issues.push(...s.ctx.common.issues),s.result;const l=o.map(u=>new Ns(u));return Me(n,{code:xe.invalid_union,unionErrors:l}),Qe}}get options(){return this._def.options}}jp.create=(t,e)=>new jp({options:t,typeName:et.ZodUnion,...it(e)});function P0(t,e){const n=ho(t),r=ho(e);if(t===e)return{valid:!0,data:t};if(n===je.object&&r===je.object){const i=gt.objectKeys(e),s=gt.objectKeys(t).filter(l=>i.indexOf(l)!==-1),o={...t,...e};for(const l of s){const u=P0(t[l],e[l]);if(!u.valid)return{valid:!1};o[l]=u.data}return{valid:!0,data:o}}else if(n===je.array&&r===je.array){if(t.length!==e.length)return{valid:!1};const i=[];for(let s=0;s<t.length;s++){const o=t[s],l=e[s],u=P0(o,l);if(!u.valid)return{valid:!1};i.push(u.data)}return{valid:!0,data:i}}else return n===je.date&&r===je.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Lp extends ft{_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=(s,o)=>{if(m_(s)||m_(o))return Qe;const l=P0(s.value,o.value);return l.valid?((g_(s)||g_(o))&&n.dirty(),{status:n.value,value:l.data}):(Me(r,{code:xe.invalid_intersection_types}),Qe)};return r.common.async?Promise.all([this._def.left._parseAsync({data:r.data,path:r.path,parent:r}),this._def.right._parseAsync({data:r.data,path:r.path,parent:r})]).then(([s,o])=>i(s,o)):i(this._def.left._parseSync({data:r.data,path:r.path,parent:r}),this._def.right._parseSync({data:r.data,path:r.path,parent:r}))}}Lp.create=(t,e,n)=>new Lp({left:t,right:e,typeName:et.ZodIntersection,...it(n)});class ja extends ft{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==je.array)return Me(r,{code:xe.invalid_type,expected:je.array,received:r.parsedType}),Qe;if(r.data.length<this._def.items.length)return Me(r,{code:xe.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Qe;!this._def.rest&&r.data.length>this._def.items.length&&(Me(r,{code:xe.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());const s=[...r.data].map((o,l)=>{const u=this._def.items[l]||this._def.rest;return u?u._parse(new Po(r,o,r.path,l)):null}).filter(o=>!!o);return r.common.async?Promise.all(s).then(o=>Nr.mergeArray(n,o)):Nr.mergeArray(n,s)}get items(){return this._def.items}rest(e){return new ja({...this._def,rest:e})}}ja.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ja({items:t,typeName:et.ZodTuple,rest:null,...it(e)})};class C_ extends ft{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==je.map)return Me(r,{code:xe.invalid_type,expected:je.map,received:r.parsedType}),Qe;const i=this._def.keyType,s=this._def.valueType,o=[...r.data.entries()].map(([l,u],f)=>({key:i._parse(new Po(r,l,r.path,[f,"key"])),value:s._parse(new Po(r,u,r.path,[f,"value"]))}));if(r.common.async){const l=new Map;return Promise.resolve().then(async()=>{for(const u of o){const f=await u.key,h=await u.value;if(f.status==="aborted"||h.status==="aborted")return Qe;(f.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(f.value,h.value)}return{status:n.value,value:l}})}else{const l=new Map;for(const u of o){const f=u.key,h=u.value;if(f.status==="aborted"||h.status==="aborted")return Qe;(f.status==="dirty"||h.status==="dirty")&&n.dirty(),l.set(f.value,h.value)}return{status:n.value,value:l}}}}C_.create=(t,e,n)=>new C_({valueType:e,keyType:t,typeName:et.ZodMap,...it(n)});class Td extends ft{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.parsedType!==je.set)return Me(r,{code:xe.invalid_type,expected:je.set,received:r.parsedType}),Qe;const i=this._def;i.minSize!==null&&r.data.size<i.minSize.value&&(Me(r,{code:xe.too_small,minimum:i.minSize.value,type:"set",inclusive:!0,exact:!1,message:i.minSize.message}),n.dirty()),i.maxSize!==null&&r.data.size>i.maxSize.value&&(Me(r,{code:xe.too_big,maximum:i.maxSize.value,type:"set",inclusive:!0,exact:!1,message:i.maxSize.message}),n.dirty());const s=this._def.valueType;function o(u){const f=new Set;for(const h of u){if(h.status==="aborted")return Qe;h.status==="dirty"&&n.dirty(),f.add(h.value)}return{status:n.value,value:f}}const l=[...r.data.values()].map((u,f)=>s._parse(new Po(r,u,r.path,f)));return r.common.async?Promise.all(l).then(u=>o(u)):o(l)}min(e,n){return new Td({...this._def,minSize:{value:e,message:Pe.toString(n)}})}max(e,n){return new Td({...this._def,maxSize:{value:e,message:Pe.toString(n)}})}size(e,n){return this.min(e,n).max(e,n)}nonempty(e){return this.min(1,e)}}Td.create=(t,e)=>new Td({valueType:t,minSize:null,maxSize:null,typeName:et.ZodSet,...it(e)});class E_ extends ft{get schema(){return this._def.getter()}_parse(e){const{ctx:n}=this._processInputParams(e);return this._def.getter()._parse({data:n.data,path:n.path,parent:n})}}E_.create=(t,e)=>new E_({getter:t,typeName:et.ZodLazy,...it(e)});class T_ extends ft{_parse(e){if(e.data!==this._def.value){const n=this._getOrReturnCtx(e);return Me(n,{received:n.data,code:xe.invalid_literal,expected:this._def.value}),Qe}return{status:"valid",value:e.data}}get value(){return this._def.value}}T_.create=(t,e)=>new T_({value:t,typeName:et.ZodLiteral,...it(e)});function iO(t,e){return new mc({values:t,typeName:et.ZodEnum,...it(e)})}class mc extends ft{_parse(e){if(typeof e.data!="string"){const n=this._getOrReturnCtx(e),r=this._def.values;return Me(n,{expected:gt.joinValues(r),received:n.parsedType,code:xe.invalid_type}),Qe}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const n=this._getOrReturnCtx(e),r=this._def.values;return Me(n,{received:n.data,code:xe.invalid_enum_value,options:r}),Qe}return Qr(e.data)}get options(){return this._def.values}get enum(){const e={};for(const n of this._def.values)e[n]=n;return e}get Values(){const e={};for(const n of this._def.values)e[n]=n;return e}get Enum(){const e={};for(const n of this._def.values)e[n]=n;return e}extract(e,n=this._def){return mc.create(e,{...this._def,...n})}exclude(e,n=this._def){return mc.create(this.options.filter(r=>!e.includes(r)),{...this._def,...n})}}mc.create=iO;class __ extends ft{_parse(e){const n=gt.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==je.string&&r.parsedType!==je.number){const i=gt.objectValues(n);return Me(r,{expected:gt.joinValues(i),received:r.parsedType,code:xe.invalid_type}),Qe}if(this._cache||(this._cache=new Set(gt.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const i=gt.objectValues(n);return Me(r,{received:r.data,code:xe.invalid_enum_value,options:i}),Qe}return Qr(e.data)}get enum(){return this._def.values}}__.create=(t,e)=>new __({values:t,typeName:et.ZodNativeEnum,...it(e)});class Pp extends ft{unwrap(){return this._def.type}_parse(e){const{ctx:n}=this._processInputParams(e);if(n.parsedType!==je.promise&&n.common.async===!1)return Me(n,{code:xe.invalid_type,expected:je.promise,received:n.parsedType}),Qe;const r=n.parsedType===je.promise?n.data:Promise.resolve(n.data);return Qr(r.then(i=>this._def.type.parseAsync(i,{path:n.path,errorMap:n.common.contextualErrorMap})))}}Pp.create=(t,e)=>new Pp({type:t,typeName:et.ZodPromise,...it(e)});class gc extends ft{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===et.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:n,ctx:r}=this._processInputParams(e),i=this._def.effect||null,s={addIssue:o=>{Me(r,o),o.fatal?n.abort():n.dirty()},get path(){return r.path}};if(s.addIssue=s.addIssue.bind(s),i.type==="preprocess"){const o=i.transform(r.data,s);if(r.common.async)return Promise.resolve(o).then(async l=>{if(n.value==="aborted")return Qe;const u=await this._def.schema._parseAsync({data:l,path:r.path,parent:r});return u.status==="aborted"?Qe:u.status==="dirty"||n.value==="dirty"?Gu(u.value):u});{if(n.value==="aborted")return Qe;const l=this._def.schema._parseSync({data:o,path:r.path,parent:r});return l.status==="aborted"?Qe:l.status==="dirty"||n.value==="dirty"?Gu(l.value):l}}if(i.type==="refinement"){const o=l=>{const u=i.refinement(l,s);if(r.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return l};if(r.common.async===!1){const l=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});return l.status==="aborted"?Qe:(l.status==="dirty"&&n.dirty(),o(l.value),{status:n.value,value:l.value})}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(l=>l.status==="aborted"?Qe:(l.status==="dirty"&&n.dirty(),o(l.value).then(()=>({status:n.value,value:l.value}))))}if(i.type==="transform")if(r.common.async===!1){const o=this._def.schema._parseSync({data:r.data,path:r.path,parent:r});if(!hc(o))return Qe;const l=i.transform(o.value,s);if(l instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:l}}else return this._def.schema._parseAsync({data:r.data,path:r.path,parent:r}).then(o=>hc(o)?Promise.resolve(i.transform(o.value,s)).then(l=>({status:n.value,value:l})):Qe);gt.assertNever(i)}}gc.create=(t,e,n)=>new gc({schema:t,typeName:et.ZodEffects,effect:e,...it(n)});gc.createWithPreprocess=(t,e,n)=>new gc({schema:e,effect:{type:"preprocess",transform:t},typeName:et.ZodEffects,...it(n)});class Mo extends ft{_parse(e){return this._getType(e)===je.undefined?Qr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Mo.create=(t,e)=>new Mo({innerType:t,typeName:et.ZodOptional,...it(e)});class yc extends ft{_parse(e){return this._getType(e)===je.null?Qr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}yc.create=(t,e)=>new yc({innerType:t,typeName:et.ZodNullable,...it(e)});class z0 extends ft{_parse(e){const{ctx:n}=this._processInputParams(e);let r=n.data;return n.parsedType===je.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:n.path,parent:n})}removeDefault(){return this._def.innerType}}z0.create=(t,e)=>new z0({innerType:t,typeName:et.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...it(e)});class $0 extends ft{_parse(e){const{ctx:n}=this._processInputParams(e),r={...n,common:{...n.common,issues:[]}},i=this._def.innerType._parse({data:r.data,path:r.path,parent:{...r}});return Dp(i)?i.then(s=>({status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ns(r.common.issues)},input:r.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new Ns(r.common.issues)},input:r.data})}}removeCatch(){return this._def.innerType}}$0.create=(t,e)=>new $0({innerType:t,typeName:et.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...it(e)});class A_ extends ft{_parse(e){if(this._getType(e)!==je.nan){const r=this._getOrReturnCtx(e);return Me(r,{code:xe.invalid_type,expected:je.nan,received:r.parsedType}),Qe}return{status:"valid",value:e.data}}}A_.create=t=>new A_({typeName:et.ZodNaN,...it(t)});class OU extends ft{_parse(e){const{ctx:n}=this._processInputParams(e),r=n.data;return this._def.type._parse({data:r,path:n.path,parent:n})}unwrap(){return this._def.type}}class _w extends ft{_parse(e){const{status:n,ctx:r}=this._processInputParams(e);if(r.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:r.data,path:r.path,parent:r});return s.status==="aborted"?Qe:s.status==="dirty"?(n.dirty(),Gu(s.value)):this._def.out._parseAsync({data:s.value,path:r.path,parent:r})})();{const i=this._def.in._parseSync({data:r.data,path:r.path,parent:r});return i.status==="aborted"?Qe:i.status==="dirty"?(n.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:r.path,parent:r})}}static create(e,n){return new _w({in:e,out:n,typeName:et.ZodPipeline})}}class B0 extends ft{_parse(e){const n=this._def.innerType._parse(e),r=i=>(hc(i)&&(i.value=Object.freeze(i.value)),i);return Dp(n)?n.then(i=>r(i)):r(n)}unwrap(){return this._def.innerType}}B0.create=(t,e)=>new B0({innerType:t,typeName:et.ZodReadonly,...it(e)});var et;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(et||(et={}));const R_=Co.create,DU=pc.create,IU=L0.create;zo.create;const jU=ji.create,LU=un.create;jp.create;Lp.create;ja.create;mc.create;Pp.create;Mo.create;yc.create;function PU(t){const e={};for(const[n,r]of Object.entries(t)){let i;switch(r.type){case"number":i=DU(),r.min!=null&&(i=i.min(r.min)),r.max!=null&&(i=i.max(r.max));break;case"boolean":i=IU();break;case"file[]":case"enum[]":i=jU(R_());break;default:i=R_()}r.required||(i=i.optional()),e[n]=i}return LU(e)}function Zm(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function id(t,e){const n=e?.optionLabels?.[t]?.trim();return n||Zm(t)}function zU(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $U(t,e,n){const r=e.label?.trim()||Zm(t),i=r.replace(new RegExp(`^${zU(n)}\\s+`,"i"),"");if(/^inventory$/i.test(n)){const s=r.replace(/^stock\s+/i,"").trim();if(s&&s!==r)return s}return/^pricing$/i.test(n)&&/cents/i.test(r)?r.replace(/\s*\(cents\)/i,"").trim()||r:i||r}const BU=/(description|body|content|summary|bio|copy|caption|details)/i;function sO(t,e){if(e?.type==="richtext")return!0;const n=`${t} ${e?.label??""}`;return BU.test(n)}function M_(t){const e=typeof t=="string"?t.trim():"";return e?{characters:e.length,words:e.split(/\s+/).filter(Boolean).length}:{characters:0,words:0}}function _d(t){return/^https?:\/\//i.test(t)||t.startsWith("//")}function La(t,e){if(e?.type==="file[]")return!0;const n=`${t} ${e?.label??""}`;return/(image|img|photo|avatar|thumbnail|thumb|cover)/i.test(n)}function oO(t){if(typeof t=="string"&&_d(t))return{url:t};if(t&&typeof t=="object"&&"url"in t){const e=t.url,n=t.name;if(typeof e=="string"&&_d(e))return{url:e,name:typeof n=="string"?n:void 0}}return null}function VU(t,e){const n=[];for(const[r,i]of Object.entries(t)){if(!La(r,i))continue;const s=i.label?.trim()||r,o=e?.[r],l=Array.isArray(o)?o:[o];l.forEach((u,f)=>{const h=oO(u);h&&n.push({id:`${r}:${f}`,url:h.url,name:h.name||(l.length>1?`${s} ${f+1}`:s),field:r})})}return n}function V0(t){const e=Array.isArray(t)?t:t==null||t===""?[]:[t],n=[];for(const r of e){const i=oO(r);i&&n.push(i.url)}return n}function HU(t){return t.length>0&&t.every(([,e])=>e.type==="boolean")}function UU(t,e){const n=`${t} ${e?.label??""}`;return/(stock|inventory|qty|quantity)/i.test(n)}function Ym(t,e){if(/^show[A-Z]/.test(t))return!1;if(/^specs$/i.test(e?.group??""))return!0;const n=`${t} ${e?.label??""}`;return/(material|fit|care|fabric|composition|^details$)/i.test(n)}function aO(t,e){const n=`${t} ${e?.label??""}`;return/(detail|notes|bio|bullets|body|message|html)/i.test(n)}function FU(t,e,n){if(e.type==="boolean"||e.type==="enum[]"||e.type==="richtext"||sO(t,e)||aO(t,e)||n==="record"&&La(t,e))return"full"}function Aw(t){return`show${t.charAt(0).toUpperCase()}${t.slice(1)}`}function qU(t){const e={...t};for(const[n,r]of Object.entries(t)){if(r.type==="boolean"||!Ym(n,r))continue;const i=Aw(n);e[i]||(e[i]={type:"boolean",default:!0,label:`Show ${r.label??Zm(n)}`})}return e}function GU(t,e){const n={...e};for(const[r,i]of Object.entries(t)){if(i.type==="boolean"||!Ym(r,i))continue;const s=Aw(r);!(s in n)||n[s]==null?n[s]=!0:n[s]=n[s]!==!1}return n}function WU(t){return t.charAt(0).toLowerCase()+t.slice(1)}function KU(t,e){const n=Aw(t),r=[n];t==="priceCents"&&r.push("showPrice");for(const i of r)if(e[i]?.type==="boolean")return i;return Ym(t,e[t])?n:null}const H0={Pricing:"showPrice",Inventory:"showStock",Content:"showDescription"};function ZU(t){return Object.keys(H0).find(e=>H0[e]===t)}function YU(t,e){if(!/^show[A-Z]/.test(t)||e[t]?.type!=="boolean")return!1;if(ZU(t))return!0;const n=WU(t.slice(4));return e[n]?!0:t==="showPrice"&&!!e.priceCents}function Rw(t,e){const n=H0[t];return n&&e[n]?.type==="boolean"?n:null}function XU(t,e,n){const r=KU(t,e);return!r||n&&Rw(n,e)===r?null:r}const N_=["Details","Content","Specs","Pricing","Inventory","Media","Display","Status"];function JU(t,e){if(e.group?.trim())return e.group.trim();const r=(e.label?.trim()||Zm(t)).split(/\s+/).filter(Boolean);return r.length>=2?r[0]:"General"}function QU(t,e){if(e.group?.trim())return e.group.trim();const n=t.toLowerCase(),r=(e.label??"").toLowerCase(),i=`${n} ${r}`;return/(image|img|photo|avatar|thumbnail|thumb|cover|media_url)/i.test(i)?"Media":/(price|cost|cents|amount|msrp)/i.test(i)?"Pricing":/(stock|inventory|qty|quantity)/i.test(i)?"Inventory":/^display$/i.test(e.group??"")||/^show[A-Z]/.test(t)?"Display":e.type==="boolean"||/(^|_)(active|enabled|published|status|visible)(_|$)/i.test(n)||/^(active|enabled|published|status|visible)$/i.test(r)?"Status":e.type==="richtext"||/(description|body|content|summary|bio)/i.test(i)?"Content":Ym(t,e)?"Specs":"Details"}function eF(t,e){if(e!=="record")return t;const n=r=>{const i=N_.indexOf(r);return i===-1?N_.length+1:i};return[...t].sort((r,i)=>n(r.id)-n(i.id))}function tF(t,e){const n=[],r=new Map,i=new Set;for(const o of Object.entries(t)){const[l,u]=o;if(YU(l,t))continue;const f=e==="record"?QU(l,u):JU(l,u);u.group?.trim()&&i.add(f),r.has(f)||(r.set(f,[]),n.push(f)),r.get(f).push(o)}if(e==="config")for(const[o,l]of[...r.entries()]){if(l.length>1||i.has(o)||o==="General")continue;r.has("General")||(r.set("General",[]),n.unshift("General")),r.get("General").push(...l),r.delete(o);const u=n.indexOf(o);u>=0&&n.splice(u,1)}const s=n.filter(o=>r.has(o)).map(o=>({id:o,label:o,fields:r.get(o)}));return eF(s,e)}function zp(t){const e=Array.isArray(t)?t:[t];for(const n of e){if(typeof n=="string"&&_d(n))return n;if(n&&typeof n=="object"&&"url"in n){const r=n.url;if(typeof r=="string"&&_d(r))return r}}return null}function nF(t,e){for(const[n,r]of Object.entries(t))if(La(n,r)&&zp(e?.[n]))return n;for(const[n,r]of Object.entries(t))if(La(n,r))return n;return null}function rF(t){return t.join(",")}function Nc({meta:t,disabled:e,multiple:n=!1,label:r,onUpload:i}){const s=E.useRef(null),[o,l]=E.useState(!1),[u,f]=E.useState(null),[h,m]=E.useState(!1),g=async b=>{if(!b||e||o)return;const x=Array.from(b);if(x.length){l(!0),f(null);try{await i(n?x:x.slice(0,1))}catch(S){f(S instanceof Error?S.message:"Upload failed")}finally{l(!1),s.current&&(s.current.value="")}}};return y.jsxs("div",{className:"vertebr-upload",children:[y.jsxs("div",{className:"vertebr-upload-drop","data-busy":o?"true":void 0,"data-drag":h?"true":void 0,onDragEnter:b=>{b.preventDefault(),m(!0)},onDragOver:b=>{b.preventDefault(),m(!0)},onDragLeave:b=>{b.preventDefault(),m(!1)},onDrop:b=>{b.preventDefault(),m(!1),g(b.dataTransfer.files)},children:[y.jsx("p",{className:"vertebr-upload-copy",children:o?"Uploading…":r??(n?"Drop images here or browse":"Drop an image here or browse")}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:e||o,onClick:()=>s.current?.click(),children:n?"Choose images":"Choose image"}),y.jsx("input",{ref:s,type:"file",accept:rF(t.accept),multiple:n,hidden:!0,onChange:b=>{g(b.target.files)}})]}),u?y.jsx("p",{className:"vertebr-upload-error",role:"alert",children:u}):null]})}var Oc=_M();const iF=TM(Oc);var sF=Object.defineProperty,Mw=(t,e)=>sF(t,"name",{value:e,configurable:!0});function U0(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Mw(U0,"setRef");function lO(...t){return e=>{let n=!1;const r=t.map(i=>{const s=U0(i,e);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():U0(t[i],null)}}}}Mw(lO,"composeRefs");function rn(...t){return E.useCallback(lO(...t),t)}Mw(rn,"useComposedRefs");var oF=Object.defineProperty,bi=(t,e)=>oF(t,"name",{value:e,configurable:!0});function Pa(t){const e=E.forwardRef((n,r)=>{let{children:i,...s}=n,o=null,l=!1;const u=[];F0(i)&&typeof Ch=="function"&&(i=Ch(i._payload)),E.Children.forEach(i,g=>{if(fO(g)){l=!0;const b=g;let x="child"in b.props?b.props.child:b.props.children;F0(x)&&typeof Ch=="function"&&(x=Ch(x._payload)),o=lF(b,x),u.push(o?.props?.children)}else u.push(g)}),o?o=E.cloneElement(o,void 0,u):!l&&E.Children.count(i)===1&&E.isValidElement(i)&&(o=i);const f=o?dO(o):void 0,h=rn(r,f);if(!o){if(i||i===0)throw new Error(l?dF(t):uF(t));return i}const m=uO(s,o.props??{});return o.type!==E.Fragment&&(m.ref=r?h:f),E.cloneElement(o,m)});return e.displayName=`${t}.Slot`,e}bi(Pa,"createSlot");var cO=Symbol.for("radix.slottable");function aF(t){const e=bi(n=>"child"in n?n.children(n.child):n.children,"Slottable");return e.displayName=`${t}.Slottable`,e.__radixId=cO,e}bi(aF,"createSlottable");var lF=bi((t,e)=>{if("child"in t.props){const n=t.props.child;return E.isValidElement(n)?E.cloneElement(n,void 0,t.props.children(n.props.children)):null}return E.isValidElement(e)?e:null},"getSlottableElementFromSlottable");function uO(t,e){const n={...e};for(const r in e){const i=t[r],s=e[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...l)=>{const u=s(...l);return i(...l),u}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...t,...n}}bi(uO,"mergeProps");function dO(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}bi(dO,"getElementRef");function fO(t){return E.isValidElement(t)&&typeof t.type=="function"&&"__radixId"in t.type&&t.type.__radixId===cO}bi(fO,"isSlottable");var cF=Symbol.for("react.lazy");function F0(t){return t!=null&&typeof t=="object"&&"$$typeof"in t&&t.$$typeof===cF&&"_payload"in t&&hO(t._payload)}bi(F0,"isLazyComponent");function hO(t){return typeof t=="object"&&t!==null&&"then"in t}bi(hO,"isPromiseLike");var uF=bi(t=>`${t} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,"createSlotError"),dF=bi(t=>`${t} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,"createSlottableError"),Ch=Hd[" use ".trim().toString()],fF=Object.defineProperty,hF=(t,e)=>fF(t,"name",{value:e,configurable:!0}),pF=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],En=pF.reduce((t,e)=>{const n=Pa(`Primitive.${e}`),r=E.forwardRef((i,s)=>{const{asChild:o,...l}=i,u=o?n:e;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),y.jsx(u,{...l,ref:s})});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});function pO(t,e){t&&Oc.flushSync(()=>t.dispatchEvent(e))}hF(pO,"dispatchDiscreteCustomEvent");var mF=Object.defineProperty,gF=(t,e)=>mF(t,"name",{value:e,configurable:!0}),yF=E.forwardRef(gF(function(e,n){return y.jsx(En.label,{...e,ref:n,onMouseDown:r=>{r.target.closest("button, input, select, textarea")||(e.onMouseDown?.(r),!r.defaultPrevented&&r.detail>1&&r.preventDefault())}})},"Label")),fv=yF,bF=Object.defineProperty,Dc=(t,e)=>bF(t,"name",{value:e,configurable:!0}),mO=!!(typeof window<"u"&&window.document&&window.document.createElement);function dn(t,e,{checkForDefaultPrevented:n=!0}={}){return Dc(function(i){if(t?.(i),n===!1||!i||!i.defaultPrevented)return e?.(i)},"handleEvent")}Dc(dn,"composeEventHandlers");function vF(t){if(!mO)throw new Error("Cannot access window outside of the DOM");return t?.ownerDocument?.defaultView??window}Dc(vF,"getOwnerWindow");function q0(t){if(!mO)throw new Error("Cannot access document outside of the DOM");return t?.ownerDocument??document}Dc(q0,"getOwnerDocument");function gO(t,e=!1){const{activeElement:n}=q0(t);if(!n?.nodeName)return null;if(yO(n)&&n.contentDocument)return gO(n.contentDocument.body,e);if(e){const r=n.getAttribute("aria-activedescendant");if(r){const i=q0(n).getElementById(r);if(i)return i}}return n}Dc(gO,"getActiveElement");function yO(t){return t.tagName==="IFRAME"}Dc(yO,"isFrame");var xF=Object.defineProperty,Kr=(t,e)=>xF(t,"name",{value:e,configurable:!0});function wF(t,e){const n=E.createContext(e);n.displayName=t+"Context";const r=Kr(s=>{const{children:o,...l}=s,u=E.useMemo(()=>l,Object.values(l));return y.jsx(n.Provider,{value:u,children:o})},"Provider");r.displayName=t+"Provider";function i(s,o={}){const{optional:l=!1}=o,u=E.useContext(n);if(u)return u;if(e!==void 0)return e;if(!l)throw new Error(`\`${s}\` must be used within \`${t}\``)}return Kr(i,"useContext"),[r,i]}Kr(wF,"createContext");function Ic(t,e=[]){let n=[];function r(s,o){const l=E.createContext(o);l.displayName=s+"Context";const u=n.length;n=[...n,o];const f=Kr(m=>{const{scope:g,children:b,...x}=m,S=g?.[t]?.[u]||l,k=E.useMemo(()=>x,Object.values(x));return y.jsx(S.Provider,{value:k,children:b})},"Provider");f.displayName=s+"Provider";function h(m,g,b={}){const{optional:x=!1}=b,S=g?.[t]?.[u]||l,k=E.useContext(S);if(k)return k;if(o!==void 0)return o;if(!x)throw new Error(`\`${m}\` must be used within \`${s}\``)}return Kr(h,"useContext"),[f,h]}Kr(r,"createContext");const i=Kr(()=>{const s=n.map(o=>E.createContext(o));return Kr(function(l){const u=l?.[t]||s;return E.useMemo(()=>({[`__scope${t}`]:{...l,[t]:u}}),[l,u])},"useScope")},"createScope");return i.scopeName=t,[r,bO(i,...e)]}Kr(Ic,"createContextScope");function bO(...t){const e=t[0];if(t.length===1)return e;const n=Kr(()=>{const r=t.map(i=>({useScope:i(),scopeName:i.scopeName}));return Kr(function(s){const o=r.reduce((l,{useScope:u,scopeName:f})=>{const m=u(s)[`__scope${f}`];return{...l,...m}},{});return E.useMemo(()=>({[`__scope${e.scopeName}`]:o}),[o])},"useComposedScopes")},"createScope");return n.scopeName=e.scopeName,n}Kr(bO,"composeContextScopes");var tr=globalThis?.document?E.useLayoutEffect:()=>{},SF=Object.defineProperty,kF=(t,e)=>SF(t,"name",{value:e,configurable:!0}),O_=Hd[" useEffectEvent ".trim().toString()],D_=Hd[" useInsertionEffect ".trim().toString()];function vO(t){if(typeof O_=="function")return O_(t);const e=E.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof D_=="function"?D_(()=>{e.current=t}):tr(()=>{e.current=t}),E.useMemo(()=>((...n)=>e.current?.(...n)),[])}kF(vO,"useEffectEvent");var CF=Object.defineProperty,Jd=(t,e)=>CF(t,"name",{value:e,configurable:!0}),EF=Hd[" useInsertionEffect ".trim().toString()]||tr;function $p({prop:t,defaultProp:e,onChange:n=Jd(()=>{},"onChange"),caller:r}){const[i,s,o]=xO({defaultProp:e,onChange:n}),l=t!==void 0,u=l?t:i,f=E.useCallback(h=>{if(l){const m=wO(h)?h(t):h;m!==t&&o.current?.(m)}else s(h)},[l,t,s,o]);return[u,f]}Jd($p,"useControllableState");function xO({defaultProp:t,onChange:e}){const[n,r]=E.useState(t),i=E.useRef(n),s=E.useRef(e);return EF(()=>{s.current=e},[e]),E.useEffect(()=>{i.current!==n&&(s.current?.(n),i.current=n)},[n,i]),[n,r,s]}Jd(xO,"useUncontrolledState");function wO(t){return typeof t=="function"}Jd(wO,"isFunction");var I_=Symbol("RADIX:SYNC_STATE");function TF(t,e,n,r){const{prop:i,defaultProp:s,onChange:o,caller:l}=e,u=i!==void 0,f=vO(o),h=[{...n,state:s}];r&&h.push(r);const[m,g]=E.useReducer((k,C)=>{if(C.type===I_)return{...k,state:C.state};const A=t(k,C);return u&&!Object.is(A.state,k.state)&&f(A.state),A},...h),b=m.state,x=E.useRef(b);E.useEffect(()=>{x.current!==b&&(x.current=b,u||f(b))},[b,x,u]);const S=E.useMemo(()=>i!==void 0?{...m,state:i}:m,[m,i]);return E.useEffect(()=>{u&&!Object.is(i,m.state)&&g({type:I_,state:i})},[i,m.state,u]),[S,g]}Jd(TF,"useControllableStateReducer");var _F=Object.defineProperty,AF=(t,e)=>_F(t,"name",{value:e,configurable:!0});function Nw(t){const[e,n]=E.useState(void 0);return tr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,l;if("borderBoxSize"in s){const u=s.borderBoxSize,f=Array.isArray(u)?u[0]:u;o=f.inlineSize,l=f.blockSize}else o=t.offsetWidth,l=t.offsetHeight;n({width:o,height:l})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}AF(Nw,"useSize");var RF=Object.defineProperty,$o=(t,e)=>RF(t,"name",{value:e,configurable:!0}),Ow="Switch",[MF,Fte]=Ic(Ow),[NF,Dw]=MF(Ow);function SO(t){const{__scopeSwitch:e,checked:n,children:r,defaultChecked:i,disabled:s,form:o,name:l,onCheckedChange:u,required:f,value:h="on",internal_do_not_use_render:m}=t,[g,b]=$p({prop:n,defaultProp:i??!1,onChange:u,caller:Ow}),[x,S]=E.useState(null),[k,C]=E.useState(null),A=E.useRef(!1),[R,_]=E.useReducer(D=>D+1,0),M=x?!!o||!!x.closest("form"):!0,O={checked:g,setChecked:b,disabled:s,control:x,setControl:S,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:A,userInteractionCount:R,onUserInteraction:_,required:f,defaultChecked:i,isFormControl:M,bubbleInput:k,setBubbleInput:C};return y.jsx(NF,{scope:e,...O,children:kO(m)?m(O):r})}$o(SO,"SwitchProvider");var OF="SwitchTrigger",DF=E.forwardRef($o(function({__scopeSwitch:e,onClick:n,...r},i){const{control:s,form:o,value:l,disabled:u,checked:f,required:h,setControl:m,setChecked:g,hasConsumerStoppedPropagationRef:b,onUserInteraction:x,isFormControl:S,bubbleInput:k}=Dw(OF,e),C=rn(i,m),A=E.useRef(f);return E.useEffect(()=>{const R=o?s?.ownerDocument.getElementById(o):s?.form;if(R instanceof HTMLFormElement){const _=$o(()=>g(A.current),"reset");return R.addEventListener("reset",_),()=>R.removeEventListener("reset",_)}},[s,o,g]),y.jsx(En.button,{type:"button",role:"switch","aria-checked":f,"aria-required":h,"data-state":Iw(f),"data-disabled":u?"":void 0,disabled:u,value:l,...r,ref:C,onClick:dn(n,R=>{x(),g(_=>!_),k&&S&&(b.current=R.isPropagationStopped(),b.current||R.stopPropagation())})})},"SwitchTrigger")),j_=E.forwardRef($o(function(e,n){const{__scopeSwitch:r,name:i,checked:s,defaultChecked:o,required:l,disabled:u,value:f,onCheckedChange:h,form:m,...g}=e;return y.jsx(SO,{__scopeSwitch:r,checked:s,defaultChecked:o,disabled:u,required:l,onCheckedChange:h,name:i,form:m,value:f,internal_do_not_use_render:({isFormControl:b})=>y.jsxs(y.Fragment,{children:[y.jsx(DF,{...g,ref:n,__scopeSwitch:r}),b&&y.jsx(LF,{__scopeSwitch:r})]})})},"Switch")),IF="SwitchThumb",L_=E.forwardRef($o(function(e,n){const{__scopeSwitch:r,...i}=e,s=Dw(IF,r);return y.jsx(En.span,{"data-state":Iw(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:n})},"SwitchThumb")),jF="SwitchBubbleInput",LF=E.forwardRef($o(function({__scopeSwitch:e,onClick:n,...r},i){const{control:s,hasConsumerStoppedPropagationRef:o,userInteractionCount:l,checked:u,defaultChecked:f,required:h,disabled:m,name:g,value:b,form:x,bubbleInput:S,setBubbleInput:k}=Dw(jF,e),C=rn(i,k),A=Nw(s),R=E.useRef(!1),_=E.useRef(u),M=E.useRef(l);E.useEffect(()=>{const D=S;if(!D)return;const I=window.HTMLInputElement.prototype,B=Object.getOwnPropertyDescriptor(I,"checked").set,re=l!==M.current;M.current=l;const K=_.current!==u;_.current=u;const ee=!(re&&o.current);if(K&&B){R.current=!re;const Q=new Event("click",{bubbles:ee});B.call(D,u),D.dispatchEvent(Q),R.current=!1}},[S,u,o,l]);const O=E.useRef(u);return y.jsx(En.input,{type:"checkbox","aria-hidden":!0,defaultChecked:f??O.current,required:h,disabled:m,name:g,value:b,form:x,...r,tabIndex:-1,ref:C,onClick:dn(n,D=>{R.current&&D.stopPropagation()}),style:{...r.style,...A,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function kO(t){return typeof t=="function"}$o(kO,"isFunction");function Iw(t){return t?"checked":"unchecked"}$o(Iw,"getState");function CO({name:t,label:e,form:n}){const r=n.watch(t)!==!1;return E.useEffect(()=>{n.register(t)},[n,t]),y.jsx(EO,{visible:r,label:e,onChange:i=>n.setValue(t,i,{shouldDirty:!0,shouldTouch:!0})})}function EO({visible:t,label:e,dirty:n,disabled:r,onChange:i}){return y.jsx("button",{type:"button",className:"vertebr-visibility-btn","data-dirty":n?"true":void 0,"aria-pressed":t,"aria-label":t?`Hide ${e} on storefront`:`Show ${e} on storefront`,title:t?"Visible on storefront":"Hidden on storefront",disabled:r,onClick:s=>{s.stopPropagation(),i(!t)},children:t?y.jsx(PF,{}):y.jsx(zF,{})})}function PF(){return y.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0"}),y.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function zF(){return y.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49"}),y.jsx("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),y.jsx("path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143"}),y.jsx("path",{d:"m2 2 20 20"})]})}const $F=/(cents|priceCents|amountCents)/i,P_=/(price|amount|cost|total|msrp)/i;function jw(t,e){return $F.test(t)||/cents/i.test(e?.label??"")}function TO(t,e){return jw(t,e)?!0:P_.test(t)||P_.test(e?.label??"")}function _O(t,e){return e?t/100:t}function BF(t,e){return e?Math.round(t*100):t}function G0(t,e){const n=e?.asCents??!0,r=e?.currency??"USD",i=_O(t,n);try{return new Intl.NumberFormat(void 0,{style:"currency",currency:r,minimumFractionDigits:2,maximumFractionDigits:2}).format(i)}catch{return`$${i.toFixed(2)}`}}function hv(t,e=!0){return typeof t!="number"||!Number.isFinite(t)?"":_O(t,e).toFixed(2)}function VF(t,e=!0){const n=t.replace(/[^0-9.-]/g,"");if(!n||n==="-"||n==="."||n==="-.")return;const r=Number(n);if(Number.isFinite(r))return BF(r,e)}function up({family:t,bodyWeight:e=400,headingWeight:n=700,compact:r=!1}){const i=`"${t.replace(/"/g,"")}", ui-sans-serif, sans-serif`,s={fontFamily:i,fontWeight:n},o={fontFamily:i,fontWeight:e};return y.jsxs("div",{className:"vertebr-font-preview-sample","data-compact":r?"true":void 0,children:[y.jsx("span",{className:"vertebr-font-preview-eyebrow",style:s,children:"Eyebrow label"}),y.jsx("strong",{className:"vertebr-font-preview-heading",style:s,children:"The quick brown fox"}),y.jsx("p",{className:"vertebr-font-preview-body",style:o,children:"Jumps over the lazy dog. Maxer Mentality essentials for people who hold the standard."}),r?null:y.jsxs(y.Fragment,{children:[y.jsxs("p",{className:"vertebr-font-preview-alphabet",style:o,children:["ABCDEFGHIJKLMNOPQRSTUVWXYZ",y.jsx("br",{}),"abcdefghijklmnopqrstuvwxyz",y.jsx("br",{}),"0123456789"]}),y.jsxs("div",{className:"vertebr-font-preview-weights",style:o,children:[y.jsx("span",{style:{fontWeight:400},children:"Regular 400"}),y.jsx("span",{style:{fontWeight:600},children:"Semibold 600"}),y.jsx("span",{style:{fontWeight:700},children:"Bold 700"})]})]})]})}function AO({items:t,apiBase:e="/admin/api"}){const n=E.useId().replace(/:/g,""),r=E.useMemo(()=>AH(t,e),[t,e]);return E.useEffect(()=>{const i=r.map(l=>LN(l)).join("");if(!i)return;const s=i.match(/url\("([^"]+)"\)/)?.[1]??null;console.info("[mm:fonts] FontFaceInjector",{items:r.length,cssRules:(i.match(/@font-face/g)??[]).length,apiBase:e,sampleUrl:s,usesFirebase:i.includes("firebasestorage.googleapis.com")});const o=document.createElement("style");return o.id=`vertebr-font-faces-${n}`,o.textContent=i,document.head.appendChild(o),()=>{o.remove()}},[r,n]),null}function Lu(t,e){return t?e==="heading"?t.files.find(n=>n.weight>=600)?.weight??700:t.files.find(n=>n.weight>=400&&n.weight<600)?.weight??400:e==="heading"?700:400}function HF({id:t,value:e,label:n,description:r,readOnly:i,fonts:s,loading:o,onChange:l,onRefreshFonts:u,fontApiBase:f="/admin/api"}){const[h,m]=E.useState(!1),[g,b]=E.useState(""),x=E.useRef(""),S=typeof e=="string"?e.trim():"";E.useEffect(()=>{h&&u&&u()},[h,u]),E.useEffect(()=>{h&&(x.current=S,b(S))},[h,S]);const k=(_=!1)=>{_&&g!==x.current&&l(x.current),m(!1)},C=_=>{b(_),l(_)},A=E.useMemo(()=>s.find(_=>_.id===S)??null,[s,S]),R=E.useMemo(()=>g===""?null:s.find(_=>_.id===g)??null,[s,g]);return y.jsxs("div",{className:"vertebr-font-picker",children:[y.jsx(AO,{items:s,apiBase:f}),y.jsxs("div",{className:"vertebr-font-picker-current",children:[y.jsxs("div",{children:[y.jsx("strong",{children:A?.label??"Default system fonts"}),A?y.jsx("span",{children:A.family}):y.jsx("span",{children:"Manrope / Syne until a library font is chosen"})]}),i?y.jsx("span",{id:t,className:"vertebr-font-picker-ro-anchor"}):y.jsx("button",{id:t,type:"button",className:"vertebr-btn",onClick:()=>m(!0),children:"Choose font"})]}),A?y.jsx("div",{className:"vertebr-font-picker-preview",children:y.jsx(up,{family:A.family,bodyWeight:Lu(A,"body"),headingWeight:Lu(A,"heading"),compact:!0})}):null,h?y.jsx("div",{className:"vertebr-font-picker-modal-backdrop",onClick:()=>k(!0),children:y.jsxs("div",{className:"vertebr-font-picker-modal",role:"dialog","aria-labelledby":`${t}-font-picker-title`,onClick:_=>_.stopPropagation(),children:[y.jsxs("div",{className:"vertebr-font-picker-modal-head",children:[y.jsxs("div",{children:[y.jsx("h3",{id:`${t}-font-picker-title`,children:n??"Choose a font"}),r?y.jsx("p",{children:r}):null]}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>k(!0),children:"Close"})]}),o?y.jsx("div",{className:"vertebr-empty",children:"Loading fonts…"}):s.length===0?y.jsx("div",{className:"vertebr-empty",children:"No fonts in the library yet. Open Font Library to upload or add Google Fonts."}):y.jsxs("div",{className:"vertebr-font-picker-modal-body",children:[y.jsx("div",{className:"vertebr-font-picker-grid-scroll",children:y.jsxs("div",{className:"vertebr-font-picker-grid",children:[y.jsxs("button",{type:"button",className:"vertebr-font-picker-option","data-active":g===""||void 0,onClick:()=>C(""),children:[y.jsx("strong",{children:"Default"}),y.jsx("span",{children:"Manrope / Syne"})]}),s.map(_=>y.jsxs("button",{type:"button",className:"vertebr-font-picker-option","data-active":_.id===g||void 0,style:{fontFamily:`"${_.family}", ui-sans-serif, sans-serif`,fontWeight:Lu(_,"heading")},onClick:()=>C(_.id),children:[y.jsx("strong",{children:_.label}),y.jsx("span",{children:_.family}),y.jsx("em",{children:"The quick brown fox"})]},_.id))]})}),y.jsxs("aside",{className:"vertebr-font-picker-detail",children:[y.jsx("p",{className:"vertebr-font-picker-detail-label",children:"Preview"}),g===""?y.jsx(up,{family:"Manrope",bodyWeight:400,headingWeight:700}):R?y.jsx(up,{family:R.family,bodyWeight:Lu(R,"body"),headingWeight:Lu(R,"heading")}):y.jsx("div",{className:"vertebr-empty",children:"Select a font to preview."})]})]}),y.jsxs("div",{className:"vertebr-font-picker-modal-actions",children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>k(!0),children:"Cancel"}),y.jsx("button",{type:"button",className:"vertebr-btn",disabled:o,onClick:()=>k(!1),children:"Done"})]})]})}):null]})}var pv={exports:{}},mv={};var z_;function UF(){if(z_)return mv;z_=1;var t=Vd();function e(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:e,r=t.useState,i=t.useEffect,s=t.useLayoutEffect,o=t.useDebugValue;function l(m,g){var b=g(),x=r({inst:{value:b,getSnapshot:g}}),S=x[0].inst,k=x[1];return s(function(){S.value=b,S.getSnapshot=g,u(S)&&k({inst:S})},[m,b,g]),i(function(){return u(S)&&k({inst:S}),m(function(){u(S)&&k({inst:S})})},[m]),o(b),b}function u(m){var g=m.getSnapshot;m=m.value;try{var b=g();return!n(m,b)}catch{return!0}}function f(m,g){return g()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:l;return mv.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:h,mv}var $_;function RO(){return $_||($_=1,pv.exports=UF()),pv.exports}var MO=RO();function Dn(t){this.content=t}Dn.prototype={constructor:Dn,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,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Dn(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Dn(n)},addToStart:function(t,e){return new Dn([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Dn(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Dn(i)},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=Dn.from(t),t.size?new Dn(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Dn.from(t),t.size?new Dn(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Dn.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}};Dn.from=function(t){if(t instanceof Dn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Dn(e)};function NO(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){let o=i.text,l=s.text,u=0;for(;o[u]==l[u];u++)n++;return u&&u<o.length&&u<l.length&&IO(o.charCodeAt(u-1))&&DO(o.charCodeAt(u))&&n--,n}if(i.content.size||s.content.size){let o=NO(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function OO(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),l=e.child(--s),u=o.nodeSize;if(o==l){n-=u,r-=u;continue}if(!o.sameMarkup(l))return{a:n,b:r};if(o.isText&&o.text!=l.text){let f=o.text,h=l.text,m=f.length,g=h.length;for(;m>0&&g>0&&f[m-1]==h[g-1];)m--,g--,n--,r--;return m&&g&&m<f.length&&IO(f.charCodeAt(m-1))&&DO(f.charCodeAt(m))&&(n++,r++),{a:n,b:r}}if(o.content.size||l.content.size){let f=OO(o.content,l.content,n-1,r-1);if(f)return f}n-=u,r-=u}}function DO(t){return t>=56320&&t<57344}function IO(t){return t>=55296&&t<56320}class de{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,i=0,s){for(let o=0,l=0;l<n;o++){let u=this.content[o],f=l+u.nodeSize;if(f>e&&r(u,i+l,s||null,o)!==!1&&u.content.size){let h=l+1;u.nodesBetween(Math.max(0,e-h),Math.min(u.content.size,n-h),r,i+h)}l=f}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(l,u)=>{let f=l.isText?l.text.slice(Math.max(e,u)-u,n-u):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&f||l.isTextblock)&&r&&(o?o=!1:s+=r),s+=f},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new de(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let l=this.content[s],u=o+l.nodeSize;u>e&&((o<e||u>n)&&(l.isText?l=l.cut(Math.max(0,e-o),Math.min(l.text.length,n-o)):l=l.cut(Math.max(0,e-o-1),Math.min(l.content.size,n-o-1))),r.push(l),i+=l.nodeSize),o=u}return new de(r,i)}cutByIndex(e,n){return e==n?de.empty:e==0&&n==this.content.length?this:new de(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new de(i,s)}addToStart(e){return new de([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new de(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 i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return NO(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return OO(this,e,n,r)}findIndex(e){if(e==0)return Eh(0,e);if(e==this.size)return Eh(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 i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?Eh(n+1,s):Eh(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return de.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return de.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return de.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new de(n||e,r)}static from(e){if(!e)return de.empty;if(e instanceof de)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new de([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}de.empty=new de([],0);const gv={index:0,offset:0};function Eh(t,e){return gv.index=t,gv.offset=e,gv}function Bp(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(!Bp(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!Bp(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let Ot=class W0{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}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&&Bp(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 i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}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 W0.none;if(e instanceof W0)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};Ot.none=[];class Ad extends Error{}class Ee{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=LO(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new Ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new Ee(jO(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 Ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new Ee(de.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new Ee(e,r,i)}}Ee.empty=new Ee(de.empty,0,0);function jO(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:l}=t.findIndex(n);if(i==e||s.isText){if(l!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(jO(s.content,e-i-1,n-i-1)))}function LO(t,e,n,r,i,s){let{index:o,offset:l}=t.findIndex(e),u=t.maybeChild(o);if(l==e||u.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let f=LO(u.content,e-l-1,n,o==0?r-1:0,o==t.childCount-1?i-1:0,u);return f&&t.replaceChild(o,u.copy(f))}function FF(t,e,n){if(n.openStart>t.depth)throw new Ad("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ad("Inconsistent open depths");return PO(t,e,n,0)}function PO(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=PO(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,l=o.content;return Ra(o,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:o,end:l}=qF(n,t);return Ra(s,$O(t,o,l,e,r))}else return Ra(s,Vp(t,e,r))}function zO(t,e){if(!e.type.compatibleContent(t.type))throw new Ad("Cannot join "+e.type.name+" onto "+t.type.name)}function K0(t,e,n){let r=t.node(n);return zO(r,e.node(n)),r}function Aa(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 sd(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Aa(t.nodeAfter,r),s++));for(let l=s;l<o;l++)Aa(i.child(l),r);e&&e.depth==n&&e.textOffset&&Aa(e.nodeBefore,r)}function Ra(t,e){if(!t.type.validContent(e))throw new Ad("Invalid content for node "+t.type.name);return t.copy(e)}function $O(t,e,n,r,i){let s=t.depth>i&&K0(t,e,i+1),o=r.depth>i&&K0(n,r,i+1),l=[];return sd(null,t,i,l),s&&o&&e.index(i)==n.index(i)?(zO(s,o),Aa(Ra(s,$O(t,e,n,r,i+1)),l)):(s&&Aa(Ra(s,Vp(t,e,i+1)),l),sd(e,n,i,l),o&&Aa(Ra(o,Vp(n,r,i+1)),l)),sd(r,null,i,l),new de(l)}function Vp(t,e,n){let r=[];if(sd(null,t,n,r),t.depth>n){let i=K0(t,e,n+1);Aa(Ra(i,Vp(t,e,n+1)),r)}return sd(e,null,n,r),new de(r)}function qF(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(de.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Rd{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],i=e.child(n);return r?e.child(n).cut(r):i}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],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return Ot.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let l=r;r=i,i=l}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].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 Hp(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=[],i=0,s=n;for(let o=e;;){let{index:l,offset:u}=o.content.findIndex(s),f=s-u;if(r.push(o,l,i+u),!f||(o=o.child(l),o.isText))break;s=f-1,i+=u+1}return new Rd(n,r,s)}static resolveCached(e,n){let r=B_.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else B_.set(e,r=new GF);let i=r.elts[r.i]=Rd.resolve(e,n);return r.i=(r.i+1)%WF,i}}class GF{constructor(){this.elts=[],this.i=0}}const WF=12,B_=new WeakMap;class Hp{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 KF=Object.create(null);let No=class Z0{constructor(e,n,r,i=Ot.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||de.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,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&Bp(this.attrs,n||e.defaultAttrs||KF)&&Ot.sameSet(this.marks,r||Ot.none)}copy(e=null){return e==this.content?this:new Z0(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Z0(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 Ee.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),l=i.start(o),f=i.node(o).content.cut(i.pos-l,s.pos-l);return new Ee(f,i.depth-o,s.depth-o)}replace(e,n,r){return FF(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+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 i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return Rd.resolveCached(this,e)}resolveNoCache(e){return Rd.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),BO(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=de.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),l=o&&o.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let u=i;u<s;u++)if(!this.type.allowsMarks(r.child(u).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=Ot.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(!Ot.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 i=de.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};No.prototype.text=void 0;class Up extends No{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):BO(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 Up(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Up(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 BO(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class za{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new ZF(e,n);if(r.next==null)return za.empty;let i=VO(r);r.next&&r.err("Unexpected trailing text");let s=n4(t4(i));return r4(s,r),s}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 i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type: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 i=[this];function s(o,l){let u=o.matchFragment(e,r);if(u&&(!n||u.validEnd))return de.from(l.map(f=>f.createAndFill()));for(let f=0;f<o.next.length;f++){let{type:h,next:m}=o.next[f];if(!(h.isText||h.hasRequiredAttrs())&&i.indexOf(m)==-1){i.push(m);let g=s(m,l.concat(h));if(g)return g}}return null}return s(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 i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let l=i;l.type;l=l.via)o.push(l.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:l,next:u}=s.next[o];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!i.type||u.validEnd)&&(r.push({match:l.contentMatch,type:l,via:i}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
|
|
65
|
+
`)}}za.empty=new za(!0);class ZF{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 VO(t){let e=[];do e.push(YF(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function YF(t){let e=[];do e.push(XF(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function XF(t){let e=e4(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=JF(t,e);else break;return e}function V_(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function JF(t,e){let n=V_(t),r=n;return t.eat(",")&&(t.next!="}"?r=V_(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function QF(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function e4(t){if(t.eat("(")){let e=VO(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=QF(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 t4(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,l,u){let f={term:u,to:l};return e[o].push(f),f}function i(o,l){o.forEach(u=>u.to=l)}function s(o,l){if(o.type=="choice")return o.exprs.reduce((u,f)=>u.concat(s(f,l)),[]);if(o.type=="seq")for(let u=0;;u++){let f=s(o.exprs[u],l);if(u==o.exprs.length-1)return f;i(f,l=n())}else if(o.type=="star"){let u=n();return r(l,u),i(s(o.expr,u),u),[r(u)]}else if(o.type=="plus"){let u=n();return i(s(o.expr,l),u),i(s(o.expr,u),u),[r(u)]}else{if(o.type=="opt")return[r(l)].concat(s(o.expr,l));if(o.type=="range"){let u=l;for(let f=0;f<o.min;f++){let h=n();i(s(o.expr,u),h),u=h}if(o.max==-1)i(s(o.expr,u),u);else for(let f=o.min;f<o.max;f++){let h=n();r(u,h),i(s(o.expr,u),h),u=h}return[r(u)]}else{if(o.type=="name")return[r(l,void 0,o.value)];throw new Error("Unknown expr type")}}}}function HO(t,e){return e-t}function H_(t,e){let n=[];return r(e),n.sort(HO);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:l,to:u}=s[o];!l&&n.indexOf(u)==-1&&r(u)}}}function n4(t){let e=Object.create(null);return n(H_(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:l,to:u})=>{if(!l)return;let f;for(let h=0;h<i.length;h++)i[h][0]==l&&(f=i[h][1]);H_(t,u).forEach(h=>{f||i.push([l,f=[]]),f.indexOf(h)==-1&&f.push(h)})})});let s=e[r.join(",")]=new za(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let l=i[o][1].sort(HO);s.next.push({type:i[o][0],next:e[l.join(",")]||n(l)})}return s}}function r4(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let l=0;l<i.next.length;l++){let{type:u,next:f}=i.next[l];o.push(u.name),s&&!(u.isText||u.hasRequiredAttrs())&&(s=!1),r.indexOf(f)==-1&&r.push(f)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function UO(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 FO(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function qO(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${r}`);for(let i in t)t[i].validate&&t[i].validate(e[i])}function GO(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new s4(t,r,e[r]);return n}let U_=class WO{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=GO(e,r.attrs),this.defaultAttrs=UO(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==za.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:FO(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new No(this,this.computeAttrs(e),de.from(n),Ot.setFrom(r))}createChecked(e=null,n,r){return n=de.from(n),this.checkContent(n),new No(this,this.computeAttrs(e),n,Ot.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=de.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(de.empty,!0);return s?new No(this,e,n.append(s),Ot.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){qO(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:Ot.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new WO(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function i4(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class s4{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?i4(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Xm{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=GO(e,i.attrs),this.excluded=null;let s=UO(this.attrs);this.instance=s?new Ot(this,s):null}create(e=null){return!e&&this.instance?this.instance:new Ot(this,FO(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new Xm(s,i++,n,o)),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){qO(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class KO{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Dn.from(e.nodes),n.marks=Dn.from(e.marks||{}),this.nodes=U_.compile(this.spec.nodes,this),this.marks=Xm.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=za.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?F_(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:F_(this,o.split(" "))}this.nodeFromJSON=i=>No.fromJSON(this,i),this.markFromJSON=i=>Ot.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof U_){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,i)}text(e,n){let r=this.nodes.text;return new Up(r,r.defaultAttrs,e,Ot.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 F_(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let l in t.marks){let u=t.marks[l];(i=="_"||u.spec.group&&u.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=u)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function o4(t){return t.tag!=null}function a4(t){return t.style!=null}class Cs{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(o4(i))this.tags.push(i);else if(a4(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new G_(this,n,!1);return r.addAll(e,Ot.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new G_(this,n,!0);return r.addAll(e,Ot.none,n.from,n.to),Ee.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(u4(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],l=o.style;if(!(l.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(o.getAttrs){let u=o.getAttrs(n);if(u===!1)continue;o.attrs=u||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let l=n[o];if((l.priority==null?50:l.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=W_(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=W_(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Cs(e,Cs.schemaRules(e)))}}const ZO={address:!0,article:!0,aside:!0,blockquote:!0,body:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},l4={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},YO={ol:!0,ul:!0},Md=1,Y0=2,od=4;function q_(t,e,n){return e!=null?(e?Md:0)|(e==="full"?Y0:0):t&&t.whitespace=="pre"?Md|Y0:n&~od}class Th{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=Ot.none,this.match=s||(o&od?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(de.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Md)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=de.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(de.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&&!ZO.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class G_{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=q_(null,n.preserveWhitespace,0)|(r?od:0);i?s=new Th(i.type,i.attrs,Ot.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new Th(null,null,Ot.none,!0,null,o):s=new Th(e.schema.topNodeType,null,Ot.none,!0,null,o),this.nodes=[s],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,i=this.top,s=i.options&Y0?"full":this.localPreserveWS||(i.options&Md)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
|
|
66
|
+
`);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let l=r.split(/\r?\n|\r/);for(let u=0;u<l.length;u++)u&&this.insertNode(o.linebreakReplacement.create(),n,!0),l[u]&&this.insertNode(o.text(l[u]),n,!/\S/.test(l[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 l=i.content[i.content.length-1],u=e.previousSibling;(!l||u&&u.nodeName=="BR"||l.isText&&/[ \t\r\n\u000c]$/.test(l.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),l;YO.hasOwnProperty(o)&&this.parser.normalizeLists&&c4(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(u?u.ignore:l4.hasOwnProperty(o))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,h=this.needsBlock;if(ZO.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),f=!0,s.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(s),this.needsBlock=h}else{let f=this.readStyles(e,n);f&&this.addElementByRule(e,u,f,u.consuming===!1?l:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
67
|
+
`),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 i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let l=void 0;;){let u=this.parser.matchStyle(s,o,this,l);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)l=u;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let u=this.enter(o,n.attrs||null,r,n.preserveWhitespace);u&&(s=!0,r=u)}else{let u=this.parser.schema.marks[n.mark];r=r.concat(u.create(n.attrs))}let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);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)}s&&this.sync(l)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,l=i==null?null:e.childNodes[i];o!=l;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,l=0;o>=0;o--){let u=this.nodes[o],f=u.findWrapping(e);if(f&&(!i||i.length>f.length+l)&&(i=f,s=u,!f.length))break;if(u.solid){if(r)break;l+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=Ot.none;for(let l of i.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):K_(l.type,e.type))&&(o=l.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let l=q_(e,s,o.options);o.options&od&&o.content.length==0&&(l|=od);let u=Ot.none;return r=r.filter(f=>(o.type?o.type.allowsMarkType(f.type):K_(f.type,e))?(u=f.addToSet(u),!1):!0),this.nodes.push(new Th(e,n,u,i,null,l)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=Md)}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 i=r.length-1;i>=0;i--)e+=r[i].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 i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].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,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(l,u)=>{for(;l>=0;l--){let f=n[l];if(f==""){if(l==n.length-1||l==0)continue;for(;u>=s;u--)if(o(l-1,u))return!0;return!1}else{let h=u>0||u==0&&i?this.nodes[u].type:r&&u>=s?r.node(u-s).type:null;if(!h||h.name!=f&&!h.isInGroup(f))return!1;u--}}return!0};return o(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 c4(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&YO.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function u4(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function W_(t){let e={};for(let n in t)e[n]=t[n];return e}function K_(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=l=>{s.push(l);for(let u=0;u<l.edgeCount;u++){let{type:f,next:h}=l.edge(u);if(f==e||s.indexOf(h)<0&&o(h))return!0}};if(o(i.contentMatch))return!0}}class Xa{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=_h(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let l=0,u=0;for(;l<s.length&&u<o.marks.length;){let f=o.marks[u];if(!this.marks[f.type.name]){u++;continue}if(!f.eq(s[l][0])||f.type.spec.spanning===!1)break;l++,u++}for(;l<s.length;)i=s.pop()[1];for(;u<o.marks.length;){let f=o.marks[u++],h=this.serializeMark(f,o.isInline,n);h&&(s.push([f,i]),i.appendChild(h.dom),i=h.contentDOM||h.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return _h(n).createTextNode(e.text);let{dom:r,contentDOM:i}=dp(_h(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&dp(_h(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:dp(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Xa(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Z_(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Z_(e.marks)}}function Z_(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function _h(t){return t.document||window.document}const Y_=new WeakMap;function d4(t){let e=Y_.get(t);return e===void 0&&Y_.set(t,e=f4(t)),e}function f4(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 i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function dp(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=d4(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let l,u=n?t.createElementNS(n,i):t.createElement(i),f=e[1],h=1;if(f&&typeof f=="object"&&f.nodeType==null&&!Array.isArray(f)){h=2;for(let m in f)if(f[m]!=null){let g=m.indexOf(" ");g>0?u.setAttributeNS(m.slice(0,g),m.slice(g+1),f[m]):m=="style"&&u.style?u.style.cssText=f[m]:u.setAttribute(m,f[m])}}for(let m=h;m<e.length;m++){let g=e[m];if(g===0){if(m<e.length-1||m>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:u,contentDOM:u}}else if(typeof g=="string")u.appendChild(t.createTextNode(g));else{let{dom:b,contentDOM:x}=dp(t,g,n,r);if(u.appendChild(b),x){if(l)throw new RangeError("Multiple content holes");l=x}}}return{dom:u,contentDOM:l}}const XO=65535,JO=Math.pow(2,16);function h4(t,e){return t+e*JO}function X_(t){return t&XO}function p4(t){return(t-(t&XO))/JO}const QO=1,eD=2,fp=4,tD=8;class X0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&tD)>0}get deletedBefore(){return(this.delInfo&(QO|fp))>0}get deletedAfter(){return(this.delInfo&(eD|fp))>0}get deletedAcross(){return(this.delInfo&fp)>0}}class Ar{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ar.empty)return Ar.empty}recover(e){let n=0,r=X_(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+p4(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 i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let u=this.ranges[l]-(this.inverted?i:0);if(u>e)break;let f=this.ranges[l+s],h=this.ranges[l+o],m=u+f;if(e<=m){let g=f?e==u?-1:e==m?1:n:n,b=u+i+(g<0?0:h);if(r)return b;let x=e==(n<0?u:m)?null:h4(l/3,e-u),S=e==u?eD:e==m?QO:fp;return(n<0?e!=u:e!=m)&&(S|=tD),new X0(b,S,x)}i+=h-f}return r?e+i:new X0(e+i,0,null)}touches(e,n){let r=0,i=X_(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let u=this.ranges[l]-(this.inverted?r:0);if(u>e)break;let f=this.ranges[l+s],h=u+f;if(e<=h&&l==i*3)return!0;r+=this.ranges[l+o]-f}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],l=o-(this.inverted?s:0),u=o+(this.inverted?0:s),f=this.ranges[i+n],h=this.ranges[i+r];e(l,l+f,u,u+h),s+=h-f}}invert(){return new Ar(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ar.empty:new Ar(e<0?[0,-e,0]:[0,0,e])}}Ar.empty=new Ar([]);class Nd{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new Nd(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 i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i: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 i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Nd;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 i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],l=o.mapResult(e,n);if(l.recover!=null){let u=this.getMirror(s);if(u!=null&&u>s&&u<this.to){s=u,e=this._maps[u].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return r?e:new X0(e,i,null)}}const yv=Object.create(null);class Kn{getMap(){return Ar.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yv[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 yv)throw new RangeError("Duplicate use of step JSON ID "+e);return yv[e]=n,n.prototype.jsonID=e,n}}class hn{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new hn(e,null)}static fail(e){return new hn(null,e)}static fromReplace(e,n,r,i){try{return hn.ok(e.replace(n,r,i))}catch(s){if(s instanceof Ad)return hn.fail(s.message);throw s}}}function Lw(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Lw(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return de.fromArray(r)}class Eo extends Kn{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),i=r.node(r.sharedDepth(this.to)),s=new Ee(Lw(n.content,(o,l)=>!o.isAtom||!l.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return hn.fromReplace(e,this.from,this.to,s)}invert(){return new pi(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 Eo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Eo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Eo(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 Eo(n.from,n.to,e.markFromJSON(n.mark))}}Kn.jsonID("addMark",Eo);class pi extends Kn{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 Ee(Lw(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return hn.fromReplace(e,this.from,this.to,r)}invert(){return new Eo(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 pi(n.pos,r.pos,this.mark)}merge(e){return e instanceof pi&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pi(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 pi(n.from,n.to,e.markFromJSON(n.mark))}}Kn.jsonID("removeMark",pi);class To extends Kn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return hn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return hn.fromReplace(e,this.pos,this.pos+1,new Ee(de.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 i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new To(this.pos,n.marks[i]);return new To(this.pos,this.mark)}}return new $a(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new To(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 To(n.pos,e.markFromJSON(n.mark))}}Kn.jsonID("addNodeMark",To);class $a extends Kn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return hn.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return hn.fromReplace(e,this.pos,this.pos+1,new Ee(de.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new To(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new $a(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 $a(n.pos,e.markFromJSON(n.mark))}}Kn.jsonID("removeNodeMark",$a);class fn extends Kn{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&J0(e,this.from,this.to)?hn.fail("Structure replace would overwrite content"):hn.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ar([this.from,this.to-this.from,this.slice.size])}invert(e){return new fn(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&fn.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new fn(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof fn)||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?Ee.empty:new Ee(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new fn(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?Ee.empty:new Ee(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new fn(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 fn(n.from,n.to,Ee.fromJSON(e,n.slice),!!n.structure)}}fn.MAP_BIAS=1;Kn.jsonID("replace",fn);class kn extends Kn{constructor(e,n,r,i,s,o,l=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=l}apply(e){if(this.structure&&(J0(e,this.from,this.gapFrom)||J0(e,this.gapTo,this.to)))return hn.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return hn.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?hn.fromReplace(e,this.from,this.to,r):hn.fail("Content does not fit in gap")}getMap(){return new Ar([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 kn(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),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new kn(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,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 kn(n.from,n.to,n.gapFrom,n.gapTo,Ee.fromJSON(e,n.slice),n.insert,!!n.structure)}}Kn.jsonID("replaceAround",kn);function J0(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function m4(t,e,n,r){let i=[],s=[],o,l;t.doc.nodesBetween(e,n,(u,f,h)=>{if(!u.isInline)return;let m=u.marks;if(!r.isInSet(m)&&h.type.allowsMarkType(r.type)){let g=Math.max(f,e),b=Math.min(f+u.nodeSize,n),x=r.addToSet(m);for(let S=0;S<m.length;S++)m[S].isInSet(x)||(o&&o.to==g&&o.mark.eq(m[S])?o.to=b:i.push(o=new pi(g,b,m[S])));l&&l.to==g?l.to=b:s.push(l=new Eo(g,b,r))}}),i.forEach(u=>t.step(u)),s.forEach(u=>t.step(u))}function g4(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,l)=>{if(!o.isInline)return;s++;let u=null;if(r instanceof Xm){let f=o.marks,h;for(;h=r.isInSet(f);)(u||(u=[])).push(h),f=h.removeFromSet(f)}else r?r.isInSet(o.marks)&&(u=[r]):u=o.marks;if(u&&u.length){let f=Math.min(l+o.nodeSize,n);for(let h=0;h<u.length;h++){let m=u[h],g;for(let b=0;b<i.length;b++){let x=i[b];x.step==s-1&&m.eq(i[b].style)&&(g=x)}g?(g.to=f,g.step=s):i.push({style:m,from:Math.max(l,e),to:f,step:s})}}}),i.forEach(o=>t.step(new pi(o.from,o.to,o.style)))}function Pw(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],l=e+1;for(let u=0;u<s.childCount;u++){let f=s.child(u),h=l+f.nodeSize,m=r.matchType(f.type);if(!m)o.push(new fn(l,h,Ee.empty));else{r=m;for(let g=0;g<f.marks.length;g++)n.allowsMarkType(f.marks[g].type)||t.step(new pi(l,h,f.marks[g]));if(i&&f.isText&&n.whitespace!="pre"){let g,b=/\r?\n|\r/g,x;for(;g=b.exec(f.text);)x||(x=new Ee(de.from(n.schema.text(" ",n.allowedMarks(f.marks))),0,0)),o.push(new fn(l+g.index,l+g.index+g[0].length,x))}}l=h}if(!r.validEnd){let u=r.fillBefore(de.empty,!0);t.replace(l,l,new Ee(u,0,0))}for(let u=o.length-1;u>=0;u--)t.step(o[u])}function y4(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function jc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),l=t.$from.index(r)+i,u=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(l,u,n))return r;if(r==0||o.type.spec.isolating||!y4(o,l,u))break;l&&(i=1),u<o.childCount&&(s=1)}return null}function b4(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),l=i.after(s+1),u=o,f=l,h=de.empty,m=0;for(let x=s,S=!1;x>n;x--)S||r.index(x)>0?(S=!0,h=de.from(r.node(x).copy(h)),m++):u--;let g=de.empty,b=0;for(let x=s,S=!1;x>n;x--)S||i.after(x+1)<i.end(x)?(S=!0,g=de.from(i.node(x).copy(g)),b++):f++;t.step(new kn(u,f,o,l,new Ee(h.append(g),m,b),h.size-m,!0))}function zw(t,e,n=null,r=t){let i=v4(t,e),s=i&&x4(r,e);return s?i.map(J_).concat({type:e,attrs:n}).concat(s.map(J_)):null}function J_(t){return{type:t,attrs:null}}function v4(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function x4(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let u=(o.length?o[o.length-1]:e).contentMatch;for(let f=r;u&&f<i;f++)u=u.matchType(n.child(f).type);return!u||!u.validEnd?null:o}function w4(t,e,n){let r=de.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let l=n[o].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=de.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new kn(i,s,i,s,new Ee(r,0,0),n.length,!0))}function S4(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,l)=>{let u=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,u)&&k4(t.doc,t.mapping.slice(s).map(l),r)){let f=null;if(r.schema.linebreakReplacement){let b=r.whitespace=="pre",x=!!r.contentMatch.matchType(r.schema.linebreakReplacement);b&&!x?f=!1:!b&&x&&(f=!0)}f===!1&&rD(t,o,l,s),Pw(t,t.mapping.slice(s).map(l,1),r,void 0,f===null);let h=t.mapping.slice(s),m=h.map(l,1),g=h.map(l+o.nodeSize,1);return t.step(new kn(m,g,m+1,g-1,new Ee(de.from(r.create(u,null,o.marks)),0,0),1,!0)),f===!0&&nD(t,o,l,s),!1}})}function nD(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,l=/\r?\n|\r/g;for(;o=l.exec(i.text);){let u=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(u,u+1,e.type.schema.linebreakReplacement.create())}}})}function rD(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
|
|
68
|
+
`))}})}function k4(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function C4(t,e,n,r,i){let s=t.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let o=n.create(r,null,i||s.marks);if(s.isLeaf)return t.replaceWith(e,e+s.nodeSize,o);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new kn(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new Ee(de.from(o),0,0),1,!0))}function Es(t,e,n=1,r){let i=t.resolve(e),s=i.depth-n,o=r&&r[r.length-1]||i.parent;if(s<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let f=i.depth-1,h=n-2;f>s;f--,h--){let m=i.node(f),g=i.index(f);if(m.type.spec.isolating)return!1;let b=m.content.cutByIndex(g,m.childCount),x=r&&r[h+1];x&&(b=b.replaceChild(0,x.type.create(x.attrs)));let S=r&&r[h]||m;if(!m.canReplace(g+1,m.childCount)||!S.type.validContent(b))return!1}let l=i.indexAfter(s),u=r&&r[0];return i.node(s).canReplaceWith(l,l,u?u.type:i.node(s+1).type)}function E4(t,e,n=1,r){let i=t.doc.resolve(e),s=de.empty,o=de.empty;for(let l=i.depth,u=i.depth-n,f=n-1;l>u;l--,f--){s=de.from(i.node(l).copy(s));let h=r&&r[f];o=de.from(h?h.type.create(h.attrs,o):i.node(l).copy(o))}t.step(new fn(e,e,new Ee(s.append(o),n,n),!0))}function Ko(t,e){let n=t.resolve(e),r=n.index();return iD(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function T4(t,e){e.content.size||t.type.compatibleContent(e.type);let n=t.contentMatchAt(t.childCount),{linebreakReplacement:r}=t.type.schema;for(let i=0;i<e.childCount;i++){let s=e.child(i),o=s.type==r?t.type.schema.nodes.text:s.type;if(n=n.matchType(o),!n||!t.type.allowsMarks(s.marks))return!1}return n.validEnd}function iD(t,e){return!!(t&&e&&!t.isLeaf&&T4(t,e))}function Jm(t,e,n=-1){let r=t.resolve(e);for(let i=r.depth;;i--){let s,o,l=r.index(i);if(i==r.depth?(s=r.nodeBefore,o=r.nodeAfter):n>0?(s=r.node(i+1),l++,o=r.node(i).maybeChild(l)):(s=r.node(i).maybeChild(l-1),o=r.node(i+1)),s&&!s.isTextblock&&iD(s,o)&&r.node(i).canReplace(l,l+1))return e;if(i==0)break;e=n<0?r.before(i):r.after(i)}}function _4(t,e,n){let r=null,{linebreakReplacement:i}=t.doc.type.schema,s=t.doc.resolve(e-n),o=s.node().type;if(i&&o.inlineContent){let h=o.whitespace=="pre",m=!!o.contentMatch.matchType(i);h&&!m?r=!1:!h&&m&&(r=!0)}let l=t.steps.length;if(r===!1){let h=t.doc.resolve(e+n);rD(t,h.node(),h.before(),l)}o.inlineContent&&Pw(t,e+n-1,o,s.node().contentMatchAt(s.index()),r==null);let u=t.mapping.slice(l),f=u.map(e-n);if(t.step(new fn(f,u.map(e+n,-1),Ee.empty,!0)),r===!0){let h=t.doc.resolve(f);nD(t,h.node(),h.before(),t.steps.length)}return t}function A4(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 i=r.depth-1;i>=0;i--){let s=r.index(i);if(r.node(i).canReplaceWith(s,s,n))return r.before(i+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let s=r.indexAfter(i);if(r.node(i).canReplaceWith(s,s,n))return r.after(i+1);if(s<r.node(i).childCount)return null}return null}function sD(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let s=0;s<n.openStart;s++)i=i.firstChild.content;for(let s=1;s<=(n.openStart==0&&n.size?2:1);s++)for(let o=r.depth;o>=0;o--){let l=o==r.depth?0:r.pos<=(r.start(o+1)+r.end(o+1))/2?-1:1,u=r.index(o)+(l>0?1:0),f=r.node(o),h=!1;if(s==1)h=f.canReplace(u,u,i);else{let m=f.contentMatchAt(u).findWrapping(i.firstChild.type);h=m&&f.canReplaceWith(u,u,m[0])}if(h)return l==0?r.pos:l<0?r.before(o+1):r.after(o+1)}return null}function Qm(t,e,n=e,r=Ee.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),s=t.resolve(n);return oD(i,s,r)?new fn(e,n,r):new R4(i,s,r).fit()}function oD(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class R4{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=de.empty;for(let i=0;i<=e.depth;i++){let s=e.node(i);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=de.from(e.node(i).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,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let s=this.placed,o=r.depth,l=i.depth;for(;o&&l&&s.childCount==1;)s=s.firstChild.content,o--,l--;let u=new Ee(s,o,l);return e>-1?new kn(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new fn(r.pos,i.pos,u):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r<e;r++){let s=n.firstChild;if(n.childCount>1&&(i=0),s.type.spec.isolating&&i<=r){e=r;break}n=s.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,s=null;r?(s=bv(this.unplaced.content,r-1).firstChild,i=s.content):i=this.unplaced.content;let o=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:u,match:f}=this.frontier[l],h,m=null;if(n==1&&(o?f.matchType(o.type)||(m=f.fillBefore(de.from(o),!1)):s&&u.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:m};if(n==2&&o&&(h=f.findWrapping(o.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:h};if(s&&f.matchType(s.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=bv(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new Ee(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=bv(e,n);if(i.childCount<=1&&n>0){let s=e.size-n<=n+i.size;this.unplaced=new Ee(Wu(e,n-1,1),n-1,s?n-1:r)}else this.unplaced=new Ee(Wu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:s}){for(;this.depth>n;)this.closeFrontierNode();if(s)for(let S=0;S<s.length;S++)this.openFrontierNode(s[S]);let o=this.unplaced,l=r?r.content:o.content,u=o.openStart-e,f=0,h=[],{match:m,type:g}=this.frontier[n];if(i){for(let S=0;S<i.childCount;S++)h.push(i.child(S));m=m.matchFragment(i)}let b=l.size+e-(o.content.size-o.openEnd);for(;f<l.childCount;){let S=l.child(f),k=m.matchType(S.type);if(!k)break;f++,(f>1||u==0||S.content.size)&&(m=k,h.push(aD(S.mark(g.allowedMarks(S.marks)),f==1?u:0,f==l.childCount?b:-1)))}let x=f==l.childCount;x||(b=-1),this.placed=Ku(this.placed,n,de.from(h)),this.frontier[n].match=m,x&&b<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let S=0,k=l;S<b;S++){let C=k.lastChild;this.frontier.push({type:C.type,match:C.contentMatchAt(C.childCount)}),k=C.content}this.unplaced=x?e==0?Ee.empty:new Ee(Wu(o.content,e-1,1),e-1,b<0?o.openEnd:e-1):new Ee(Wu(o.content,e,f),o.openStart,o.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!vv(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,i=this.$to.after(r);for(;r>1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],s=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),o=vv(e,n,i,r,s);if(o){for(let l=n-1;l>=0;l--){let{match:u,type:f}=this.frontier[l],h=vv(e,l,f,u,!0);if(!h||h.childCount)continue e}return{depth:n,fit:o,move:s?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=Ku(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),s=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,s)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ku(this.placed,this.depth,de.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(de.empty,!0);n.childCount&&(this.placed=Ku(this.placed,this.frontier.length,n))}}function Wu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Wu(t.firstChild.content,e-1,n)))}function Ku(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Ku(t.lastChild.content,e-1,n)))}function bv(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function aD(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,aD(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(de.empty,!0)))),t.copy(r)}function vv(t,e,n,r,i){let s=t.node(e),o=i?t.indexAfter(e):t.index(e);if(o==s.childCount&&!n.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,o);return l&&!M4(n,s.content,o)?l:null}function M4(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}function N4(t){return t.spec.defining||t.spec.definingForContent}function O4(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let i=t.doc.resolve(e),s=t.doc.resolve(n);if(oD(i,s,r))return t.step(new fn(e,n,r));let o=cD(i,s);o[o.length-1]==0&&o.pop();let l=-(i.depth+1);o.unshift(l);for(let g=i.depth,b=i.pos-1;g>0;g--,b--){let x=i.node(g).type.spec;if(x.defining||x.definingAsContext||x.isolating)break;o.indexOf(g)>-1?l=g:i.before(g)==b&&o.splice(1,0,-g)}let u=o.indexOf(l),f=[],h=r.openStart;for(let g=r.content,b=0;;b++){let x=g.firstChild;if(f.push(x),b==r.openStart)break;g=x.content}for(let g=h-1;g>=0;g--){let b=f[g],x=N4(b.type);if(x&&!b.sameMarkup(i.node(Math.abs(l)-1)))h=g;else if(x||!b.type.isTextblock)break}for(let g=r.openStart;g>=0;g--){let b=(g+h+1)%(r.openStart+1),x=f[b];if(x)for(let S=0;S<o.length;S++){let k=o[(S+u)%o.length],C=!0;k<0&&(C=!1,k=-k);let A=i.node(k-1),R=i.index(k-1);if(A.canReplaceWith(R,R,x.type,x.marks))return t.replace(i.before(k),C?s.after(k):n,new Ee(lD(r.content,0,r.openStart,b),b,r.openEnd))}}let m=t.steps.length;for(let g=o.length-1;g>=0&&(t.replace(e,n,r),!(t.steps.length>m));g--){let b=o[g];b<0||(e=i.before(b),n=s.after(b))}}function lD(t,e,n,r,i){if(e<n){let s=t.firstChild;t=t.replaceChild(0,s.copy(lD(s.content,e+1,n,r,s)))}if(e>r){let s=i.contentMatchAt(0),o=s.fillBefore(t).append(t);t=o.append(s.matchFragment(o).fillBefore(de.empty,!0))}return t}function D4(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=A4(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new Ee(de.from(r),0,0))}function I4(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n);if(r.parent.isTextblock&&i.parent.isTextblock&&r.start()!=i.start()&&r.parentOffset==0&&i.parentOffset==0){let o=r.sharedDepth(n),l=!1;for(let u=r.depth;u>o;u--)r.node(u).type.spec.isolating&&(l=!0);for(let u=i.depth;u>o;u--)i.node(u).type.spec.isolating&&(l=!0);if(!l){for(let u=r.depth;u>0&&e==r.start(u);u--)e=r.before(u);for(let u=i.depth;u>0&&n==i.start(u);u--)n=i.before(u);r=t.doc.resolve(e),i=t.doc.resolve(n)}}let s=cD(r,i);for(let o=0;o<s.length;o++){let l=s[o],u=o==s.length-1;if(u&&l==0||r.node(l).type.contentMatch.validEnd)return t.delete(r.start(l),i.end(l));if(l>0&&(u||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let o=1;o<=r.depth&&o<=i.depth;o++)if(e-r.start(o)==r.depth-o&&n>r.end(o)&&i.end(o)-n!=i.depth-o&&r.start(o-1)==i.start(o-1)&&r.node(o-1).canReplace(r.index(o-1),i.index(o-1)))return t.delete(r.before(o),n);t.delete(e,n)}function cD(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let s=t.start(i);if(s<t.pos-(t.depth-i)||e.end(i)>e.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(s==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==s-1)&&n.push(i)}return n}class oc extends Kn{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 hn.fail("No node at attribute step's position");let r=Object.create(null);for(let s in n.attrs)r[s]=n.attrs[s];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return hn.fromReplace(e,this.pos,this.pos+1,new Ee(de.from(i),0,n.isLeaf?0:1))}getMap(){return Ar.empty}invert(e){return new oc(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 oc(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 oc(n.pos,n.attr,n.value)}}Kn.jsonID("attr",oc);class Od extends Kn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return hn.ok(r)}getMap(){return Ar.empty}invert(e){return new Od(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 Od(n.attr,n.value)}}Kn.jsonID("docAttr",Od);let bc=class extends Error{};bc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};bc.prototype=Object.create(Error.prototype);bc.prototype.constructor=bc;bc.prototype.name="TransformError";class $w{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Nd}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new bc(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 i=this.mapping.maps[r];r&&(e=i.map(e,1),n=i.map(n,-1)),i.forEach((s,o,l,u)=>{e=Math.min(e,l),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=Ee.empty){let i=Qm(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new Ee(de.from(r),0,0))}delete(e,n){return this.replace(e,n,Ee.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return O4(this,e,n,r),this}replaceRangeWith(e,n,r){return D4(this,e,n,r),this}deleteRange(e,n){return I4(this,e,n),this}lift(e,n){return b4(this,e,n),this}join(e,n=1){return _4(this,e,n),this}wrap(e,n){return w4(this,e,n),this}setBlockType(e,n=e,r,i=null){return S4(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return C4(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new oc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Od(e,n)),this}addNodeMark(e,n){return this.step(new To(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 Ot)n.isInSet(r.marks)&&this.step(new $a(e,n));else{let i=r.marks,s,o=[];for(;s=n.isInSet(i);)o.push(new $a(e,s)),i=s.removeFromSet(i);for(let l=o.length-1;l>=0;l--)this.step(o[l])}return this}split(e,n=1,r){return E4(this,e,n,r),this}addMark(e,n,r){return m4(this,e,n,r),this}removeMark(e,n,r){return g4(this,e,n,r),this}clearIncompatible(e,n,r){return Pw(this,e,n,r),this}}const xv=Object.create(null);class Ke{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new uD(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=Ee.empty){let r=n.content.lastChild,i=null;for(let l=0;l<n.openEnd;l++)i=r,r=r.lastChild;let s=e.steps.length,o=this.ranges;for(let l=0;l<o.length;l++){let{$from:u,$to:f}=o[l],h=e.mapping.slice(s);e.replaceRange(h.map(u.pos),h.map(f.pos),l?Ee.empty:n),l==0&&tA(e,s,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:o,$to:l}=i[s],u=e.mapping.slice(r),f=u.map(o.pos),h=u.map(l.pos);s?e.deleteRange(f,h):(e.replaceRangeWith(f,h,n),tA(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ze(e):Jl(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let s=e.depth-1;s>=0;s--){let o=n<0?Jl(e.node(0),e.node(s),e.before(s+1),e.index(s),n,r):Jl(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,n,r);if(o)return o}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Mr(e.node(0))}static atStart(e){return Jl(e,e,0,0,1)||new Mr(e)}static atEnd(e){return Jl(e,e,e.content.size,e.childCount,-1)||new Mr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=xv[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 xv)throw new RangeError("Duplicate use of selection JSON ID "+e);return xv[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ze.between(this.$anchor,this.$head).getBookmark()}}Ke.prototype.visible=!0;class uD{constructor(e,n){this.$from=e,this.$to=n}}let Q_=!1;function eA(t){!Q_&&!t.parent.inlineContent&&(Q_=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ze extends Ke{constructor(e,n=e){eA(e),eA(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 Ke.near(r);let i=e.resolve(n.map(this.anchor));return new ze(i.parent.inlineContent?i:r,r)}replace(e,n=Ee.empty){if(super.replace(e,n),n==Ee.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ze&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new eg(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 ze(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let s=Ke.findFrom(n,r,!0)||Ke.findFrom(n,-r,!0);if(s)n=s.$head;else return Ke.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(Ke.findFrom(e,-r,!0)||Ke.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new ze(e,n)}}Ke.jsonID("text",ze);class eg{constructor(e,n){this.anchor=e,this.head=n}map(e){return new eg(e.map(this.anchor),e.map(this.head))}resolve(e){return ze.between(e.resolve(this.anchor),e.resolve(this.head))}}class He extends Ke{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:i}=n.mapResult(this.anchor),s=e.resolve(i);return r?Ke.near(s):new He(s)}content(){return new Ee(de.from(this.node),0,0)}eq(e){return e instanceof He&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Bw(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new He(e.resolve(n.anchor))}static create(e,n){return new He(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}He.prototype.visible=!1;Ke.jsonID("node",He);class Bw{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new eg(r,r):new Bw(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&He.isSelectable(r)?new He(n):Ke.near(n)}}class Mr extends Ke{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=Ee.empty){if(n==Ee.empty){e.delete(0,e.doc.content.size);let r=Ke.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Mr(e)}map(e){return new Mr(e)}eq(e){return e instanceof Mr}getBookmark(){return j4}}Ke.jsonID("all",Mr);const j4={map(){return this},resolve(t){return new Mr(t)}};function Jl(t,e,n,r,i,s=!1){if(e.inlineContent)return ze.create(t,n);for(let o=r-(i>0?0:1);i>0?o<e.childCount:o>=0;o+=i){let l=e.child(o);if(l.isAtom){if(!s&&He.isSelectable(l))return He.create(t,n-(i<0?l.nodeSize:0))}else{let u=Jl(t,l,n+i,i<0?l.childCount:0,i,s);if(u)return u}n+=l.nodeSize*i}return null}function tA(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof fn||i instanceof kn))return;let s=t.mapping.maps[r],o;s.forEach((l,u,f,h)=>{o==null&&(o=h)}),t.setSelection(Ke.near(t.doc.resolve(o),n))}const nA=1,Ah=2,rA=4;class L4 extends $w{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|nA)&~Ah,this.storedMarks=null,this}get selectionSet(){return(this.updated&nA)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Ah,this}ensureMarks(e){return Ot.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&Ah)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Ah,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)||Ot.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),!e)return this.deleteRange(n,r);let s=this.storedMarks;if(!s){let o=this.doc.resolve(n);s=r==n?o.marks():o.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,s)),!this.selection.empty&&this.selection.to==n+e.length&&this.setSelection(Ke.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|=rA,this}get scrolledIntoView(){return(this.updated&rA)>0}}function iA(t,e){return!e||!t?t:t.bind(e)}class Zu{constructor(e,n,r){this.name=e,this.init=iA(n.init,r),this.apply=iA(n.apply,r)}}const P4=[new Zu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Zu("selection",{init(t,e){return t.selection||Ke.atStart(e.doc)},apply(t){return t.selection}}),new Zu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Zu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class wv{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=P4.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 Zu(r.key,r.spec.state,r))})}}class Sa{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 i=this.config.plugins[r];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],r=this.applyInner(e),i=null;for(;;){let s=!1;for(let o=0;o<this.config.plugins.length;o++){let l=this.config.plugins[o];if(l.spec.appendTransaction){let u=i?i[o].n:0,f=i?i[o].state:this,h=u<n.length&&l.spec.appendTransaction.call(l,u?n.slice(u):n,f,r);if(h&&r.filterTransaction(h,o)){if(h.setMeta("appendedTransaction",e),!i){i=[];for(let m=0;m<this.config.plugins.length;m++)i.push(m<o?{state:r,n:n.length}:{state:this,n:0})}n.push(h),r=r.applyInner(h),s=!0}i&&(i[o]={state:r,n:n.length})}}if(!s)return{state:r,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Sa(this.config),r=this.config.fields;for(let i=0;i<r.length;i++){let s=r[i];n[s.name]=s.apply(e,this[s.name],this,n)}return n}get tr(){return new L4(this)}static create(e){let n=new wv(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Sa(n);for(let i=0;i<n.fields.length;i++)r[n.fields[i].name]=n.fields[i].init(e,r);return r}reconfigure(e){let n=new wv(this.schema,e.plugins),r=n.fields,i=new Sa(n);for(let s=0;s<r.length;s++){let o=r[s].name;i[o]=this.hasOwnProperty(o)?this[o]:r[s].init(e,i)}return i}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 i=e[r],s=i.spec.state;s&&s.toJSON&&(n[r]=s.toJSON.call(i,this[i.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 i=new wv(e.schema,e.plugins),s=new Sa(i);return i.fields.forEach(o=>{if(o.name=="doc")s.doc=No.fromJSON(e.schema,n.doc);else if(o.name=="selection")s.selection=Ke.fromJSON(s.doc,n.selection);else if(o.name=="storedMarks")n.storedMarks&&(s.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let u=r[l],f=u.spec.state;if(u.key==o.name&&f&&f.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){s[o.name]=f.fromJSON.call(u,e,n[l],s);return}}s[o.name]=o.init(e,s)}}),s}}function dD(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=dD(i,e,{})),n[r]=i}return n}class Lt{constructor(e){this.spec=e,this.props={},e.props&&dD(e.props,this,this.props),this.key=e.key?e.key.key:fD("plugin")}getState(e){return e[this.key]}}const Sv=Object.create(null);function fD(t){return t in Sv?t+"$"+ ++Sv[t]:(Sv[t]=0,t+"$")}class Qt{constructor(e="key"){this.key=fD(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const hD=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function pD(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const mD=(t,e,n)=>{let r=pD(t,n);if(!r)return!1;let i=Vw(r);if(!i){let o=r.blockRange(),l=o&&jc(o);return l==null?!1:(e&&e(t.tr.lift(o,l).scrollIntoView()),!0)}let s=i.nodeBefore;if(CD(t,i,e,-1))return!0;if(r.parent.content.size==0&&(vc(s,"end")||He.isSelectable(s)))for(let o=r.depth;;o--){let l=Qm(t.doc,r.before(o),r.after(o),Ee.empty);if(l&&l.slice.size<l.to-l.from){if(e){let u=t.tr.step(l);u.setSelection(vc(s,"end")?Ke.findFrom(u.doc.resolve(u.mapping.map(i.pos,-1)),-1):He.create(u.doc,i.pos-s.nodeSize)),e(u.scrollIntoView())}return!0}if(o==1||r.node(o-1).childCount>1)break}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos-s.nodeSize,i.pos).scrollIntoView()),!0):!1},z4=(t,e,n)=>{let r=pD(t,n);if(!r)return!1;let i=Vw(r);return i?gD(t,i,e):!1},$4=(t,e,n)=>{let r=bD(t,n);if(!r)return!1;let i=Hw(r);return i?gD(t,i,e):!1};function gD(t,e,n){let r=e.nodeBefore,i=r,s=e.pos-1;for(;!i.isTextblock;s--){if(i.type.spec.isolating)return!1;let h=i.lastChild;if(!h)return!1;i=h}let o=e.nodeAfter,l=o,u=e.pos+1;for(;!l.isTextblock;u++){if(l.type.spec.isolating)return!1;let h=l.firstChild;if(!h)return!1;l=h}let f=Qm(t.doc,s,u,Ee.empty);if(!f||f.from!=s||f instanceof fn&&f.slice.size>=u-s)return!1;if(n){let h=t.tr.step(f);h.setSelection(ze.create(h.doc,s)),n(h.scrollIntoView())}return!0}function vc(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 yD=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;s=Vw(r)}let o=s&&s.nodeBefore;return!o||!He.isSelectable(o)?!1:(e&&e(t.tr.setSelection(He.create(t.doc,s.pos-o.nodeSize)).scrollIntoView()),!0)};function Vw(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 bD(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}const vD=(t,e,n)=>{let r=bD(t,n);if(!r)return!1;let i=Hw(r);if(!i)return!1;let s=i.nodeAfter;if(CD(t,i,e,1))return!0;if(r.parent.content.size==0&&(vc(s,"start")||He.isSelectable(s))){let o=Qm(t.doc,r.before(),r.after(),Ee.empty);if(o&&o.slice.size<o.to-o.from){if(e){let l=t.tr.step(o);l.setSelection(vc(s,"start")?Ke.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):He.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&i.depth==r.depth-1?(e&&e(t.tr.delete(i.pos,i.pos+s.nodeSize).scrollIntoView()),!0):!1},xD=(t,e,n)=>{let{$head:r,empty:i}=t.selection,s=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;s=Hw(r)}let o=s&&s.nodeAfter;return!o||!He.isSelectable(o)?!1:(e&&e(t.tr.setSelection(He.create(t.doc,s.pos)).scrollIntoView()),!0)};function Hw(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 B4=(t,e)=>{let n=t.selection,r=n instanceof He,i;if(r){if(n.node.isTextblock||!Ko(t.doc,n.from))return!1;i=n.from}else if(i=Jm(t.doc,n.from,-1),i==null)return!1;if(e){let s=t.tr.join(i);r&&s.setSelection(He.create(s.doc,i-t.doc.resolve(i).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},V4=(t,e)=>{let n=t.selection,r;if(n instanceof He){if(n.node.isTextblock||!Ko(t.doc,n.to))return!1;r=n.to}else if(r=Jm(t.doc,n.to,1),r==null)return!1;return e&&e(t.tr.join(r).scrollIntoView()),!0},H4=(t,e)=>{let{$from:n,$to:r}=t.selection,i=n.blockRange(r),s=i&&jc(i);return s==null?!1:(e&&e(t.tr.lift(i,s).scrollIntoView()),!0)},wD=(t,e)=>{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(`
|
|
69
|
+
`).scrollIntoView()),!0)};function Uw(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 U4=(t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),s=n.indexAfter(-1),o=Uw(i.contentMatchAt(s));if(!o||!i.canReplaceWith(s,s,o))return!1;if(e){let l=n.after(),u=t.tr.replaceWith(l,l,o.createAndFill());u.setSelection(Ke.near(u.doc.resolve(l),1)),e(u.scrollIntoView())}return!0},SD=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Mr||r.parent.inlineContent||i.parent.inlineContent)return!1;let s=Uw(i.parent.contentMatchAt(i.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let o=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,l=t.tr.insert(o,s.createAndFill());l.setSelection(ze.create(l.doc,o+1)),e(l.scrollIntoView())}return!0},kD=(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 s=n.before();if(Es(t.doc,s))return e&&e(t.tr.split(s).scrollIntoView()),!0}let r=n.blockRange(),i=r&&jc(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function F4(t){return(e,n)=>{if(e.selection instanceof He&&e.selection.node.isBlock){let{$from:b}=e.selection;return!b.parentOffset||!Es(e.doc,b.pos)?!1:(n&&n(e.tr.split(b.pos).scrollIntoView()),!0)}if(!e.selection.$from.depth)return!1;let r=e.tr;!e.selection.empty&&(e.selection instanceof ze||e.selection instanceof Mr)&&r.deleteSelection();let{$from:i}=r.selection,s=r.steps.length,o=[],l,u,f=!1,h=!1;for(let b=i.depth;;b--)if(i.node(b).isBlock){f=i.end(b)==i.pos+(i.depth-b),h=i.start(b)==i.pos-(i.depth-b),u=Uw(i.node(b-1).contentMatchAt(i.indexAfter(b-1))),o.unshift(f&&u?{type:u}:null),l=b;break}else{if(b==1)return!1;o.unshift(null)}let m=i.pos,g=Es(r.doc,m,o.length,o);if(g||(o[0]=u?{type:u}:null,g=Es(r.doc,m,o.length,o)),!g)return!1;if(r.split(m,o.length,o),!f&&h&&i.node(l).type!=u){let b=r.mapping.slice(s),x=b.map(i.before(l)),S=r.doc.resolve(x);u&&i.node(l-1).canReplaceWith(S.index(),S.index()+1,u)&&r.setNodeMarkup(b.map(i.before(l)),u)}return n&&n(r.scrollIntoView()),!0}}const q4=F4(),G4=(t,e)=>{let{$from:n,to:r}=t.selection,i,s=n.sharedDepth(r);return s==0?!1:(i=n.before(s),e&&e(t.tr.setSelection(He.create(t.doc,i))),!0)};function W4(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,s=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(i.isTextblock||Ko(t.doc,e.pos))?!1:(n&&n(t.tr.join(e.pos).scrollIntoView()),!0)}function CD(t,e,n,r){let i=e.nodeBefore,s=e.nodeAfter,o,l,u=i.type.spec.isolating||s.type.spec.isolating;if(!u&&W4(t,e,n))return!0;let f=!u&&e.parent.canReplace(e.index(),e.index()+1);if(f&&(o=(l=i.contentMatchAt(i.childCount)).findWrapping(s.type))&&l.matchType(o[0]||s.type).validEnd){if(n){let b=e.pos+s.nodeSize,x=de.empty;for(let C=o.length-1;C>=0;C--)x=de.from(o[C].create(null,x));x=de.from(i.copy(x));let S=t.tr.step(new kn(e.pos-1,b,e.pos,b,new Ee(x,1,0),o.length,!0)),k=S.doc.resolve(b+2*o.length);k.nodeAfter&&k.nodeAfter.type==i.type&&Ko(S.doc,k.pos)&&S.join(k.pos),n(S.scrollIntoView())}return!0}let h=s.type.spec.isolating||r>0&&u?null:Ke.findFrom(e,1),m=h&&h.$from.blockRange(h.$to),g=m&&jc(m);if(g!=null&&g>=e.depth)return n&&n(t.tr.lift(m,g).scrollIntoView()),!0;if(f&&vc(s,"start",!0)&&vc(i,"end")){let b=i,x=[];for(;x.push(b),!b.isTextblock;)b=b.lastChild;let S=s,k=1;for(;!S.isTextblock;S=S.firstChild)k++;if(b.canReplace(b.childCount,b.childCount,S.content)){if(n){let C=de.empty;for(let R=x.length-1;R>=0;R--)C=de.from(x[R].copy(C));let A=t.tr.step(new kn(e.pos-x.length,e.pos+s.nodeSize,e.pos+k,e.pos+s.nodeSize-k,new Ee(C,x.length,0),0,!0));n(A.scrollIntoView())}return!0}}return!1}function ED(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,s=i.depth;for(;i.node(s).isInline;){if(!s)return!1;s--}return i.node(s).isTextblock?(n&&n(e.tr.setSelection(ze.create(e.doc,t<0?i.start(s):i.end(s)))),!0):!1}}const K4=ED(-1),Z4=ED(1);function Y4(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s),l=o&&zw(o,t,e);return l?(r&&r(n.tr.wrap(o,l).scrollIntoView()),!0):!1}}function sA(t,e=null){return function(n,r){let i=!1;for(let s=0;s<n.selection.ranges.length&&!i;s++){let{$from:{pos:o},$to:{pos:l}}=n.selection.ranges[s];n.doc.nodesBetween(o,l,(u,f)=>{if(i)return!1;if(!(!u.isTextblock||u.hasMarkup(t,e)))if(u.type==t)i=!0;else{let h=n.doc.resolve(f),m=h.index();i=h.parent.canReplaceWith(m,m+1,t)}})}if(!i)return!1;if(r){let s=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:l},$to:{pos:u}}=n.selection.ranges[o];s.setBlockType(l,u,t,e)}r(s.scrollIntoView())}return!0}}function Fw(...t){return function(e,n,r){for(let i=0;i<t.length;i++)if(t[i](e,n,r))return!0;return!1}}Fw(hD,mD,yD);Fw(hD,vD,xD);Fw(wD,SD,kD,q4);typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function X4(t,e=null){return function(n,r){let{$from:i,$to:s}=n.selection,o=i.blockRange(s);if(!o)return!1;let l=r?n.tr:null;return J4(l,o,t,e)?(r&&r(l.scrollIntoView()),!0):!1}}function J4(t,e,n,r=null){let i=!1,s=e,o=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=o.resolve(e.start-2);s=new Hp(u,u,e.depth),e.endIndex<e.parent.childCount&&(e=new Hp(e.$from,o.resolve(e.$to.end(e.depth)),e.depth)),i=!0}let l=zw(s,n,r,e);return l?(t&&Q4(t,e,l,i,n),!0):!1}function Q4(t,e,n,r,i){let s=de.empty;for(let h=n.length-1;h>=0;h--)s=de.from(n[h].type.create(n[h].attrs,s));t.step(new kn(e.start-(r?2:0),e.end,e.start,e.end,new Ee(s,0,0),n.length,!0));let o=0;for(let h=0;h<n.length;h++)n[h].type==i&&(o=h+1);let l=n.length-o,u=e.start+n.length-(r?2:0),f=e.parent;for(let h=e.startIndex,m=e.endIndex,g=!0;h<m;h++,g=!1)!g&&Es(t.doc,u,l)&&(t.split(u,l),u+=2*l),u+=f.child(h).nodeSize;return t}function e6(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,o=>o.childCount>0&&o.firstChild.type==t);return s?n?r.node(s.depth-1).type==t?t6(e,n,t,s):n6(e,n,s):!0:!1}}function t6(t,e,n,r){let i=t.tr,s=r.end,o=r.$to.end(r.depth);s<o&&(i.step(new kn(s-1,o,s,o,new Ee(de.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new Hp(i.doc.resolve(r.$from.pos),i.doc.resolve(o),r.depth));const l=jc(r);if(l==null)return!1;i.lift(r,l);let u=i.doc.resolve(i.mapping.map(s,-1)-1);return Ko(i.doc,u.pos)&&u.nodeBefore.type==u.nodeAfter.type&&i.join(u.pos),e(i.scrollIntoView()),!0}function n6(t,e,n){let r=t.tr,i=n.parent;for(let b=n.end,x=n.endIndex-1,S=n.startIndex;x>S;x--)b-=i.child(x).nodeSize,r.delete(b-1,b+1);let s=r.doc.resolve(n.start),o=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let l=n.startIndex==0,u=n.endIndex==i.childCount,f=s.node(-1),h=s.index(-1);if(!f.canReplace(h+(l?0:1),h+1,o.content.append(u?de.empty:de.from(i))))return!1;let m=s.pos,g=m+o.nodeSize;return r.step(new kn(m-(l?1:0),g+(u?1:0),m+1,g-1,new Ee((l?de.empty:de.from(i.copy(de.empty))).append(u?de.empty:de.from(i.copy(de.empty))),l?0:1,u?0:1),l?0:1)),e(r.scrollIntoView()),!0}function r6(t){return function(e,n){let{$from:r,$to:i}=e.selection,s=r.blockRange(i,f=>f.childCount>0&&f.firstChild.type==t);if(!s)return!1;let o=s.startIndex;if(o==0)return!1;let l=s.parent,u=l.child(o-1);if(u.type!=t)return!1;if(n){let f=u.lastChild&&u.lastChild.type==l.type,h=de.from(f?t.create():null),m=new Ee(de.from(t.create(null,de.from(l.type.create(null,h)))),f?3:1,0),g=s.start,b=s.end;n(e.tr.step(new kn(g-(f?3:1),b,g,b,m,1,!0)).scrollIntoView())}return!0}}const Ln=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},xc=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Q0=null;const hs=function(t,e,n){let r=Q0||(Q0=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},i6=function(){Q0=null},Ba=function(t,e,n,r){return n&&(oA(t,e,n,r,-1)||oA(t,e,n,r,1))},s6=/^(img|br|input|textarea|hr)$/i;function oA(t,e,n,r,i){for(var s;;){if(t==n&&e==r)return!0;if(e==(i<0?0:Zr(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Qd(t)||s6.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ln(t)+(i<0?0:1),t=o}else if(t.nodeType==1){let o=t.childNodes[e+(i<0?-1:0)];if(o.nodeType==1&&o.contentEditable=="false")if(!((s=o.pmViewDesc)===null||s===void 0)&&s.ignoreForSelection)e+=i;else return!1;else t=o,e=i<0?Zr(t):0}else return!1}}function Zr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function o6(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=Zr(t)}else if(t.parentNode&&!Qd(t))e=Ln(t),t=t.parentNode;else return null}}function a6(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&&!Qd(t))e=Ln(t)+1,t=t.parentNode;else return null}}function l6(t,e,n){for(let r=e==0,i=e==Zr(t);r||i;){if(t==n)return!0;let s=Ln(t);if(t=t.parentNode,!t)return!1;r=r&&s==0,i=i&&s==Zr(t)}}function Qd(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 tg=function(t){return t.focusNode&&Ba(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function va(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function c6(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function u6(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:Math.min(Zr(r.offsetNode),r.offset)}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:Math.min(Zr(r.startContainer),r.startOffset)}}}const Li=typeof navigator<"u"?navigator:null,aA=typeof document<"u"?document:null,Zo=Li&&Li.userAgent||"",ex=/Edge\/(\d+)/.exec(Zo),TD=/MSIE \d/.exec(Zo),tx=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Zo),mr=!!(TD||tx||ex),Oo=TD?document.documentMode:tx?+tx[1]:ex?+ex[1]:0,Yr=!mr&&/gecko\/(\d+)/i.test(Zo);Yr&&+(/Firefox\/(\d+)/.exec(Zo)||[0,0])[1];const nx=!mr&&/Chrome\/(\d+)/.exec(Zo),zn=!!nx,_D=nx?+nx[1]:0,Gn=!mr&&!!Li&&/Apple Computer/.test(Li.vendor),wc=Gn&&(/Mobile\/\w+/.test(Zo)||!!Li&&Li.maxTouchPoints>2),Wr=wc||(Li?/Mac/.test(Li.platform):!1),AD=Li?/Win/.test(Li.platform):!1,Ss=/Android \d/.test(Zo),ef=!!aA&&"webkitFontSmoothing"in aA.documentElement.style,d6=ef?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function f6(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 as(t,e){return typeof t=="number"?t:t[e]}function h6(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 lA(t,e,n){if(!rx(e)&&e.left==0)return;let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,s=t.dom.ownerDocument;for(let o=n||t.dom;o;){if(o.nodeType!=1){o=xc(o);continue}let l=o,u=l==s.body,f=u?f6(s):h6(l),h=0,m=0;if(e.top<f.top+as(r,"top")?m=-(f.top-e.top+as(i,"top")):e.bottom>f.bottom-as(r,"bottom")&&(m=e.bottom-e.top>f.bottom-f.top?e.top+as(i,"top")-f.top:e.bottom-f.bottom+as(i,"bottom")),e.left<f.left+as(r,"left")?h=-(f.left-e.left+as(i,"left")):e.right>f.right-as(r,"right")&&(h=e.right-f.right+as(i,"right")),h||m)if(u)s.defaultView.scrollBy(h,m);else{let b=l.scrollLeft,x=l.scrollTop;m&&(l.scrollTop+=m),h&&(l.scrollLeft+=h);let S=l.scrollLeft-b,k=l.scrollTop-x;e={left:e.left-S,top:e.top-k,right:e.right-S,bottom:e.bottom-k}}let g=u?"fixed":getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(g))break;o=g=="absolute"?o.offsetParent:xc(o)}}function p6(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let s=(e.left+e.right)/2,o=n+1;o<Math.min(innerHeight,e.bottom);o+=5){let l=t.root.elementFromPoint(s,o);if(!l||l==t.dom||!t.dom.contains(l))continue;let u=l.getBoundingClientRect();if(u.top>=n-20){r=l,i=u.top;break}}return{refDOM:r,refTop:i,stack:RD(t.dom)}}function RD(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=xc(r));return e}function m6({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;MD(n,r==0?0:r-e)}function MD(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:i,left:s}=t[n];r.scrollTop!=i+e&&(r.scrollTop=i+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let Vl=null;function g6(t){if(t.setActive)return t.setActive();if(Vl)return t.focus(Vl);let e=RD(t);t.focus(Vl==null?{get preventScroll(){return Vl={preventScroll:!0},!0}}:void 0),Vl||(Vl=!1,MD(e,0))}function ND(t,e){let n,r=2e8,i,s=0,o=e.top,l=e.top,u,f;for(let h=t.firstChild,m=0;h;h=h.nextSibling,m++){let g;if(h.nodeType==1)g=h.getClientRects();else if(h.nodeType==3)g=hs(h).getClientRects();else continue;for(let b=0;b<g.length;b++){let x=g[b];if(x.top<=o&&x.bottom>=l){o=Math.max(x.bottom,o),l=Math.min(x.top,l);let S=x.left>e.left?x.left-e.left:x.right<e.left?e.left-x.right:0;if(S<r){n=h,r=S,i=S&&n.nodeType==3?{left:x.right<e.left?x.right:x.left,top:e.top}:e,h.nodeType==1&&S&&(s=m+(e.left>=(x.left+x.right)/2?1:0));continue}}else x.top>e.top&&!u&&x.left<=e.left&&x.right>=e.left&&(u=h,f={left:Math.max(x.left,Math.min(x.right,e.left)),top:x.top});!n&&(e.left>=x.right&&e.top>=x.top||e.left>=x.left&&e.top>=x.bottom)&&(s=m+1)}}return!n&&u&&(n=u,i=f,r=0),n&&n.nodeType==3?y6(n,i):!n||r&&n.nodeType==1?{node:t,offset:s}:ND(n,i)}function y6(t,e){let n=t.nodeValue.length,r=document.createRange(),i;for(let s=0;s<n;s++){r.setEnd(t,s+1),r.setStart(t,s);let o=uo(r,1);if(o.top!=o.bottom&&qw(e,o)){i={node:t,offset:s+(e.left>=(o.left+o.right)/2?1:0)};break}}return r.detach(),i||{node:t,offset:0}}function qw(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function b6(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function v6(t,e,n){let{node:r,offset:i}=ND(e,n),s=-1;if(r.nodeType==1&&!r.firstChild){let o=r.getBoundingClientRect();s=o.left!=o.right&&n.left>(o.left+o.right)/2?1:-1}return t.docView.posFromDOM(r,i,s)}function x6(t,e,n,r){let i=-1;for(let s=e,o=!1;s!=t.dom;){let l=t.docView.nearestDesc(s,!0),u;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((u=l.dom.getBoundingClientRect()).width||u.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!o&&u.left>r.left||u.top>r.top?i=l.posBefore:(!o&&u.right<r.left||u.bottom<r.top)&&(i=l.posAfter),o=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?r.top<(u.top+u.bottom)/2:r.left<(u.left+u.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return i>-1?i:t.docView.posFromDOM(e,n,-1)}function OD(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),s=i;;){let o=t.childNodes[s];if(o.nodeType==1){let l=o.getClientRects();for(let u=0;u<l.length;u++){let f=l[u];if(qw(e,f))return OD(o,e,f)}}if((s=(s+1)%r)==i)break}return t}function w6(t,e){let n=t.dom.ownerDocument,r,i=0,s=u6(n,e.left,e.top);s&&({node:r,offset:i}=s);let o=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!o||!t.dom.contains(o.nodeType!=1?o.parentNode:o)){let f=t.dom.getBoundingClientRect();if(!qw(e,f)||(o=OD(t.dom,e,f),!o))return null}if(Gn)for(let f=o;r&&f;f=xc(f))f.draggable&&(r=void 0);if(o=b6(o,e),r){if(Yr&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let h=r.childNodes[i],m;h.nodeName=="IMG"&&(m=h.getBoundingClientRect()).right<=e.left&&m.bottom>e.top&&i++}let f;ef&&i&&r.nodeType==1&&(f=r.childNodes[i-1]).nodeType==1&&f.contentEditable=="false"&&f.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=x6(t,r,i,e))}l==null&&(l=v6(t,o,e));let u=t.docView.nearestDesc(o,!0);return{pos:l,inside:u?u.posAtStart-u.border:-1}}function rx(t){return t.top<t.bottom||t.left<t.right}function uo(t,e){let n=t.getClientRects();if(n.length){let r=n[e<0?0:n.length-1];if(rx(r))return r}return Array.prototype.find.call(n,rx)||t.getBoundingClientRect()}const S6=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function DD(t,e,n){let{node:r,offset:i,atom:s}=t.docView.domFromPos(e,n<0?-1:1),o=ef||Yr;if(r.nodeType==3)if(o&&(S6.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let u=uo(hs(r,i,i),n);if(Yr&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let f=uo(hs(r,i-1,i-1),-1);if(f.top==u.top){let h=uo(hs(r,i,i+1),-1);if(h.top!=u.top)return Pu(h,h.left<f.left)}}return u}else{let u=i,f=i,h=n<0?1:-1;return n<0&&!i?(f++,h=-1):n>=0&&i==r.nodeValue.length?(u--,h=1):n<0?u--:f++,Pu(uo(hs(r,u,f),h),h<0)}if(!t.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&i&&(n<0||i==Zr(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return kv(u.getBoundingClientRect(),!1)}if(s==null&&i<Zr(r)){let u=r.childNodes[i];if(u.nodeType==1)return kv(u.getBoundingClientRect(),!0)}return kv(r.getBoundingClientRect(),n>=0)}if(s==null&&i&&(n<0||i==Zr(r))){let u=r.childNodes[i-1],f=u.nodeType==3?hs(u,Zr(u)-(o?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(f)return Pu(uo(f,1),!1)}if(s==null&&i<Zr(r)){let u=r.childNodes[i];for(;u.pmViewDesc&&u.pmViewDesc.ignoreForCoords;)u=u.nextSibling;let f=u?u.nodeType==3?hs(u,0,o?0:1):u.nodeType==1?u:null:null;if(f)return Pu(uo(f,-1),!0)}return Pu(uo(r.nodeType==3?hs(r):r,-n),n>=0)}function Pu(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 kv(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 ID(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function k6(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return ID(t,e,()=>{let{node:s}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let o=DD(t,i.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let u;if(l.nodeType==1)u=l.getClientRects();else if(l.nodeType==3)u=hs(l,0,l.nodeValue.length).getClientRects();else continue;for(let f=0;f<u.length;f++){let h=u[f];if(h.bottom>h.top+1&&(n=="up"?o.top-h.top>(h.bottom-o.top)*2:h.bottom-o.bottom>(o.bottom-h.top)*2))return!1}}return!0})}const C6=/[\u0590-\u08ac]/;function E6(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,s=!i,o=i==r.parent.content.size,l=t.domSelection();return l?!C6.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?s:o:ID(t,e,()=>{let{focusNode:u,focusOffset:f,anchorNode:h,anchorOffset:m}=t.domSelectionRange(),g=l.caretBidiLevel;l.modify("move",n,"character");let b=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:x,focusOffset:S}=t.domSelectionRange(),k=x&&!b.contains(x.nodeType==1?x:x.parentNode)||u==x&&f==S;try{l.collapse(h,m),u&&(u!=h||f!=m)&&l.extend&&l.extend(u,f)}catch{}return g!=null&&(l.caretBidiLevel=g),k}):r.pos==r.start()||r.pos==r.end()}let cA=null,uA=null,dA=!1;function T6(t,e,n){return cA==e&&uA==n?dA:(cA=e,uA=n,dA=n=="up"||n=="down"?k6(t,e,n):E6(t,e,n))}const Xr=0,fA=1,ka=2,gi=3;class tf{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Xr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(e){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 i=this.children[n];if(i==e)return r;r+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,o;if(e==this.contentDOM)s=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(o)+o.size:this.posAtStart}else{let s,o;if(e==this.contentDOM)s=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((o=s.pmViewDesc)&&o.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(o):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=n>Ln(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!1;break}if(s.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){i=!0;break}if(s.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let s=this.getDesc(i),o;if(s&&(!n||s.node))if(r&&(o=s.nodeDOM)&&!(o.nodeType==1?o.contains(e.nodeType==1?e:e.parentNode):o==e))r=!1;else return s}}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 i=e;i;i=i.parentNode){let s=this.getDesc(i);if(s)return s.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;n<this.children.length;n++){let i=this.children[n],s=r+i.size;if(r==e&&s!=r){for(;!i.border&&i.children.length;)for(let o=0;o<i.children.length;o++){let l=i.children[o];if(l.size){i=l;break}}return i}if(e<s)return i.descAt(e-r-i.border);r=s}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,i=0;for(let s=0;r<this.children.length;r++){let o=this.children[r],l=s+o.size;if(l>e||o instanceof LD){i=e-s;break}s=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof jD&&s.side>=0;r--);if(n<=0){let s,o=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,o=!1);return s&&n&&o&&!s.border&&!s.domAtom?s.domFromPos(s.size,n):{node:this.contentDOM,offset:s?Ln(s.dom)+1:0}}else{let s,o=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,o=!1);return s&&o&&!s.border&&!s.domAtom?s.domFromPos(0,n):{node:this.contentDOM,offset:s?Ln(s.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 i=-1,s=-1;for(let o=r,l=0;;l++){let u=this.children[l],f=o+u.size;if(i==-1&&e<=f){let h=o+u.border;if(e>=h&&n<=f-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,h);e=o;for(let m=l;m>0;m--){let g=this.children[m-1];if(g.size&&g.dom.parentNode==this.contentDOM&&!g.emptyChildAt(1)){i=Ln(g.dom)+1;break}e-=g.size}i==-1&&(i=0)}if(i>-1&&(f>n||l==this.children.length-1)){n=f;for(let h=l+1;h<this.children.length;h++){let m=this.children[h];if(m.size&&m.dom.parentNode==this.contentDOM&&!m.emptyChildAt(-1)){s=Ln(m.dom);break}n+=m.size}s==-1&&(s=this.contentDOM.childNodes.length);break}o=f}return{node:this.contentDOM,from:e,to:n,fromOffset:i,toOffset:s}}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,i=!1){let s=Math.min(e,n),o=Math.max(e,n);for(let b=0,x=0;b<this.children.length;b++){let S=this.children[b],k=x+S.size;if(s>x&&o<k)return S.setSelection(e-x-S.border,n-x-S.border,r,i);x=k}let l=this.domFromPos(e,e?-1:1),u=n==e?l:this.domFromPos(n,n?-1:1),f=r.root.getSelection(),h=r.domSelectionRange(),m=!1;if((Yr||Gn)&&e==n){let{node:b,offset:x}=l;if(b.nodeType==3){if(m=!!(x&&b.nodeValue[x-1]==`
|
|
70
|
+
`),m&&x==b.nodeValue.length)for(let S=b,k;S;S=S.parentNode){if(k=S.nextSibling){k.nodeName=="BR"&&(l=u={node:k.parentNode,offset:Ln(k)+1});break}let C=S.pmViewDesc;if(C&&C.node&&C.node.isBlock)break}}else{let S=b.childNodes[x-1];m=S&&(S.nodeName=="BR"||S.contentEditable=="false")}}if(Yr&&h.focusNode&&h.focusNode!=u.node&&h.focusNode.nodeType==1){let b=h.focusNode.childNodes[h.focusOffset];b&&b.contentEditable=="false"&&(i=!0)}if(!(i||m&&Gn)&&Ba(l.node,l.offset,h.anchorNode,h.anchorOffset)&&Ba(u.node,u.offset,h.focusNode,h.focusOffset))return;let g=!1;if((f.extend||e==n)&&!(m&&Yr)){f.collapse(l.node,l.offset);try{e!=n&&f.extend(u.node,u.offset),g=!0}catch{}}if(!g){if(e>n){let x=l;l=u,u=x}let b=document.createRange();b.setEnd(u.node,u.offset),b.setStart(l.node,l.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,i=0;i<this.children.length;i++){let s=this.children[i],o=r+s.size;if(r==o?e<=o&&n>=r:e<o&&n>r){let l=r+s.border,u=o-s.border;if(e>=l&&n<=u){this.dirty=e==r||n==o?ka:fA,e==l&&n==u&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=gi:s.markDirty(e-l,n-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?ka:gi}r=o}this.dirty=ka}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?ka:fA;n.dirty<r&&(n.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class jD extends tf{constructor(e,n,r,i){let s,o=n.type.toDOM;if(typeof o=="function"&&(o=o(r,()=>{if(!s)return i;if(s.parent)return s.parent.posBeforeChild(s)})),!n.type.spec.raw){if(o.nodeType!=1){let l=document.createElement("span");l.appendChild(o),o=l}o.contentEditable="false",o.classList.add("ProseMirror-widget")}super(e,[],o,null),this.widget=n,this.widget=n,s=this}matchesWidget(e){return this.dirty==Xr&&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 _6 extends tf{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}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 Do extends tf{constructor(e,n,r,i,s){super(e,[],r,i),this.mark=n,this.spec=s}static create(e,n,r,i){let s=i.nodeViews[n.type.name],o=s&&s(n,i,r);return(!o||!o.dom)&&(o=Xa.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new Do(e,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&gi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=gi&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=Xr){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Xr}}slice(e,n,r){let i=Do.create(this.parent,this.mark,!0,r),s=this.children,o=this.size;n<o&&(s=sx(s,n,o,r)),e>0&&(s=sx(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=i;return i.children=s,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Io extends tf{constructor(e,n,r,i,s,o,l){super(e,[],s,o),this.node=n,this.outerDeco=r,this.innerDeco=i,this.nodeDOM=l}static create(e,n,r,i,s,o){let l=s.nodeViews[n.type.name],u,f=l&&l(n,s,()=>{if(!u)return o;if(u.parent)return u.parent.posBeforeChild(u)},r,i),h=f&&f.dom,m=f&&f.contentDOM;if(n.isText){if(!h)h=document.createTextNode(n.text);else if(h.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else h||({dom:h,contentDOM:m}=Xa.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!m&&!n.isText&&h.nodeName!="BR"&&(h.hasAttribute("contenteditable")||(h.contentEditable="false"),n.type.spec.draggable&&(h.draggable=!0));let g=h;return h=$D(h,r,n),f?u=new A6(e,n,r,i,h,m||null,g,f):n.isText?new ng(e,n,r,i,h,g):new Io(e,n,r,i,h,m||null,g)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let n={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(n.preserveWhitespace="full"),!this.contentDOM)n.getContent=()=>this.node.content;else if(!this.contentLost)n.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let i=this.children[r];if(this.dom.contains(i.dom.parentNode)){n.contentElement=i.dom.parentNode;break}}if(!n.contentElement){let r=e&&e.find(i=>i.nodeType==1&&e.indexOf(i.parentNode)<0&&this.dom.contains(i));r?n.contentElement=r:n.getContent=()=>de.empty}}return n}matchesNode(e,n,r){return this.dirty==Xr&&e.eq(this.node)&&Fp(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,i=n,s=e.composing?this.localCompositionInfo(e,n):null,o=s&&s.pos>-1?s:null,l=s&&s.pos<0,u=new M6(this,o&&o.node,e);D6(this.node,this.innerDeco,(f,h,m)=>{f.spec.marks?u.syncToMarks(f.spec.marks,r,e,h):f.type.side>=0&&!m&&u.syncToMarks(h==this.node.childCount?Ot.none:this.node.child(h).marks,r,e,h),u.placeWidget(f,e,i)},(f,h,m,g)=>{u.syncToMarks(f.marks,r,e,g);let b;u.findNodeMatch(f,h,m,g)||l&&e.state.selection.from>i&&e.state.selection.to<i+f.nodeSize&&(b=u.findIndexWithChild(s.node))>-1&&u.updateNodeAt(f,h,m,b,e)||u.updateNextNode(f,h,m,e,g,i)||u.addNode(f,h,m,e,i),i+=f.nodeSize}),u.syncToMarks([],r,e,0),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==ka)&&(o&&this.protectLocalComposition(e,o),PD(this.contentDOM,this.children,e),wc&&I6(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof ze)||r<n||i>n+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let o=s.nodeValue,l=j6(this.node.content,o,r-n,i-n);return l<0?null:{node:s,pos:l,text:o}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let s=n;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let o=new _6(this,s,n,i);e.input.compositionNodes.push(o),this.children=sx(this.children,r,r+i.length,e,o)}update(e,n,r,i){return this.dirty==gi||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Xr}updateOuterDeco(e){if(Fp(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=zD(this.dom,this.nodeDOM,ix(this.outerDeco,this.node,n),ix(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 hA(t,e,n,r,i){$D(r,e,t);let s=new Io(void 0,t,e,n,r,r,r);return s.contentDOM&&s.updateChildren(i,0),s}class ng extends Io{constructor(e,n,r,i,s,o){super(e,n,r,i,s,null,o)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==gi||this.dirty!=Xr&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Xr||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Xr,!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 i=this.node.cut(e,n),s=document.createTextNode(i.text);return new ng(this.parent,i,this.outerDeco,this.innerDeco,s,s)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=gi)}get domAtom(){return!1}isText(e){return this.node.text==e}}class LD extends tf{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Xr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class A6 extends Io{constructor(e,n,r,i,s,o,l,u){super(e,n,r,i,s,o,l),this.spec=u}update(e,n,r,i){if(this.dirty==gi)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,n,r);return s&&this.updateInner(e,n,r,i),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r.root):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function PD(t,e,n){let r=t.firstChild,i=!1;for(let s=0;s<e.length;s++){let o=e[s],l=o.dom;if(l.parentNode==t){for(;l!=r;)r=pA(r),i=!0;r=r.nextSibling}else i=!0,t.insertBefore(l,r);if(o instanceof Do){let u=r?r.previousSibling:t.lastChild;PD(o.contentDOM,o.children,n),r=u?u.nextSibling:t.firstChild}}for(;r;)r=pA(r),i=!0;i&&n.trackWrites==t&&(n.trackWrites=null)}const ad=function(t){t&&(this.nodeName=t)};ad.prototype=Object.create(null);const Ca=[new ad];function ix(t,e,n){if(t.length==0)return Ca;let r=n?Ca[0]:new ad,i=[r];for(let s=0;s<t.length;s++){let o=t[s].type.attrs;if(o){o.nodeName&&i.push(r=new ad(o.nodeName));for(let l in o){let u=o[l];u!=null&&(n&&i.length==1&&i.push(r=new ad(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+u:l=="style"?r.style=(r.style?r.style+";":"")+u:l!="nodeName"&&(r[l]=u))}}}return i}function zD(t,e,n,r){if(n==Ca&&r==Ca)return e;let i=e;for(let s=0;s<r.length;s++){let o=r[s],l=n[s];if(s){let u;l&&l.nodeName==o.nodeName&&i!=t&&(u=i.parentNode)&&u.nodeName.toLowerCase()==o.nodeName||(u=document.createElement(o.nodeName),u.pmIsDeco=!0,u.appendChild(i),l=Ca[0]),i=u}R6(i,l||Ca[0],o)}return i}function R6(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):[],i=n.class?n.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)i.indexOf(r[s])==-1&&t.classList.remove(r[s]);for(let s=0;s<i.length;s++)r.indexOf(i[s])==-1&&t.classList.add(i[s]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=r.exec(e.style);)t.style.removeProperty(i[1])}n.style&&(t.style.cssText+=n.style)}}function $D(t,e,n){return zD(t,t,Ca,ix(e,n,t.nodeType!=1))}function Fp(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 pA(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class M6{constructor(e,n,r){this.lock=n,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=N6(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,i){let s=0,o=this.stack.length>>1,l=Math.min(o,e.length);for(;s<l&&(s==o-1?this.top:this.stack[s+1<<1]).matchesMark(e[s])&&e[s].type.spec.spanning!==!1;)s++;for(;s<o;)this.destroyRest(),this.top.dirty=Xr,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<e.length;){this.stack.push(this.top,this.index+1);let u=-1,f=this.top.children.length;i<this.preMatch.index&&(f=Math.min(this.index+3,f));for(let h=this.index;h<f;h++){let m=this.top.children[h];if(m.matchesMark(e[o])&&!this.isLocked(m.dom)){u=h;break}}if(u<0&&this.index<this.top.children.length){let h=this.top.children[this.index];h instanceof Do&&h.dirty!=gi&&h.mark.type==e[o].type&&h.spec.update&&!this.isLocked(h.dom)&&h.spec.update(e[o])&&(h.mark=e[o],u=this.index,this.changed=!0)}if(u>-1)u>this.index&&(this.changed=!0,this.destroyBetween(this.index,u)),this.top=this.top.children[this.index];else{let h=Do.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,h),this.top=h,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let s=-1,o;if(i>=this.preMatch.index&&(o=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&o.matchesNode(e,n,r))s=this.top.children.indexOf(o,this.index);else for(let l=this.index,u=Math.min(this.top.children.length,l+5);l<u;l++){let f=this.top.children[l];if(f.matchesNode(e,n,r)&&!this.preMatch.matched.has(f)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,n,r,i,s){let o=this.top.children[i];return o.dirty==gi&&o.dom==o.contentDOM&&(o.dirty=ka),o.update(e,n,r,s)?(this.destroyBetween(this.index,i),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 i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==r)return i}return-1}e=n}}updateNextNode(e,n,r,i,s,o){for(let l=this.index;l<this.top.children.length;l++){let u=this.top.children[l];if(u instanceof Io){let f=this.preMatch.matched.get(u);if(f!=null&&f!=s)return!1;let h=u.dom,m,g=this.isLocked(h)&&!(e.isText&&u.node&&u.node.isText&&u.nodeDOM.nodeValue==e.text&&u.dirty!=gi&&Fp(n,u.outerDeco));if(!g&&u.update(e,n,r,i))return this.destroyBetween(this.index,l),u.dom!=h&&(this.changed=!0),this.index++,!0;if(!g&&(m=this.recreateWrapper(u,e,n,r,i,o)))return this.destroyBetween(this.index,l),this.top.children[this.index]=m,m.contentDOM&&(m.dirty=ka,m.updateChildren(i,o+1),m.dirty=Xr),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,r,i,s,o){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!Fp(r,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=Io.create(this.top,n,r,i,s,o);if(l.contentDOM){l.children=e.children,e.children=[];for(let u of l.children)u.parent=l}return e.destroy(),l}addNode(e,n,r,i,s){let o=Io.create(this.top,e,n,r,i,s);o.contentDOM&&o.updateChildren(i,s+1),this.top.children.splice(this.index++,0,o),this.changed=!0}placeWidget(e,n,r){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let s=new jD(this.top,e,n,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Do;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof ng)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Gn||zn)&&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 i=new LD(this.top,[],r,null);n!=this.top?n.children.push(i):n.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function N6(t,e){let n=e,r=n.children.length,i=t.childCount,s=new Map,o=[];e:for(;i>0;){let l;for(;;)if(r){let f=n.children[r-1];if(f instanceof Do)n=f,r=f.children.length;else{l=f,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=l.node;if(u){if(u!=t.child(i-1))break;--i,s.set(l,i),o.push(l)}}return{index:i,matched:s,matches:o.reverse()}}function O6(t,e){return t.type.side-e.type.side}function D6(t,e,n,r){let i=e.locals(t),s=0;if(i.length==0){for(let f=0;f<t.childCount;f++){let h=t.child(f);r(h,i,e.forChild(s,h),f),s+=h.nodeSize}return}let o=0,l=[],u=null;for(let f=0;;){let h,m;for(;o<i.length&&i[o].to==s;){let k=i[o++];k.widget&&(h?(m||(m=[h])).push(k):h=k)}if(h)if(m){m.sort(O6);for(let k=0;k<m.length;k++)n(m[k],f,!!u)}else n(h,f,!!u);let g,b;if(u)b=-1,g=u,u=null;else if(f<t.childCount)b=f,g=t.child(f++);else break;for(let k=0;k<l.length;k++)l[k].to<=s&&l.splice(k--,1);for(;o<i.length&&i[o].from<=s&&i[o].to>s;)l.push(i[o++]);let x=s+g.nodeSize;if(g.isText){let k=x;o<i.length&&i[o].from<k&&(k=i[o].from);for(let C=0;C<l.length;C++)l[C].to<k&&(k=l[C].to);k<x&&(u=g.cut(k-s),g=g.cut(0,k-s),x=k,b=-1)}else for(;o<i.length&&i[o].to<x;)o++;let S=g.isInline&&!g.isLeaf?l.filter(k=>!k.inline):l.slice();r(g,S,e.forChild(s,g),b),s=x}}function I6(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 j6(t,e,n,r){for(let i=0,s=0;i<t.childCount&&s<=r;){let o=t.child(i++),l=s;if(s+=o.nodeSize,!o.isText)continue;let u=o.text;for(;i<t.childCount;){let f=t.child(i++);if(s+=f.nodeSize,!f.isText)break;u+=f.text}if(s>=n){if(s>=r&&u.slice(r-e.length-l,r-l)==e)return r-e.length;let f=l<r?u.lastIndexOf(e,r-l-1):-1;if(f>=0&&f+e.length+l>=n)return l+f;if(n==r&&u.length>=r+e.length-l&&u.slice(r-l,r-l+e.length)==e)return r}}return-1}function sx(t,e,n,r,i){let s=[];for(let o=0,l=0;o<t.length;o++){let u=t[o],f=l,h=l+=u.size;f>=n||h<=e?s.push(u):(f<e&&s.push(u.slice(0,e-f,r)),i&&(s.push(i),i=void 0),h>n&&s.push(u.slice(n-f,u.size,r)))}return s}function Gw(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),s=i&&i.size==0,o=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let l=r.resolve(o),u,f;if(tg(n)){for(u=o;i&&!i.node;)i=i.parent;let m=i.node;if(i&&m.isAtom&&He.isSelectable(m)&&i.parent&&!(m.isInline&&l6(n.focusNode,n.focusOffset,i.dom))){let g=i.posBefore;f=new He(o==g?l:r.resolve(g))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let m=o,g=o;for(let b=0;b<n.rangeCount;b++){let x=n.getRangeAt(b);m=Math.min(m,t.docView.posFromDOM(x.startContainer,x.startOffset,1)),g=Math.max(g,t.docView.posFromDOM(x.endContainer,x.endOffset,-1))}if(m<0)return null;[u,o]=g==t.state.selection.anchor?[g,m]:[m,g],l=r.resolve(o)}else u=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(u<0)return null}let h=r.resolve(u);if(!f){let m=e=="pointer"||t.state.selection.head<l.pos&&!s?1:-1;f=Ww(t,h,l,m)}return f}function BD(t){return t.editable?t.hasFocus():HD(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ts(t,e=!1){let n=t.state.selection;if(VD(t,n),!BD(t))return;let r=t.input.mouseDown;if(!e&&zn&&r){let i=t.domSelectionRange(),s=t.domObserver.currentSelection;if(i.anchorNode&&s.anchorNode&&Ba(i.anchorNode,i.anchorOffset,s.anchorNode,s.anchorOffset)&&r.delaySelUpdate()){t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)P6(t);else{let{anchor:i,head:s}=n,o,l;mA&&!(n instanceof ze)&&(n.$from.parent.inlineContent||(o=gA(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(l=gA(t,n.to))),t.docView.setSelection(i,s,t,e),mA&&(o&&yA(o),l&&yA(l)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&L6(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}const mA=Gn||zn&&_D<63;function gA(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),i=r<n.childNodes.length?n.childNodes[r]:null,s=r?n.childNodes[r-1]:null;if(Gn&&i&&i.contentEditable=="false")return Cv(i);if((!i||i.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(i)return Cv(i);if(s)return Cv(s)}}function Cv(t){return t.contentEditable="true",Gn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function yA(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function L6(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!BD(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function P6(t){let e=t.domSelection();if(!e)return;let n=t.cursorWrapper.dom,r=n.nodeName=="IMG";r?e.collapse(n.parentNode,Ln(n)+1):e.collapse(n,0),!r&&!t.state.selection.visible&&mr&&Oo<=11&&(n.disabled=!0,n.disabled=!1)}function VD(t,e){if(e instanceof He){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(bA(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else bA(t)}function bA(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Ww(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||ze.between(e,n,r)}function vA(t){return t.editable&&!t.hasFocus()?!1:HD(t)}function HD(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 z6(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Ba(e.node,e.offset,n.anchorNode,n.anchorOffset)}function ox(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),s=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return s&&Ke.findFrom(s,e)}function po(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function xA(t,e,n){let r=t.state.selection;if(r instanceof ze)if(n.indexOf("s")>-1){let{$head:i}=r,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let o=t.state.doc.resolve(i.pos+s.nodeSize*(e<0?-1:1));return po(t,new ze(r.$anchor,o))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=ox(t.state,e);return i&&i instanceof He?po(t,i):!1}else if(!(Wr&&n.indexOf("m")>-1)){let i=r.$head,s=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,o;if(!s||s.isText)return!1;let l=e<0?i.pos-s.nodeSize:i.pos;return s.isAtom||(o=t.docView.descAt(l))&&!o.contentDOM?He.isSelectable(s)?po(t,new He(e<0?t.state.doc.resolve(i.pos-s.nodeSize):i)):ef?po(t,new ze(t.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof He&&r.node.isInline)return po(t,new ze(e>0?r.$to:r.$from));{let i=ox(t.state,e);return i?po(t,i):!1}}}function qp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ld(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Hl(t,e){return e<0?$6(t):B6(t)}function $6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,s,o=!1;for(Yr&&n.nodeType==1&&r<qp(n)&&ld(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(ld(l,-1))i=n,s=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(UD(n))break;{let l=n.previousSibling;for(;l&&ld(l,-1);)i=n.parentNode,s=Ln(l),l=l.previousSibling;if(l)n=l,r=qp(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}o?ax(t,n,r):i&&ax(t,i,s)}function B6(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=qp(n),s,o;for(;;)if(r<i){if(n.nodeType!=1)break;let l=n.childNodes[r];if(ld(l,1))s=n,o=++r;else break}else{if(UD(n))break;{let l=n.nextSibling;for(;l&&ld(l,1);)s=l.parentNode,o=Ln(l)+1,l=l.nextSibling;if(l)n=l,r=0,i=qp(n);else{if(n=n.parentNode,n==t.dom)break;r=i=0}}}s&&ax(t,s,o)}function UD(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function V6(t,e){for(;t&&e==t.childNodes.length&&!Qd(t);)e=Ln(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 H6(t,e){for(;t&&!e&&!Qd(t);)e=Ln(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 ax(t,e,n){if(e.nodeType!=3){let s,o;(o=V6(e,n))?(e=o,n=0):(s=H6(e,n))&&(e=s,n=s.nodeValue.length)}let r=t.domSelection();if(!r)return;if(tg(r)){let s=document.createRange();s.setEnd(e,n),s.setStart(e,n),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:i}=t;setTimeout(()=>{t.state==i&&Ts(t)},50)}function wA(t,e){let n=t.state.doc.resolve(e);if(!(zn||AD)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let s=t.coordsAtPos(e-1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left<i.left?"ltr":"rtl"}if(e<n.end()){let s=t.coordsAtPos(e+1),o=(s.top+s.bottom)/2;if(o>i.top&&o<i.bottom&&Math.abs(s.left-i.left)>1)return s.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function SA(t,e,n){let r=t.state.selection;if(r instanceof ze&&!r.empty||n.indexOf("s")>-1||Wr&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let o=ox(t.state,e);if(o&&o instanceof He)return po(t,o)}if(!i.parent.inlineContent){let o=e<0?i:s,l=r instanceof Mr?Ke.near(o,e):Ke.findFrom(o,e);return l?po(t,l):!1}return!1}function kA(t,e){if(!(t.state.selection instanceof ze))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let o=t.state.tr;return e<0?o.delete(n.pos-s.nodeSize,n.pos):o.delete(n.pos,n.pos+s.nodeSize),t.dispatch(o),!0}return!1}function CA(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function U6(t){if(!Gn||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;CA(t,r,"true"),setTimeout(()=>CA(t,r,"false"),20)}return!1}function F6(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function q6(t,e){let n=e.keyCode,r=F6(e);if(n==8||Wr&&n==72&&r=="c")return kA(t,-1)||Hl(t,-1);if(n==46&&!e.shiftKey||Wr&&n==68&&r=="c")return kA(t,1)||Hl(t,1);if(n==13||n==27)return!0;if(n==37||Wr&&n==66&&r=="c"){let i=n==37?wA(t,t.state.selection.from)=="ltr"?-1:1:-1;return xA(t,i,r)||Hl(t,i)}else if(n==39||Wr&&n==70&&r=="c"){let i=n==39?wA(t,t.state.selection.from)=="ltr"?1:-1:1;return xA(t,i,r)||Hl(t,i)}else{if(n==38||Wr&&n==80&&r=="c")return SA(t,-1,r)||Hl(t,-1);if(n==40||Wr&&n==78&&r=="c")return U6(t)||SA(t,1,r)||Hl(t,1);if(r==(Wr?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function Kw(t,e){t.someProp("transformCopied",b=>{e=b(e,t)});let n=[],{content:r,openStart:i,openEnd:s}=e;for(;i>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,s--;let b=r.firstChild;n.push(b.type.name,b.attrs!=b.type.defaultAttrs?b.attrs:null),r=b.content}let o=t.someProp("clipboardSerializer")||Xa.fromSchema(t.state.schema),l=ZD(),u=l.createElement("div");u.appendChild(o.serializeFragment(r,{document:l}));let f=u.firstChild,h,m=0;for(;f&&f.nodeType==1&&(h=KD[f.nodeName.toLowerCase()]);){for(let b=h.length-1;b>=0;b--){let x=l.createElement(h[b]);for(;u.firstChild;)x.appendChild(u.firstChild);u.appendChild(x),m++}f=u.firstChild}f&&f.nodeType==1&&f.setAttribute("data-pm-slice",`${i} ${s}${m?` -${m}`:""} ${JSON.stringify(n)}`);let g=t.someProp("clipboardTextSerializer",b=>b(e,t))||e.content.textBetween(0,e.content.size,`
|
|
71
|
+
|
|
72
|
+
`);return{dom:u,text:g,slice:e}}function FD(t,e,n,r,i){let s=i.parent.type.spec.code,o,l;if(!n&&!e)return null;let u=!!e&&(r||s||!n);if(u){if(t.someProp("transformPastedText",g=>{e=g(e,s||r,t)}),s)return l=new Ee(de.from(t.state.schema.text(e.replace(/\r\n?/g,`
|
|
73
|
+
`))),0,0),t.someProp("transformPasted",g=>{l=g(l,t,!0)}),l;let m=t.someProp("clipboardTextParser",g=>g(e,i,r,t));if(m)l=m;else{let g=i.marks(),{schema:b}=t.state,x=Xa.fromSchema(b);o=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(S=>{let k=o.appendChild(document.createElement("p"));S&&k.appendChild(x.serializeNode(b.text(S,g)))})}}else t.someProp("transformPastedHTML",m=>{n=m(n,t)}),o=Z6(n),ef&&Y6(o);let f=o&&o.querySelector("[data-pm-slice]"),h=f&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(f.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let m=+h[3];m>0;m--){let g=o.firstChild;for(;g&&g.nodeType!=1;)g=g.nextSibling;if(!g)break;o=g}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Cs.fromSchema(t.state.schema)).parseSlice(o,{preserveWhitespace:!!(u||h),context:i,ruleFromNode(g){return g.nodeName=="BR"&&!g.nextSibling&&g.parentNode&&!G6.test(g.parentNode.nodeName)?{ignore:!0}:null}})),h)l=X6(EA(l,+h[1],+h[2]),h[4]);else if(l=Ee.maxOpen(W6(l.content,i),!0),l.openStart||l.openEnd){let m=0,g=0;for(let b=l.content.firstChild;m<l.openStart&&!b.type.spec.isolating;m++,b=b.firstChild);for(let b=l.content.lastChild;g<l.openEnd&&!b.type.spec.isolating;g++,b=b.lastChild);l=EA(l,m,g)}return t.someProp("transformPasted",m=>{l=m(l,t,u)}),l}const G6=/^(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 W6(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),s,o=[];if(t.forEach(l=>{if(!o)return;let u=i.findWrapping(l.type),f;if(!u)return o=null;if(f=o.length&&s.length&&GD(u,s,l,o[o.length-1],0))o[o.length-1]=f;else{o.length&&(o[o.length-1]=WD(o[o.length-1],s.length));let h=qD(l,u);o.push(h),i=i.matchType(h.type),s=u}}),o)return de.from(o)}return t}function qD(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,de.from(t));return t}function GD(t,e,n,r,i){if(i<t.length&&i<e.length&&t[i]==e[i]){let s=GD(t,e,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==t.length-1?n.type:t[i+1]))return r.copy(r.content.append(de.from(qD(n,t,i+1))))}}function WD(t,e){if(e==0)return t;let n=t.content.replaceChild(t.childCount-1,WD(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(de.empty,!0);return t.copy(n.append(r))}function lx(t,e,n,r,i,s){let o=e<0?t.firstChild:t.lastChild,l=o.content;return t.childCount>1&&(s=0),i<r-1&&(l=lx(l,e,n,r,i+1,s)),i>=n&&(l=e<0?o.contentMatchAt(0).fillBefore(l,s<=i).append(l):l.append(o.contentMatchAt(o.childCount).fillBefore(de.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,o.copy(l))}function EA(t,e,n){return e<t.openStart&&(t=new Ee(lx(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new Ee(lx(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const KD={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function ZD(){return document.implementation.createHTMLDocument("title")}let Ev=null;function K6(t){let e=window.trustedTypes;return e?(Ev||(Ev=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:n=>n})),Ev.createHTML(t)):t}function Z6(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=ZD(),r=n.body,i=/<([a-z][^>\s]+)/i.exec(t),s;if((s=i&&KD[i[1].toLowerCase()])&&(t=s.map(o=>"<"+o+">").join("")+t+s.map(o=>"</"+o+">").reverse().join("")),r.innerHTML=K6(t),s)for(let o=0;o<s.length;o++)r=r.querySelector(s[o])||r;for(let o=0;o<n.styleSheets.length;o++){let l=n.styleSheets[o];for(let u=0;u<l.rules.length;u++){let f=l.rules[u];if(f instanceof CSSStyleRule){let h=r.querySelectorAll(f.selectorText);for(let m=0;m<h.length;m++)h[m].style.cssText+=f.style.cssText}}}return r}function Y6(t){let e=t.querySelectorAll(zn?"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 X6(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:i,openStart:s,openEnd:o}=t;for(let l=r.length-2;l>=0;l-=2){let u=n.nodes[r[l]];if(!u||u.hasRequiredAttrs())break;i=de.from(u.create(r[l+1],i)),s++,o++}return new Ee(i,s,o)}const rr={},ir={},J6={touchstart:!0,touchmove:!0};class Q6{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 e5(t){for(let e in rr){let n=rr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{n5(t,r)&&!Zw(t,r)&&(t.editable||!(r.type in ir))&&n(t,r)},J6[e]?{passive:!0}:void 0)}Gn&&t.dom.addEventListener("input",()=>null),cx(t)}function ks(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function t5(t){t.input.mouseDown&&t.input.mouseDown.done(),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 cx(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>Zw(t,r))})}function Zw(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function n5(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 r5(t,e){!Zw(t,e)&&rr[e.type]&&(t.editable||!(e.type in ir))&&rr[e.type](t,e)}ir.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!QD(t)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(Ss&&zn&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),wc&&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",i=>i(t,va(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||q6(t,n)?n.preventDefault():ks(t,"key")};ir.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};ir.keypress=(t,e)=>{let n=e;if(QD(t)||!n.charCode||n.ctrlKey&&!n.altKey||Wr&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof ze)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode),s=()=>t.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i,s))&&t.dispatch(s()),n.preventDefault()}};function nf(t){return{left:t.clientX,top:t.clientY}}function i5(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function Yw(t,e,n,r,i){if(r==-1)return!1;let s=t.state.doc.resolve(r);for(let o=s.depth+1;o>0;o--)if(t.someProp(e,l=>o>s.depth?l(t,n,s.nodeAfter,s.before(o),i,!0):l(t,n,s.node(o),s.before(o),i,!1)))return!0;return!1}function rf(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 s5(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&He.isSelectable(r)?(rf(t,new He(n)),!0):!1}function o5(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof He&&(r=n.node);let s=t.state.doc.resolve(e);for(let o=s.depth+1;o>0;o--){let l=o>s.depth?s.nodeAfter:s.node(o);if(He.isSelectable(l)){r&&n.$from.depth>0&&o>=n.$from.depth&&s.before(n.$from.depth+1)==n.$from.pos?i=s.before(n.$from.depth):i=s.before(o);break}}return i!=null?(rf(t,He.create(t.state.doc,i)),!0):!1}function a5(t,e,n,r,i){return Yw(t,"handleClickOn",e,n,r)||t.someProp("handleClick",s=>s(t,e,r))||(i?o5(t,n):s5(t,n))}function l5(t,e,n,r){return Yw(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function c5(t,e,n,r){return Yw(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||u5(t,n,r)}function u5(t,e,n){if(n.button!=0)return!1;let r=YD(t,e,!0),i=t.state.doc;return r?(rf(t,r),r instanceof ze&&i.eq(t.state.doc)&&(t.input.mouseDown=new f5(t,r)),!0):!1}function YD(t,e,n){let r=t.state.doc;if(e==-1)return r.inlineContent?ze.create(r,0,r.content.size):null;let i=r.resolve(e);for(let s=i.depth+1;s>0;s--){let o=s>i.depth?i.nodeAfter:i.node(s),l=i.before(s);if(o.inlineContent)return ze.create(r,l+1,l+1+o.content.size);if(n&&He.isSelectable(o))return He.create(r,l)}return null}function Xw(t){return Gp(t)}const XD=Wr?"metaKey":"ctrlKey";rr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=Xw(t),i=Date.now(),s="singleClick";i-t.input.lastClick.time<500&&i5(n,t.input.lastClick)&&!n[XD]&&t.input.lastClick.button==n.button&&(t.input.lastClick.type=="singleClick"?s="doubleClick":t.input.lastClick.type=="doubleClick"&&(s="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:s,button:n.button},t.input.mouseDown&&t.input.mouseDown.done();let o=t.posAtCoords(nf(n));o&&(s=="singleClick"?t.input.mouseDown=new d5(t,o,n,!!r):(s=="doubleClick"?l5:c5)(t,o.pos,o.inside,n)?n.preventDefault():ks(t,"pointer"))};class JD{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){e.buttons==0&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class d5 extends JD{constructor(e,n,r,i){super(e),this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!r[XD],this.allowDefault=r.shiftKey;let s,o;if(n.inside>-1)s=e.state.doc.nodeAt(n.inside),o=n.inside;else{let h=e.state.doc.resolve(n.pos);s=h.parent,o=h.depth?h.before():0}const l=i?null:r.target,u=l?e.docView.nearestDesc(l,!0):null;this.target=u&&u.nodeDOM.nodeType==1?u.nodeDOM:null;let{selection:f}=e.state;r.button==0&&(s.type.spec.draggable&&s.type.spec.selectable!==!1||f instanceof He&&f.from<=o&&f.to>o)&&(this.mightDrag={node:s,pos:o,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()),ks(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Ts(this.view)})}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(nf(e))),this.updateAllowDefault(e),this.allowDefault||!n?ks(this.view,"pointer"):a5(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Gn&&this.mightDrag&&!this.mightDrag.node.isAtom||zn&&!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)?(rf(this.view,Ke.near(this.view.state.doc.resolve(n.pos))),e.preventDefault()):ks(this.view,"pointer")}move(e){this.updateAllowDefault(e),ks(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return this.allowDefault?(this.delayedSelectionSync=!0,!0):!1}}class f5 extends JD{constructor(e,n){super(e),this.startSelection=n,this.startDoc=e.state.doc}move(e){if(e.buttons==0||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc)){this.done();return}e.preventDefault(),ks(this.view,"pointer");let n=this.view.posAtCoords(nf(e)),r=n&&YD(this.view,n.inside,!1);if(!r)return;let{doc:i}=this.view.state,s=this.startSelection,[o,l]=r.from<s.from?[s.to,r.from]:[s.from,r.to];rf(this.view,ze.create(i,o,l))}}rr.touchstart=t=>{t.input.lastTouch=Date.now(),Xw(t),ks(t,"pointer")};rr.touchmove=t=>{t.input.lastTouch=Date.now(),ks(t,"pointer")};rr.contextmenu=t=>Xw(t);function QD(t,e){return t.composing?!0:Gn&&Math.abs(Date.now()-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const h5=Ss?5e3:-1;ir.compositionstart=ir.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof ze&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)||zn&&AD&&p5(t)))t.markCursor=t.state.storedMarks||n.marks(),Gp(t,!0),t.markCursor=null;else if(Gp(t,!e.selection.empty),Yr&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,s=r.focusOffset;i&&i.nodeType==1&&s!=0;){let o=s<0?i.lastChild:i.childNodes[s-1];if(!o)break;if(o.nodeType==3){let l=t.domSelection();l&&l.collapse(o,o.nodeValue.length);break}else i=o,s=-1}}t.input.composing=!0}eI(t,h5)};function p5(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"}ir.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now(),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++,eI(t,20))};function eI(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Gp(t),e))}function tI(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=Date.now());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function m5(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=o6(e.focusNode,e.focusOffset),r=a6(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let i=r.pmViewDesc,s=t.domObserver.lastChangedTextNode;if(n==s||r==s)return s;if(!i||!i.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let o=n.pmViewDesc;if(!(!o||!o.isText(n.nodeValue)))return r}}return n||r}function Gp(t,e=!1){if(!(Ss&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),tI(t),e||t.docView&&t.docView.dirty){let n=Gw(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 g5(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(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Dd=mr&&Oo<15||wc&&d6<604;rr.copy=ir.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let s=Dd?null:n.clipboardData,o=r.content(),{dom:l,text:u}=Kw(t,o);s?(n.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",u)):g5(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function y5(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function b5(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 i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Id(t,r.value,null,i,e):Id(t,r.textContent,r.innerHTML,i,e)},50)}function Id(t,e,n,r,i){let s=FD(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,s||Ee.empty)))return!0;if(!s)return!1;let o=y5(s),l=o?t.state.tr.replaceSelectionWith(o,r):t.state.tr.replaceSelection(s);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function nI(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," "):""}ir.paste=(t,e)=>{let n=e;if(t.composing&&!Ss)return;let r=Dd?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Id(t,nI(r),r.getData("text/html"),i,n)?n.preventDefault():b5(t,n)};class rI{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const v5=Wr?"altKey":"ctrlKey";function iI(t,e){let n;return t.someProp("dragCopies",r=>{n=n||r(e)}),n!=null?!n:!e[v5]}rr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,s=i.empty?null:t.posAtCoords(nf(n)),o;if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof He?i.to-1:i.to))){if(r&&r.mightDrag)o=He.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&&(o=He.create(t.state.doc,m.posBefore))}}let l=(o||t.state.selection).content(),{dom:u,text:f,slice:h}=Kw(t,l);(!n.dataTransfer.files.length||!zn||_D>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Dd?"Text":"text/html",u.innerHTML),n.dataTransfer.effectAllowed="copyMove",Dd||n.dataTransfer.setData("text/plain",f),t.dragging=new rI(h,iI(t,n),o)};rr.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};ir.dragover=ir.dragenter=(t,e)=>e.preventDefault();ir.drop=(t,e)=>{try{x5(t,e,t.dragging)}finally{t.dragging=null}};function x5(t,e,n){if(!e.dataTransfer)return;let r=t.posAtCoords(nf(e));if(!r)return;let i=t.state.doc.resolve(r.pos),s=n&&n.slice;s?t.someProp("transformPasted",b=>{s=b(s,t,!1)}):s=FD(t,nI(e.dataTransfer),Dd?null:e.dataTransfer.getData("text/html"),!1,i);let o=!!(n&&iI(t,e));if(t.someProp("handleDrop",b=>b(t,e,s||Ee.empty,o))){e.preventDefault();return}if(!s)return;e.preventDefault();let l=s?sD(t.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let u=t.state.tr;if(o){let{node:b}=n;b?b.replace(u):u.deleteSelection()}let f=u.mapping.map(l),h=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,m=u.doc;if(h?u.replaceRangeWith(f,f,s.content.firstChild):u.replaceRange(f,f,s),u.doc.eq(m))return;let g=u.doc.resolve(f);if(h&&He.isSelectable(s.content.firstChild)&&g.nodeAfter&&g.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new He(g));else{let b=u.mapping.map(l);u.mapping.maps[u.mapping.maps.length-1].forEach((x,S,k,C)=>b=C),u.setSelection(Ww(t,g,u.doc.resolve(b)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))}rr.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())&&Ts(t)},20))};rr.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)};rr.beforeinput=(t,e)=>{if(Ss&&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",s=>s(t,va(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in ir)rr[t]=ir[t];function jd(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 Wp{constructor(e,n){this.toDOM=e,this.spec=n||Ma,this.side=this.spec.side||0}map(e,n,r,i){let{pos:s,deleted:o}=e.mapResult(n.from+i,this.side<0?-1:1);return o?null:new Sn(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Wp&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&jd(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class jo{constructor(e,n){this.attrs=e,this.spec=n||Ma}map(e,n,r,i){let s=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,o=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return s>=o?null:new Sn(s,o,this)}valid(e,n){return n.from<n.to}eq(e){return this==e||e instanceof jo&&jd(this.attrs,e.attrs)&&jd(this.spec,e.spec)}static is(e){return e.type instanceof jo}destroy(){}}class Jw{constructor(e,n){this.attrs=e,this.spec=n||Ma}map(e,n,r,i){let s=e.mapResult(n.from+i,1);if(s.deleted)return null;let o=e.mapResult(n.to+i,-1);return o.deleted||o.pos<=s.pos?null:new Sn(s.pos-r,o.pos-r,this)}valid(e,n){let{index:r,offset:i}=e.content.findIndex(n.from),s;return i==n.from&&!(s=e.child(r)).isText&&i+s.nodeSize==n.to}eq(e){return this==e||e instanceof Jw&&jd(this.attrs,e.attrs)&&jd(this.spec,e.spec)}destroy(){}}class Sn{constructor(e,n,r){this.from=e,this.to=n,this.type=r}copy(e,n){return new Sn(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 Sn(e,e,new Wp(n,r))}static inline(e,n,r,i){return new Sn(e,n,new jo(r,i))}static node(e,n,r,i){return new Sn(e,n,new Jw(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof jo}get widget(){return this.type instanceof Wp}}const Ql=[],Ma={};class kt{constructor(e,n){this.local=e.length?e:Ql,this.children=n.length?n:Ql}static create(e,n){return n.length?Kp(n,e,0,Ma):Fn}find(e,n,r){let i=[];return this.findInner(e??0,n??1e9,i,0,r),i}findInner(e,n,r,i,s){for(let o=0;o<this.local.length;o++){let l=this.local[o];l.from<=n&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let o=0;o<this.children.length;o+=3)if(this.children[o]<n&&this.children[o+1]>e){let l=this.children[o]+1;this.children[o+2].findInner(e-l,n-l,r,i+l,s)}}map(e,n,r){return this==Fn||e.maps.length==0?this:this.mapInner(e,n,0,0,r||Ma)}mapInner(e,n,r,i,s){let o;for(let l=0;l<this.local.length;l++){let u=this.local[l].map(e,r,i);u&&u.type.valid(n,u)?(o||(o=[])).push(u):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?w5(this.children,o||[],e,n,r,i,s):o?new kt(o.sort(Na),Ql):Fn}add(e,n){return n.length?this==Fn?kt.create(e,n):this.addInner(e,n,0):this}addInner(e,n,r){let i,s=0;e.forEach((l,u)=>{let f=u+r,h;if(h=oI(n,l,f)){for(i||(i=this.children.slice());s<i.length&&i[s]<u;)s+=3;i[s]==u?i[s+2]=i[s+2].addInner(l,h,f+1):i.splice(s,0,u,u+l.nodeSize,Kp(h,l,f+1,Ma)),s+=3}});let o=sI(s?aI(n):n,-r);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||o.splice(l--,1);return new kt(o.length?this.local.concat(o).sort(Na):this.local,i||this.children)}remove(e){return e.length==0||this==Fn?this:this.removeInner(e,0)}removeInner(e,n){let r=this.children,i=this.local;for(let s=0;s<r.length;s+=3){let o,l=r[s]+n,u=r[s+1]+n;for(let h=0,m;h<e.length;h++)(m=e[h])&&m.from>l&&m.to<u&&(e[h]=null,(o||(o=[])).push(m));if(!o)continue;r==this.children&&(r=this.children.slice());let f=r[s+2].removeInner(o,l+1);f!=Fn?r[s+2]=f:(r.splice(s,3),s-=3)}if(i.length){for(let s=0,o;s<e.length;s++)if(o=e[s])for(let l=0;l<i.length;l++)i[l].eq(o,n)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new kt(i,r):Fn}forChild(e,n){if(this==Fn)return this;if(n.isLeaf)return kt.empty;let r,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,o=s+n.content.size;for(let l=0;l<this.local.length;l++){let u=this.local[l];if(u.from<o&&u.to>s&&u.type instanceof jo){let f=Math.max(s,u.from)-s,h=Math.min(o,u.to)-s;f<h&&(i||(i=[])).push(u.copy(f,h))}}if(i){let l=new kt(i.sort(Na),Ql);return r?new wo([l,r]):l}return r||Fn}eq(e){if(this==e)return!0;if(!(e instanceof kt)||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 Qw(this.localsInner(e))}localsInner(e){if(this==Fn)return Ql;if(e.inlineContent||!this.local.some(jo.is))return this.local;let n=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof jo||n.push(this.local[r]);return n}forEachSet(e){e(this)}}kt.empty=new kt([],[]);kt.removeOverlap=Qw;const Fn=kt.empty;class wo{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,Ma));return wo.from(r)}forChild(e,n){if(n.isLeaf)return kt.empty;let r=[];for(let i=0;i<this.members.length;i++){let s=this.members[i].forChild(e,n);s!=Fn&&(s instanceof wo?r=r.concat(s.members):r.push(s))}return wo.from(r)}eq(e){if(!(e instanceof wo)||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 i=0;i<this.members.length;i++){let s=this.members[i].localsInner(e);if(s.length)if(!n)n=s;else{r&&(n=n.slice(),r=!1);for(let o=0;o<s.length;o++)n.push(s[o])}}return n?Qw(r?n:n.sort(Na)):Ql}static from(e){switch(e.length){case 0:return Fn;case 1:return e[0];default:return new wo(e.every(n=>n instanceof kt)?e:e.reduce((n,r)=>n.concat(r instanceof kt?r:r.members),[]))}}forEachSet(e){for(let n=0;n<this.members.length;n++)this.members[n].forEachSet(e)}}function w5(t,e,n,r,i,s,o){let l=t.slice();for(let f=0,h=s;f<n.maps.length;f++){let m=0;n.maps[f].forEach((g,b,x,S)=>{let k=S-x-(b-g);for(let C=0;C<l.length;C+=3){let A=l[C+1];if(A<0||g>A+h-m)continue;let R=l[C]+h-m;b>=R?l[C+1]=g<=R?-2:-1:g>=h&&k&&(l[C]+=k,l[C+1]+=k)}m+=k}),h=n.maps[f].map(h,-1)}let u=!1;for(let f=0;f<l.length;f+=3)if(l[f+1]<0){if(l[f+1]==-2){u=!0,l[f+1]=-1;continue}let h=n.map(t[f]+s),m=h-i;if(m<0||m>=r.content.size){u=!0;continue}let g=n.map(t[f+1]+s,-1),b=g-i,{index:x,offset:S}=r.content.findIndex(m),k=r.maybeChild(x);if(k&&S==m&&S+k.nodeSize==b){let C=l[f+2].mapInner(n,k,h+1,t[f]+s+1,o);C!=Fn?(l[f]=m,l[f+1]=b,l[f+2]=C):(l[f+1]=-2,u=!0)}else u=!0}if(u){let f=S5(l,t,e,n,i,s,o),h=Kp(f,r,0,o);e=h.local;for(let m=0;m<l.length;m+=3)l[m+1]<0&&(l.splice(m,3),m-=3);for(let m=0,g=0;m<h.children.length;m+=3){let b=h.children[m];for(;g<l.length&&l[g]<b;)g+=3;l.splice(g,0,h.children[m],h.children[m+1],h.children[m+2])}}return new kt(e.sort(Na),l)}function sI(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let i=t[r];n.push(new Sn(i.from+e,i.to+e,i.type))}return n}function S5(t,e,n,r,i,s,o){function l(u,f){for(let h=0;h<u.local.length;h++){let m=u.local[h].map(r,i,f);m?n.push(m):o.onRemove&&o.onRemove(u.local[h].spec)}for(let h=0;h<u.children.length;h+=3)l(u.children[h+2],u.children[h]+f+1)}for(let u=0;u<t.length;u+=3)t[u+1]==-1&&l(t[u+2],e[u]+s+1);return n}function oI(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,i=null;for(let s=0,o;s<t.length;s++)(o=t[s])&&o.from>n&&o.to<r&&((i||(i=[])).push(o),t[s]=null);return i}function aI(t){let e=[];for(let n=0;n<t.length;n++)t[n]!=null&&e.push(t[n]);return e}function Kp(t,e,n,r){let i=[],s=!1;e.forEach((l,u)=>{let f=oI(t,l,u+n);if(f){s=!0;let h=Kp(f,l,n+u+1,r);h!=Fn&&i.push(u,u+l.nodeSize,h)}});let o=sI(s?aI(t):t,-n).sort(Na);for(let l=0;l<o.length;l++)o[l].type.valid(e,o[l])||(r.onRemove&&r.onRemove(o[l].spec),o.splice(l--,1));return o.length||i.length?new kt(o,i):Fn}function Na(t,e){return t.from-e.from||t.to-e.to}function Qw(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let i=n+1;i<e.length;i++){let s=e[i];if(s.from==r.from){s.to!=r.to&&(e==t&&(e=t.slice()),e[i]=s.copy(s.from,r.to),TA(e,i+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,s.from),TA(e,i,r.copy(s.from,r.to)));break}}}return e}function TA(t,e,n){for(;e<t.length&&Na(n,t[e])>0;)e++;t.splice(e,0,n)}function Tv(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=Fn&&e.push(r)}),t.cursorWrapper&&e.push(kt.create(t.state.doc,[t.cursorWrapper.deco])),wo.from(e)}const k5={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},C5=mr&&Oo<=11;class E5{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 T5{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new E5,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;i<r.length;i++)this.queue.push(r[i]);mr&&Oo<=11&&r.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():Gn&&e.composing&&r.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),C5&&(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,k5)),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(vA(this.view)){if(this.suppressingSelectionUpdates)return Ts(this.view);if(mr&&Oo<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ba(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 s=e.focusNode;s;s=xc(s))n.add(s);for(let s=e.anchorNode;s;s=xc(s))if(n.has(s)){r=s;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.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(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&vA(e)&&!this.ignoreSelectionChange(r),s=-1,o=-1,l=!1,u=[];if(e.editable)for(let h=0;h<n.length;h++){let m=this.registerMutation(n[h],u);m&&(s=s<0?m.from:Math.min(m.from,s),o=o<0?m.to:Math.max(m.to,o),m.typeOver&&(l=!0))}if(u.some(h=>h.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46||zn&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&n.some(h=>h.type=="childList"&&h.removedNodes.length))){for(let h of u)if(h.nodeName=="BR"&&h.parentNode){let m=h.nextSibling;for(;m&&m.nodeType==1;){if(m.contentEditable=="false"){h.parentNode.removeChild(h);break}m=m.firstChild}}}else if(Yr&&u.length){let h=u.filter(m=>m.nodeName=="BR");if(h.length==2){let[m,g]=h;m.parentNode&&m.parentNode.parentNode==g.parentNode?g.remove():m.remove()}else{let{focusNode:m}=this.currentSelection;for(let g of h){let b=g.parentNode;b&&b.nodeName=="LI"&&(!m||R5(e,m)!=b)&&g.remove()}}}let f=null;s<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&tg(r)&&(f=Gw(e))&&f.eq(Ke.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ts(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||i)&&(s>-1&&(e.docView.markDirty(s,o),_5(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,M5(e,u)),this.handleDOMChange(s,o,l,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ts(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 h=0;h<e.addedNodes.length;h++){let m=e.addedNodes[h];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 i=e.previousSibling,s=e.nextSibling;if(mr&&Oo<=11&&e.addedNodes.length)for(let h=0;h<e.addedNodes.length;h++){let{previousSibling:m,nextSibling:g}=e.addedNodes[h];(!m||Array.prototype.indexOf.call(e.addedNodes,m)<0)&&(i=m),(!g||Array.prototype.indexOf.call(e.addedNodes,g)<0)&&(s=g)}let o=i&&i.parentNode==e.target?Ln(i)+1:0,l=r.localPosFromDOM(e.target,o,-1),u=s&&s.parentNode==e.target?Ln(s):e.target.childNodes.length,f=r.localPosFromDOM(e.target,u,1);return{from:l,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 _A=new WeakMap,AA=!1;function _5(t){if(!_A.has(t)&&(_A.set(t,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace)!==-1)){if(t.requiresGeckoHackNode=Yr,AA)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."),AA=!0}}function RA(t,e){let n=e.startContainer,r=e.startOffset,i=e.endContainer,s=e.endOffset,o=t.domAtPos(t.state.selection.anchor);return Ba(o.node,o.offset,i,s)&&([n,r,i,s]=[i,s,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:s}}function A5(t,e){if(e.getComposedRanges){let i=e.getComposedRanges(t.root)[0];if(i)return RA(t,i)}let n;function r(i){i.preventDefault(),i.stopImmediatePropagation(),n=i.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?RA(t,n):null}function R5(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 M5(t,e){var n;let{focusNode:r,focusOffset:i}=t.domSelectionRange();for(let s of e)if(((n=s.parentNode)===null||n===void 0?void 0:n.nodeName)=="TR"){let o=s.nextSibling;for(;o&&o.nodeName!="TD"&&o.nodeName!="TH";)o=o.nextSibling;if(o){let l=o;for(;;){let u=l.firstChild;if(!u||u.nodeType!=1||u.contentEditable=="false"||/^(BR|IMG)$/.test(u.nodeName))break;l=u}l.insertBefore(s,l.firstChild),r==s&&t.domSelection().collapse(s,i)}else s.parentNode.removeChild(s)}}function N5(t,e,n,r){let{node:i,fromOffset:s,toOffset:o,from:l,to:u}=t.docView.parseRange(e,n),f=t.domSelectionRange(),h,m=f.anchorNode;if(m&&t.dom.contains(m.nodeType==1?m:m.parentNode)&&(h=[{node:m,offset:f.anchorOffset}],tg(f)||h.push({node:f.focusNode,offset:f.focusOffset})),zn&&t.input.lastKeyCode===8)for(let C=o;C>s;C--){let A=i.childNodes[C-1],R=A.pmViewDesc;if(A.nodeName=="BR"&&!R){o=C;break}if(!R||R.size)break}let g=t.state.doc,b=t.someProp("domParser")||Cs.fromSchema(t.state.schema),x=g.resolve(l),S=null,k=b.parse(i,{topNode:x.parent,topMatch:x.parent.contentMatchAt(x.index()),topOpen:!0,from:s,to:o,preserveWhitespace:x.parent.type.whitespace=="pre"?"full":!0,findPositions:h,ruleFromNode:O5(r),context:x});if(h&&h[0].pos!=null){let C=h[0].pos,A=h[1]&&h[1].pos;A==null&&(A=C),S={anchor:C+l,head:A+l}}return{doc:k,sel:S,from:l,to:u}}const O5=t=>e=>{let n=e.pmViewDesc;if(n)return n.parseRule(t);if(e.nodeName=="BR"&&e.parentNode){if(Gn&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Gn&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null},D5=/^(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 I5(t,e,n,r,i){let s=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let D=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,I=Gw(t,D);if(I&&!t.state.selection.eq(I)){if(zn&&Ss&&t.input.lastKeyCode===13&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",B=>B(t,va(13,"Enter"))))return;let P=t.state.tr.setSelection(I);D=="pointer"?P.setMeta("pointer",!0):D=="key"&&P.scrollIntoView(),s&&P.setMeta("composition",s),t.dispatch(P)}return}let o=t.state.doc.resolve(e),l=o.sharedDepth(n);e=o.before(l+1),n=t.state.doc.resolve(n).after(l+1);let u=t.state.selection,f=N5(t,e,n,i),h=t.state.doc,m=h.slice(f.from,f.to),g,b;t.input.lastKeyCode===8&&Date.now()-100<t.input.lastKeyCodeTime?(g=t.state.selection.to,b="end"):(g=t.state.selection.from,b="start"),t.input.lastKeyCode=null;let x=P5(m.content,f.doc.content,f.from,g,b);if(x&&t.input.domChangeCount++,(wc&&t.input.lastIOSEnter>Date.now()-225||Ss)&&i.some(D=>D.nodeType==1&&!D5.test(D.nodeName))&&(!x||x.endA>=x.endB)&&t.someProp("handleKeyDown",D=>D(t,va(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!x)if(r&&u instanceof ze&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(f.sel&&f.sel.anchor!=f.sel.head))x={start:u.from,endA:u.to,endB:u.to};else{if(f.sel){let D=MA(t,t.state.doc,f.sel);if(D&&!D.eq(t.state.selection)){let I=t.state.tr.setSelection(D);s&&I.setMeta("composition",s),t.dispatch(I)}}return}t.state.selection.from<t.state.selection.to&&x.start==x.endB&&t.state.selection instanceof ze&&(x.start>t.state.selection.from&&x.start<=t.state.selection.from+2&&t.state.selection.from>=f.from?x.start=t.state.selection.from:x.endA<t.state.selection.to&&x.endA>=t.state.selection.to-2&&t.state.selection.to<=f.to&&(x.endB+=t.state.selection.to-x.endA,x.endA=t.state.selection.to)),mr&&Oo<=11&&x.endB==x.start+1&&x.endA==x.start&&x.start>f.from&&f.doc.textBetween(x.start-f.from-1,x.start-f.from+1)==" "&&(x.start--,x.endA--,x.endB--);let S=f.doc.resolveNoCache(x.start-f.from),k=f.doc.resolveNoCache(x.endB-f.from),C=h.resolve(x.start),A=S.sameParent(k)&&S.parent.inlineContent&&C.end()>=x.endA;if((wc&&t.input.lastIOSEnter>Date.now()-225&&(!A||i.some(D=>D.nodeName=="DIV"||D.nodeName=="P"))||!A&&S.pos<f.doc.content.size&&(!S.sameParent(k)||!S.parent.inlineContent)&&S.pos<k.pos&&!/\S/.test(f.doc.textBetween(S.pos,k.pos,"","")))&&t.someProp("handleKeyDown",D=>D(t,va(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>x.start&&L5(h,x.start,x.endA,S,k)&&t.someProp("handleKeyDown",D=>D(t,va(8,"Backspace")))){Ss&&zn&&t.domObserver.suppressSelectionUpdates();return}zn&&x.endB==x.start&&(t.input.lastChromeDelete=Date.now()),Ss&&!A&&S.start()!=k.start()&&k.parentOffset==0&&S.depth==k.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==x.endA&&(x.endB-=2,k=f.doc.resolveNoCache(x.endB-f.from),setTimeout(()=>{t.someProp("handleKeyDown",function(D){return D(t,va(13,"Enter"))})},20));let R=x.start,_=x.endA,M=D=>{let I=D||t.state.tr.replace(R,_,f.doc.slice(x.start-f.from,x.endB-f.from));if(f.sel){let P=MA(t,I.doc,f.sel);P&&!(zn&&t.composing&&P.empty&&(x.start!=x.endB||t.input.lastChromeDelete<Date.now()-100)&&(P.head==R||P.head==I.mapping.map(_)-1)||mr&&P.empty&&P.head==R)&&I.setSelection(P)}return s&&I.setMeta("composition",s),I.scrollIntoView()},O;if(A)if(S.pos==k.pos){mr&&Oo<=11&&S.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ts(t),20));let D=M(t.state.tr.delete(R,_)),I=h.resolve(x.start).marksAcross(h.resolve(x.endA));I&&D.ensureMarks(I),t.dispatch(D)}else if(x.endA==x.endB&&(O=j5(S.parent.content.cut(S.parentOffset,k.parentOffset),C.parent.content.cut(C.parentOffset,x.endA-C.start())))){let D=M(t.state.tr);O.type=="add"?D.addMark(R,_,O.mark):D.removeMark(R,_,O.mark),t.dispatch(D)}else if(S.parent.child(S.index()).isText&&S.index()==k.index()-(k.textOffset?0:1)){let D=S.parent.textBetween(S.parentOffset,k.parentOffset),I=()=>M(t.state.tr.insertText(D,R,_));t.someProp("handleTextInput",P=>P(t,R,_,D,I))||t.dispatch(I())}else t.dispatch(M());else t.dispatch(M())}function MA(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Ww(t,e.resolve(n.anchor),e.resolve(n.head))}function j5(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,s=r,o,l,u;for(let h=0;h<r.length;h++)i=r[h].removeFromSet(i);for(let h=0;h<n.length;h++)s=n[h].removeFromSet(s);if(i.length==1&&s.length==0)l=i[0],o="add",u=h=>h.mark(l.addToSet(h.marks));else if(i.length==0&&s.length==1)l=s[0],o="remove",u=h=>h.mark(l.removeFromSet(h.marks));else return null;let f=[];for(let h=0;h<e.childCount;h++)f.push(u(e.child(h)));if(de.from(f).eq(t))return{mark:l,type:o}}function L5(t,e,n,r,i){if(n-e<=i.pos-r.pos||_v(r,!0,!1)<i.pos)return!1;let s=t.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&n==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let o=t.resolve(_v(s,!0,!0));return!o.parent.isTextblock||o.pos>n||_v(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function _v(t,e,n){let r=t.depth,i=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let s=t.node(r).maybeChild(t.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,i++}return i}function P5(t,e,n,r,i){let s=t.findDiffStart(e,n),o=n+t.size,l=n+e.size;if(s==null)return null;let{a:u,b:f}=t.findDiffEnd(e,o,l);if(i=="end"){let h=Math.max(0,s-Math.min(u,f));r-=u+h-s}if(u<s&&o<l){let h=r<=s&&r>=u?s-r:0;s-=h,f=s+(f-u),u=s}else if(f<s){let h=r<=s&&r>=f?s-r:0;s-=h,u=s+(u-f),f=s}return{start:s,endA:u,endB:f}}class lI{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 Q6,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(jA),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=DA(this),OA(this),this.nodeViews=IA(this),this.docView=hA(this.state.doc,NA(this),Tv(this),this.dom,this),this.domObserver=new T5(this,(r,i,s,o)=>I5(this,r,i,s,o)),this.domObserver.start(),e5(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&&cx(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(jA),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 i=this.state,s=!1,o=!1;e.storedMarks&&this.composing&&(tI(this),o=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let b=IA(this);$5(b,this.nodeViews)&&(this.nodeViews=b,s=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&cx(this),this.editable=DA(this),OA(this);let u=Tv(this),f=NA(this),h=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",m=s||!this.docView.matchesNode(e.doc,f,u);(m||!e.selection.eq(i.selection))&&(o=!0);let g=h=="preserve"&&o&&this.dom.style.overflowAnchor==null&&p6(this);if(o){this.domObserver.stop();let b=m&&(mr||zn)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&z5(i.selection,e.selection);if(m){let S=zn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=m5(this)),(s||!this.docView.update(e.doc,f,u,this))&&(this.docView.updateOuterDeco(f),this.docView.destroy(),this.docView=hA(e.doc,f,u,this.dom,this)),S&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(b=!0)}let x=this.input.mouseDown;b||!(x&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&z6(this)&&x.delaySelUpdate())?Ts(this,b):(VD(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),h=="reset"?this.dom.scrollTop=0:h=="to selection"?this.scrollToSelection():g&&m6(g)}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 He){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&lA(this,n.getBoundingClientRect(),e)}else lA(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let 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,i=-1;if(r.from<this.state.doc.content.size&&this.state.doc.nodeAt(r.from)==r.node)i=r.from;else{let s=r.from+(this.state.doc.content.size-n.doc.content.size);(s>0&&s<this.state.doc.content.size&&this.state.doc.nodeAt(s))==r.node&&(i=s)}this.dragging=new rI(e.slice,e.move,i<0?void 0:He.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let o=0;o<this.directPlugins.length;o++){let l=this.directPlugins[o].props[e];if(l!=null&&(i=n?n(l):l))return i}let s=this.state.plugins;if(s)for(let o=0;o<s.length;o++){let l=s[o].props[e];if(l!=null&&(i=n?n(l):l))return i}}hasFocus(){if(mr){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&&g6(this.dom),Ts(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 w6(this,e)}coordsAtPos(e,n=1){return DD(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 i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return T6(this,n||this.state,e)}pasteHTML(e,n){return Id(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Id(this,e,null,!0,n||new ClipboardEvent("paste"))}serializeForClipboard(e){return Kw(this,e)}destroy(){this.docView&&(t5(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Tv(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,i6())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return r5(this,e)}domSelectionRange(){let e=this.domSelection();return e?Gn&&this.root.nodeType===11&&c6(this.dom.ownerDocument)==this.dom&&A5(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}lI.prototype.dispatch=function(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))};function NA(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"),[Sn.node(0,t.state.doc.content.size,e)]}function OA(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:Sn.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function DA(t){return!t.someProp("editable",e=>e(t.state)===!1)}function z5(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 IA(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function $5(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function jA(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 Bo={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:"'"},Zp={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},B5=typeof navigator<"u"&&/Mac/.test(navigator.platform),V5=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var Pn=0;Pn<10;Pn++)Bo[48+Pn]=Bo[96+Pn]=String(Pn);for(var Pn=1;Pn<=24;Pn++)Bo[Pn+111]="F"+Pn;for(var Pn=65;Pn<=90;Pn++)Bo[Pn]=String.fromCharCode(Pn+32),Zp[Pn]=String.fromCharCode(Pn);for(var Av in Bo)Zp.hasOwnProperty(Av)||(Zp[Av]=Bo[Av]);function H5(t){var e=B5&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||V5&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Zp:Bo)[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 U5=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),F5=typeof navigator<"u"&&/Win/.test(navigator.platform);function q5(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l++){let u=e[l];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))U5?o=!0:i=!0;else throw new Error("Unrecognized modifier name: "+u)}return r&&(n="Alt-"+n),i&&(n="Ctrl-"+n),o&&(n="Meta-"+n),s&&(n="Shift-"+n),n}function G5(t){let e=Object.create(null);for(let n in t)e[q5(n)]=t[n];return e}function Rv(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 W5(t){return new Lt({props:{handleKeyDown:eS(t)}})}function eS(t){let e=G5(t);return function(n,r){let i=H5(r),s,o=e[Rv(i,r)];if(o&&o(n.state,n.dispatch,n))return!0;if(i.length==1&&i!=" "){if(r.shiftKey){let l=e[Rv(i,r,!1)];if(l&&l(n.state,n.dispatch,n))return!0}if((r.altKey||r.metaKey||r.ctrlKey)&&!(F5&&r.ctrlKey&&r.altKey)&&(s=Bo[r.keyCode])&&s!=i){let l=e[Rv(s,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}var K5=Object.defineProperty,tS=(t,e)=>{for(var n in e)K5(t,n,{get:e[n],enumerable:!0})};function rg(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:s}=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 s},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,s=n.storedMarks,n}}}var ig=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:i}=n,s=this.buildProps(i);return Object.fromEntries(Object.entries(t).map(([o,l])=>[o,(...f)=>{const h=l(...f)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(i),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o=[],l=!!t,u=t||i.tr,f=()=>(!l&&e&&!u.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(u),o.every(m=>m===!0)),h={...Object.fromEntries(Object.entries(n).map(([m,g])=>[m,(...x)=>{const S=this.buildProps(u,e),k=g(...x)(S);return o.push(k),h}])),run:f};return h}createCan(t){const{rawCommands:e,state:n}=this,r=!1,i=t||n.tr,s=this.buildProps(i,r);return{...Object.fromEntries(Object.entries(e).map(([l,u])=>[l,(...f)=>u(...f)({...s,dispatch:void 0})])),chain:()=>this.createChain(i,r)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:i}=this,{view:s}=r,o={tr:t,editor:r,view:s,state:rg({state:i,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map(([l,u])=>[l,(...f)=>u(...f)(o)]))}};return o}},oi={};tS(oi,{blur:()=>Z5,clearContent:()=>Y5,clearNodes:()=>X5,command:()=>J5,createParagraphNear:()=>Q5,cut:()=>eq,deleteCurrentNode:()=>tq,deleteNode:()=>nq,deleteRange:()=>rq,deleteSelection:()=>oq,enter:()=>aq,exitCode:()=>lq,extendMarkRange:()=>cq,first:()=>uq,focus:()=>fq,forEach:()=>hq,insertContent:()=>pq,insertContentAt:()=>gq,insertDefaultBlock:()=>yq,joinBackward:()=>xq,joinDown:()=>vq,joinForward:()=>wq,joinItemBackward:()=>Sq,joinItemForward:()=>kq,joinTextblockBackward:()=>Cq,joinTextblockForward:()=>Eq,joinUp:()=>bq,keyboardShortcut:()=>_q,lift:()=>Aq,liftEmptyBlock:()=>Rq,liftListItem:()=>Mq,newlineInCode:()=>Nq,resetAttributes:()=>Oq,scrollIntoView:()=>Dq,selectAll:()=>Iq,selectNodeBackward:()=>jq,selectNodeForward:()=>Lq,selectParentNode:()=>Pq,selectTextblockEnd:()=>zq,selectTextblockStart:()=>$q,setContent:()=>Bq,setMark:()=>s9,setMeta:()=>o9,setNode:()=>a9,setNodeSelection:()=>l9,setTextDirection:()=>c9,setTextSelection:()=>u9,sinkListItem:()=>d9,splitBlock:()=>f9,splitListItem:()=>h9,toggleList:()=>m9,toggleMark:()=>g9,toggleNode:()=>y9,toggleWrap:()=>b9,undoInputRule:()=>v9,unsetAllMarks:()=>x9,unsetMark:()=>w9,unsetTextDirection:()=>S9,updateAttributes:()=>k9,wrapIn:()=>C9,wrapInList:()=>E9});var Z5=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window?.getSelection())==null||n.removeAllRanges())}),!0),Y5=(t=!0)=>({commands:e})=>e.setContent("",{emitUpdate:t}),X5=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:s,$to:o})=>{t.doc.nodesBetween(s.pos,o.pos,(l,u)=>{if(l.type.isText)return;const{doc:f,mapping:h}=e,m=f.resolve(h.map(u)),g=f.resolve(h.map(u+l.nodeSize)),b=m.blockRange(g);if(!b)return;const x=jc(b);if(l.type.isTextblock){const{defaultType:S}=m.parent.contentMatchAt(m.index());e.setNodeMarkup(b.start,S)}(x||x===0)&&e.lift(b,x)})}),!0},J5=t=>e=>t(e),Q5=()=>({state:t,dispatch:e})=>SD(t,e),eq=(t,e)=>({editor:n,tr:r})=>{const{state:i}=n,s=i.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const o=r.mapping.map(e);return r.insert(o,s.content),r.setSelection(new ze(r.doc.resolve(Math.max(o-1,0)))),!0},tq=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===r.type){if(e){const l=i.before(s),u=i.after(s);t.delete(l,u).scrollIntoView()}return!0}return!1};function pn(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 nq=t=>({tr:e,state:n,dispatch:r})=>{const i=pn(t,n.schema),s=e.selection.$anchor;for(let o=s.depth;o>0;o-=1)if(s.node(o).type===i){if(r){const u=s.before(o),f=s.after(o);e.delete(u,f).scrollIntoView()}return!0}return!1},rq=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},iq=t=>t.content?/^text(\*|\+)/.test(t.content):!1,LA=(t,e,n)=>{if(!t.parent.isInline||n==="left"&&t.pos>t.start()||n==="right"&&t.pos<t.end())return t.pos;const r=e.nodes[t.parent.type.name].spec;return iq(r)?n==="left"?t.start()-1:t.end()+1:t.pos},sq=(t,e,n)=>{const r=LA(t,n,"left"),i=LA(e,n,"right");return{from:r,to:i}},oq=()=>({state:t,dispatch:e})=>{if(t.selection.empty)return!1;if(e){const n=t.tr,{ranges:r}=t.selection,i=n.steps.length;r.forEach(s=>{const o=n.mapping.slice(i),l=n.doc.resolve(o.map(s.$from.pos)),u=n.doc.resolve(o.map(s.$to.pos)),{from:f,to:h}=sq(l,u,t.schema);n.deleteRange(f,h)}),n.selection.empty||n.setSelection(ze.near(n.doc.resolve(n.selection.from))),n.scrollIntoView(),e(n)}return!0},aq=()=>({commands:t})=>t.keyboardShortcut("Enter"),lq=()=>({state:t,dispatch:e})=>U4(t,e);function nS(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Yp(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:nS(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function cI(t,e,n={}){return t.find(r=>r.type===e&&Yp(Object.fromEntries(Object.keys(n).map(i=>[i,r.attrs[i]])),n))}function PA(t,e,n={}){return!!cI(t,e,n)}function rS(t,e,n){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if((!r.node||!r.node.marks.some(f=>f.type===e))&&(r=t.parent.childBefore(t.parentOffset)),!r.node||!r.node.marks.some(f=>f.type===e))return;if(!n){const f=r.node.marks.find(h=>h.type===e);f&&(n=f.attrs)}if(!cI([...r.node.marks],e,n))return;let s=r.index,o=t.start()+r.offset,l=s+1,u=o+r.node.nodeSize;for(;s>0&&PA([...t.parent.child(s-1).marks],e,n);)s-=1,o-=t.parent.child(s).nodeSize;for(;l<t.parent.childCount&&PA([...t.parent.child(l).marks],e,n);)u+=t.parent.child(l).nodeSize,l+=1;return{from:o,to:u}}function js(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 cq=(t,e)=>({tr:n,state:r,dispatch:i})=>{const s=js(t,r.schema),{doc:o,selection:l}=n,{$from:u,from:f,to:h}=l;if(i){const m=rS(u,s,e);if(m&&m.from<=f&&m.to>=h){const g=ze.create(o,m.from,m.to);n.setSelection(g)}}return!0},uq=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 uI(t){return t instanceof ze}function Ea(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ux(t,e=null){if(!e)return null;const n=Ke.atStart(t),r=Ke.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,s=r.to;return e==="all"?ze.create(t,Ea(0,i,s),Ea(t.content.size,i,s)):ze.create(t,Ea(e,i,s),Ea(e,i,s))}function zA(){return["Android"].includes(navigator.platform)||/android/i.test(navigator.userAgent)}function Xp(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}function dq(){return typeof navigator<"u"?/^((?!chrome|android).)*safari/i.test(navigator.userAgent):!1}var fq=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:s})=>{e={scrollIntoView:!0,...e};const o=()=>{(Xp()||zA())&&r.dom.focus(),dq()&&!Xp()&&!zA()&&r.dom.focus({preventScroll:!0}),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e?.scrollIntoView&&n.commands.scrollIntoView())})};try{if(r.hasFocus()&&t===null||t===!1)return!0}catch{return!1}if(s&&t===null&&!uI(n.state.selection))return o(),!0;const l=ux(i.doc,t)||n.state.selection,u=n.state.selection.eq(l);return s&&(u||i.setSelection(l),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),o()),!0},hq=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),pq=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),dI=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&&dI(r)}return t};function Yu(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 dI(n)}function Sc(t,e,n){if(t instanceof No||t instanceof de)return t;n={slice:!0,parseOptions:{},...n};const r=typeof t=="object"&&t!==null,i=typeof t=="string";if(r)try{if(Array.isArray(t)&&t.length>0)return de.fromArray(t.map(l=>e.nodeFromJSON(l)));const o=e.nodeFromJSON(t);return n.errorOnInvalidContent&&o.check(),o}catch(s){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",s),Sc("",e,n)}if(i){if(n.errorOnInvalidContent){let o=!1,l="";const u=new KO({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=>(o=!0,l=typeof f=="string"?f:f.outerHTML,null)}]}})});if(n.slice?Cs.fromSchema(u).parseSlice(Yu(t),n.parseOptions):Cs.fromSchema(u).parse(Yu(t),n.parseOptions),n.errorOnInvalidContent&&o)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=Cs.fromSchema(e);return n.slice?s.parseSlice(Yu(t),n.parseOptions).content:s.parse(Yu(t),n.parseOptions)}return Sc("",e,n)}function fI(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof fn||i instanceof kn))return;const s=t.mapping.maps[r];let o=0;s.forEach((l,u,f,h)=>{o===0&&(o=h)}),t.setSelection(Ke.near(t.doc.resolve(o),n))}var mq=t=>!("type"in t),gq=(t,e,n)=>({tr:r,dispatch:i,editor:s})=>{var o;if(i){n={parseOptions:s.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};let l;const u=k=>{s.emit("contentError",{editor:s,error:k,disableCollaboration:()=>{"collaboration"in s.storage&&typeof s.storage.collaboration=="object"&&s.storage.collaboration&&(s.storage.collaboration.isDisabled=!0)}})},f={preserveWhitespace:"full",...n.parseOptions};if(!n.errorOnInvalidContent&&!s.options.enableContentCheck&&s.options.emitContentError)try{Sc(e,s.schema,{parseOptions:f,errorOnInvalidContent:!0})}catch(k){u(k)}try{l=Sc(e,s.schema,{parseOptions:f,errorOnInvalidContent:(o=n.errorOnInvalidContent)!=null?o:s.options.enableContentCheck})}catch(k){return u(k),!1}let{from:h,to:m}=typeof t=="number"?{from:t,to:t}:{from:t.from,to:t.to},g=!0,b=!0;if((mq(l)?l:[l]).forEach(k=>{k.check(),g=g?k.isText&&k.marks.length===0:!1,b=b?k.isBlock:!1}),h===m&&b){const{parent:k}=r.doc.resolve(h);k.isTextblock&&!k.type.spec.code&&!k.childCount&&(h-=1,m+=1)}let S;if(g){if(Array.isArray(e))S=e.map(k=>k.text||"").join("");else if(e instanceof de){let k="";e.forEach(C=>{C.text&&(k+=C.text)}),S=k}else typeof e=="object"&&e&&e.text?S=e.text:S=e;r.insertText(S,h,m)}else{S=l;const k=r.doc.resolve(h),C=k.node(),A=k.parentOffset===0,R=C.isText||C.isTextblock,_=C.content.size>0;A&&R&&_&&b&&(h=Math.max(0,h-1)),r.replaceWith(h,m,S)}n.updateSelection&&fI(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:h,text:S}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:h,text:S})}return!0};function hI(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}var yq=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{pos:i,attrs:s,content:o,updateSelection:l=!0}=t;let u;typeof i=="number"?u=e.doc.resolve(i):i?u=i:u=e.selection.$from;const f=hI(u.parent.contentMatchAt(u.index()));if(!f)return!1;const h=Object.keys(f.spec.attrs||{}),m=s?Object.fromEntries(Object.entries(s).filter(([b])=>h.includes(b))):{};let g;if(o){const b=Sc(o,r.schema);g=f.createAndFill(m,b)}else g=f.createAndFill(m);return g?(n&&(e.insert(u.pos,g),l&&fI(e,e.steps.length-1,-1)),!0):!1},bq=()=>({state:t,dispatch:e})=>B4(t,e),vq=()=>({state:t,dispatch:e})=>V4(t,e),xq=()=>({state:t,dispatch:e})=>mD(t,e),wq=()=>({state:t,dispatch:e})=>vD(t,e),Sq=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Jm(t.doc,t.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},kq=()=>({state:t,dispatch:e,tr:n})=>{try{const r=Jm(t.doc,t.selection.$from.pos,1);return r==null?!1:(n.join(r,2),e&&e(n),!0)}catch{return!1}},Cq=()=>({state:t,dispatch:e})=>z4(t,e),Eq=()=>({state:t,dispatch:e})=>$4(t,e);function pI(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Tq(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,s,o;for(let l=0;l<e.length-1;l+=1){const u=e[l];if(/^(cmd|meta|m)$/i.test(u))o=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))s=!0;else if(/^mod$/i.test(u))Xp()||pI()?o=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),o&&(n=`Meta-${n}`),s&&(n=`Shift-${n}`),n}var _q=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const s=Tq(t).split(/-(?!$)/),o=s.find(f=>!["Alt","Ctrl","Meta","Shift"].includes(f)),l=new KeyboardEvent("keydown",{key:o==="Space"?" ":o,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",f=>f(n,l))});return u?.steps.forEach(f=>{const h=f.map(r.mapping);h&&i&&r.maybeStep(h)}),!0};function Vo(t,e,n={}){const{from:r,to:i,empty:s}=t.selection,o=e?pn(e,t.schema):null,l=[];t.doc.nodesBetween(r,i,(m,g)=>{if(m.isText)return;const b=Math.max(r,g),x=Math.min(i,g+m.nodeSize);l.push({node:m,from:b,to:x})});const u=i-r,f=l.filter(m=>o?o.name===m.node.type.name:!0).filter(m=>Yp(m.node.attrs,n,{strict:!1}));return s?!!f.length:f.reduce((m,g)=>m+g.to-g.from,0)>=u}var Aq=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return Vo(n,i,e)?H4(n,r):!1},Rq=()=>({state:t,dispatch:e})=>kD(t,e),Mq=t=>({state:e,dispatch:n})=>{const r=pn(t,e.schema);return e6(r)(e,n)},Nq=()=>({state:t,dispatch:e})=>wD(t,e);function sg(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function $A(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}var Oq=(t,e)=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=sg(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=pn(t,r.schema)),l==="mark"&&(o=js(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{r.doc.nodesBetween(f.$from.pos,f.$to.pos,(h,m)=>{s&&s===h.type&&(u=!0,i&&n.setNodeMarkup(m,void 0,$A(h.attrs,e))),o&&h.marks.length&&h.marks.forEach(g=>{o===g.type&&(u=!0,i&&n.addMark(m,m+h.nodeSize,o.create($A(g.attrs,e))))})})}),u},Dq=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Iq=()=>({tr:t,dispatch:e})=>{if(e){const n=new Mr(t.doc);t.setSelection(n)}return!0},jq=()=>({state:t,dispatch:e})=>yD(t,e),Lq=()=>({state:t,dispatch:e})=>xD(t,e),Pq=()=>({state:t,dispatch:e})=>G4(t,e),zq=()=>({state:t,dispatch:e})=>Z4(t,e),$q=()=>({state:t,dispatch:e})=>K4(t,e);function dx(t,e,n={},r={}){return Sc(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}var Bq=(t,{errorOnInvalidContent:e,emitUpdate:n=!0,parseOptions:r={}}={})=>({editor:i,tr:s,dispatch:o,commands:l})=>{const{doc:u}=s;if(r.preserveWhitespace!=="full"){const f=dx(t,i.schema,r,{errorOnInvalidContent:e??i.options.enableContentCheck});return o&&s.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!n),!0}return o&&s.setMeta("preventUpdate",!n),l.insertContentAt({from:0,to:u.content.size},t,{parseOptions:r,errorOnInvalidContent:e??i.options.enableContentCheck})};function mI(t,e){const n=js(e,t.schema),{from:r,to:i,empty:s}=t.selection,o=[];s?(t.storedMarks&&o.push(...t.storedMarks),o.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{o.push(...u.marks)});const l=o.find(u=>u.type.name===n.name);return l?{...l.attrs}:{}}function gI(t,e){const n=new $w(t);return e.forEach(r=>{r.steps.forEach(i=>{n.step(i)})}),n}function Vq(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,(i,s)=>{n(i)&&r.push({node:i,pos:s})}),r}function yI(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 og(t){return e=>yI(e.$from,t)}function De(t,e,n){return t.config[e]===void 0&&t.parent?De(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?De(t.parent,e,n):null}):t.config[e]}function ag(t){return t.map(e=>{const n={name:e.name,options:e.options,storage:e.storage},r=De(e,"addExtensions",n);return r?[e,...ag(r())]:e}).flat(10)}function iS(t,e){const n=Xa.fromSchema(e).serializeFragment(t),i=document.implementation.createHTMLDocument().createElement("div");return i.appendChild(n),i.innerHTML}function bI(t){return typeof t=="function"}function mt(t,e=void 0,...n){return bI(t)?e?t.bind(e)(...n):t(...n):t}function Hq(t={}){return Object.keys(t).length===0&&t.constructor===Object}function kc(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function vI(t){const e=[],{nodeExtensions:n,markExtensions:r}=kc(t),i=[...n,...r],s={default:null,validate:void 0,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1},o=n.filter(f=>f.name!=="text").map(f=>f.name),l=r.map(f=>f.name),u=[...o,...l];return t.forEach(f=>{const h={name:f.name,options:f.options,storage:f.storage,extensions:i},m=De(f,"addGlobalAttributes",h);if(!m)return;m().forEach(b=>{let x;Array.isArray(b.types)?x=b.types:b.types==="*"?x=u:b.types==="nodes"?x=o:b.types==="marks"?x=l:x=[],x.forEach(S=>{Object.entries(b.attributes).forEach(([k,C])=>{e.push({type:S,name:k,attribute:{...s,...C}})})})})}),i.forEach(f=>{const h={name:f.name,options:f.options,storage:f.storage},m=De(f,"addAttributes",h);if(!m)return;const g=m();Object.entries(g).forEach(([b,x])=>{const S={...s,...x};typeof S?.default=="function"&&(S.default=S.default()),S?.isRequired&&S?.default===void 0&&delete S.default,e.push({type:f.name,name:b,attribute:S})})}),e}function Uq(t){const e=[];let n="",r=!1,i=!1,s=0;const o=t.length;for(let l=0;l<o;l+=1){const u=t[l];if(u==="'"&&!i){r=!r,n+=u;continue}if(u==='"'&&!r){i=!i,n+=u;continue}if(!r&&!i){if(u==="("){s+=1,n+=u;continue}if(u===")"&&s>0){s-=1,n+=u;continue}if(u===";"&&s===0){e.push(n),n="";continue}}n+=u}return n&&e.push(n),e}function BA(t){const e=[],n=Uq(t||""),r=n.length;for(let i=0;i<r;i+=1){const s=n[i],o=s.indexOf(":");if(o===-1)continue;const l=s.slice(0,o).trim(),u=s.slice(o+1).trim();l&&u&&e.push([l,u])}return e}function jt(...t){return t.filter(e=>!!e).reduce((e,n)=>{const r={...e};return Object.entries(n).forEach(([i,s])=>{if(!r[i]){r[i]=s;return}if(i==="class"){const l=s?String(s).split(" "):[],u=r[i]?r[i].split(" "):[],f=l.filter(h=>!u.includes(h));r[i]=[...u,...f].join(" ")}else if(i==="style"){const l=new Map([...BA(r[i]),...BA(s)]);r[i]=Array.from(l.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[i]=s}),r},{})}function Cc(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)=>jt(n,r),{})}function Fq(t){return typeof t!="string"?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):t==="true"?!0:t==="false"?!1:t}function VA(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 i=e.reduce((s,o)=>{const l=o.attribute.parseHTML?o.attribute.parseHTML(n):Fq(n.getAttribute(o.name));return l==null?s:{...s,[o.name]:l}},{});return{...r,...i}}}}function HA(t){return Object.fromEntries(Object.entries(t).filter(([e,n])=>e==="attrs"&&Hq(n)?!1:n!=null))}function UA(t){var e,n;const r={};return!((e=t?.attribute)!=null&&e.isRequired)&&"default"in(t?.attribute||{})&&(r.default=t.attribute.default),((n=t?.attribute)==null?void 0:n.validate)!==void 0&&(r.validate=t.attribute.validate),[t.name,r]}function xI(t,e){var n;const r=vI(t),{nodeExtensions:i,markExtensions:s}=kc(t),o=(n=i.find(f=>De(f,"topNode")))==null?void 0:n.name,l=Object.fromEntries(i.map(f=>{const h=r.filter(C=>C.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((C,A)=>{const R=De(A,"extendNodeSchema",m);return{...C,...R?R(f):{}}},{}),b=HA({...g,content:mt(De(f,"content",m)),marks:mt(De(f,"marks",m)),group:mt(De(f,"group",m)),inline:mt(De(f,"inline",m)),atom:mt(De(f,"atom",m)),selectable:mt(De(f,"selectable",m)),draggable:mt(De(f,"draggable",m)),code:mt(De(f,"code",m)),whitespace:mt(De(f,"whitespace",m)),linebreakReplacement:mt(De(f,"linebreakReplacement",m)),defining:mt(De(f,"defining",m)),isolating:mt(De(f,"isolating",m)),attrs:Object.fromEntries(h.map(UA))}),x=mt(De(f,"parseHTML",m));x&&(b.parseDOM=x.map(C=>VA(C,h)));const S=De(f,"renderHTML",m);S&&(b.toDOM=C=>S({node:C,HTMLAttributes:Cc(C,h)}));const k=De(f,"renderText",m);return k&&(b.toText=k),[f.name,b]})),u=Object.fromEntries(s.map(f=>{const h=r.filter(k=>k.type===f.name),m={name:f.name,options:f.options,storage:f.storage,editor:e},g=t.reduce((k,C)=>{const A=De(C,"extendMarkSchema",m);return{...k,...A?A(f):{}}},{}),b=HA({...g,inclusive:mt(De(f,"inclusive",m)),excludes:mt(De(f,"excludes",m)),group:mt(De(f,"group",m)),spanning:mt(De(f,"spanning",m)),code:mt(De(f,"code",m)),attrs:Object.fromEntries(h.map(UA))}),x=mt(De(f,"parseHTML",m));x&&(b.parseDOM=x.map(k=>VA(k,h)));const S=De(f,"renderHTML",m);return S&&(b.toDOM=k=>S({mark:k,HTMLAttributes:Cc(k,h)})),[f.name,b]}));return new KO({topNode:o,nodes:l,marks:u})}function qq(t){const e=t.filter((n,r)=>t.indexOf(n)!==r);return Array.from(new Set(e))}function ac(t){return t.sort((n,r)=>{const i=De(n,"priority")||100,s=De(r,"priority")||100;return i>s?-1:i<s?1:0})}function sS(t){const e=ac(ag(t)),n=qq(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 wI(t,e){const n=sS(t);return xI(n,e)}function Gq(t,e){const n=wI(e),r=Yu(t);return Cs.fromSchema(n).parse(r).toJSON()}function SI(t,e,n){const{from:r,to:i}=e,{blockSeparator:s=`
|
|
74
|
+
|
|
75
|
+
`,textSerializers:o={}}=n||{};let l="";return t.nodesBetween(r,i,(u,f,h,m)=>{var g;u.isBlock&&f>r&&(l+=s);const b=o?.[u.type.name];if(b)return h&&(l+=b({node:u,pos:f,parent:h,index:m,range:e})),!1;u.isText&&(l+=(g=u?.text)==null?void 0:g.slice(Math.max(r,f)-f,i-f))}),l}function Wq(t,e){const n={from:0,to:t.content.size};return SI(t,n,e)}function kI(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}function Kq(t,e){const n=pn(e,t.schema),{from:r,to:i}=t.selection,s=[];t.doc.nodesBetween(r,i,l=>{s.push(l)});const o=s.reverse().find(l=>l.type.name===n.name);return o?{...o.attrs}:{}}function CI(t,e){const n=sg(typeof e=="string"?e:e.name,t.schema);return n==="node"?Kq(t,e):n==="mark"?mI(t,e):{}}function Zq(t,e=JSON.stringify){const n={};return t.filter(r=>{const i=e(r);return Object.prototype.hasOwnProperty.call(n,i)?!1:n[i]=!0})}function Yq(t){const e=Zq(t);return e.length===1?e:e.filter((n,r)=>!e.filter((s,o)=>o!==r).some(s=>n.oldRange.from>=s.oldRange.from&&n.oldRange.to<=s.oldRange.to&&n.newRange.from>=s.newRange.from&&n.newRange.to<=s.newRange.to))}function oS(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach((i,s)=>{const o=[];if(i.ranges.length)i.forEach((l,u)=>{o.push({from:l,to:u})});else{const{from:l,to:u}=n[s];if(l===void 0||u===void 0)return;o.push({from:l,to:u})}o.forEach(({from:l,to:u})=>{const f=e.slice(s).map(l,-1),h=e.slice(s).map(u),m=e.invert().map(f,-1),g=e.invert().map(h);r.push({oldRange:{from:m,to:g},newRange:{from:f,to:h}})})}),Yq(r)}function aS(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach(i=>{const s=n.resolve(t),o=rS(s,i.type);o&&r.push({mark:i,...o})}):n.nodesBetween(t,e,(i,s)=>{!i||i?.nodeSize===void 0||r.push(...i.marks.map(o=>({from:s,to:s+i.nodeSize,mark:o})))}),r}var Xq=(t,e,n,r=20)=>{const i=t.doc.resolve(n);let s=r,o=null;for(;s>0&&o===null;){const l=i.node(s);l?.type.name===e?o=l:s-=1}return[o,s]};function zu(t,e){return e.nodes[t]||e.marks[t]||null}function hp(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(s=>s.type===e&&s.name===r);return i?i.attribute.keepOnSplit:!1}))}var Jq=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,(i,s,o,l)=>{var u,f;const h=((f=(u=i.type.spec).toText)==null?void 0:f.call(u,{node:i,pos:s,parent:o,index:l}))||i.textContent||"%leaf%";n+=i.isAtom&&!i.isText?h:h.slice(0,Math.max(0,r-s))}),n};function fx(t,e,n={}){const{empty:r,ranges:i}=t.selection,s=e?js(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(m=>s?s.name===m.type.name:!0).find(m=>Yp(m.attrs,n,{strict:!1}));let o=0;const l=[];if(i.forEach(({$from:m,$to:g})=>{const b=m.pos,x=g.pos;t.doc.nodesBetween(b,x,(S,k)=>{if(s&&S.inlineContent&&!S.type.allowsMarkType(s))return!1;if(!S.isText&&!S.marks.length)return;const C=Math.max(b,k),A=Math.min(x,k+S.nodeSize),R=A-C;o+=R,l.push(...S.marks.map(_=>({mark:_,from:C,to:A})))})}),o===0)return!1;const u=l.filter(m=>s?s.name===m.mark.type.name:!0).filter(m=>Yp(m.mark.attrs,n,{strict:!1})).reduce((m,g)=>m+g.to-g.from,0),f=l.filter(m=>s?m.mark.type!==s&&m.mark.type.excludes(s):!0).reduce((m,g)=>m+g.to-g.from,0);return(u>0?u+f:u)>=o}function Qq(t,e,n={}){if(!e)return Vo(t,null,n)||fx(t,null,n);const r=sg(e,t.schema);return r==="node"?Vo(t,e,n):r==="mark"?fx(t,e,n):!1}var e9=(t,e)=>{const{$from:n,$to:r,$anchor:i}=t.selection;if(e){const s=og(l=>l.type.name===e)(t.selection);if(!s)return!1;const o=t.doc.resolve(s.pos+1);return i.pos+1===o.end()}return!(r.parentOffset<r.parent.nodeSize-2||n.pos!==r.pos)},t9=t=>{const{$from:e,$to:n}=t.selection;return!(e.parentOffset>0||e.pos!==n.pos)};function FA(t,e){return Array.isArray(e)?e.some(n=>(typeof n=="string"?n:n.name)===t.name):e}function Mv(t,e){const{nodeExtensions:n}=kc(e),r=n.find(o=>o.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},s=mt(De(r,"group",i));return typeof s!="string"?!1:s.split(" ").includes("list")}function sf(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if(t.type.name==="hardBreak")return!0;if(t.isText)return!/\S/.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 i=!0;return t.content.forEach(s=>{i!==!1&&(sf(s,{ignoreWhitespace:n,checkChildren:e})||(i=!1))}),i}return!1}function EI(t){return t instanceof He}var TI=class _I{constructor(e){this.position=e}static fromJSON(e){return new _I(e.position)}toJSON(){return{position:this.position}}};function n9(t,e){const n=e.mapping.mapResult(t.position);return{position:new TI(n.pos),mapResult:n}}function r9(t){return new TI(t)}function i9(t,e,n){var r;const{selection:i}=e;let s=null;if(uI(i)&&(s=i.$cursor),s){const l=(r=t.storedMarks)!=null?r:s.marks();return s.parent.type.allowsMarkType(n)&&(!!n.isInSet(l)||!l.some(f=>f.type.excludes(n)))}const{ranges:o}=i;return o.some(({$from:l,$to:u})=>{let f=l.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(l.pos,u.pos,(h,m,g)=>{if(f)return!1;if(h.isInline){const b=!g||g.type.allowsMarkType(n),x=!!n.isInSet(h.marks)||!h.marks.some(S=>S.type.excludes(n));f=b&&x}return!f}),f})}var s9=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=n,{empty:o,ranges:l}=s,u=js(t,r.schema);if(i)if(o){const f=mI(r,u);n.addStoredMark(u.create({...f,...e}))}else l.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;r.doc.nodesBetween(h,m,(g,b)=>{const x=Math.max(b,h),S=Math.min(b+g.nodeSize,m);g.marks.find(C=>C.type===u)?g.marks.forEach(C=>{u===C.type&&n.addMark(x,S,u.create({...C.attrs,...e}))}):n.addMark(x,S,u.create(e))})});return i9(r,n,u)},o9=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),a9=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const s=pn(t,n.schema);let o;return n.selection.$anchor.sameParent(n.selection.$head)&&(o=n.selection.$anchor.parent.attrs),s.isTextblock?i().command(({commands:l})=>sA(s,{...o,...e})(n)?!0:l.clearNodes()).command(({state:l})=>sA(s,{...o,...e})(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},l9=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Ea(t,0,r.content.size),s=He.create(r,i);e.setSelection(s)}return!0},c9=(t,e)=>({tr:n,state:r,dispatch:i})=>{const{selection:s}=r;let o,l;return typeof e=="number"?(o=e,l=e):e&&"from"in e&&"to"in e?(o=e.from,l=e.to):(o=s.from,l=s.to),i&&n.doc.nodesBetween(o,l,(u,f)=>{u.isText||n.setNodeMarkup(f,void 0,{...u.attrs,dir:t})}),!0},u9=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:s}=typeof t=="number"?{from:t,to:t}:t,o=ze.atStart(r).from,l=ze.atEnd(r).to,u=Ea(i,o,l),f=Ea(s,o,l),h=ze.create(r,u,f);e.setSelection(h)}return!0},d9=t=>({state:e,dispatch:n})=>{const r=pn(t,e.schema);return r6(r)(e,n)};function qA(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e?.includes(i.type.name));t.tr.ensureMarks(r)}}var f9=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:s,doc:o}=e,{$from:l,$to:u}=s,f=i.extensionManager.attributes,h=hp(f,l.node().type.name,l.node().attrs);if(s instanceof He&&s.node.isBlock)return!l.parentOffset||!Es(o,l.pos)?!1:(r&&(t&&qA(n,i.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const m=u.parentOffset===u.parent.content.size,g=l.depth===0?void 0:hI(l.node(-1).contentMatchAt(l.indexAfter(-1)));let b=m&&g?[{type:g,attrs:h}]:void 0,x=Es(e.doc,e.mapping.map(l.pos),1,b);if(!b&&!x&&Es(e.doc,e.mapping.map(l.pos),1,g?[{type:g}]:void 0)&&(x=!0,b=g?[{type:g,attrs:h}]:void 0),r){if(x&&(s instanceof ze&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,b),g&&!m&&!l.parentOffset&&l.parent.type!==g)){const S=e.mapping.map(l.before()),k=e.doc.resolve(S);l.node(-1).canReplaceWith(k.index(),k.index()+1,g)&&e.setNodeMarkup(e.mapping.map(l.before()),g)}t&&qA(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return x},h9=(t,e={})=>({tr:n,state:r,dispatch:i,editor:s})=>{var o;const l=pn(t,r.schema),{$from:u,$to:f}=r.selection,h=r.selection.node;if(h&&h.isBlock||u.depth<2||!u.sameParent(f))return!1;const m=u.node(-1);if(m.type!==l)return!1;const g=s.extensionManager.attributes;if(u.parent.content.size===0&&u.node(-1).childCount===u.indexAfter(-1)){if(u.depth===2||u.node(-3).type!==l||u.index(-2)!==u.node(-2).childCount-1)return!1;if(i){let C=de.empty;const A=u.index(-1)?1:u.index(-2)?2:3;for(let I=u.depth-A;I>=u.depth-3;I-=1)C=de.from(u.node(I).copy(C));const R=u.indexAfter(-1)<u.node(-2).childCount?1:u.indexAfter(-2)<u.node(-3).childCount?2:3,_={...hp(g,u.node().type.name,u.node().attrs),...e},M=((o=l.contentMatch.defaultType)==null?void 0:o.createAndFill(_))||void 0;C=C.append(de.from(l.createAndFill(null,M)||void 0));const O=u.before(u.depth-(A-1));n.replace(O,u.after(-R),new Ee(C,4-A,0));let D=-1;n.doc.nodesBetween(O,n.doc.content.size,(I,P)=>{if(D>-1)return!1;I.isTextblock&&I.content.size===0&&(D=P+1)}),D>-1&&n.setSelection(ze.near(n.doc.resolve(D))),n.scrollIntoView()}return!0}const b=f.pos===u.end()?m.contentMatchAt(0).defaultType:null,x={...hp(g,m.type.name,m.attrs),...e},S={...hp(g,u.node().type.name,u.node().attrs),...e};n.delete(u.pos,f.pos);const k=b?[{type:l,attrs:x},{type:b,attrs:S}]:[{type:l,attrs:x}];if(!Es(n.doc,u.pos,2))return!1;if(i){const{selection:C,storedMarks:A}=r,{splittableMarks:R}=s.extensionManager,_=A||C.$to.parentOffset&&C.$from.marks();if(n.split(u.pos,2,k).scrollIntoView(),!_||!i)return!0;const M=_.filter(O=>R.includes(O.type.name));n.ensureMarks(M)}return!0};function GA(t){return!t||t==="1"?null:t}function AI(t,e){return GA(t)===GA(e)}var Nv=(t,e)=>{const n=og(o=>o.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 i=t.doc.nodeAt(r);return!(n.node.type===i?.type&&Ko(t.doc,n.pos))||!AI(n.node.attrs.type,i?.attrs.type)||t.join(n.pos),!0},Ov=(t,e)=>{const n=og(o=>o.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 i=t.doc.nodeAt(r);return!(n.node.type===i?.type&&Ko(t.doc,r))||!AI(n.node.attrs.type,i?.attrs.type)||t.join(r),!0};function p9(t){const e=t.doc,n=e.firstChild;if(!n)return null;const r=e.resolve(1),i=e.resolve(n.nodeSize-1);return ze.between(r,i)}var m9=(t,e,n,r={})=>({editor:i,tr:s,state:o,dispatch:l,chain:u,commands:f,can:h})=>{const{extensions:m,splittableMarks:g}=i.extensionManager,b=pn(t,o.schema),x=pn(e,o.schema),{selection:S,storedMarks:k}=o,{$from:C,$to:A}=S,R=C.blockRange(A),_=k||S.$to.parentOffset&&S.$from.marks();if(!R)return!1;const M=og(ee=>Mv(ee.type.name,m))(S),O=S.from===0&&S.to===o.doc.content.size,D=o.doc.content.content,I=D.length===1?D[0]:null,P=O&&I&&Mv(I.type.name,m)?{node:I,pos:0}:null,B=M??P,re=!!M&&R.depth>=1&&R.depth-M.depth<=1,K=!!P;if((re||K)&&B){if(B.node.type===b)return O&&K?u().command(({tr:ee,dispatch:Q})=>{const fe=p9(ee);return fe?(ee.setSelection(fe),Q&&Q(ee),!0):!1}).liftListItem(x).run():f.liftListItem(x);if(Mv(B.node.type.name,m)&&b.validContent(B.node.content))return u().command(()=>(s.setNodeMarkup(B.pos,b),!0)).command(()=>Nv(s,b)).command(()=>Ov(s,b)).run()}return!n||!_||!l?u().command(()=>h().wrapInList(b,r)?!0:f.clearNodes()).wrapInList(b,r).command(()=>Nv(s,b)).command(()=>Ov(s,b)).run():u().command(()=>{const ee=h().wrapInList(b,r),Q=_.filter(fe=>g.includes(fe.type.name));return s.ensureMarks(Q),ee?!0:f.clearNodes()}).wrapInList(b,r).command(()=>Nv(s,b)).command(()=>Ov(s,b)).run()},g9=(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:s=!1}=n,o=js(t,r.schema);return fx(r,o,e)?i.unsetMark(o,{extendEmptyMarkRange:s}):i.setMark(o,e)},y9=(t,e,n={})=>({state:r,commands:i})=>{const s=pn(t,r.schema),o=pn(e,r.schema),l=Vo(r,s,n);let u;return r.selection.$anchor.sameParent(r.selection.$head)&&(u=r.selection.$anchor.parent.attrs),l?i.setNode(o,u):i.setNode(s,{...u,...n})},b9=(t,e={})=>({state:n,commands:r})=>{const i=pn(t,n.schema);return Vo(n,i,e)?r.lift(i):r.wrapIn(i,e)},v9=()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let s;if(i.spec.isInputRules&&(s=i.getState(t))){if(e){const o=t.tr,l=s.transform;for(let u=l.steps.length-1;u>=0;u-=1)o.step(l.steps[u].invert(l.docs[u]));if(s.text){const u=o.doc.resolve(s.from).marks();o.replaceWith(s.from,s.to,t.schema.text(s.text,u))}else o.delete(s.from,s.to)}return!0}}return!1},x9=(t={})=>({tr:e,dispatch:n,editor:r})=>{const{ignoreClearable:i=!1}=t,{selection:s}=e,{empty:o,ranges:l}=s;if(o)return!0;const{nonClearableMarks:u}=r.extensionManager;if(n){const f=Object.values(r.schema.marks).filter(h=>i||!u.includes(h.name));l.forEach(h=>{for(const m of f)e.removeMark(h.$from.pos,h.$to.pos,m)})}return!0},w9=(t,e={})=>({tr:n,state:r,dispatch:i})=>{var s;const{extendEmptyMarkRange:o=!1}=e,{selection:l}=n,u=js(t,r.schema),{$from:f,empty:h,ranges:m}=l;if(!i)return!0;if(h&&o){let{from:g,to:b}=l;const x=(s=f.marks().find(k=>k.type===u))==null?void 0:s.attrs,S=rS(f,u,x);S&&(g=S.from,b=S.to),n.removeMark(g,b,u)}else m.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},S9=t=>({tr:e,state:n,dispatch:r})=>{const{selection:i}=n;let s,o;return typeof t=="number"?(s=t,o=t):t&&"from"in t&&"to"in t?(s=t.from,o=t.to):(s=i.from,o=i.to),r&&e.doc.nodesBetween(s,o,(l,u)=>{if(l.isText)return;const f={...l.attrs};delete f.dir,e.setNodeMarkup(u,void 0,f)}),!0},k9=(t,e={})=>({tr:n,state:r,dispatch:i})=>{let s=null,o=null;const l=sg(typeof t=="string"?t:t.name,r.schema);if(!l)return!1;l==="node"&&(s=pn(t,r.schema)),l==="mark"&&(o=js(t,r.schema));let u=!1;return n.selection.ranges.forEach(f=>{const h=f.$from.pos,m=f.$to.pos;let g,b,x,S;n.selection.empty?r.doc.nodesBetween(h,m,(k,C)=>{s&&s===k.type&&(u=!0,x=Math.max(C,h),S=Math.min(C+k.nodeSize,m),g=C,b=k)}):r.doc.nodesBetween(h,m,(k,C)=>{C<h&&s&&s===k.type&&(u=!0,x=Math.max(C,h),S=Math.min(C+k.nodeSize,m),g=C,b=k),C>=h&&C<=m&&(s&&s===k.type&&(u=!0,i&&n.setNodeMarkup(C,void 0,{...k.attrs,...e})),o&&k.marks.length&&k.marks.forEach(A=>{if(o===A.type&&(u=!0,i)){const R=Math.max(C,h),_=Math.min(C+k.nodeSize,m);n.addMark(R,_,o.create({...A.attrs,...e}))}}))}),b&&(g!==void 0&&i&&n.setNodeMarkup(g,void 0,{...b.attrs,...e}),o&&b.marks.length&&b.marks.forEach(k=>{o===k.type&&i&&n.addMark(x,S,o.create({...k.attrs,...e}))}))}),u},C9=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return Y4(i,e)(n,r)},E9=(t,e={})=>({state:n,dispatch:r})=>{const i=pn(t,n.schema);return X4(i,e)(n,r)},T9=class{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach(r=>r.apply(this,e)),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter(r=>r!==e):delete this.callbacks[t]),this}once(t,e){const n=(...r)=>{this.off(t,n),e.apply(this,r)};return this.on(t,n)}removeAllListeners(){this.callbacks={}}};function Ec(t,e){if(t===e)return!0;if(!t||!e)return!1;const n=Object.keys(t),r=Object.keys(e);return n.length!==r.length?!1:n.every(i=>Object.prototype.hasOwnProperty.call(e,i)&&Object.is(t[i],e[i]))}function _9(t,e){const{selection:n}=t,{$from:r}=n;if(n instanceof He){const s=r.index();return r.parent.canReplaceWith(s,s+1,e)}let i=r.depth;for(;i>=0;){const s=r.index(i);if(r.node(i).contentMatchAt(s).matchType(e))return!0;i-=1}return!1}function A9(t,e,n){const r=document.querySelector("style[data-tiptap-style]");if(r!==null)return r;const i=document.createElement("style");return e&&i.setAttribute("nonce",e),i.setAttribute("data-tiptap-style",""),i.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(i),i}function WA(t){return t.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/&/g,"&")}function R9(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function M9(t){return typeof t=="number"}function N9(t){return Object.prototype.toString.call(t).slice(8,-1)}function Rh(t){return N9(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}var O9={};tS(O9,{createAtomBlockMarkdownSpec:()=>D9,createBlockMarkdownSpec:()=>I9,createInlineMarkdownSpec:()=>P9,parseAttributes:()=>lS,parseIndentedBlocks:()=>hx,renderNestedMarkdownContent:()=>uS,serializeAttributes:()=>cS});function lS(t){if(!t?.trim())return{};const e={},n=[],r=t.replace(/["']([^"']*)["']/g,f=>(n.push(f),`__QUOTED_${n.length-1}__`)),i=r.match(/(?:^|\s)\.([\w-]+)/g);if(i){const f=i.map(h=>h.trim().slice(1));e.class=f.join(" ")}const s=r.match(/(?:^|\s)#([\w-]+)/);s&&(e.id=s[1]);const o=/([a-zA-Z][\w-]*)\s*=\s*(__QUOTED_\d+__)/g;Array.from(r.matchAll(o)).forEach(([,f,h])=>{var m;const g=parseInt(((m=h.match(/__QUOTED_(\d+)__/))==null?void 0:m[1])||"0",10),b=n[g];b&&(e[f]=b.slice(1,-1))});const u=r.replace(/(?:^|\s)\.([\w-]+)/g,"").replace(/(?:^|\s)#([\w-]+)/g,"").replace(/([a-zA-Z][\w-]*)\s*=\s*__QUOTED_\d+__/g,"").trim();return u&&u.split(/\s+/).filter(Boolean).forEach(h=>{h.match(/^[a-zA-Z][\w-]*$/)&&(e[h]=!0)}),e}function cS(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 D9(t){const{nodeName:e,name:n,parseAttributes:r=lS,serializeAttributes:i=cS,defaultAttributes:s={},requiredAttributes:o=[],allowedAttributes:l}=t,u=n||e,f=h=>{if(!l)return h;const m={};return l.forEach(g=>{g in h&&(m[g]=h[g])}),m};return{parseMarkdown:(h,m)=>{const g={...s,...h.attributes};return m.createNode(e,g,[])},markdownTokenizer:{name:e,level:"block",start(h){var m;const g=new RegExp(`^:::${u}(?:\\s|$)`,"m"),b=(m=h.match(g))==null?void 0:m.index;return b!==void 0?b:-1},tokenize(h,m,g){const b=new RegExp(`^:::${u}(?:\\s+\\{([^}]*)\\})?\\s*:::(?:\\n|$)`),x=h.match(b);if(!x)return;const S=x[1]||"",k=r(S);if(!o.find(A=>!(A in k)))return{type:e,raw:x[0],attributes:k}}},renderMarkdown:h=>{const m=f(h.attrs||{}),g=i(m),b=g?` {${g}}`:"";return`:::${u}${b} :::`}}}function I9(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=lS,serializeAttributes:s=cS,defaultAttributes:o={},content:l="block",allowedAttributes:u}=t,f=n||e,h=m=>{if(!u)return m;const g={};return u.forEach(b=>{b in m&&(g[b]=m[b])}),g};return{parseMarkdown:(m,g)=>{let b;if(r){const S=r(m);b=typeof S=="string"?[{type:"text",text:S}]:S}else l==="block"?b=g.parseChildren(m.tokens||[]):b=g.parseInline(m.tokens||[]);const x={...o,...m.attributes};return g.createNode(e,x,b)},markdownTokenizer:{name:e,level:"block",start(m){var g;const b=new RegExp(`^:::${f}`,"m"),x=(g=m.match(b))==null?void 0:g.index;return x!==void 0?x:-1},tokenize(m,g,b){var x;const S=new RegExp(`^:::${f}(?:\\s+\\{([^}]*)\\})?\\s*\\n`),k=m.match(S);if(!k)return;const[C,A=""]=k,R=i(A);let _=1;const M=C.length;let O="";const D=/^:::([\w-]*)(\s.*)?/gm,I=m.slice(M);for(D.lastIndex=0;;){const P=D.exec(I);if(P===null)break;const B=P.index,re=P[1];if(!((x=P[2])!=null&&x.endsWith(":::"))){if(re)_+=1;else if(_-=1,_===0){const K=I.slice(0,B);O=K.trim();const ee=m.slice(0,M+B+P[0].length);let Q=[];if(O)if(l==="block")for(Q=b.blockTokens(K),Q.forEach(fe=>{fe.text&&(!fe.tokens||fe.tokens.length===0)&&(fe.tokens=b.inlineTokens(fe.text))});Q.length>0;){const fe=Q[Q.length-1];if(fe.type==="paragraph"&&(!fe.text||fe.text.trim()===""))Q.pop();else break}else Q=b.inlineTokens(O);return{type:e,raw:ee,attributes:R,content:O,tokens:Q}}}}}},renderMarkdown:(m,g)=>{const b=h(m.attrs||{}),x=s(b),S=x?` {${x}}`:"",k=g.renderChildren(m.content||[],`
|
|
76
|
+
|
|
77
|
+
`);return`:::${f}${S}
|
|
78
|
+
|
|
79
|
+
${k}
|
|
80
|
+
|
|
81
|
+
:::`}}}function j9(t){if(!t.trim())return{};const e={},n=/(\w+)=(?:"([^"]*)"|'([^']*)')/g;let r=n.exec(t);for(;r!==null;){const[,i,s,o]=r;e[i]=s||o,r=n.exec(t)}return e}function L9(t){return Object.entries(t).filter(([,e])=>e!=null).map(([e,n])=>`${e}="${n}"`).join(" ")}function P9(t){const{nodeName:e,name:n,getContent:r,parseAttributes:i=j9,serializeAttributes:s=L9,defaultAttributes:o={},selfClosing:l=!1,allowedAttributes:u}=t,f=n||e,h=g=>{if(!u)return g;const b={};return u.forEach(x=>{const S=typeof x=="string"?x:x.name,k=typeof x=="string"?void 0:x.skipIfDefault;if(S in g){const C=g[S];if(k!==void 0&&C===k)return;b[S]=C}}),b},m=f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return{parseMarkdown:(g,b)=>{const x={...o,...g.attributes};if(l)return b.createNode(e,x);const S=r?r(g):g.content||"";return S?b.createNode(e,x,[b.createTextNode(S)]):b.createNode(e,x,[])},markdownTokenizer:{name:e,level:"inline",start(g){const b=l?new RegExp(`\\[${m}\\s*[^\\]]*\\]`):new RegExp(`\\[${m}\\s*[^\\]]*\\][\\s\\S]*?\\[\\/${m}\\]`),x=g.match(b),S=x?.index;return S!==void 0?S:-1},tokenize(g,b,x){const S=l?new RegExp(`^\\[${m}\\s*([^\\]]*)\\]`):new RegExp(`^\\[${m}\\s*([^\\]]*)\\]([\\s\\S]*?)\\[\\/${m}\\]`),k=g.match(S);if(!k)return;let C="",A="";if(l){const[,_]=k;A=_}else{const[,_,M]=k;A=_,C=M||""}const R=i(A.trim());return{type:e,raw:k[0],content:C.trim(),attributes:R}}},renderMarkdown:g=>{let b="";r?b=r(g):g.content&&g.content.length>0&&(b=g.content.filter(C=>C.type==="text").map(C=>C.text).join(""));const x=h(g.attrs||{}),S=s(x),k=S?` ${S}`:"";return l?`[${f}${k}]`:`[${f}${k}]${b}[/${f}]`}}}function hx(t,e,n){var r,i,s,o;const l=t.split(`
|
|
82
|
+
`),u=[];let f="",h=0;const m=e.baseIndentSize||2;for(;h<l.length;){const g=l[h],b=g.match(e.itemPattern);if(!b){if(u.length>0)break;if(g.trim()===""){h+=1,f=`${f}${g}
|
|
83
|
+
`;continue}else return}const x=e.extractItemData(b),{indentLevel:S,mainContent:k}=x;f=`${f}${g}
|
|
84
|
+
`;const C=[k];for(h+=1;h<l.length;){const M=l[h];if(M.trim()===""){const D=l.slice(h+1).findIndex(B=>B.trim()!=="");if(D===-1)break;if((((i=(r=l[h+1+D].match(/^(\s*)/))==null?void 0:r[1])==null?void 0:i.length)||0)>S){C.push(M),f=`${f}${M}
|
|
85
|
+
`,h+=1;continue}else break}if((((o=(s=M.match(/^(\s*)/))==null?void 0:s[1])==null?void 0:o.length)||0)>S)C.push(M),f=`${f}${M}
|
|
86
|
+
`,h+=1;else break}let A;const R=C.slice(1);if(R.length>0){const M=R.map(O=>O.slice(S+m)).join(`
|
|
87
|
+
`);M.trim()&&(e.customNestedParser?A=e.customNestedParser(M):A=n.blockTokens(M))}const _=e.createToken(x,A);u.push(_)}if(u.length!==0)return{items:u,raw:f}}function uS(t,e,n,r){if(!t||!Array.isArray(t.content))return"";const i=typeof n=="function"?n(r):n,[s,...o]=t.content,l=e.renderChildren([s]);let u=`${i}${l}`;return o&&o.length>0&&o.forEach((f,h)=>{var m,g;const b=(g=(m=e.renderChild)==null?void 0:m.call(e,f,h+1))!=null?g:e.renderChildren([f]);if(b!=null){const x=b.split(`
|
|
88
|
+
`).map(S=>S?e.indent(S):e.indent("")).join(`
|
|
89
|
+
`);u+=f.type==="paragraph"?`
|
|
90
|
+
|
|
91
|
+
${x}`:`
|
|
92
|
+
${x}`}}),u}function KA(t){return typeof t.type=="string"?t.type:t.type.name}function z9(t,e){if(t.length!==e.length)return!1;const n=Array.from({length:e.length},()=>!1);return t.every(r=>{const i=KA(r),s=e.findIndex((o,l)=>!n[l]&&i===KA(o)&&Ec(r.attrs,o.attrs));return s===-1?!1:(n[s]=!0,!0)})}function RI(t,e){const n={...t};return Rh(t)&&Rh(e)&&Object.keys(e).forEach(r=>{Rh(e[r])&&Rh(t[r])?n[r]=RI(t[r],e[r]):n[r]=e[r]}),n}function $9(t,e,n={}){const{state:r}=e,{doc:i,tr:s}=r,o=t;i.descendants((l,u)=>{const f=s.mapping.map(u),h=s.mapping.map(u)+l.nodeSize;let m=null;if(l.marks.forEach(b=>{if(b!==o)return!1;m=b}),!m)return;let g=!1;if(Object.keys(n).forEach(b=>{n[b]!==m.attrs[b]&&(g=!0)}),g){const b=t.type.create({...t.attrs,...n});s.removeMark(f,h,t.type),s.addMark(f,h,b)}}),s.docChanged&&e.view.dispatch(s)}var of=class{constructor(t){var e;this.find=t.find,this.handler=t.handler,this.undoable=(e=t.undoable)!=null?e:!0}},B9=(t,e)=>{if(nS(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 Mh(t){var e;const{editor:n,from:r,to:i,text:s,rules:o,plugin:l}=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(g=>g.type.spec.code))return!1;let h=!1;const m=Jq(f)+s;return o.forEach(g=>{if(h)return;const b=B9(m,g.find);if(!b)return;const x=b[0].length-s.length;if(x>0){const O=f.parentOffset-x;if(O<0||f.parent.textBetween(O,f.parentOffset)!==b[0].slice(0,x))return}const S=u.state.tr,k=rg({state:u.state,transaction:S}),C={from:r-(b[0].length-s.length),to:i},{commands:A,chain:R,can:_}=new ig({editor:n,state:k});g.handler({state:k,range:C,match:b,commands:A,chain:R,can:_})===null||!S.steps.length||(g.undoable&&S.setMeta(l,{transform:S,from:r,to:i,text:s}),u.dispatch(S),h=!0)}),h}function V9(t){const{editor:e,rules:n}=t,r=new Lt({state:{init(){return null},apply(i,s,o){const l=i.getMeta(r);if(l)return l;const u=i.getMeta("applyInputRules");return u&&setTimeout(()=>{let{text:h}=u;typeof h=="string"?h=h:h=iS(de.from(h),o.schema);const{from:m}=u,g=m+h.length;Mh({editor:e,from:m,to:g,text:h,rules:n,plugin:r})}),i.selectionSet||i.docChanged?null:s}},props:{handleTextInput(i,s,o,l){return Mh({editor:e,from:s,to:o,text:l,rules:n,plugin:r})},handleDOMEvents:{compositionend:i=>(setTimeout(()=>{const{$cursor:s}=i.state.selection;s&&Mh({editor:e,from:s.pos,to:s.pos,text:"",rules:n,plugin:r})}),!1)},handleKeyDown(i,s){if(s.key!=="Enter")return!1;const{$cursor:o}=i.state.selection;return o?Mh({editor:e,from:o.pos,to:o.pos,text:`
|
|
93
|
+
`,rules:n,plugin:r}):!1}},isInputRules:!0});return r}var dS=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{...mt(De(this,"addOptions",{name:this.name}))}}get storage(){return{...mt(De(this,"addStorage",{name:this.name,options:this.options}))}}configure(t={}){const e=this.extend({...this.config,addOptions:()=>RI(this.options,t)});return e.name=this.name,e.parent=this.parent,this.child=null,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}},Ja=class MI extends dS{constructor(){super(...arguments),this.type="mark"}static create(e={}){const n=typeof e=="function"?e():e;return new MI(n)}static handleExit({editor:e,mark:n}){const{tr:r}=e.state,i=e.state.selection.$from;if(i.pos===i.end()){const o=i.marks();if(!!!o.find(f=>f?.type.name===n.name))return!1;const u=o.find(f=>f?.type.name===n.name);return u&&r.removeStoredMark(u),r.insertText(" ",i.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)}},NI=class{constructor(t){this.find=t.find,this.handler=t.handler}},H9=(t,e,n)=>{if(nS(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map(i=>{const s=[i.text];return s.index=i.index,s.input=t,s.data=i.data,i.replaceWith&&(i.text.includes(i.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),s.push(i.replaceWith)),s}):[]};function U9(t){const{editor:e,state:n,from:r,to:i,rule:s,pasteEvent:o,dropEvent:l}=t,{commands:u,chain:f,can:h}=new ig({editor:e,state:n}),m=[];return n.doc.nodesBetween(r,i,(b,x)=>{var S,k,C,A,R;if((k=(S=b.type)==null?void 0:S.spec)!=null&&k.code||!(b.isText||b.isTextblock||b.isInline))return;const _=(R=(A=(C=b.content)==null?void 0:C.size)!=null?A:b.nodeSize)!=null?R:0,M=Math.max(r,x),O=Math.min(i,x+_);if(M>=O)return;const D=b.isText?b.text||"":b.textBetween(M-x,O-x,void 0,"");H9(D,s.find,o).forEach(P=>{if(P.index===void 0)return;const B=M+P.index+1,re=B+P[0].length,K={from:n.tr.mapping.map(B),to:n.tr.mapping.map(re)},ee=s.handler({state:n,range:K,match:P,commands:u,chain:f,can:h,pasteEvent:o,dropEvent:l});m.push(ee)})}),m.every(b=>b!==null)}var Nh=null,F9=t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=n.clipboardData)==null||e.setData("text/html",t),n};function q9(t){const{editor:e,rules:n}=t;let r=null,i=!1,s=!1,o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}const u=({state:h,from:m,to:g,rule:b,pasteEvt:x})=>{const S=h.tr,k=rg({state:h,transaction:S});if(!(!U9({editor:e,state:k,from:Math.max(m-1,0),to:g.b-1,rule:b,pasteEvent:x,dropEvent:l})||!S.steps.length)){try{l=typeof DragEvent<"u"?new DragEvent("drop"):null}catch{l=null}return o=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,S}};return n.map(h=>new Lt({view(m){const g=x=>{var S;r=(S=m.dom.parentElement)!=null&&S.contains(x.target)?m.dom.parentElement:null,r&&(Nh=e)},b=()=>{Nh&&(Nh=null)};return window.addEventListener("dragstart",g),window.addEventListener("dragend",b),{destroy(){window.removeEventListener("dragstart",g),window.removeEventListener("dragend",b)}}},props:{handleDOMEvents:{drop:(m,g)=>{if(s=r===m.dom.parentElement,l=g,!s){const b=Nh;b?.isEditable&&setTimeout(()=>{const x=b.state.selection;x&&b.commands.deleteRange({from:x.from,to:x.to})},10)}return!1},paste:(m,g)=>{var b;const x=(b=g.clipboardData)==null?void 0:b.getData("text/html");return o=g,i=!!x?.includes("data-pm-slice"),!1}}},appendTransaction:(m,g,b)=>{const x=m[0],S=x.getMeta("uiEvent")==="paste"&&!i,k=x.getMeta("uiEvent")==="drop"&&!s,C=x.getMeta("applyPasteRules"),A=!!C;if(!S&&!k&&!A)return;if(A){let{text:M}=C;typeof M=="string"?M=M:M=iS(de.from(M),b.schema);const{from:O}=C,D=O+M.length,I=F9(M);return u({rule:h,state:b,from:O,to:{b:D},pasteEvt:I})}const R=g.doc.content.findDiffStart(b.doc.content),_=g.doc.content.findDiffEnd(b.doc.content);if(!(!M9(R)||!_||R===_.b))return u({rule:h,state:b,from:R,to:_,pasteEvt:o})}}))}var lg=class{constructor(t,e){this.splittableMarks=[],this.nonClearableMarks=[],this.editor=e,this.baseExtensions=t,this.extensions=sS(t),this.schema=xI(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:zu(e.name,this.schema)},r=De(e,"addCommands",n);return r?{...t,...r()}:t},{})}get plugins(){const{editor:t}=this;return ac([...this.extensions].reverse()).flatMap(r=>{const i={name:r.name,options:r.options,storage:this.editor.extensionStorage[r.name],editor:t,type:zu(r.name,this.schema)},s=[],o=De(r,"addKeyboardShortcuts",i);let l={};if(r.type==="mark"&&De(r,"exitable",i)&&(l.ArrowRight=()=>Ja.handleExit({editor:t,mark:r})),o){const g=Object.fromEntries(Object.entries(o()).map(([b,x])=>[b,()=>x({editor:t})]));l={...l,...g}}const u=W5(l);s.push(u);const f=De(r,"addInputRules",i);if(FA(r,t.options.enableInputRules)&&f){const g=f();if(g&&g.length){const b=V9({editor:t,rules:g}),x=Array.isArray(b)?b:[b];s.push(...x)}}const h=De(r,"addPasteRules",i);if(FA(r,t.options.enablePasteRules)&&h){const g=h();if(g&&g.length){const b=q9({editor:t,rules:g});s.push(...b)}}const m=De(r,"addProseMirrorPlugins",i);if(m){const g=m();s.push(...g)}return s})}get attributes(){return vI(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=kc(this.extensions);return Object.fromEntries(e.filter(n=>!!De(n,"addNodeView")).map(n=>{const r=this.attributes.filter(u=>u.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:pn(n.name,this.schema)},s=De(n,"addNodeView",i);if(!s)return[];const o=s();if(!o)return[];const l=(u,f,h,m,g)=>{const b=Cc(u,r);return o({node:u,view:f,getPos:h,decorations:m,innerDecorations:g,editor:t,extension:n,HTMLAttributes:b})};return[n.name,l]}))}dispatchTransaction(t){const{editor:e}=this;return ac([...this.extensions].reverse()).reduceRight((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:zu(i.name,this.schema)},o=De(i,"dispatchTransaction",s);return o?l=>{o.call(s,{transaction:l,next:r})}:r},t)}transformPastedHTML(t){const{editor:e}=this;return ac([...this.extensions]).reduce((r,i)=>{const s={name:i.name,options:i.options,storage:this.editor.extensionStorage[i.name],editor:e,type:zu(i.name,this.schema)},o=De(i,"transformPastedHTML",s);return o?(l,u)=>{const f=r(l,u);return o.call(s,f)}:r},t||(r=>r))}get markViews(){const{editor:t}=this,{markExtensions:e}=kc(this.extensions);return Object.fromEntries(e.filter(n=>!!De(n,"addMarkView")).map(n=>{const r=this.attributes.filter(l=>l.type===n.name),i={name:n.name,options:n.options,storage:this.editor.extensionStorage[n.name],editor:t,type:js(n.name,this.schema)},s=De(n,"addMarkView",i);if(!s)return[];const o=(l,u,f)=>{const h=Cc(l,r);return s()({mark:l,view:u,inline:f,editor:t,extension:n,HTMLAttributes:h,updateAttributes:m=>{$9(l,t,m)}})};return[n.name,o]}))}destroy(){this.extensions.forEach(t=>{let e=t;for(;e.parent;){const n=e.parent;n.child===e&&(n.child=null),e=n}}),this.extensions=[],this.baseExtensions=[],this.schema=null,this.editor=null}setupExtensions(){const t=this.extensions;this.editor.extensionStorage=Object.fromEntries(t.map(e=>[e.name,e.storage])),t.forEach(e=>{var n,r;const i={name:e.name,options:e.options,storage:this.editor.extensionStorage[e.name],editor:this.editor,type:zu(e.name,this.schema)};e.type==="mark"&&(((n=mt(De(e,"keepOnSplit",i)))==null||n)&&this.splittableMarks.push(e.name),(r=mt(De(e,"clearable",i)))==null||r||this.nonClearableMarks.push(e.name));const s=De(e,"onBeforeCreate",i),o=De(e,"onCreate",i),l=De(e,"onUpdate",i),u=De(e,"onSelectionUpdate",i),f=De(e,"onTransaction",i),h=De(e,"onFocus",i),m=De(e,"onBlur",i),g=De(e,"onDestroy",i);s&&this.editor.on("beforeCreate",s),o&&this.editor.on("create",o),l&&this.editor.on("update",l),u&&this.editor.on("selectionUpdate",u),f&&this.editor.on("transaction",f),h&&this.editor.on("focus",h),m&&this.editor.on("blur",m),g&&this.editor.on("destroy",g)})}};lg.resolve=sS;lg.sort=ac;lg.flatten=ag;var G9={};tS(G9,{ClipboardTextSerializer:()=>DI,Commands:()=>II,Delete:()=>jI,Drop:()=>LI,Editable:()=>PI,FocusEvents:()=>$I,Keymap:()=>BI,Paste:()=>VI,Tabindex:()=>HI,TextDirection:()=>UI,focusEventsPluginKey:()=>zI});var Ft=class OI extends dS{constructor(){super(...arguments),this.type="extension"}static create(e={}){const n=typeof e=="function"?e():e;return new OI(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}},DI=Ft.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new Lt({key:new Qt("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,s=kI(n),{blockSeparator:o}=this.options,l={...o!==void 0?{blockSeparator:o}:{},textSerializers:s};return[...i.ranges].sort((f,h)=>f.$from.pos-h.$from.pos).map(({$from:f,$to:h})=>SI(r,{from:f.pos,to:h.pos},l)).join(o??`
|
|
94
|
+
|
|
95
|
+
`)}}})]}}),II=Ft.create({name:"commands",addCommands(){return{...oi}}}),jI=Ft.create({name:"delete",onUpdate({transaction:t,appendedTransactions:e}){var n,r,i;const s=()=>{var o,l,u,f;if((f=(u=(l=(o=this.editor.options.coreExtensionOptions)==null?void 0:o.delete)==null?void 0:l.filterTransaction)==null?void 0:u.call(l,t))!=null?f:t.getMeta("y-sync$"))return;const h=gI(t.before,[t,...e]);oS(h).forEach(b=>{h.mapping.mapResult(b.oldRange.from).deletedAfter&&h.mapping.mapResult(b.oldRange.to).deletedBefore&&h.before.nodesBetween(b.oldRange.from,b.oldRange.to,(x,S)=>{const k=S+x.nodeSize-2,C=b.oldRange.from<=S&&k<=b.oldRange.to;this.editor.emit("delete",{type:"node",node:x,from:S,to:k,newFrom:h.mapping.map(S),newTo:h.mapping.map(k),deletedRange:b.oldRange,newRange:b.newRange,partial:!C,editor:this.editor,transaction:t,combinedTransform:h})})});const g=h.mapping;h.steps.forEach((b,x)=>{var S,k;if(b instanceof pi){const C=g.slice(x).map(b.from,-1),A=g.slice(x).map(b.to),R=g.invert().map(C,-1),_=g.invert().map(A),M=C>0?(S=h.doc.nodeAt(C-1))==null?void 0:S.marks.some(D=>D.eq(b.mark)):!1,O=(k=h.doc.nodeAt(A))==null?void 0:k.marks.some(D=>D.eq(b.mark));this.editor.emit("delete",{type:"mark",mark:b.mark,from:b.from,to:b.to,deletedRange:{from:R,to:_},newRange:{from:C,to:A},partial:!!(O||M),editor:this.editor,transaction:t,combinedTransform:h})}})};(i=(r=(n=this.editor.options.coreExtensionOptions)==null?void 0:n.delete)==null?void 0:r.async)==null||i?setTimeout(s,0):s()}}),LI=Ft.create({name:"drop",addProseMirrorPlugins(){return[new Lt({key:new Qt("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),PI=Ft.create({name:"editable",addProseMirrorPlugins(){return[new Lt({key:new Qt("editable"),props:{editable:()=>this.editor.options.editable}})]}}),zI=new Qt("focusEvents"),$I=Ft.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Lt({key:zI,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}}}})]}}),BI=Ft.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:o})=>[()=>o.undoInputRule(),()=>o.command(({tr:l})=>{const{selection:u,doc:f}=l,{empty:h,$anchor:m}=u,{pos:g,parent:b}=m,x=m.parent.isTextblock&&g>0?l.doc.resolve(g-1):m,S=x.parent.type.spec.isolating,k=m.pos-m.parentOffset,C=S&&x.parent.childCount===1?k===m.pos:Ke.atStart(f).from===g;return!h||!b.type.isTextblock||b.textContent.length||!C||C&&m.parent.type.name==="paragraph"?!1:o.clearNodes()}),()=>o.deleteSelection(),()=>o.joinBackward(),()=>o.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:o})=>[()=>o.deleteSelection(),()=>o.deleteCurrentNode(),()=>o.joinForward(),()=>o.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:o})=>[()=>o.newlineInCode(),()=>o.createParagraphNear(),()=>o.liftEmptyBlock(),()=>o.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()},i={...r},s={...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 Xp()||pI()?s:i},addProseMirrorPlugins(){return[new Lt({key:new Qt("clearDocument"),appendTransaction:(t,e,n)=>{if(t.some(S=>S.getMeta("composition")))return;const r=t.some(S=>S.docChanged)&&!e.doc.eq(n.doc),i=t.some(S=>S.getMeta("preventClearDocument"));if(!r||i)return;const{empty:s,from:o,to:l}=e.selection,u=Ke.atStart(e.doc).from,f=Ke.atEnd(e.doc).to;if(s||!(o===u&&l===f)||!sf(n.doc))return;const g=n.tr,b=rg({state:n,transaction:g}),{commands:x}=new ig({editor:this.editor,state:b});if(x.clearNodes(),!!g.steps.length)return g}})]}}),VI=Ft.create({name:"paste",addProseMirrorPlugins(){return[new Lt({key:new Qt("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),HI=Ft.create({name:"tabindex",addOptions(){return{value:void 0}},addProseMirrorPlugins(){return[new Lt({key:new Qt("tabindex"),props:{attributes:()=>{var t;return!this.editor.isEditable&&this.options.value===void 0?{}:{tabindex:(t=this.options.value)!=null?t:"0"}}}})]}}),UI=Ft.create({name:"textDirection",addOptions(){return{direction:void 0}},addGlobalAttributes(){if(!this.options.direction)return[];const{nodeExtensions:t}=kc(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 Lt({key:new Qt("textDirection"),props:{attributes:()=>{const t=this.options.direction;return t?{dir:t}:{}}}})]}}),W9=class Xu{constructor(e,n,r=!1,i=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=n,this.currentNode=i}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 Xu(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 Xu(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 Xu(e,this.editor)}get children(){const e=[];return this.node.content.forEach((n,r)=>{const i=n.isBlock&&!n.isTextblock,s=n.isAtom&&!n.isText,o=n.isInline,l=this.pos+r+(s?0:1);if(l<0||l>this.resolvedPos.doc.nodeSize-2)return;const u=this.resolvedPos.doc.resolve(l);if(!i&&!o&&u.depth<=this.depth)return;const f=new Xu(u,this.editor,i,i||o?n:null);i&&(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,i=this.parent;for(;i&&!r;){if(i.node.type.name===e)if(Object.keys(n).length>0){const s=i.node.attrs,o=Object.keys(n);for(let l=0;l<o.length;l+=1){const u=o[l];if(s[u]!==n[u])break}}else r=i;i=i.parent}return r}querySelector(e,n={}){return this.querySelectorAll(e,n,!0)[0]||null}querySelectorAll(e,n={},r=!1){let i=[];if(!this.children||this.children.length===0)return i;const s=Object.keys(n);return this.children.forEach(o=>{r&&i.length>0||(o.node.type.name===e&&s.every(u=>n[u]===o.node.attrs[u])&&i.push(o),!(r&&i.length>0)&&(i=i.concat(o.querySelectorAll(e,n,r))))}),i}setAttribute(e){const{tr:n}=this.editor.state;n.setNodeMarkup(this.from,void 0,{...this.node.attrs,...e}),this.editor.view.dispatch(n)}},K9=`.ProseMirror {
|
|
96
|
+
position: relative;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.ProseMirror {
|
|
100
|
+
word-wrap: break-word;
|
|
101
|
+
white-space: pre-wrap;
|
|
102
|
+
white-space: break-spaces;
|
|
103
|
+
-webkit-font-variant-ligatures: none;
|
|
104
|
+
font-variant-ligatures: none;
|
|
105
|
+
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.ProseMirror [contenteditable="false"] {
|
|
109
|
+
white-space: normal;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.ProseMirror [contenteditable="false"] [contenteditable="true"] {
|
|
113
|
+
white-space: pre-wrap;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.ProseMirror pre {
|
|
117
|
+
white-space: pre-wrap;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
img.ProseMirror-separator {
|
|
121
|
+
display: inline !important;
|
|
122
|
+
border: none !important;
|
|
123
|
+
margin: 0 !important;
|
|
124
|
+
width: 0 !important;
|
|
125
|
+
height: 0 !important;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.ProseMirror-gapcursor {
|
|
129
|
+
display: none;
|
|
130
|
+
pointer-events: none;
|
|
131
|
+
position: absolute;
|
|
132
|
+
margin: 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.ProseMirror-gapcursor:after {
|
|
136
|
+
content: "";
|
|
137
|
+
display: block;
|
|
138
|
+
position: absolute;
|
|
139
|
+
top: -2px;
|
|
140
|
+
width: 20px;
|
|
141
|
+
border-top: 1px solid black;
|
|
142
|
+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@keyframes ProseMirror-cursor-blink {
|
|
146
|
+
to {
|
|
147
|
+
visibility: hidden;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.ProseMirror-hideselection *::selection {
|
|
152
|
+
background: transparent;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.ProseMirror-hideselection *::-moz-selection {
|
|
156
|
+
background: transparent;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.ProseMirror-hideselection * {
|
|
160
|
+
caret-color: transparent;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.ProseMirror-focused .ProseMirror-gapcursor {
|
|
164
|
+
display: block;
|
|
165
|
+
}`,Z9=class extends T9{constructor(t={}){super(),this.css=null,this.className="tiptap",this.editorView=null,this.isFocused=!1,this.destroyed=!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:n})=>{throw n},onPaste:()=>null,onDrop:()=>null,onDelete:()=>null,enableExtensionDispatchTransaction:!0},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.utils={getUpdatedPosition:n9,createMappablePosition:r9},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:n,slice:r,moved:i})=>this.options.onDrop(n,r,i)),this.on("paste",({event:n,slice:r})=>this.options.onPaste(n,r)),this.on("delete",this.options.onDelete);const e=this.createDoc();if(!this.editorState){const n=ux(e,this.options.autofocus);this.editorState=Sa.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?.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=A9(K9,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=bI(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(i=>{const s=typeof i=="string"?`${i}$`:i.key;n=n.filter(o=>!o.key.startsWith(s))}),e.length===n.length)return;const r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}createExtensionManager(){var t,e,n,r;const s=[...this.options.enableCoreExtensions?[PI,DI.configure({blockSeparator:(e=(t=this.options.coreExtensionOptions)==null?void 0:t.clipboardTextSerializer)==null?void 0:e.blockSeparator}),II,$I,BI,HI.configure({value:(r=(n=this.options.coreExtensionOptions)==null?void 0:n.tabindex)==null?void 0:r.value}),LI,VI,jI,UI.configure({direction:this.options.textDirection})].filter(o=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[o.name]!==!1:!0):[],...this.options.extensions].filter(o=>["extension","node","mark"].includes(o?.type));this.extensionManager=new lg(s,this)}createCommandManager(){this.commandManager=new ig({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createDoc(){let t;try{t=dx(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;const n=dx(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1});return this.editorState=Sa.create({doc:n,schema:this.schema,selection:ux(n,this.options.autofocus)||void 0}),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(r=>r.name!=="collaboration"),this.createExtensionManager()}}),this.editorState.doc}return t}createView(t){const{editorProps:e,enableExtensionDispatchTransaction:n}=this.options,r=e.dispatchTransaction||this.dispatchTransaction.bind(this),i=n?this.extensionManager.dispatchTransaction(r):r,s=e.transformPastedHTML,o=this.extensionManager.transformPastedHTML(s);this.editorView=new lI(t,{...e,attributes:{role:"textbox",...e?.attributes},dispatchTransaction:i,transformPastedHTML:o,state:this.editorState,markViews:this.extensionManager.markViews,nodeViews:this.extensionManager.nodeViews});const l=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(l),this.prependClass(),this.injectCSS();const u=this.view.dom;u.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 h;return(h=this.capturedTransaction)==null?void 0:h.step(f)});return}const{state:e,transactions:n}=this.state.applyTransaction(t),r=!this.state.selection.eq(e.selection),i=n.includes(t),s=this.state;if(this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),!i)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 o=n.findLast(f=>f.getMeta("focus")||f.getMeta("blur")),l=o?.getMeta("focus"),u=o?.getMeta("blur");l&&this.emit("focus",{editor:this,event:l.event,transaction:o}),u&&this.emit("blur",{editor:this,event:u.event,transaction:o}),!(t.getMeta("preventUpdate")||!n.some(f=>f.docChanged)||s.doc.eq(e.doc))&&this.emit("update",{editor:this,transaction:t,appendedTransactions:n.slice(1)})}getAttributes(t){return CI(this.state,t)}isActive(t,e){const n=typeof t=="string"?t:null,r=typeof t=="string"?e:t;return Qq(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return iS(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e=`
|
|
166
|
+
|
|
167
|
+
`,textSerializers:n={}}=t||{};return Wq(this.state.doc,{blockSeparator:e,textSerializers:{...kI(this.schema),...n}})}get isEmpty(){return sf(this.state.doc)}destroy(){this.destroyed||(this.destroyed=!0,this.emit("destroy"),this.unmount(),this.removeAllListeners(),this.extensionManager.destroy(),this.extensionManager=null,this.schema=null,this.commandManager=null,this.extensionStorage={})}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),n=t>0&&e.nodeAfter&&!e.nodeAfter.isText&&e.nodeAfter.isAtom?e.nodeAfter:null;return new W9(e,this,!1,n)}get $doc(){return this.$pos(0)}};function Va(t){return new of({find:t.find,handler:({state:e,range:n,match:r})=>{const i=mt(t.getAttributes,void 0,r);if(i===!1||i===null)return null;const{tr:s}=e,o=r[r.length-1],l=r[0];if(o){const u=l.search(/\S/),f=n.from+l.indexOf(o),h=f+o.length;if(aS(n.from,n.to,e.doc).filter(b=>b.mark.type.excluded.find(S=>S===t.type&&S!==b.mark.type)).filter(b=>b.to>f).length)return null;h<n.to&&s.delete(h,n.to),f>n.from&&s.delete(n.from+u,f);const g=n.from+u+o.length;s.addMark(n.from+u,g,t.type.create(i||{})),s.removeStoredMark(t.type)}},undoable:t.undoable})}function FI(t){return new of({find:t.find,handler:({state:e,range:n,match:r})=>{const i=mt(t.getAttributes,void 0,r)||{},{tr:s}=e,o=n.from;let l=n.to;const u=t.type.create(i);if(r[1]){const f=r[0].lastIndexOf(r[1]);let h=o+f;h>l?h=l:l=h+r[1].length;const m=r[0][r[0].length-1];s.insertText(m,o+r[0].length-1),s.replaceWith(h,l,u)}else if(r[0]){const f=t.type.isInline?o:o-1;s.insert(f,t.type.create(i)).delete(s.mapping.map(o),s.mapping.map(l))}s.scrollIntoView()},undoable:t.undoable})}function px(t){return new of({find:t.find,handler:({state:e,range:n,match:r})=>{const i=e.doc.resolve(n.from),s=mt(t.getAttributes,void 0,r)||{};if(!i.node(-1).canReplaceWith(i.index(-1),i.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,s)},undoable:t.undoable})}function Tc(t){return new of({find:t.find,handler:({state:e,range:n,match:r,chain:i})=>{const s=mt(t.getAttributes,void 0,r)||{},o=e.tr.delete(n.from,n.to),u=o.doc.resolve(n.from).blockRange(),f=u&&zw(u,t.type,s);if(!f)return null;if(o.wrap(u,f),t.keepMarks&&t.editor){const{selection:m,storedMarks:g}=e,{splittableMarks:b}=t.editor.extensionManager,x=g||m.$to.parentOffset&&m.$from.marks();if(x){const S=x.filter(k=>b.includes(k.type.name));o.ensureMarks(S)}}if(t.keepAttributes){const m=t.type.name==="bulletList"||t.type.name==="orderedList"?"listItem":"taskList";i().updateAttributes(m,s).run()}const h=o.doc.resolve(n.from-1).nodeBefore;h&&h.type===t.type&&Ko(o.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,h))&&o.join(n.from-1)},undoable:t.undoable})}var Y9=t=>"touches"in t,X9=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=l=>{if(!this.isResizing||!this.activeHandle)return;const u=l.clientX-this.startX,f=l.clientY-this.startY;this.handleResize(u,f)},this.handleTouchMove=l=>{if(!this.isResizing||!this.activeHandle)return;const u=l.touches[0];if(!u)return;const f=u.clientX-this.startX,h=u.clientY-this.startY;this.handleResize(f,h)},this.handleMouseUp=()=>{if(!this.isResizing)return;const l=this.element.offsetWidth,u=this.element.offsetHeight;this.onCommit(l,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=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!0)},this.handleKeyUp=l=>{l.key==="Shift"&&(this.isShiftKeyPressed=!1)};var e,n,r,i,s,o;this.node=t.node,this.editor=t.editor,this.element=t.element,this.element.draggable=!1,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?.options)!=null&&r.directions&&(this.directions=t.options.directions),(i=t.options)!=null&&i.preserveAspectRatio&&(this.preserveAspectRatio=t.options.preserveAspectRatio),(s=t.options)!=null&&s.className&&(this.classNames={container:t.options.className.container||"",wrapper:t.options.className.wrapper||"",handle:t.options.className.handle||"",resizing:t.options.className.resizing||""}),(o=t.options)!=null&&o.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=this.node.type.isInline?"inline-flex":"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"),i=e.includes("left"),s=e.includes("right");n&&(t.style.top="0"),r&&(t.style.bottom="0"),i&&(t.style.left="0"),s&&(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,Y9(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:i}=this.calculateNewDimensions(this.activeHandle,t,e),s=this.applyConstraints(r,i,n);this.element.style.width=`${s.width}px`,this.element.style.height=`${s.height}px`,this.onResize&&this.onResize(s.width,s.height)}calculateNewDimensions(t,e,n){let r=this.startWidth,i=this.startHeight;const s=t.includes("right"),o=t.includes("left"),l=t.includes("bottom"),u=t.includes("top");return s?r=this.startWidth+e:o&&(r=this.startWidth-e),l?i=this.startHeight+n:u&&(i=this.startHeight-n),(t==="right"||t==="left")&&(r=this.startWidth+(s?e:-e)),(t==="top"||t==="bottom")&&(i=this.startHeight+(l?n:-n)),this.preserveAspectRatio||this.isShiftKeyPressed?this.applyAspectRatio(r,i,t):{width:r,height:i}}applyConstraints(t,e,n){var r,i,s,o;if(!n){let f=Math.max(this.minSize.width,t),h=Math.max(this.minSize.height,e);return(r=this.maxSize)!=null&&r.width&&(f=Math.min(this.maxSize.width,f)),(i=this.maxSize)!=null&&i.height&&(h=Math.min(this.maxSize.height,h)),{width:f,height:h}}let l=t,u=e;return l<this.minSize.width&&(l=this.minSize.width,u=l/this.aspectRatio),u<this.minSize.height&&(u=this.minSize.height,l=u*this.aspectRatio),(s=this.maxSize)!=null&&s.width&&l>this.maxSize.width&&(l=this.maxSize.width,u=l/this.aspectRatio),(o=this.maxSize)!=null&&o.height&&u>this.maxSize.height&&(u=this.maxSize.height,l=u*this.aspectRatio),{width:l,height:u}}applyAspectRatio(t,e,n){const r=n==="left"||n==="right",i=n==="top"||n==="bottom";return r?{width:t,height:t/this.aspectRatio}:i?{width:e*this.aspectRatio,height:e}:{width:t,height:t/this.aspectRatio}}},Tn=class qI extends dS{constructor(){super(...arguments),this.type="node"}static create(e={}){const n=typeof e=="function"?e():e;return new qI(n)}configure(e){return super.configure(e)}extend(e){const n=typeof e=="function"?e():e;return super.extend(n)}};function Ho(t){return new NI({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:i})=>{const s=mt(t.getAttributes,void 0,r,i);if(s===!1||s===null)return null;const{tr:o}=e,l=r[r.length-1],u=r[0];let f=n.to;if(l){const h=u.search(/\S/),m=n.from+u.indexOf(l),g=m+l.length;if(aS(n.from,n.to,e.doc).filter(S=>S.mark.type.excluded.find(C=>C===t.type&&C!==S.mark.type)).filter(S=>S.to>m).length)return null;g<n.to&&o.delete(g,n.to),m>n.from&&o.delete(n.from+h,m),f=n.from+h+l.length,o.addMark(n.from+h,f,t.type.create(s||{})),r.index!==void 0&&r.input!==void 0&&r.index+r[0].length>=r.input.length||o.removeStoredMark(t.type)}}})}const{getOwnPropertyNames:J9,getOwnPropertySymbols:Q9}=Object,{hasOwnProperty:eG}=Object.prototype;function Dv(t,e){return function(r,i,s){return t(r,i,s)&&e(r,i,s)}}function Oh(t){return function(n,r,i){if(!n||!r||typeof n!="object"||typeof r!="object")return t(n,r,i);const{cache:s}=i,o=s.get(n),l=s.get(r);if(o&&l)return o===r&&l===n;s.set(n,r),s.set(r,n);const u=t(n,r,i);return s.delete(n),s.delete(r),u}}function tG(t){return t?.[Symbol.toStringTag]}function ZA(t){return J9(t).concat(Q9(t))}const nG=Object.hasOwn||((t,e)=>eG.call(t,e));function Qa(t,e){return t===e||!t&&!e&&t!==t&&e!==e}const rG="__v",iG="__o",sG="_owner",{getOwnPropertyDescriptor:YA,keys:XA}=Object;function oG(t,e){return t.byteLength===e.byteLength&&Jp(new Uint8Array(t),new Uint8Array(e))}function aG(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 lG(t,e){return t.byteLength===e.byteLength&&Jp(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}function cG(t,e){return Qa(t.getTime(),e.getTime())}function uG(t,e){return t.name===e.name&&t.message===e.message&&t.cause===e.cause&&t.stack===e.stack}function dG(t,e){return t===e}function JA(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.entries();let o,l,u=0;for(;(o=s.next())&&!o.done;){const f=e.entries();let h=!1,m=0;for(;(l=f.next())&&!l.done;){if(i[m]){m++;continue}const g=o.value,b=l.value;if(n.equals(g[0],b[0],u,m,t,e,n)&&n.equals(g[1],b[1],g[0],b[0],t,e,n)){h=i[m]=!0;break}m++}if(!h)return!1;u++}return!0}const fG=Qa;function hG(t,e,n){const r=XA(t);let i=r.length;if(XA(e).length!==i)return!1;for(;i-- >0;)if(!GI(t,e,n,r[i]))return!1;return!0}function $u(t,e,n){const r=ZA(t);let i=r.length;if(ZA(e).length!==i)return!1;let s,o,l;for(;i-- >0;)if(s=r[i],!GI(t,e,n,s)||(o=YA(t,s),l=YA(e,s),(o||l)&&(!o||!l||o.configurable!==l.configurable||o.enumerable!==l.enumerable||o.writable!==l.writable)))return!1;return!0}function pG(t,e){return Qa(t.valueOf(),e.valueOf())}function mG(t,e){return t.source===e.source&&t.flags===e.flags}function QA(t,e,n){const r=t.size;if(r!==e.size)return!1;if(!r)return!0;const i=new Array(r),s=t.values();let o,l;for(;(o=s.next())&&!o.done;){const u=e.values();let f=!1,h=0;for(;(l=u.next())&&!l.done;){if(!i[h]&&n.equals(o.value,l.value,o.value,l.value,t,e,n)){f=i[h]=!0;break}h++}if(!f)return!1}return!0}function Jp(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 gG(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 GI(t,e,n,r){return(r===sG||r===iG||r===rG)&&(t.$$typeof||e.$$typeof)?!0:nG(e,r)&&n.equals(t[r],e[r],r,r,t,e,n)}const yG="[object ArrayBuffer]",bG="[object Arguments]",vG="[object Boolean]",xG="[object DataView]",wG="[object Date]",SG="[object Error]",kG="[object Map]",CG="[object Number]",EG="[object Object]",TG="[object RegExp]",_G="[object Set]",AG="[object String]",RG={"[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},MG="[object URL]",NG=Object.prototype.toString;function OG({areArrayBuffersEqual:t,areArraysEqual:e,areDataViewsEqual:n,areDatesEqual:r,areErrorsEqual:i,areFunctionsEqual:s,areMapsEqual:o,areNumbersEqual:l,areObjectsEqual:u,arePrimitiveWrappersEqual:f,areRegExpsEqual:h,areSetsEqual:m,areTypedArraysEqual:g,areUrlsEqual:b,unknownTagComparators:x}){return function(k,C,A){if(k===C)return!0;if(k==null||C==null)return!1;const R=typeof k;if(R!==typeof C)return!1;if(R!=="object")return R==="number"?l(k,C,A):R==="function"?s(k,C,A):!1;const _=k.constructor;if(_!==C.constructor)return!1;if(_===Object)return u(k,C,A);if(Array.isArray(k))return e(k,C,A);if(_===Date)return r(k,C,A);if(_===RegExp)return h(k,C,A);if(_===Map)return o(k,C,A);if(_===Set)return m(k,C,A);const M=NG.call(k);if(M===wG)return r(k,C,A);if(M===TG)return h(k,C,A);if(M===kG)return o(k,C,A);if(M===_G)return m(k,C,A);if(M===EG)return typeof k.then!="function"&&typeof C.then!="function"&&u(k,C,A);if(M===MG)return b(k,C,A);if(M===SG)return i(k,C,A);if(M===bG)return u(k,C,A);if(RG[M])return g(k,C,A);if(M===yG)return t(k,C,A);if(M===xG)return n(k,C,A);if(M===vG||M===CG||M===AG)return f(k,C,A);if(x){let O=x[M];if(!O){const D=tG(k);D&&(O=x[D])}if(O)return O(k,C,A)}return!1}}function DG({circular:t,createCustomConfig:e,strict:n}){let r={areArrayBuffersEqual:oG,areArraysEqual:n?$u:aG,areDataViewsEqual:lG,areDatesEqual:cG,areErrorsEqual:uG,areFunctionsEqual:dG,areMapsEqual:n?Dv(JA,$u):JA,areNumbersEqual:fG,areObjectsEqual:n?$u:hG,arePrimitiveWrappersEqual:pG,areRegExpsEqual:mG,areSetsEqual:n?Dv(QA,$u):QA,areTypedArraysEqual:n?Dv(Jp,$u):Jp,areUrlsEqual:gG,unknownTagComparators:void 0};if(e&&(r=Object.assign({},r,e(r))),t){const i=Oh(r.areArraysEqual),s=Oh(r.areMapsEqual),o=Oh(r.areObjectsEqual),l=Oh(r.areSetsEqual);r=Object.assign({},r,{areArraysEqual:i,areMapsEqual:s,areObjectsEqual:o,areSetsEqual:l})}return r}function IG(t){return function(e,n,r,i,s,o,l){return t(e,n,l)}}function jG({circular:t,comparator:e,createState:n,equals:r,strict:i}){if(n)return function(l,u){const{cache:f=t?new WeakMap:void 0,meta:h}=n();return e(l,u,{cache:f,equals:r,meta:h,strict:i})};if(t)return function(l,u){return e(l,u,{cache:new WeakMap,equals:r,meta:void 0,strict:i})};const s={cache:void 0,equals:r,meta:void 0,strict:i};return function(l,u){return e(l,u,s)}}const LG=Yo();Yo({strict:!0});Yo({circular:!0});Yo({circular:!0,strict:!0});Yo({createInternalComparator:()=>Qa});Yo({strict:!0,createInternalComparator:()=>Qa});Yo({circular:!0,createInternalComparator:()=>Qa});Yo({circular:!0,createInternalComparator:()=>Qa,strict:!0});function Yo(t={}){const{circular:e=!1,createInternalComparator:n,createState:r,strict:i=!1}=t,s=DG(t),o=OG(s),l=n?n(o):IG(o);return jG({circular:e,comparator:o,createState:r,equals:l,strict:i})}var Iv={exports:{}},jv={};var eR;function PG(){if(eR)return jv;eR=1;var t=Vd(),e=RO();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=e.useSyncExternalStore,s=t.useRef,o=t.useEffect,l=t.useMemo,u=t.useDebugValue;return jv.useSyncExternalStoreWithSelector=function(f,h,m,g,b){var x=s(null);if(x.current===null){var S={hasValue:!1,value:null};x.current=S}else S=x.current;x=l(function(){function C(O){if(!A){if(A=!0,R=O,O=g(O),b!==void 0&&S.hasValue){var D=S.value;if(b(D,O))return _=D}return _=O}if(D=_,r(R,O))return D;var I=g(O);return b!==void 0&&b(D,I)?(R=O,D):(R=O,_=I)}var A=!1,R,_,M=m===void 0?null:m;return[function(){return C(h())},M===null?void 0:function(){return C(M())}]},[h,m,g,b]);var k=i(f,x[0],x[1]);return o(function(){S.hasValue=!0,S.value=k},[k]),u(k),k},jv}var tR;function zG(){return tR||(tR=1,Iv.exports=PG()),Iv.exports}var $G=zG(),BG=(...t)=>e=>{t.forEach(n=>{typeof n=="function"?n(e):n&&(n.current=e)})},VG=({contentComponent:t})=>{const e=MO.useSyncExternalStore(t.subscribe,t.getSnapshot,t.getServerSnapshot);return y.jsx(y.Fragment,{children:Object.values(e)})};function HG(){const t=new Set;let e={},n=!1;const r=()=>{n||!t.size||(n=!0,queueMicrotask(()=>{n=!1,t.forEach(i=>i())}))};return{subscribe(i){return t.add(i),()=>{t.delete(i)}},getSnapshot(){return e},getServerSnapshot(){return e},setRenderer(i,s){e={...e,[i]:iF.createPortal(s.reactElement,s.element,i)},r()},removeRenderer(i){const s={...e};delete s[i],e=s,r()}}}var UG=class extends qe.Component{constructor(t){super(t),this.editorContentRef=qe.createRef()}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=HG(),e.createNodeViews(),e.isEditorContentInitialized=!0,this.forceUpdate()}}componentWillUnmount(){var t;const e=this.props.editor;if(e){e.isEditorContentInitialized=!1,e.isDestroyed||e.view.setProps({nodeViews:{}}),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 y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:BG(e,this.editorContentRef),...n}),t?.contentComponent&&y.jsx(VG,{contentComponent:t.contentComponent})]})}},FG=E.forwardRef((t,e)=>{const n=qe.useMemo(()=>Math.floor(Math.random()*4294967295).toString(),[t.editor]);return qe.createElement(UG,{key:n,innerRef:e,...t})}),WI=qe.memo(FG),qG=typeof window<"u"?E.useLayoutEffect:E.useEffect,GG=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){let e;const n=i=>{i?.transaction!==void 0&&i.transaction===e||(e=i?.transaction,this.transactionNumber+=1,this.subscribers.forEach(s=>s()))},r=this.editor;return r.on("transaction",n),r.on("update",n),()=>{r.off("transaction",n),r.off("update",n)}}}};function KI(t){var e;const[n]=E.useState(()=>new GG(t.editor)),r=$G.useSyncExternalStoreWithSelector(n.subscribe,n.getSnapshot,n.getServerSnapshot,t.selector,(e=t.equalityFn)!=null?e:LG);return qG(()=>n.watch(t.editor),[t.editor,n]),E.useDebugValue(r),r}var WG=!1,ZI=typeof window>"u",KG=ZI||!!(typeof window<"u"&&window.next),ZG=class YI{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(){const e=this.options.current.immediatelyRender;let n=e??!0;return ZI?(n&&WG&&console.warn("SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches"),n=!1):KG&&e===void 0&&(n=!1),n?this.createEditor():null}createEditor(){const e={...this.options.current,onBeforeCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onBeforeCreate)==null?void 0:s.call(i,...r)},onBlur:(...r)=>{var i,s;return(s=(i=this.options.current).onBlur)==null?void 0:s.call(i,...r)},onCreate:(...r)=>{var i,s;return(s=(i=this.options.current).onCreate)==null?void 0:s.call(i,...r)},onDestroy:(...r)=>{var i,s;return(s=(i=this.options.current).onDestroy)==null?void 0:s.call(i,...r)},onFocus:(...r)=>{var i,s;return(s=(i=this.options.current).onFocus)==null?void 0:s.call(i,...r)},onSelectionUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onSelectionUpdate)==null?void 0:s.call(i,...r)},onTransaction:(...r)=>{var i,s;return(s=(i=this.options.current).onTransaction)==null?void 0:s.call(i,...r)},onUpdate:(...r)=>{var i,s;return(s=(i=this.options.current).onUpdate)==null?void 0:s.call(i,...r)},onContentError:(...r)=>{var i,s;return(s=(i=this.options.current).onContentError)==null?void 0:s.call(i,...r)},onDrop:(...r)=>{var i,s;return(s=(i=this.options.current).onDrop)==null?void 0:s.call(i,...r)},onPaste:(...r)=>{var i,s;return(s=(i=this.options.current).onPaste)==null?void 0:s.call(i,...r)},onDelete:(...r)=>{var i,s;return(s=(i=this.options.current).onDelete)==null?void 0:s.call(i,...r)},onMount:(...r)=>{var i,s;return(s=(i=this.options.current).onMount)==null?void 0:s.call(i,...r)},onUnmount:(...r)=>{var i,s;return(s=(i=this.options.current).onUnmount)==null?void 0:s.call(i,...r)}};return new Z9(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((i,s)=>{var o;return i===((o=n.extensions)==null?void 0:o[s])}):e[r]===n[r])}onRender(e){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&e.length===0?YI.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,i)=>r===e[i]))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 YG(t={},e=[]){const n=E.useRef(t);n.current=t;const[r]=E.useState(()=>new ZG(n)),i=MO.useSyncExternalStore(r.subscribe,r.getEditor,r.getServerSnapshot);return E.useDebugValue(i),E.useEffect(r.onRender(e)),KI({editor:i,selector:({transactionNumber:s})=>t.shouldRerenderOnTransaction===!1||t.shouldRerenderOnTransaction===void 0?null:t.immediatelyRender&&s===0?0:s+1}),i}var XI=E.createContext({editor:null});XI.Consumer;var XG=E.createContext({onDragStart:()=>{},nodeViewContentChildren:void 0,nodeViewContentRef:()=>{}}),JG=()=>E.useContext(XG);qe.forwardRef((t,e)=>{const{onDragStart:n}=JG(),r=t.as||"div";return y.jsx(r,{...t,ref:e,"data-node-view-wrapper":"",onDragStart:n,style:{whiteSpace:"normal",...t.style}})});qe.createContext({markViewContentRef:()=>{}});var fS=E.createContext({get editor(){throw new Error("useTiptap must be used within a <Tiptap> provider")}});fS.displayName="TiptapContext";var QG=()=>E.useContext(fS);function JI({children:t,...e}){const n="editor"in e?e.editor:e.instance;if(!n)throw new Error("Tiptap: An editor instance is required. Pass a non-null `editor` prop.");const r=E.useMemo(()=>({editor:n}),[n]),i=E.useMemo(()=>({editor:n}),[n]);return y.jsx(XI.Provider,{value:i,children:y.jsx(fS.Provider,{value:r,children:t})})}JI.displayName="Tiptap";function QI({...t}){const{editor:e}=QG();return y.jsx(WI,{editor:e,...t})}QI.displayName="Tiptap.Content";Object.assign(JI,{Content:QI});var Qp=(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]},e8=(t,e)=>{var n;const{state:r,view:i}=t,{selection:s}=r;if(!s.empty)return!1;const{$from:o}=s;if(o.parentOffset!==0)return!1;const l=o.depth-1;if(l<0)return!1;const u=o.node(l),f=o.index(l);if(f===0)return!1;if(u.type===e)return t.commands.lift(e.name);const h=u.child(f-1);if(h.type!==e||!((n=h.lastChild)!=null&&n.isTextblock))return!1;const m=o.before(),b=m-1-1,{tr:x}=r;return x.delete(m,o.after()).insert(b,o.parent.content),x.setSelection(ze.create(x.doc,b)),i.dispatch(x.scrollIntoView()),!0},t8=/^\s*>\s$/,n8=Tn.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:t}){return Qp("blockquote",{...jt(this.options.HTMLAttributes,t),children:Qp("slot",{})})},parseMarkdown:(t,e)=>{var n;const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;return e.createNode("blockquote",void 0,r(t.tokens||[]))},renderMarkdown:(t,e)=>{if(!t.content)return"";const n=">",r=[];return t.content.forEach((i,s)=>{var o,l;const h=((l=(o=e.renderChild)==null?void 0:o.call(e,i,s))!=null?l:e.renderChildren([i])).split(`
|
|
168
|
+
`).map(m=>m.trim()===""?n:`${n} ${m}`);r.push(h.join(`
|
|
169
|
+
`))}),r.join(`
|
|
170
|
+
${n}
|
|
171
|
+
`)},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(),Backspace:()=>e8(this.editor,this.type)}},addInputRules(){return[Tc({find:t8,type:this.type})]}}),r8=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,i8=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,s8=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,o8=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,a8=Ja.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 Qp("strong",{...jt(this.options.HTMLAttributes,t),children:Qp("slot",{})})},markdownTokenName:"strong",parseMarkdown:(t,e)=>e.applyMark("bold",e.parseInline(t.tokens||[])),markdownOptions:{htmlReopen:{open:"<strong>",close:"</strong>"}},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[Va({find:r8,type:this.type}),Va({find:s8,type:this.type})]},addPasteRules(){return[Ho({find:i8,type:this.type}),Ho({find:o8,type:this.type})]}}),l8=t=>{const e=/`([^`]+)`(?!`)$/.exec(t);return!e||e.index>0&&t[e.index-1]==="`"?null:{index:e.index,text:e[0],replaceWith:e[1]}},c8=t=>{const e=/`([^`]+)`(?!`)/g,n=[];let r;for(;(r=e.exec(t))!==null;)r.index>0&&t[r.index-1]==="`"||n.push({index:r.index,text:r[0],replaceWith:r[1]});return n},u8=Ja.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:t}){return["code",jt(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[Va({find:l8,type:this.type})]},addPasteRules(){return[Ho({find:c8,type:this.type})]}}),Lv=4,d8=/^```([a-z]+)?[\s\n]$/,f8=/^~~~([a-z]+)?[\s\n]$/,h8=Tn.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,exitOnArrowUp:!0,defaultLanguage:null,enableTabIndentation:!1,tabSize:Lv,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 s=[...((e=t.firstElementChild)==null?void 0:e.classList)||[]].filter(o=>o.startsWith(n)).map(o=>o.replace(n,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:t,HTMLAttributes:e}){return["pre",jt(this.options.HTMLAttributes,e),["code",{class:t.attrs.language?this.options.languageClassPrefix+t.attrs.language:null},0]]},markdownTokenName:"code",parseMarkdown:(t,e)=>{var n,r;return((n=t.raw)==null?void 0:n.startsWith("```"))===!1&&((r=t.raw)==null?void 0:r.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 i=((n=t.attrs)==null?void 0:n.language)||"";return t.content?r=[`\`\`\`${i}`,e.renderChildren(t.content),"```"].join(`
|
|
172
|
+
`):r=`\`\`\`${i}
|
|
173
|
+
|
|
174
|
+
\`\`\``,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:Lv,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;if(s.parent.type!==this.type)return!1;const l=" ".repeat(n);return o?t.commands.insertContent(l):t.commands.command(({tr:u})=>{const{from:f,to:h}=i,b=r.doc.textBetween(f,h,`
|
|
175
|
+
`,`
|
|
176
|
+
`).split(`
|
|
177
|
+
`).map(x=>l+x).join(`
|
|
178
|
+
`);return u.replaceWith(f,h,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:Lv,{state:r}=t,{selection:i}=r,{$from:s,empty:o}=i;return s.parent.type!==this.type?!1:o?t.commands.command(({tr:l})=>{var u;const{pos:f}=s,h=s.start(),m=s.end(),b=r.doc.textBetween(h,m,`
|
|
179
|
+
`,`
|
|
180
|
+
`).split(`
|
|
181
|
+
`);let x=0,S=0;const k=f-h;for(let O=0;O<b.length;O+=1){if(S+b[O].length>=k){x=O;break}S+=b[O].length+1}const A=((u=b[x].match(/^ */))==null?void 0:u[0])||"",R=Math.min(A.length,n);if(R===0)return!0;let _=h;for(let O=0;O<x;O+=1)_+=b[O].length+1;return l.delete(_,_+R),f-_<=R&&l.setSelection(ze.create(l.doc,_)),!0}):t.commands.command(({tr:l})=>{const{from:u,to:f}=i,g=r.doc.textBetween(u,f,`
|
|
182
|
+
`,`
|
|
183
|
+
`).split(`
|
|
184
|
+
`).map(b=>{var x;const S=((x=b.match(/^ */))==null?void 0:x[0])||"",k=Math.min(S.length,n);return b.slice(k)}).join(`
|
|
185
|
+
`);return l.replaceWith(u,f,r.schema.text(g)),!0})},Enter:({editor:t})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
|
186
|
+
|
|
187
|
+
`);return!s||!o?!1:t.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowUp:({editor:t})=>{if(!this.options.exitOnArrowUp)return!1;const{state:e}=t,{selection:n}=e,{$from:r,empty:i}=n;if(!i||r.parent.type!==this.type||r.parentOffset!==0)return!1;const s=r.before();return s>0?!1:t.commands.insertDefaultBlock({pos:s})},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:r}=e,{$from:i,empty:s}=n;if(!s||i.parent.type!==this.type||!(i.parentOffset===i.parent.nodeSize-2))return!1;const l=i.after();return l===void 0?!1:r.nodeAt(l)?t.commands.command(({tr:f})=>(f.setSelection(Ke.near(r.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[px({find:d8,type:this.type,getAttributes:t=>({language:t[1]})}),px({find:f8,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Lt({key:new Qt("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"),i=r?JSON.parse(r):void 0,s=i?.mode;if(!n||!s)return!1;const{tr:o,schema:l}=t.state,u=l.text(n.replace(/\r\n?/g,`
|
|
188
|
+
`));return o.replaceSelectionWith(this.type.create({language:s},u)),o.selection.$from.parent.type!==this.type&&o.setSelection(ze.near(o.doc.resolve(Math.max(0,o.selection.from-2)))),o.setMeta("paste",!0),t.dispatch(o),!0}}})]}}),p8=Tn.create({name:"doc",topNode:!0,content:"block+",renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
189
|
+
|
|
190
|
+
`):""}),m8=Tn.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",jt(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
191
|
+
`},renderMarkdown:()=>`
|
|
192
|
+
`,parseMarkdown:()=>({type:"hardBreak"}),addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:r})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:i,storedMarks:s}=n;if(i.$from.parent.type.spec.isolating)return!1;const{keepMarks:o}=this.options,{splittableMarks:l}=r.extensionManager,u=s||i.$to.parentOffset&&i.$from.marks();return e().insertContent({type:this.name}).command(({tr:f,dispatch:h})=>{if(h&&u&&o){const m=u.filter(g=>l.includes(g.type.name));f.ensureMarks(m)}return!0}).scrollIntoView().run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),g8=Tn.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]}`,jt(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,i="#".repeat(r);return t.content?`${i} ${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=>px({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}}),y8=Tn.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{},nextNodeType:"paragraph"}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",jt(this.options.HTMLAttributes,t)]},markdownTokenName:"hr",parseMarkdown:(t,e)=>e.createNode("horizontalRule"),renderMarkdown:()=>"---",addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{if(!_9(e,e.schema.nodes[this.name]))return!1;const{selection:n}=e,{$to:r}=n,i=t();return EI(n)?i.insertContentAt(r.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({state:s,tr:o,dispatch:l})=>{if(l){const{$to:u}=o.selection,f=u.end();if(u.nodeAfter)u.nodeAfter.isTextblock?o.setSelection(ze.create(o.doc,u.pos+1)):u.nodeAfter.isBlock?o.setSelection(He.create(o.doc,u.pos)):o.setSelection(ze.create(o.doc,u.pos));else{const h=s.schema.nodes[this.options.nextNodeType]||u.parent.type.contentMatch.defaultType,m=h?.create();m&&(o.insert(f,m),o.setSelection(ze.create(o.doc,f+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[FI({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),b8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,v8=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,x8=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,w8=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,S8=Ja.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",jt(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||[])),markdownOptions:{htmlReopen:{open:"<em>",close:"</em>"}},renderMarkdown:(t,e)=>`*${e.renderChildren(t)}*`,addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Va({find:b8,type:this.type}),Va({find:x8,type:this.type})]},addPasteRules(){return[Ho({find:v8,type:this.type}),Ho({find:w8,type:this.type})]}});const k8="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",C8="ελ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",mx="numeric",gx="ascii",yx="alpha",cd="asciinumeric",Ju="alphanumeric",bx="domain",ej="emoji",E8="scheme",T8="slashscheme",Pv="whitespace";function _8(t,e){return t in e||(e[t]=[]),e[t]}function Ta(t,e,n){e[mx]&&(e[cd]=!0,e[Ju]=!0),e[gx]&&(e[cd]=!0,e[yx]=!0),e[cd]&&(e[Ju]=!0),e[yx]&&(e[Ju]=!0),e[Ju]&&(e[bx]=!0),e[ej]&&(e[bx]=!0);for(const r in e){const i=_8(r,n);i.indexOf(t)<0&&i.push(t)}}function A8(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}function pr(t=null){this.j={},this.jr=[],this.jd=null,this.t=t}pr.groups={};pr.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 i=e.jr[r][0],s=e.jr[r][1];if(s&&i.test(t))return s}return e.jd},has(t,e=!1){return e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let i=0;i<t.length;i++)this.tt(t[i],e,n,r)},tr(t,e,n,r){r=r||pr.groups;let i;return e&&e.j?i=e:(i=new pr(e),n&&r&&Ta(e,n,r)),this.jr.push([t,i]),i},ts(t,e,n,r){let i=this;const s=t.length;if(!s)return i;for(let o=0;o<s-1;o++)i=i.tt(t[o]);return i.tt(t[s-1],e,n,r)},tt(t,e,n,r){r=r||pr.groups;const i=this;if(e&&e.j)return i.j[t]=e,e;const s=e;let o,l=i.go(t);if(l?(o=new pr,Object.assign(o.j,l.j),o.jr.push.apply(o.jr,l.jr),o.jd=l.jd,o.t=l.t):o=new pr,s){if(r)if(o.t&&typeof o.t=="string"){const u=Object.assign(A8(o.t,r),n);Ta(s,u,r)}else n&&Ta(s,n,r);o.t=s}return i.j[t]=o,o}};const rt=(t,e,n,r,i)=>t.ta(e,n,r,i),Yt=(t,e,n,r,i)=>t.tr(e,n,r,i),nR=(t,e,n,r,i)=>t.ts(e,n,r,i),ye=(t,e,n,r,i)=>t.tt(e,n,r,i),ds="WORD",vx="UWORD",tj="ASCIINUMERICAL",nj="ALPHANUMERICAL",Ld="LOCALHOST",xx="TLD",wx="UTLD",pp="SCHEME",ec="SLASH_SCHEME",hS="NUM",Sx="WS",pS="NL",ud="OPENBRACE",dd="CLOSEBRACE",em="OPENBRACKET",tm="CLOSEBRACKET",nm="OPENPAREN",rm="CLOSEPAREN",im="OPENANGLEBRACKET",sm="CLOSEANGLEBRACKET",om="FULLWIDTHLEFTPAREN",am="FULLWIDTHRIGHTPAREN",lm="LEFTCORNERBRACKET",cm="RIGHTCORNERBRACKET",um="LEFTWHITECORNERBRACKET",dm="RIGHTWHITECORNERBRACKET",fm="FULLWIDTHLESSTHAN",hm="FULLWIDTHGREATERTHAN",pm="AMPERSAND",mm="APOSTROPHE",gm="ASTERISK",mo="AT",ym="BACKSLASH",bm="BACKTICK",vm="CARET",_a="COLON",mS="COMMA",xm="DOLLAR",Ai="DOT",wm="EQUALS",gS="EXCLAMATION",Gr="HYPHEN",fd="PERCENT",Sm="PIPE",km="PLUS",Cm="POUND",hd="QUERY",yS="QUOTE",rj="FULLWIDTHMIDDLEDOT",bS="SEMI",Ri="SLASH",pd="TILDE",Em="UNDERSCORE",ij="EMOJI",Tm="SYM";var sj=Object.freeze({__proto__:null,ALPHANUMERICAL:nj,AMPERSAND:pm,APOSTROPHE:mm,ASCIINUMERICAL:tj,ASTERISK:gm,AT:mo,BACKSLASH:ym,BACKTICK:bm,CARET:vm,CLOSEANGLEBRACKET:sm,CLOSEBRACE:dd,CLOSEBRACKET:tm,CLOSEPAREN:rm,COLON:_a,COMMA:mS,DOLLAR:xm,DOT:Ai,EMOJI:ij,EQUALS:wm,EXCLAMATION:gS,FULLWIDTHGREATERTHAN:hm,FULLWIDTHLEFTPAREN:om,FULLWIDTHLESSTHAN:fm,FULLWIDTHMIDDLEDOT:rj,FULLWIDTHRIGHTPAREN:am,HYPHEN:Gr,LEFTCORNERBRACKET:lm,LEFTWHITECORNERBRACKET:um,LOCALHOST:Ld,NL:pS,NUM:hS,OPENANGLEBRACKET:im,OPENBRACE:ud,OPENBRACKET:em,OPENPAREN:nm,PERCENT:fd,PIPE:Sm,PLUS:km,POUND:Cm,QUERY:hd,QUOTE:yS,RIGHTCORNERBRACKET:cm,RIGHTWHITECORNERBRACKET:dm,SCHEME:pp,SEMI:bS,SLASH:Ri,SLASH_SCHEME:ec,SYM:Tm,TILDE:pd,TLD:xx,UNDERSCORE:Em,UTLD:wx,UWORD:vx,WORD:ds,WS:Sx});const ls=/[a-z]/,Bu=new RegExp("\\p{L}","u"),zv=new RegExp("\\p{Emoji}","u"),cs=/\d/,$v=/\s/,rR="\r",Bv=`
|
|
193
|
+
`,R8="️",M8="",Vv="";let Dh=null,Ih=null;function N8(t=[]){const e={};pr.groups=e;const n=new pr;Dh==null&&(Dh=iR(k8)),Ih==null&&(Ih=iR(C8)),ye(n,"'",mm),ye(n,"{",ud),ye(n,"}",dd),ye(n,"[",em),ye(n,"]",tm),ye(n,"(",nm),ye(n,")",rm),ye(n,"<",im),ye(n,">",sm),ye(n,"(",om),ye(n,")",am),ye(n,"「",lm),ye(n,"」",cm),ye(n,"『",um),ye(n,"』",dm),ye(n,"<",fm),ye(n,">",hm),ye(n,"&",pm),ye(n,"*",gm),ye(n,"@",mo),ye(n,"`",bm),ye(n,"^",vm),ye(n,":",_a),ye(n,",",mS),ye(n,"$",xm),ye(n,".",Ai),ye(n,"=",wm),ye(n,"!",gS),ye(n,"-",Gr),ye(n,"%",fd),ye(n,"|",Sm),ye(n,"+",km),ye(n,"#",Cm),ye(n,"?",hd),ye(n,'"',yS),ye(n,"/",Ri),ye(n,";",bS),ye(n,"~",pd),ye(n,"_",Em),ye(n,"\\",ym),ye(n,"・",rj);const r=Yt(n,cs,hS,{[mx]:!0});Yt(r,cs,r);const i=Yt(r,ls,tj,{[cd]:!0}),s=Yt(r,Bu,nj,{[Ju]:!0}),o=Yt(n,ls,ds,{[gx]:!0});Yt(o,cs,i),Yt(o,ls,o),Yt(i,cs,i),Yt(i,ls,i);const l=Yt(n,Bu,vx,{[yx]:!0});Yt(l,ls),Yt(l,cs,s),Yt(l,Bu,l),Yt(s,cs,s),Yt(s,ls),Yt(s,Bu,s);const u=ye(n,Bv,pS,{[Pv]:!0}),f=ye(n,rR,Sx,{[Pv]:!0}),h=Yt(n,$v,Sx,{[Pv]:!0});ye(n,Vv,h),ye(f,Bv,u),ye(f,Vv,h),Yt(f,$v,h),ye(h,rR),ye(h,Bv),Yt(h,$v,h),ye(h,Vv,h);const m=Yt(n,zv,ij,{[ej]:!0});ye(m,"#"),Yt(m,zv,m),ye(m,R8,m);const g=ye(m,M8);ye(g,"#"),Yt(g,zv,m);const b=[[ls,o],[cs,i]],x=[[ls,null],[Bu,l],[cs,s]];for(let S=0;S<Dh.length;S++)co(n,Dh[S],xx,ds,b);for(let S=0;S<Ih.length;S++)co(n,Ih[S],wx,vx,x);Ta(xx,{tld:!0,ascii:!0},e),Ta(wx,{utld:!0,alpha:!0},e),co(n,"file",pp,ds,b),co(n,"mailto",pp,ds,b),co(n,"http",ec,ds,b),co(n,"https",ec,ds,b),co(n,"ftp",ec,ds,b),co(n,"ftps",ec,ds,b),Ta(pp,{scheme:!0,ascii:!0},e),Ta(ec,{slashscheme:!0,ascii:!0},e),t=t.sort((S,k)=>S[0]>k[0]?1:-1);for(let S=0;S<t.length;S++){const k=t[S][0],A=t[S][1]?{[E8]:!0}:{[T8]:!0};k.indexOf("-")>=0?A[bx]=!0:ls.test(k)?cs.test(k)?A[cd]=!0:A[gx]=!0:A[mx]=!0,nR(n,k,k,A)}return nR(n,"localhost",Ld,{ascii:!0}),n.jd=new pr(Tm),{start:n,tokens:Object.assign({groups:e},sj)}}function oj(t,e){const n=O8(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=n.length,i=[];let s=0,o=0;for(;o<r;){let l=t,u=null,f=0,h=null,m=-1,g=-1;for(;o<r&&(u=l.go(n[o]));)l=u,l.accepts()?(m=0,g=0,h=l):m>=0&&(m+=n[o].length,g++),f+=n[o].length,s+=n[o].length,o++;s-=m,o-=g,f-=m,i.push({t:h.t,v:e.slice(s-f,s),s:s-f,e:s})}return i}function O8(t){const e=[],n=t.length;let r=0;for(;r<n;){let i=t.charCodeAt(r),s,o=i<55296||i>56319||r+1===n||(s=t.charCodeAt(r+1))<56320||s>57343?t[r]:t.slice(r,r+2);e.push(o),r+=o.length}return e}function co(t,e,n,r,i){let s;const o=e.length;for(let l=0;l<o-1;l++){const u=e[l];t.j[u]?s=t.j[u]:(s=new pr(r),s.jr=i.slice(),t.j[u]=s),t=s}return s=new pr(n),s.jr=i.slice(),t.j[e[o-1]]=s,s}function iR(t){const e=[],n=[];let r=0,i="0123456789";for(;r<t.length;){let s=0;for(;i.indexOf(t[r+s])>=0;)s++;if(s>0){e.push(n.join(""));for(let o=parseInt(t.substring(r,r+s),10);o>0;o--)n.pop();r+=s}else n.push(t[r]),r++}return e}const Pd={defaultProtocol:"http",events:null,format:sR,formatHref:sR,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function vS(t,e=null){let n=Object.assign({},Pd);t&&(n=Object.assign(n,t instanceof vS?t.o:t));const r=n.ignoreTags,i=[];for(let s=0;s<r.length;s++)i.push(r[s].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=i}vS.prototype={o:Pd,ignoreTags:[],defaultRender(t){return t},check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=e!=null;let i=this.o[t];return i&&(typeof i=="object"?(i=n.t in i?i[n.t]:Pd[t],typeof i=="function"&&r&&(i=i(e,n))):typeof i=="function"&&r&&(i=i(e,n.t,n)),i)},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 sR(t){return t}function aj(t,e){this.t="token",this.v=t,this.tk=e}aj.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=Pd.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),i=t.get("tagName",n,e),s=this.toFormattedString(t),o={},l=t.get("className",n,e),u=t.get("target",n,e),f=t.get("rel",n,e),h=t.getObj("attributes",n,e),m=t.getObj("events",n,e);return o.href=r,l&&(o.class=l),u&&(o.target=u),f&&(o.rel=f),h&&Object.assign(o,h),{tagName:i,attributes:o,content:s,eventListeners:m}}};function cg(t,e){class n extends aj{constructor(i,s){super(i,s),this.t=t}}for(const r in e)n.prototype[r]=e[r];return n.t=t,n}const D8=cg("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),oR=cg("text"),I8=cg("nl"),jh=cg("url",{isLink:!0,toHref(t=Pd.defaultProtocol){return this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Ld&&t[1].t===_a}}),qr=t=>new pr(t);function j8({groups:t}){const e=t.domain.concat([pm,gm,mo,ym,bm,vm,xm,wm,Gr,hS,fd,Sm,km,Cm,Ri,Tm,pd,Em]),n=[mm,_a,mS,Ai,gS,fd,hd,yS,bS,im,sm,ud,dd,tm,em,nm,rm,om,am,lm,cm,um,dm,fm,hm],r=[pm,mm,gm,ym,bm,vm,xm,wm,Gr,ud,dd,fd,Sm,km,Cm,hd,Ri,Tm,pd,Em],i=qr(),s=ye(i,pd);rt(s,r,s),rt(s,t.domain,s);const o=qr(),l=qr(),u=qr();rt(i,t.domain,o),rt(i,t.scheme,l),rt(i,t.slashscheme,u),rt(o,r,s),rt(o,t.domain,o);const f=ye(o,mo);ye(s,mo,f),ye(l,mo,f),ye(u,mo,f);const h=ye(s,Ai);rt(h,r,s),rt(h,t.domain,s);const m=qr();rt(f,t.domain,m),rt(m,t.domain,m);const g=ye(m,Ai);rt(g,t.domain,m);const b=qr(D8);rt(g,t.tld,b),rt(g,t.utld,b),ye(f,Ld,b);const x=ye(m,Gr);ye(x,Gr,x),rt(x,t.domain,m),rt(b,t.domain,m),ye(b,Ai,g),ye(b,Gr,x);const S=ye(o,Gr),k=ye(o,Ai);ye(S,Gr,S),rt(S,t.domain,o),rt(k,r,s),rt(k,t.domain,o);const C=qr(jh);rt(k,t.tld,C),rt(k,t.utld,C),rt(C,t.domain,o),rt(C,r,s),ye(C,Ai,k),ye(C,Gr,S),ye(C,mo,f);const A=ye(C,_a),R=qr(jh);rt(A,t.numeric,R);const _=qr(jh),M=qr();rt(_,e,_),rt(_,n,M),rt(M,e,_),rt(M,n,M),ye(C,Ri,_),ye(R,Ri,_);const O=ye(l,_a),D=ye(u,_a),I=ye(D,Ri),P=ye(I,Ri);rt(l,t.domain,o),ye(l,Ai,k),ye(l,Gr,S),rt(u,t.domain,o),ye(u,Ai,k),ye(u,Gr,S),rt(O,t.domain,_),ye(O,Ri,_),ye(O,hd,_),rt(P,t.domain,_),rt(P,e,_),ye(P,Ri,_);const B=[[ud,dd],[em,tm],[nm,rm],[im,sm],[om,am],[lm,cm],[um,dm],[fm,hm]];for(let re=0;re<B.length;re++){const[K,ee]=B[re],Q=ye(_,K);ye(M,K,Q);const fe=qr(jh);rt(Q,e,fe);const z=qr();rt(Q,n,z),ye(Q,ee,_),rt(fe,e,fe),rt(fe,n,z),rt(z,e,fe),rt(z,n,z),ye(fe,ee,_),ye(z,ee,_)}return ye(i,Ld,C),ye(i,pS,I8),{start:i,tokens:sj}}function L8(t,e,n){let r=n.length,i=0,s=[],o=[];for(;i<r;){let l=t,u=null,f=null,h=0,m=null,g=-1;for(;i<r&&!(u=l.go(n[i].t));)o.push(n[i++]);for(;i<r&&(f=u||l.go(n[i].t));)u=null,l=f,l.accepts()?(g=0,m=l):g>=0&&g++,i++,h++;if(g<0)i-=h,i<r&&(o.push(n[i]),i++);else{o.length>0&&(s.push(Hv(oR,e,o)),o=[]),i-=g,h-=g;const b=m.t,x=n.slice(i-h,i);s.push(Hv(b,e,x))}}return o.length>0&&s.push(Hv(oR,e,o)),s}function Hv(t,e,n){const r=n[0].s,i=n[n.length-1].e,s=e.slice(r,i);return new t(s,n)}const P8=typeof console<"u"&&console&&console.warn||(()=>{}),z8="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 $8(){return pr.groups={},Bt.scanner=null,Bt.parser=null,Bt.tokenQueue=[],Bt.pluginQueue=[],Bt.customSchemes=[],Bt.initialized=!1,Bt}function aR(t,e=!1){if(Bt.initialized&&P8(`linkifyjs: already initialized - will not register custom scheme "${t}" ${z8}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error(`linkifyjs: incorrect scheme format.
|
|
194
|
+
1. Must only contain digits, lowercase ASCII letters or "-"
|
|
195
|
+
2. Cannot start or end with "-"
|
|
196
|
+
3. "-" cannot repeat`);Bt.customSchemes.push([t,e])}function B8(){Bt.scanner=N8(Bt.customSchemes);for(let t=0;t<Bt.tokenQueue.length;t++)Bt.tokenQueue[t][1]({scanner:Bt.scanner});Bt.parser=j8(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 xS(t){return Bt.initialized||B8(),L8(Bt.parser.start,t,oj(Bt.scanner.start,t))}xS.scan=oj;function lj(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 vS(n),i=xS(t),s=[];for(let o=0;o<i.length;o++){const l=i[o];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}var wS="[\0- -\u2029 ]",V8=new RegExp(wS),H8=new RegExp(`${wS}$`),U8=new RegExp(wS,"g");function F8(t){return t.length===1?t[0].isLink:t.length===3&&t[1].isLink?["()","[]"].includes(t[0].value+t[2].value):!1}function q8(t){return new Lt({key:new Qt("autolink"),appendTransaction:(e,n,r)=>{const i=e.some(f=>f.docChanged)&&!n.doc.eq(r.doc),s=e.some(f=>f.getMeta("preventAutolink"));if(!i||s)return;const{tr:o}=r,l=gI(n.doc,[...e]);if(oS(l).forEach(({newRange:f})=>{const h=Vq(r.doc,f,b=>b.isTextblock);let m,g;if(h.length>1)m=h[0],g=r.doc.textBetween(m.pos,m.pos+m.node.nodeSize,void 0," ");else if(h.length){const b=r.doc.textBetween(f.from,f.to," "," ");if(!H8.test(b))return;m=h[0],g=r.doc.textBetween(m.pos,f.to,void 0," ")}if(m&&g){const b=g.split(V8).filter(Boolean);if(b.length<=0)return!1;const x=b[b.length-1],S=m.pos+g.lastIndexOf(x);if(!x)return!1;const k=xS(x).map(C=>C.toObject(t.defaultProtocol));if(!F8(k))return!1;k.filter(C=>C.isLink).map(C=>({...C,from:S+C.start+1,to:S+C.end+1})).filter(C=>r.schema.marks.code?!r.doc.rangeHasMark(C.from,C.to,r.schema.marks.code):!0).filter(C=>t.validate(C.value)).filter(C=>t.shouldAutoLink(C.value)).forEach(C=>{aS(C.from,C.to,r.doc).some(A=>A.mark.type===t.type)||o.addMark(C.from,C.to,t.type.create({href:C.href}))})}}),!!o.steps.length)return o}})}function G8(t){return new Lt({key:new Qt("handleClickLink"),props:{handleClick:(e,n,r)=>{var i,s;if(r.button!==0||!e.editable)return!1;let o=null;if(r.target instanceof HTMLAnchorElement)o=r.target;else{const u=r.target;if(!u)return!1;const f=t.editor.view.dom;o=u.closest("a"),o&&!f.contains(o)&&(o=null)}if(!o)return!1;let l=!1;if(t.enableClickSelection&&(l=t.editor.commands.extendMarkRange(t.type.name)),t.openOnClick){const u=CI(e.state,t.type.name),f=(i=o.href)!=null?i:u.href,h=(s=o.target)!=null?s:u.target;f&&(window.open(f,h),l=!0)}return l}}})}var W8=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/,K8=/\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;function cj(t,e){let n=0;for(let r=e-1;r>=0&&t[r]==="\\";r-=1)n+=1;return n%2===1}function Z8(t,e){let n=0,r=0;for(;r<e;){if(t[r]!=="`"){r+=1;continue}if(n===0&&cj(t,r)){r+=1;continue}let i=0;for(;r<e&&t[r]==="`";)i+=1,r+=1;n===0?n=i:i===n&&(n=0)}return n>0}function uj(t,e,n){var r,i;const[,s,o]=e;return(e.index?t[e.index-1]:void 0)==="!"||cj(t,(r=e.index)!=null?r:0)||Z8(t,(i=e.index)!=null?i:0)?!1:!!s.trim()&&n(o)}function dj(t){var e,n;const[r,i,s,,o,l,u]=t,f=(e=o??l)!=null?e:u;return{index:(n=t.index)!=null?n:0,text:r,replaceWith:i,data:{href:s,title:f||null,markdown:!0}}}function Y8(t,e){return t.index<e.index+e.text.length&&e.index<t.index+t.text.length}function fj(t){var e,n,r;return{href:(e=t.data)==null?void 0:e.href,title:(r=(n=t.data)==null?void 0:n.title)!=null?r:null}}function X8(t){const e=Va({find:n=>{const r=W8.exec(n);return!r||!uj(n,r,t.isAllowedHref)?null:dj(r)},type:t.type,getAttributes:fj});return new of({find:e.find,handler:n=>{const r=e.handler(n);return r!==null&&n.state.tr.steps.length&&n.state.tr.setMeta("preventAutolink",!0),r}})}function J8(t){const e=Ho({find:n=>{var r,i;const s=[];for(const l of n.matchAll(K8))uj(n,l,t.isAllowedHref)&&s.push(dj(l));const o=((i=(r=t.findPlainUrls)==null?void 0:r.call(t,n))!=null?i:[]).filter(l=>!s.some(u=>Y8(u,l)));return[...s,...o]},type:t.type,getAttributes:fj});return new NI({find:e.find,handler:n=>{var r;const i=e.handler(n);return i!==null&&n.state.tr.steps.length&&((r=n.match.data)!=null&&r.markdown)&&n.state.tr.setMeta("preventAutolink",!0),i}})}function Q8(t){return new Lt({key:new Qt("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{shouldAutoLink:i}=t,{state:s}=e,{selection:o}=s,{empty:l}=o;if(l)return!1;let u="";r.content.forEach(h=>{u+=h.textContent});const f=lj(u,{defaultProtocol:t.defaultProtocol}).find(h=>h.isLink&&h.value===u);return!u||!f||i!==void 0&&!i(f.value)?!1:t.editor.commands.setMark(t.type,{href:f.href})}}})}function us(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const i=typeof r=="string"?r:r.scheme;i&&n.push(i)}),!t||t.replace(U8,"").match(new RegExp(`^(?:(?:${n.map(r=>r.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`,"i"))}var eW=Ja.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"){aR(t);return}aR(t.scheme,t.optionalSlashes)})},onDestroy(){$8()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,enableClickSelection:!1,linkOnPaste:!0,markdownLinks:!1,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(t,e)=>!!us(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 i=(t.includes("@")?t.split("@").pop():t).split(/[/?#:]/)[0];return!(/^\d{1,3}(\.\d{1,3}){3}$/.test(i)||!/\./.test(i))}}},addAttributes(){var t,e,n;return{href:{default:null,parseHTML(r){return r.getAttribute("href")}},target:{default:(t=this.options.HTMLAttributes.target)!=null?t:null},rel:{default:(e=this.options.HTMLAttributes.rel)!=null?e:null},class:{default:(n=this.options.HTMLAttributes.class)!=null?n:null},title:{default:null}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:n=>!!us(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=>!!us(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",jt(this.options.HTMLAttributes,t),0]:["a",jt(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,i,s;const o=(r=(n=t.attrs)==null?void 0:n.href)!=null?r:"",l=(s=(i=t.attrs)==null?void 0:i.title)!=null?s:"",u=e.renderChildren(t);return l?`[${u}](${o} "${l}")`:`[${u}](${o})`},addCommands(){return{setLink:t=>({chain:e})=>{const{href:n}=t;return this.options.isAllowedUri(n,{defaultValidate:r=>!!us(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=>!!us(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()}},addInputRules(){return this.options.markdownLinks?[X8({type:this.type,isAllowedHref:t=>this.options.isAllowedUri(t,{defaultValidate:e=>!!us(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})})]:[]},addPasteRules(){const t=e=>{const n=[];if(e){const{protocols:r,defaultProtocol:i}=this.options;lj(e).filter(o=>o.isLink&&this.options.isAllowedUri(o.value,{defaultValidate:l=>!!us(l,r),protocols:r,defaultProtocol:i})).forEach(o=>{this.options.shouldAutoLink(o.value)&&n.push({text:o.value,data:{href:o.href},index:o.start})})}return n};return this.options.markdownLinks?[J8({type:this.type,isAllowedHref:e=>this.options.isAllowedUri(e,{defaultValidate:n=>!!us(n,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol}),findPlainUrls:t})]:[Ho({find:t,type:this.type,getAttributes:e=>{var n;return{href:(n=e.data)==null?void 0:n.href}}})]},addProseMirrorPlugins(){const t=[],{protocols:e,defaultProtocol:n}=this.options;return this.options.autolink&&t.push(q8({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:i=>!!us(i,e),protocols:e,defaultProtocol:n}),shouldAutoLink:this.options.shouldAutoLink})),t.push(G8({type:this.type,editor:this.editor,openOnClick:this.options.openOnClick==="whenNotEditable"?!0:this.options.openOnClick,enableClickSelection:this.options.enableClickSelection})),this.options.linkOnPaste&&t.push(Q8({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type,shouldAutoLink:this.options.shouldAutoLink})),t}}),tW=Object.defineProperty,nW=(t,e)=>{for(var n in e)tW(t,n,{get:e[n],enumerable:!0})},rW="listItem",lR="textStyle",cR=/^\s*([-+*])\s$/,hj=Tn.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",jt(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,`
|
|
197
|
+
`):"",markdownOptions:{indentsContent:!0},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(rW,this.editor.getAttributes(lR)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=Tc({find:cR,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Tc({find:cR,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(lR),editor:this.editor})),[t]}}),iW=(t,e,n)=>{const{selection:r}=t;if(!r.empty)return null;const{$from:i}=r;if(!i.parent.isTextblock||i.parentOffset!==i.parent.content.size)return null;let s=-1;for(let b=i.depth;b>0;b-=1)if(i.node(b).type.name===e){s=b;break}if(s<0)return null;const o=i.node(s),l=i.index(s);if(l+1>=o.childCount)return null;const u=o.child(l+1);if(!n.includes(u.type.name))return null;const f=t.schema.nodes[e];let h=!1;if(u.forEach(b=>{b.type===f&&b.childCount>1&&(h=!0)}),!h)return null;const m=t.doc.resolve(i.after()).nodeAfter;if(!m||!n.includes(m.type.name))return null;const g=[];return m.forEach(b=>{g.push(b)}),g.length===0?null:{listItemDepth:s,nestedList:m,nestedListPos:i.after(),insertPos:i.after(s),items:g}},sW=(t,e,n,r)=>{const i=iW(t,n,r);if(!i)return!1;const{selection:s}=t,{nestedList:o,nestedListPos:l,insertPos:u,items:f}=i,h=t.tr;h.delete(l,l+o.nodeSize);const m=h.mapping.map(u);return h.insert(m,de.from(f)),h.setSelection(s.map(h.doc,h.mapping)),e&&e(h),!0},oW=(t,e,n)=>sW(t.state,t.view.dispatch,e,n),pj=(t,e)=>Ft.create({name:`${t}BranchingDeleteKeymap`,priority:101,addKeyboardShortcuts(){const n=()=>oW(this.editor,t,e);return{Delete:n,"Mod-Delete":n}}}),mj=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]],Lh="abcdefghijklmnopqrstuvwxyz",aW="[a-zA-Z]{1,2}",gj=String.raw`\d+|[ivxlcdmIVXLCDM]+|${aW}`;function ug(t){let e=t,n="";for(const[r,i]of mj)for(;e>=r;)n+=i,e-=r;return n}function SS(t){return ug(t).toUpperCase()}function yj(t){const e=t.toLowerCase();let n=0,r=0;for(;n<e.length;){let i=!1;for(const[s,o]of mj)if(e.startsWith(o,n)){r+=s,n+=o.length,i=!0;break}if(!i)return 0}return r}function lW(t){if(!/^[ivxlcdmIVXLCDM]+$/.test(t))return!1;const e=yj(t);return e<=0?!1:(t===t.toLowerCase()?ug(e):SS(e))===t}function cW(t){const e=t.toLowerCase();if(e.length===1)return e.charCodeAt(0)-97+1;if(e.length===2){const n=e.charCodeAt(0)-97,r=e.charCodeAt(1)-97;return(n+1)*26+r+1}return 0}function _m(t){if(t<=26)return Lh[t-1];const e=Math.floor((t-1)/26)-1,n=(t-1)%26;return e<0?Lh[n]:Lh[e]+Lh[n]}function dg(t){if(!(!t||/^\d+$/.test(t))){if(lW(t))return t===t.toLowerCase()?"i":"I";if(/^[a-z]{1,2}$/.test(t))return"a";if(/^[A-Z]{1,2}$/.test(t))return"A"}}function kS(t){if(/^\d+$/.test(t))return parseInt(t,10);const e=dg(t);if(e==="i"||e==="I")return yj(t);if(e==="a"||e==="A"){const r=cW(t);return r>0?r:1}const n=parseInt(t,10);return Number.isNaN(n)?1:n}function uW(t,e){if(t==="numeric")return String(e);switch(t){case"a":return _m(e);case"A":return _m(e).toUpperCase();case"i":return ug(e);case"I":return SS(e);default:return String(e)}}function dW(t){var e;if(t.length===0)return!1;const n=(e=dg(t[0]))!=null?e:"numeric",r=kS(t[0]);if(r<1)return!1;for(let i=0;i<t.length;i++){const s=uW(n,r+i);if(t[i]!==s)return!1}return!0}function fW(t){return{type:dg(t),start:kS(t)}}function hW(t){const{type:e,start:n}=fW(t),r={};return e&&(r.type=e),n!==1&&(r.start=n),r}function pW(t,e,n=". "){const r=e+1;if(!t||t==="1")return`${r}${n}`;switch(t){case"a":return`${_m(r)}${n}`;case"A":return`${_m(r).toUpperCase()}${n}`;case"i":return`${ug(r)}${n}`;case"I":return`${SS(r)}${n}`;default:return`${r}${n}`}}function mW(t){var e,n;const r=(e=t.tokens)==null?void 0:e[0];return!!(t.text&&((n=t.tokens)==null?void 0:n.length)===1&&r?.type==="list"&&r.ordered&&r.raw===t.text)}function gW(t,e){return e.tokenizeInline?e.parseInline(e.tokenizeInline(t)):e.parseInline([{type:"text",raw:t,text:t}])}var bj=Tn.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:t}){return["li",jt(this.options.HTMLAttributes,t),0]},markdownTokenName:"list_item",parseMarkdown:(t,e)=>{var n;if(t.type!=="list_item")return[];const r=(n=e.parseBlockChildren)!=null?n:e.parseChildren;let i=[];if(t.tokens&&t.tokens.length>0){if(mW(t))return{type:"listItem",content:[{type:"paragraph",content:gW(t.text||"",e)}]};if(t.tokens.some(o=>o.type==="paragraph"))i=r(t.tokens);else{const o=t.tokens[0];if(o&&o.type==="text"&&o.tokens&&o.tokens.length>0){if(i=[{type:"paragraph",content:e.parseInline(o.tokens)}],t.tokens.length>1){const u=t.tokens.slice(1),f=r(u);i.push(...f)}}else i=r(t.tokens)}}return i.length===0&&(i=[{type:"paragraph",content:[]}]),{type:"listItem",content:i}},renderMarkdown:(t,e,n)=>uS(t,e,r=>{var i,s,o,l;if(r.parentType==="bulletList")return"- ";if(r.parentType==="orderedList"){const u=((s=(i=r.meta)==null?void 0:i.parentAttrs)==null?void 0:s.start)||1,f=(l=(o=r.meta)==null?void 0:o.parentAttrs)==null?void 0:l.type,h=u-1+(r.index||0);return pW(f,h,". ")}return"- "},n),addExtensions(){return[pj(this.name,[this.options.bulletListTypeName,this.options.orderedListTypeName])]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),yW={};nW(yW,{findListItemPos:()=>fg,getNextListDepth:()=>CS,handleBackspace:()=>kx,handleDelete:()=>Cx,hasListBefore:()=>vj,hasListItemAfter:()=>bW,hasListItemBefore:()=>vW,listItemHasSubList:()=>xW,nextListIsDeeper:()=>xj,nextListIsHigher:()=>wj});var fg=(t,e)=>{const{$from:n}=e.selection,r=pn(t,e.schema);let i=null,s=n.depth,o=n.pos,l=null;for(;s>0&&l===null;)i=n.node(s),i.type===r?l=s:(s-=1,o-=1);return l===null?null:{$pos:e.doc.resolve(o),depth:l}},CS=(t,e)=>{const n=fg(t,e);if(!n)return!1;const[,r]=Xq(e,t,n.$pos.pos+4);return r},vj=(t,e,n)=>{const{$anchor:r}=t.selection,i=Math.max(0,r.pos-2),s=t.doc.resolve(i).node();return!(!s||!n.includes(s.type.name))},kx=(t,e,n)=>{if(t.commands.undoInputRule())return!0;if(t.state.selection.from!==t.state.selection.to)return!1;if(!Vo(t.state,e)&&vj(t.state,e,n)){const{$anchor:r}=t.state.selection,i=t.state.doc.resolve(r.before()-1),s=[];i.node().descendants((u,f)=>{u.type.name===e&&s.push({node:u,pos:f})});const o=s.at(-1);if(!o)return!1;const l=t.state.doc.resolve(i.start()+o.pos+1);return t.chain().cut({from:r.start()-1,to:r.end()+1},l.end()).joinForward().run()}return!Vo(t.state,e)||!t9(t.state)?!1:t.chain().liftListItem(e).run()},xj=(t,e)=>{const n=CS(t,e),r=fg(t,e);return!r||!n?!1:n>r.depth},wj=(t,e)=>{const n=CS(t,e),r=fg(t,e);return!r||!n?!1:n<r.depth},Cx=(t,e)=>{if(!Vo(t.state,e)||!e9(t.state,e))return!1;const{selection:n}=t.state,{$from:r,$to:i}=n;return!n.empty&&r.sameParent(i)?!1:xj(e,t.state)?t.chain().focus(t.state.selection.from+4).lift(e).joinBackward().run():wj(e,t.state)?t.chain().joinForward().joinBackward().run():t.commands.joinItemForward()},bW=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-r.parentOffset-2);return!(i.index()===i.parent.childCount-1||((n=i.nodeAfter)==null?void 0:n.type.name)!==t)},vW=(t,e)=>{var n;const{$anchor:r}=e.selection,i=e.doc.resolve(r.pos-2);return!(i.index()===0||((n=i.nodeBefore)==null?void 0:n.type.name)!==t)},xW=(t,e,n)=>{if(!n)return!1;const r=pn(t,e.schema);let i=!1;return n.descendants(s=>{s.type===r&&(i=!0)}),i},Sj=Ft.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&&Cx(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&&Cx(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&&kx(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&&kx(t,n,r)&&(e=!0)}),e}}}}),Ex=new RegExp(`^(\\s*)(${gj})([.)])\\s+(.*)$`),wW=/^\s/,Qu={heading:/^#{1,6}(?:\s|$)/,bulletItem:/^[-+*]\s+/,codeFence:/^(?:```|~~~)/,thematicBreak:/^(?:(?:-[ \t]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})$/};function SW(t){return Ex.test(t.trimStart())}function kW(t){const e=t.trimStart();return Qu.bulletItem.test(e)||SW(e)||Qu.heading.test(e)||Qu.thematicBreak.test(e)&&!e.startsWith("-")||/^>\s?/.test(e)||Qu.codeFence.test(e)}function CW(t){return Object.values(Qu).some(e=>e.test(t))}function EW(t){const e=[],n=[];let r=!1;return t.forEach(i=>{if(r){n.push(i);return}if(i.trim()===""){r=!0,n.push(i);return}if(e.length>0&&kW(i)){r=!0,n.push(i);return}e.push(i)}),{paragraphLines:e,blockLines:n}}function TW(t){const e=[];let n=0,r=0;for(;n<t.length;){const i=t[n],s=i.match(Ex);if(!s)break;const[,o,l,u,f]=s,h=o.length,m=parseInt(l,10),g=isNaN(m)?dg(l):void 0,b=isNaN(m)?kS(l):m,x=[f];let S=n+1;const k=[i];let C=!1;for(;S<t.length;){const A=t[S];if(A.match(Ex))break;if(A.trim()==="")k.push(A),x.push(""),C=!0,S+=1;else if(A.match(wW)){const _=A.length-A.trimStart().length,M=h+l.length+1;k.push(A),x.push(A.slice(Math.min(_,M))),S+=1}else{if(C||CW(A))break;k.push(A),x.push(A),S+=1}}e.push({indent:h,number:b,type:g,content:x.join(`
|
|
198
|
+
`).trim(),contentLines:x,raw:k.join(`
|
|
199
|
+
`)}),r=S,n=S}return[e,r]}var _W=new RegExp(`^(${gj})([.)])\\s+(.+)$`);function AW(t){const e=t.split(`
|
|
200
|
+
`).filter(s=>s.trim().length>0);if(e.length===0)return null;const n=[];for(const s of e){const o=s.trim().match(_W);if(!o)return null;n.push({marker:o[1],content:o[3]})}const r=n.map(s=>s.marker);return dW(r)?{type:"orderedList",attrs:hW(n[0].marker),content:n.map(s=>({type:"listItem",content:[{type:"paragraph",content:[{type:"text",text:s.content}]}]}))}:null}function kj(t,e,n){const r=[];let i=0;for(;i<t.length;){const s=t[i];if(s.indent===e){const{paragraphLines:o,blockLines:l}=EW(s.contentLines),u=o.join(`
|
|
201
|
+
`).trim(),f=[];u&&f.push({type:"paragraph",raw:u,tokens:n.inlineTokens(u)});const h=l.join(`
|
|
202
|
+
`).trim();if(h){const b=n.blockTokens(h);f.push(...b)}let m=i+1;const g=[];for(;m<t.length&&t[m].indent>e;)g.push(t[m]),m+=1;if(g.length>0){const b=Math.min(...g.map(S=>S.indent)),x=kj(g,b,n);f.push({type:"list",ordered:!0,start:g[0].number,typeMarker:g[0].type,items:x,raw:g.map(S=>S.raw).join(`
|
|
203
|
+
`)})}r.push({type:"list_item",raw:s.raw,tokens:f}),i=m}else i+=1}return r}function RW(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(i=>{if(i.type==="paragraph"||i.type==="list"||i.type==="blockquote"||i.type==="code")r.push(...e.parseChildren([i]));else if(i.type==="text"&&i.tokens){const s=e.parseChildren([i]);r.push({type:"paragraph",content:s})}else{const s=e.parseChildren([i]);s.length>0&&r.push(...s)}}),{type:"listItem",content:r}})}var MW="listItem",uR="textStyle",dR=/^(\d+)\.\s$/;function fR(t){const e=t.match(/list-style-type\s*:\s*([^;]+)/i);if(!e)return null;switch(e[1].trim().toLowerCase()){case"upper-roman":return"I";case"lower-roman":return"i";case"upper-alpha":case"upper-latin":return"A";case"lower-alpha":case"lower-latin":return"a";default:return null}}var Cj=Tn.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=>{const e=t.getAttribute("type");if(e)return e;const n=t.getAttribute("style");if(n){const i=fR(n);if(i)return i}const r=t.querySelector("li");if(r){const i=r.getAttribute("style");if(i){const s=fR(i);if(s)return s}}return null}}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,type:n,...r}=t,i=jt(this.options.HTMLAttributes,r);return e!==1&&(i.start=e),n&&n!=="1"&&(i.type=n),["ol",i,0]},markdownTokenName:"list",parseMarkdown:(t,e)=>{if(t.type!=="list"||!t.ordered)return[];const n=t.start||1,r=t.typeMarker,i=t.items?RW(t.items,e):[],s={};return n!==1&&(s.start=n),r&&(s.type=r),Object.keys(s).length>0?{type:"orderedList",attrs:s,content:i}:{type:"orderedList",content:i}},renderMarkdown:(t,e)=>t.content?e.renderChildren(t.content,`
|
|
204
|
+
`):"",markdownTokenizer:{name:"orderedList",level:"block",start:()=>-1,tokenize:(t,e,n)=>{var r,i;const s=t.split(`
|
|
205
|
+
`),[o,l]=TW(s);if(o.length===0)return;const u=kj(o,o[0].indent,n);if(u.length===0)return;const f=((r=o[0])==null?void 0:r.number)||1,h=(i=o[0])==null?void 0:i.type;return{type:"list",ordered:!0,start:f,typeMarker:h,items:u,raw:s.slice(0,l).join(`
|
|
206
|
+
`)}}},markdownOptions:{indentsContent:!0},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(MW,this.editor.getAttributes(uR)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addProseMirrorPlugins(){return[new Lt({props:{handlePaste:(t,e)=>{var n,r;const i=(n=e.clipboardData)==null?void 0:n.getData("text/html");if(i?.trim())return!1;const s=(r=e.clipboardData)==null?void 0:r.getData("text/plain");if(!s)return!1;const o=AW(s);if(!o)return!1;try{const l=t.state.schema.nodeFromJSON(o),u=t.state.tr.replaceSelectionWith(l);return t.dispatch(u),!0}catch{return!1}}}})]},addInputRules(){const t=(n,r)=>(!r.attrs.type||r.attrs.type==="1")&&r.childCount+r.attrs.start===+n[1];let e=Tc({find:dR,type:this.type,getAttributes:n=>({start:+n[1]}),joinPredicate:t});return(this.options.keepMarks||this.options.keepAttributes)&&(e=Tc({find:dR,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:n=>({start:+n[1],...this.editor.getAttributes(uR)}),joinPredicate:t,editor:this.editor})),[e]}}),NW=/^\s*(\[([( |x])?\])\s$/,OW=Tn.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",jt(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 i=`- [${(n=t.attrs)!=null&&n.checked?"x":" "}] `;return uS(t,e,i)},addExtensions(){return this.options.nested?[pj(this.name,[this.options.taskListTypeName])]:[]},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 i=document.createElement("li"),s=document.createElement("label"),o=document.createElement("span"),l=document.createElement("input"),u=document.createElement("div"),f=m=>{var g,b;l.ariaLabel=((b=(g=this.options.a11y)==null?void 0:g.checkboxLabel)==null?void 0:b.call(g,m,l.checked))||`Task item checkbox for ${m.textContent||"empty task item"}`};f(t),s.contentEditable="false",l.type="checkbox",l.addEventListener("mousedown",m=>m.preventDefault()),l.addEventListener("change",m=>{if(!r.isEditable&&!this.options.onReadOnlyChecked){l.checked=!l.checked;return}const{checked:g}=m.target;r.isEditable&&typeof n=="function"&&r.chain().focus(void 0,{scrollIntoView:!1}).command(({tr:b})=>{const x=n();if(typeof x!="number")return!1;const S=b.doc.nodeAt(x);return b.setNodeMarkup(x,void 0,{...S?.attrs,checked:g}),!0}).run(),!r.isEditable&&this.options.onReadOnlyChecked&&(this.options.onReadOnlyChecked(t,g)||(l.checked=!l.checked))}),Object.entries(this.options.HTMLAttributes).forEach(([m,g])=>{i.setAttribute(m,g)}),i.dataset.checked=t.attrs.checked,l.checked=t.attrs.checked,s.append(l,o),i.append(s,u),Object.entries(e).forEach(([m,g])=>{i.setAttribute(m,g)});let h=new Set(Object.keys(e));return{dom:i,contentDOM:u,update:m=>{if(m.type!==this.type)return!1;i.dataset.checked=m.attrs.checked,l.checked=m.attrs.checked,f(m);const g=r.extensionManager.attributes,b=Cc(m,g),x=new Set(Object.keys(b)),S=this.options.HTMLAttributes;return h.forEach(k=>{x.has(k)||(k in S?i.setAttribute(k,S[k]):i.removeAttribute(k))}),Object.entries(b).forEach(([k,C])=>{C==null?k in S?i.setAttribute(k,S[k]):i.removeAttribute(k):i.setAttribute(k,C)}),h=x,!0}}}},addInputRules(){return[Tc({find:NW,type:this.type,getAttributes:t=>({checked:t[t.length-1]==="x"})})]}}),DW=Tn.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",jt(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,`
|
|
207
|
+
`):"",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=s=>{const o=hx(s,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:l=>({indentLevel:l[1].length,mainContent:l[4],checked:l[3].toLowerCase()==="x"}),createToken:(l,u)=>({type:"taskItem",raw:"",mainContent:l.mainContent,indentLevel:l.indentLevel,checked:l.checked,text:l.mainContent,tokens:n.inlineTokens(l.mainContent),nestedTokens:u}),customNestedParser:r},n);if(o){const l={type:"taskList",raw:o.raw,items:o.items},u=s.slice(o.raw.length);return u.trim()?[l,...n.blockTokens(u)]:[l]}return n.blockTokens(s)},i=hx(t,{itemPattern:/^(\s*)([-+*])\s+\[([ xX])\]\s+(.*)$/,extractItemData:s=>({indentLevel:s[1].length,mainContent:s[4],checked:s[3].toLowerCase()==="x"}),createToken:(s,o)=>({type:"taskItem",raw:"",mainContent:s.mainContent,indentLevel:s.indentLevel,checked:s.checked,text:s.mainContent,tokens:n.inlineTokens(s.mainContent),nestedTokens:o}),customNestedParser:r},n);if(i)return{type:"taskList",raw:i.raw,items:i.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()}}});Ft.create({name:"listKit",addExtensions(){const t=[];return this.options.bulletList!==!1&&t.push(hj.configure(this.options.bulletList)),this.options.listItem!==!1&&t.push(bj.configure(this.options.listItem)),this.options.listKeymap!==!1&&t.push(Sj.configure(this.options.listKeymap)),this.options.orderedList!==!1&&t.push(Cj.configure(this.options.orderedList)),this.options.taskItem!==!1&&t.push(OW.configure(this.options.taskItem)),this.options.taskList!==!1&&t.push(DW.configure(this.options.taskList)),t}});var Ph=" ",Uv=" ",IW=Tn.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",jt(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 n.length===1&&n[0].type==="text"&&(n[0].raw===Ph||n[0].text===Ph||n[0].raw===Uv||n[0].text===Uv)&&r.length===1&&r[0].type==="text"&&(r[0].text===Ph||r[0].text===Uv)?e.createNode("paragraph",void 0,[]):e.createNode("paragraph",void 0,r)},renderMarkdown:(t,e,n)=>{var r,i;if(!t)return"";const s=Array.isArray(t.content)?t.content:[];if(s.length===0){const o=Array.isArray((r=n?.previousNode)==null?void 0:r.content)?n.previousNode.content:[];return((i=n?.previousNode)==null?void 0:i.type)==="paragraph"&&o.length===0?Ph:""}return e.renderChildren(s)},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),jW=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,LW=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,PW=Ja.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",jt(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[Va({find:jW,type:this.type})]},addPasteRules(){return[Ho({find:LW,type:this.type})]}}),zW=Tn.create({name:"text",group:"inline",parseMarkdown:t=>({type:"text",text:t.text||""}),renderMarkdown:t=>t.text||""}),$W=Ja.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",jt(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 i=/^(\+\+)([\s\S]+?)(\+\+)/.exec(t);if(!i)return;const s=i[2].trim();return{type:"underline",raw:i[0],text:s,tokens:n.inlineTokens(s)}}},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()}}});function BW(t={}){return new Lt({view(e){return new VW(e,t)}})}class VW{constructor(e,n){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,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(i=>{let s=o=>{this[i](o)};return e.dom.addEventListener(i,s),{name:i,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){if(this.cursorPos!=null&&n.doc!=e.state.doc)if(this.lastDragEvent){let r=this.computeTarget(this.lastDragEvent);r==this.cursorPos?this.updateOverlay():this.setCursor(r)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,r,i=this.editorView.dom,s=i.getBoundingClientRect(),o=s.width/i.offsetWidth,l=s.height/i.offsetHeight;if(n){let m=e.nodeBefore,g=e.nodeAfter;if(m||g){let b=this.editorView.nodeDOM(this.cursorPos-(m?m.nodeSize:0));if(b){let x=b.getBoundingClientRect(),S=m?x.bottom:x.top;m&&g&&(S=(S+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let k=this.width/2*l;r={left:x.left,right:x.right,top:S-k,bottom:S+k}}}}if(!r){let m=this.editorView.coordsAtPos(this.cursorPos),g=this.width/2*o;r={left:m.left-g,right:m.left+g,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,h;if(!u||u==document.body&&getComputedStyle(u).position=="static")f=-pageXOffset,h=-pageYOffset;else{let m=u.getBoundingClientRect(),g=m.width/u.offsetWidth,b=m.height/u.offsetHeight;f=m.left-u.scrollLeft*g,h=m.top-u.scrollTop*b}this.element.style.left=(r.left-f)/o+"px",this.element.style.top=(r.top-h)/l+"px",this.element.style.width=(r.right-r.left)/o+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),i=r&&r.type.spec.disableDropCursor,s=typeof i=="function"?i(this.editorView,n,e):i;if(!n||s)return null;let o=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=sD(this.editorView.state.doc,o,this.editorView.dragging.slice);l!=null&&(o=l)}return o}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let n=this.computeTarget(e);n!=null&&(this.setCursor(n),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class Xt extends Ke{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return Xt.valid(r)?new Xt(r):Ke.near(r)}content(){return Ee.empty}eq(e){return e instanceof Xt&&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 Xt(e.resolve(n.pos))}getBookmark(){return new ES(this.anchor)}static valid(e){let n=e.parent;if(n.inlineContent||!HW(e)||!UW(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&Xt.valid(e))return e;let i=e.pos,s=null;for(let o=e.depth;;o--){let l=e.node(o);if(n>0?e.indexAfter(o)<l.childCount:e.index(o)>0){s=l.child(n>0?e.indexAfter(o):e.index(o)-1);break}else if(o==0)return null;i+=n;let u=e.doc.resolve(i);if(Xt.valid(u))return u}for(;;){let o=n>0?s.firstChild:s.lastChild;if(!o){if(s.isAtom&&!s.isText&&!He.isSelectable(s)){e=e.doc.resolve(i+s.nodeSize*n),r=!1;continue e}break}s=o,i+=n;let l=e.doc.resolve(i);if(Xt.valid(l))return l}return null}}}Xt.prototype.visible=!1;Xt.findFrom=Xt.findGapCursorFrom;Ke.jsonID("gapcursor",Xt);class ES{constructor(e){this.pos=e}map(e){return new ES(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return Xt.valid(n)?new Xt(n):Ke.near(n)}}function Ej(t){return t.isAtom||t.spec.isolating||t.spec.createGapCursor}function HW(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 i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||Ej(i.type))return!0;if(i.inlineContent)return!1}}return!0}function UW(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 i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||Ej(i.type))return!0;if(i.inlineContent)return!1}}return!0}function FW(){return new Lt({props:{decorations:KW,createSelectionBetween(t,e,n){return e.pos==n.pos&&Xt.valid(n)?new Xt(n):null},handleClick:GW,handleKeyDown:qW,handleDOMEvents:{beforeinput:WW}}})}const qW=eS({ArrowLeft:zh("horiz",-1),ArrowRight:zh("horiz",1),ArrowUp:zh("vert",-1),ArrowDown:zh("vert",1)});function zh(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,s){let o=r.selection,l=e>0?o.$to:o.$from,u=o.empty;if(o instanceof ze){if(!s.endOfTextblock(n)||l.depth==0)return!1;u=!1,l=r.doc.resolve(e>0?l.after():l.before())}let f=Xt.findGapCursorFrom(l,e,u);return f?(i&&i(r.tr.setSelection(new Xt(f))),!0):!1}}function GW(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!Xt.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&He.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new Xt(r))),!0)}function WW(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof Xt))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 i=de.empty;for(let o=r.length-1;o>=0;o--)i=de.from(r[o].createAndFill(null,i));let s=t.state.tr.replace(n.pos,n.pos,new Ee(i,0,0));return s.setSelection(ze.near(s.doc.resolve(n.pos+1))),t.dispatch(s),!1}function KW(t){if(!(t.selection instanceof Xt))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",kt.create(t.doc,[Sn.widget(t.selection.head,e,{key:"gapcursor"})])}var Am=200,Cn=function(){};Cn.prototype.append=function(e){return e.length?(e=Cn.from(e),!this.length&&e||e.length<Am&&this.leafAppend(e)||this.length<Am&&e.leafPrepend(this)||this.appendInner(e)):this};Cn.prototype.prepend=function(e){return e.length?Cn.from(e).append(this):this};Cn.prototype.appendInner=function(e){return new ZW(this,e)};Cn.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Cn.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))};Cn.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};Cn.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)};Cn.prototype.map=function(e,n,r){n===void 0&&(n=0),r===void 0&&(r=this.length);var i=[];return this.forEach(function(s,o){return i.push(e(s,o))},n,r),i};Cn.from=function(e){return e instanceof Cn?e:e&&e.length?new Tj(e):Cn.empty};var Tj=(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(i,s){return i==0&&s==this.length?this:new e(this.values.slice(i,s))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,s,o,l){for(var u=s;u<o;u++)if(i(this.values[u],l+u)===!1)return!1},e.prototype.forEachInvertedInner=function(i,s,o,l){for(var u=s-1;u>=o;u--)if(i(this.values[u],l+u)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Am)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Am)return new e(i.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e})(Cn);Cn.empty=new Tj([]);var ZW=(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,i,s,o){var l=this.left.length;if(i<l&&this.left.forEachInner(r,i,Math.min(s,l),o)===!1||s>l&&this.right.forEachInner(r,Math.max(i-l,0),Math.min(this.length,s)-l,o+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,i,s,o){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(r,i-l,Math.max(s,l)-l,o+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(i,l),s,o)===!1)return!1},e.prototype.sliceInner=function(r,i){if(r==0&&i==this.length)return this;var s=this.left.length;return i<=s?this.left.slice(r,i):r>=s?this.right.slice(r-s,i-s):this.left.slice(r,s).append(this.right.slice(0,i-s))},e.prototype.leafAppend=function(r){var i=this.right.leafAppend(r);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(r){var i=this.left.leafPrepend(r);if(i)return new e(i,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})(Cn);const YW=500;class fi{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 i,s;n&&(i=this.remapping(r,this.items.length),s=i.maps.length);let o=e.tr,l,u,f=[],h=[];return this.items.forEach((m,g)=>{if(!m.step){i||(i=this.remapping(r,g+1),s=i.maps.length),s--,h.push(m);return}if(i){h.push(new Mi(m.map));let b=m.step.map(i.slice(s)),x;b&&o.maybeStep(b).doc&&(x=o.mapping.maps[o.mapping.maps.length-1],f.push(new Mi(x,void 0,void 0,f.length+h.length))),s--,x&&i.appendMap(x,s)}else o.maybeStep(m.step);if(m.selection)return l=i?m.selection.map(i.slice(s)):m.selection,u=new fi(this.items.slice(0,r).append(h.reverse().concat(f)),this.eventCount-1),!1},this.items.length,0),{remaining:u,transform:o,selection:l}}addTransform(e,n,r,i){let s=[],o=this.eventCount,l=this.items,u=!i&&l.length?l.get(l.length-1):null;for(let h=0;h<e.steps.length;h++){let m=e.steps[h].invert(e.docs[h]),g=new Mi(e.mapping.maps[h],m,n),b;(b=u&&u.merge(g))&&(g=b,h?s.pop():l=l.slice(0,l.length-1)),s.push(g),n&&(o++,n=void 0),i||(u=g)}let f=o-r.depth;return f>JW&&(l=XW(l,f),o-=f),new fi(l.append(s),o)}remapping(e,n){let r=new Nd;return this.items.forEach((i,s)=>{let o=i.mirrorOffset!=null&&s-i.mirrorOffset>=e?r.maps.length-i.mirrorOffset:void 0;r.appendMap(i.map,o)},e,n),r}addMaps(e){return this.eventCount==0?this:new fi(this.items.append(e.map(n=>new Mi(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),s=e.mapping,o=e.steps.length,l=this.eventCount;this.items.forEach(g=>{g.selection&&l--},i);let u=n;this.items.forEach(g=>{let b=s.getMirror(--u);if(b==null)return;o=Math.min(o,b);let x=s.maps[b];if(g.step){let S=e.steps[b].invert(e.docs[b]),k=g.selection&&g.selection.map(s.slice(u+1,b));k&&l++,r.push(new Mi(x,S,k))}else r.push(new Mi(x))},i);let f=[];for(let g=n;g<o;g++)f.push(new Mi(s.maps[g]));let h=this.items.slice(0,i).append(f).append(r),m=new fi(h,l);return m.emptyItemCount()>YW&&(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,i=[],s=0;return this.items.forEach((o,l)=>{if(l>=e)i.push(o),o.selection&&s++;else if(o.step){let u=o.step.map(n.slice(r)),f=u&&u.getMap();if(r--,f&&n.appendMap(f,r),u){let h=o.selection&&o.selection.map(n.slice(r));h&&s++;let m=new Mi(f.invert(),u,h),g,b=i.length-1;(g=i.length&&i[b].merge(m))?i[b]=g:i.push(m)}}else o.map&&r--},this.items.length,0),new fi(Cn.from(i.reverse()),s)}}fi.empty=new fi(Cn.empty,0);function XW(t,e){let n;return t.forEach((r,i)=>{if(r.selection&&e--==0)return n=i,!1}),t.slice(n)}class Mi{constructor(e,n,r,i){this.map=e,this.step=n,this.selection=r,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new Mi(n.getMap().invert(),n,this.selection)}}}class go{constructor(e,n,r,i,s){this.done=e,this.undone=n,this.prevRanges=r,this.prevTime=i,this.prevComposition=s}}const JW=20;function QW(t,e,n,r){let i=n.getMeta(Oa),s;if(i)return i.historyState;n.getMeta(n7)&&(t=new go(t.done,t.undone,null,0,-1));let o=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(o&&o.getMeta(Oa))return o.getMeta(Oa).redo?new go(t.done.addTransform(n,void 0,r,mp(e)),t.undone,hR(n.mapping.maps),t.prevTime,t.prevComposition):new go(t.done,t.undone.addTransform(n,void 0,r,mp(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(o&&o.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),u=t.prevTime==0||!o&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-r.newGroupDelay||!e7(n,t.prevRanges)),f=o?Fv(t.prevRanges,n.mapping):hR(n.mapping.maps);return new go(t.done.addTransform(n,u?e.selection.getBookmark():void 0,r,mp(e)),fi.empty,f,n.time,l??t.prevComposition)}else return(s=n.getMeta("rebased"))?new go(t.done.rebased(n,s),t.undone.rebased(n,s),Fv(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new go(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),Fv(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function e7(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((r,i)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&i>=e[s]&&(n=!0)}),n}function hR(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((r,i,s,o)=>e.push(s,o));return e}function Fv(t,e){if(!t)return null;let n=[];for(let r=0;r<t.length;r+=2){let i=e.map(t[r],1),s=e.map(t[r+1],-1);i<=s&&n.push(i,s)}return n}function t7(t,e,n){let r=mp(e),i=Oa.get(e).spec.config,s=(n?t.undone:t.done).popEvent(e,r);if(!s)return null;let o=s.selection.resolve(s.transform.doc),l=(n?t.done:t.undone).addTransform(s.transform,e.selection.getBookmark(),i,r),u=new go(n?l:s.remaining,n?s.remaining:l,null,0,-1);return s.transform.setSelection(o).setMeta(Oa,{redo:n,historyState:u})}let qv=!1,pR=null;function mp(t){let e=t.plugins;if(pR!=e){qv=!1,pR=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){qv=!0;break}}return qv}const Oa=new Qt("history"),n7=new Qt("closeHistory");function r7(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Lt({key:Oa,state:{init(){return new go(fi.empty,fi.empty,null,0,-1)},apply(e,n,r){return QW(n,r,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let r=n.inputType,i=r=="historyUndo"?Aj:r=="historyRedo"?Rj:null;return!i||!e.editable?!1:(n.preventDefault(),i(e.state,e.dispatch))}}}})}function _j(t,e){return(n,r)=>{let i=Oa.getState(n);if(!i||(t?i.undone:i.done).eventCount==0)return!1;if(r){let s=t7(i,n,t);s&&r(e?s.scrollIntoView():s)}return!0}}const Aj=_j(!1,!0),Rj=_j(!0,!0);Ft.create({name:"characterCount",addOptions(){return{limit:null,autoTrim:!0,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?.node||this.editor.state.doc;if((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?.node||this.editor.state.doc,n=e.textBetween(0,e.content.size," "," ");return this.options.wordCounter(n)}},addProseMirrorPlugins(){let t=!1;return[new Lt({key:new Qt("characterCount"),appendTransaction:(e,n,r)=>{if(t)return;const i=this.options.limit,s=this.options.autoTrim;if(i==null||i===0||s===!1){t=!0;return}const o=this.storage.characters({node:r.doc});if(o>i){const l=o-i,u=0,f=l;console.warn(`[CharacterCount] Initial content exceeded limit of ${i} characters. Content was automatically trimmed.`);const h=r.tr.deleteRange(u,f);return t=!0,h}t=!0},filterTransaction:(e,n)=>{const r=this.options.limit;if(!e.docChanged||r===0||r===null||r===void 0)return!0;const i=this.storage.characters({node:n.doc}),s=this.storage.characters({node:e.doc});if(s<=r||i>r&&s>r&&s<=i)return!0;if(i>r&&s>r&&s>i||!e.getMeta("paste"))return!1;const l=e.selection.$head.pos,u=s-r,f=l-u,h=l;return e.deleteRange(f,h),!(this.storage.characters({node:e.doc})>r)}})]}});var i7=Ft.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[BW(this.options)]}});Ft.create({name:"focus",addOptions(){return{className:"has-focus",mode:"all"}},addProseMirrorPlugins(){return[new Lt({key:new Qt("focus"),props:{decorations:({doc:t,selection:e})=>{const{isEditable:n,isFocused:r}=this.editor,{anchor:i}=e,s=[];if(!n||!r)return kt.create(t,[]);let o=0;this.options.mode==="deepest"&&t.descendants((u,f)=>{if(u.isText)return;if(!(i>=f&&i<=f+u.nodeSize-1))return!1;o+=1});let l=0;return t.descendants((u,f)=>{if(u.isText||!(i>=f&&i<=f+u.nodeSize-1))return!1;if(l+=1,this.options.mode==="deepest"&&o-l>0||this.options.mode==="shallowest"&&l>1)return this.options.mode==="deepest";s.push(Sn.node(f,f+u.nodeSize,{class:this.options.className}))}),kt.create(t,s)}}})]}});var s7=Ft.create({name:"gapCursor",addProseMirrorPlugins(){return[FW()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=mt(De(t,"allowGapCursor",n)))!=null?e:null}}}),Mj="placeholder",mR=new Qt("tiptap__placeholder");function Nj(t){const{editor:e,placeholder:n,dataAttribute:r,pos:i,node:s,isEmptyDoc:o,hasAnchor:l,classes:{emptyNode:u,emptyEditor:f}}=t,h=[u];return o&&h.push(f),Sn.node(i,i+s.nodeSize,{class:h.join(" "),[r]:typeof n=="function"?n({editor:e,node:s,pos:i,hasAnchor:l}):n})}function Oj(t,e){return typeof t=="function"?t(e):t}function Dj({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:s,to:o}){const{anchor:l}=i,u=[],f=t.isEmpty;return r.nodesBetween(s,o,(h,m)=>{const g=l>=m&&l<=m+h.nodeSize,b=!h.isLeaf&&sf(h);return h.type.isTextblock&&(g||!e.showOnlyCurrent)&&b&&u.push(Nj({editor:t,isEmptyDoc:f,dataAttribute:n,hasAnchor:g,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Oj(e.emptyNodeClass,{editor:t,node:h,pos:m,hasAnchor:g})},node:h,pos:m})),e.includeChildren}),u}function Ij({editor:t,options:e,dataAttribute:n,doc:r,selection:i}){if(!(t.isEditable||!e.showOnlyWhenEditable))return null;const{anchor:o}=i,l=[],u=t.isEmpty;if(e.showOnlyCurrent&&!e.includeChildren){const h=r.resolve(o),m=h.depth>0?h.node(1):h.nodeAfter,g=h.depth>0?h.before(1):o;if(m&&m.type.isTextblock&&sf(m)){const b=o>=g&&o<=g+m.nodeSize;l.push(Nj({editor:t,isEmptyDoc:u,dataAttribute:n,hasAnchor:b,placeholder:e.placeholder,classes:{emptyEditor:e.emptyEditorClass,emptyNode:Oj(e.emptyNodeClass,{editor:t,node:m,pos:g,hasAnchor:b})},node:m,pos:g}))}}else l.push(...Dj({editor:t,options:e,dataAttribute:n,doc:r,selection:i,from:0,to:r.content.size}));return kt.create(r,l)}function md(t,e){var n;const r=t.resolve(e);if(r.depth===0){const o=(n=r.nodeAfter)!=null?n:r.nodeBefore;if(!o)return{from:e,to:e};const l=r.nodeAfter?e:e-o.nodeSize;return{from:l,to:l+o.nodeSize}}const i=r.before(1),s=r.node(1);return{from:i,to:i+s.nodeSize}}function gd(t,e){return{from:Math.max(0,e.from-1),to:Math.min(t.content.size,e.to-1)}}function o7(t,e,n){const r=[];return t.forEach((i,s)=>{const o=s,l=o+i.nodeSize,u=o+1,f=l+1;u<n&&f>e&&r.push({from:o,to:l})}),r}function a7(t){if(t.length===0)return[];const e=[...t].sort((r,i)=>r.from-i.from),n=[{...e[0]}];for(let r=1;r<e.length;r+=1){const i=n[n.length-1],s=e[r];s.from<=i.to?i.to=Math.max(i.to,s.to):n.push({...s})}return n}function l7(t,e){const n=o7(t,e.from,e.to);return n.push(gd(t,md(t,e.from))),e.to>e.from?n.push(gd(t,md(t,Math.min(e.to,t.content.size+1)-1))):e.from<t.content.size+1&&n.push(gd(t,md(t,Math.min(e.from+1,t.content.size)))),n}function c7(t,e,n){const r=[];if(t.docChanged){const i=oS(t);for(const s of i)r.push(...l7(n.doc,s.newRange))}return t.selectionSet&&(r.push(gd(n.doc,md(n.doc,t.mapping.map(e.selection.anchor)))),r.push(gd(n.doc,md(n.doc,n.selection.anchor)))),a7(r)}function u7(t,e,n){const r=Math.max(0,Math.min(t,n.content.size)),i=Math.max(r,Math.min(e,n.content.size));return{from:r,to:i}}function d7({decorations:t,ranges:e,editor:n,options:r,dataAttribute:i,doc:s,selection:o}){let l=t;for(const u of e){const{from:f,to:h}=u7(u.from,u.to,s),m=l.find(f,h).filter(b=>b.from>=f&&b.to<=h);m.length&&(l=l.remove(m));const g=Dj({editor:n,options:r,dataAttribute:i,doc:s,selection:o,from:f,to:h});g.length&&(l=l.add(s,g))}return l}function f7({editor:t,options:e,dataAttribute:n}){return{init(r,i){const s=Ij({editor:t,options:e,dataAttribute:n,doc:i.doc,selection:i.selection});return s??kt.empty},apply(r,i,s,o){if(!r.docChanged&&!r.selectionSet)return i;const l=i.map(r.mapping,r.doc),u=c7(r,s,o);return d7({decorations:l,ranges:u,editor:t,options:e,dataAttribute:n,doc:o.doc,selection:o.selection})}}}function h7(t){return t.replace(/\s+/g,"-").replace(/[^a-zA-Z0-9-]/g,"").replace(/^[0-9-]+/,"").replace(/^-+/,"").toLowerCase()}function p7({editor:t,options:e}){const n=e.dataAttribute?`data-${h7(e.dataAttribute)}`:`data-${Mj}`,r=e.showOnlyCurrent&&!e.includeChildren;return new Lt({key:mR,...r?{}:{state:f7({editor:t,options:e,dataAttribute:n})},props:{decorations:r?({doc:i,selection:s})=>Ij({editor:t,options:e,dataAttribute:n,doc:i,selection:s}):i=>{var s;return e.showOnlyWhenEditable&&!t.isEditable?kt.empty:(s=mR.getState(i))!=null?s:kt.empty}}})}var m7=Ft.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",dataAttribute:Mj,placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[p7({editor:this.editor,options:this.options})]}});function Tx(t,e){return!t.selection.empty&&!EI(t.selection)&&e.isEditable}function g7(t,e){return Tx(t,e)&&!e.isFocused&&!e.view.dragging}function y7(){var t;(t=window.getSelection())==null||t.removeAllRanges()}function b7(t){t.focus()}Ft.create({name:"selection",addOptions(){return{className:"selection"}},addProseMirrorPlugins(){const{editor:t,options:e}=this;return[new Lt({key:new Qt("selection"),props:{decorations(n){return g7(n,t)?kt.create(n.doc,[Sn.inline(n.selection.from,n.selection.to,{class:e.className})]):null},handleDOMEvents:{blur(n){return Tx(n.state,t)&&y7(),!1},focus(n){return Tx(n.state,t)&&requestAnimationFrame(()=>{!t.isDestroyed&&n.hasFocus()&&b7(n)}),!1}}}})]}});var v7="skipTrailingNode";function gR({types:t,node:e}){return e&&Array.isArray(t)&&t.includes(e.type)||e?.type===t}var x7=Ft.create({name:"trailingNode",addOptions(){return{node:void 0,notAfter:[]}},addProseMirrorPlugins(){var t;const e=new Qt(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(([,i])=>i).filter(i=>(this.options.notAfter||[]).concat(n).includes(i.name));return[new Lt({key:e,appendTransaction:(i,s,o)=>{const{doc:l,tr:u,schema:f}=o,h=e.getState(o),m=l.content.size,g=f.nodes[n];if(!i.some(b=>b.getMeta(v7))&&h)return u.insert(m,g.create())},state:{init:(i,s)=>{const o=s.tr.doc.lastChild;return!gR({node:o,types:r})},apply:(i,s)=>{if(!i.docChanged||i.getMeta("__uniqueIDTransaction"))return s;const o=i.doc.lastChild;return!gR({node:o,types:r})}}})]}}),w7=Ft.create({name:"undoRedo",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>Aj(t,e),redo:()=>({state:t,dispatch:e})=>Rj(t,e)}},addProseMirrorPlugins(){return[r7(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()}}}),S7=Ft.create({name:"starterKit",addExtensions(){var t,e,n,r;const i=[];return this.options.bold!==!1&&i.push(a8.configure(this.options.bold)),this.options.blockquote!==!1&&i.push(n8.configure(this.options.blockquote)),this.options.bulletList!==!1&&i.push(hj.configure(this.options.bulletList)),this.options.code!==!1&&i.push(u8.configure(this.options.code)),this.options.codeBlock!==!1&&i.push(h8.configure(this.options.codeBlock)),this.options.document!==!1&&i.push(p8.configure(this.options.document)),this.options.dropcursor!==!1&&i.push(i7.configure(this.options.dropcursor)),this.options.gapcursor!==!1&&i.push(s7.configure(this.options.gapcursor)),this.options.hardBreak!==!1&&i.push(m8.configure(this.options.hardBreak)),this.options.heading!==!1&&i.push(g8.configure(this.options.heading)),this.options.undoRedo!==!1&&i.push(w7.configure(this.options.undoRedo)),this.options.horizontalRule!==!1&&i.push(y8.configure(this.options.horizontalRule)),this.options.italic!==!1&&i.push(S8.configure(this.options.italic)),this.options.listItem!==!1&&i.push(bj.configure(this.options.listItem)),this.options.listKeymap!==!1&&i.push(Sj.configure((t=this.options)==null?void 0:t.listKeymap)),this.options.link!==!1&&i.push(eW.configure((e=this.options)==null?void 0:e.link)),this.options.orderedList!==!1&&i.push(Cj.configure(this.options.orderedList)),this.options.paragraph!==!1&&i.push(IW.configure(this.options.paragraph)),this.options.strike!==!1&&i.push(PW.configure(this.options.strike)),this.options.text!==!1&&i.push(zW.configure(this.options.text)),this.options.underline!==!1&&i.push($W.configure((n=this.options)==null?void 0:n.underline)),this.options.trailingNode!==!1&&i.push(x7.configure((r=this.options)==null?void 0:r.trailingNode)),i}}),k7=S7;function TS(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var el=TS();function jj(t){el=t}var xa={exec:()=>null};function dt(t,e=""){let n=typeof t=="string"?t:t.source,r={replace:(i,s)=>{let o=typeof s=="string"?s:s.source;return o=o.replace(Qn.caret,"$1"),n=n.replace(i,o),r},getRegex:()=>new RegExp(n,e)};return r}var C7=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Qn={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},E7=/^(?:[ \t]*(?:\n|$))+/,T7=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,_7=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,af=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,A7=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,_S=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Lj=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Pj=dt(Lj).replace(/bull/g,_S).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),R7=dt(Lj).replace(/bull/g,_S).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),AS=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,M7=/^[^\n]+/,RS=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,N7=dt(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",RS).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),O7=dt(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,_S).getRegex(),hg="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",MS=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,D7=dt("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",MS).replace("tag",hg).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),zj=dt(AS).replace("hr",af).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",hg).getRegex(),I7=dt(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",zj).getRegex(),NS={blockquote:I7,code:T7,def:N7,fences:_7,heading:A7,hr:af,html:D7,lheading:Pj,list:O7,newline:E7,paragraph:zj,table:xa,text:M7},yR=dt("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",af).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",hg).getRegex(),j7={...NS,lheading:R7,table:yR,paragraph:dt(AS).replace("hr",af).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",yR).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",hg).getRegex()},L7={...NS,html:dt(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",MS).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:xa,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:dt(AS).replace("hr",af).replace("heading",` *#{1,6} *[^
|
|
208
|
+
]`).replace("lheading",Pj).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},P7=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,z7=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$j=/^( {2,}|\\)\n(?!\s*$)/,$7=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Lc=/[\p{P}\p{S}]/u,pg=/[\s\p{P}\p{S}]/u,OS=/[^\s\p{P}\p{S}]/u,B7=dt(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,pg).getRegex(),Bj=/(?!~)[\p{P}\p{S}]/u,V7=/(?!~)[\s\p{P}\p{S}]/u,H7=/(?:[^\s\p{P}\p{S}]|~)/u,U7=dt(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",C7?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Vj=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,F7=dt(Vj,"u").replace(/punct/g,Lc).getRegex(),q7=dt(Vj,"u").replace(/punct/g,Bj).getRegex(),Hj="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",G7=dt(Hj,"gu").replace(/notPunctSpace/g,OS).replace(/punctSpace/g,pg).replace(/punct/g,Lc).getRegex(),W7=dt(Hj,"gu").replace(/notPunctSpace/g,H7).replace(/punctSpace/g,V7).replace(/punct/g,Bj).getRegex(),K7=dt("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,OS).replace(/punctSpace/g,pg).replace(/punct/g,Lc).getRegex(),Z7=dt(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Lc).getRegex(),Y7="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",X7=dt(Y7,"gu").replace(/notPunctSpace/g,OS).replace(/punctSpace/g,pg).replace(/punct/g,Lc).getRegex(),J7=dt(/\\(punct)/,"gu").replace(/punct/g,Lc).getRegex(),Q7=dt(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),eK=dt(MS).replace("(?:-->|$)","-->").getRegex(),tK=dt("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",eK).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Rm=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,nK=dt(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Rm).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Uj=dt(/^!?\[(label)\]\[(ref)\]/).replace("label",Rm).replace("ref",RS).getRegex(),Fj=dt(/^!?\[(ref)\](?:\[\])?/).replace("ref",RS).getRegex(),rK=dt("reflink|nolink(?!\\()","g").replace("reflink",Uj).replace("nolink",Fj).getRegex(),bR=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,DS={_backpedal:xa,anyPunctuation:J7,autolink:Q7,blockSkip:U7,br:$j,code:z7,del:xa,delLDelim:xa,delRDelim:xa,emStrongLDelim:F7,emStrongRDelimAst:G7,emStrongRDelimUnd:K7,escape:P7,link:nK,nolink:Fj,punctuation:B7,reflink:Uj,reflinkSearch:rK,tag:tK,text:$7,url:xa},iK={...DS,link:dt(/^!?\[(label)\]\((.*?)\)/).replace("label",Rm).getRegex(),reflink:dt(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Rm).getRegex()},_x={...DS,emStrongRDelimAst:W7,emStrongLDelim:q7,delLDelim:Z7,delRDelim:X7,url:dt(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",bR).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:dt(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",bR).getRegex()},sK={..._x,br:dt($j).replace("{2,}","*").getRegex(),text:dt(_x.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},$h={normal:NS,gfm:j7,pedantic:L7},Vu={normal:DS,gfm:_x,breaks:sK,pedantic:iK},oK={"&":"&","<":"<",">":">",'"':""","'":"'"},vR=t=>oK[t];function _i(t,e){if(e){if(Qn.escapeTest.test(t))return t.replace(Qn.escapeReplace,vR)}else if(Qn.escapeTestNoEncode.test(t))return t.replace(Qn.escapeReplaceNoEncode,vR);return t}function xR(t){try{t=encodeURI(t).replace(Qn.percentDecode,"%")}catch{return null}return t}function wR(t,e){let n=t.replace(Qn.findPipe,(s,o,l)=>{let u=!1,f=o;for(;--f>=0&&l[f]==="\\";)u=!u;return u?"|":" |"}),r=n.split(Qn.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),e)if(r.length>e)r.splice(e);else for(;r.length<e;)r.push("");for(;i<r.length;i++)r[i]=r[i].trim().replace(Qn.slashPipe,"|");return r}function Hu(t,e,n){let r=t.length;if(r===0)return"";let i=0;for(;i<r&&t.charAt(r-i-1)===e;)i++;return t.slice(0,r-i)}function aK(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let r=0;r<t.length;r++)if(t[r]==="\\")r++;else if(t[r]===e[0])n++;else if(t[r]===e[1]&&(n--,n<0))return r;return n>0?-2:-1}function lK(t,e=0){let n=e,r="";for(let i of t)if(i===" "){let s=4-n%4;r+=" ".repeat(s),n+=s}else r+=i,n++;return r}function SR(t,e,n,r,i){let s=e.href,o=e.title||null,l=t[1].replace(i.other.outputLinkReplace,"$1");r.state.inLink=!0;let u={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:o,text:l,tokens:r.inlineTokens(l)};return r.state.inLink=!1,u}function cK(t,e,n){let r=t.match(n.other.indentCodeCompensation);if(r===null)return e;let i=r[1];return e.split(`
|
|
209
|
+
`).map(s=>{let o=s.match(n.other.beginningSpace);if(o===null)return s;let[l]=o;return l.length>=i.length?s.slice(i.length):s}).join(`
|
|
210
|
+
`)}var Mm=class{options;rules;lexer;constructor(t){this.options=t||el}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Hu(n,`
|
|
211
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],r=cK(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:r}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let r=Hu(n,"#");(this.options.pedantic||!r||this.rules.other.endingSpaceChar.test(r))&&(n=r.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Hu(e[0],`
|
|
212
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Hu(e[0],`
|
|
213
|
+
`).split(`
|
|
214
|
+
`),r="",i="",s=[];for(;n.length>0;){let o=!1,l=[],u;for(u=0;u<n.length;u++)if(this.rules.other.blockquoteStart.test(n[u]))l.push(n[u]),o=!0;else if(!o)l.push(n[u]);else break;n=n.slice(u);let f=l.join(`
|
|
215
|
+
`),h=f.replace(this.rules.other.blockquoteSetextReplace,`
|
|
216
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");r=r?`${r}
|
|
217
|
+
${f}`:f,i=i?`${i}
|
|
218
|
+
${h}`:h;let m=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,s,!0),this.lexer.state.top=m,n.length===0)break;let g=s.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let b=g,x=b.raw+`
|
|
219
|
+
`+n.join(`
|
|
220
|
+
`),S=this.blockquote(x);s[s.length-1]=S,r=r.substring(0,r.length-b.raw.length)+S.raw,i=i.substring(0,i.length-b.text.length)+S.text;break}else if(g?.type==="list"){let b=g,x=b.raw+`
|
|
221
|
+
`+n.join(`
|
|
222
|
+
`),S=this.list(x);s[s.length-1]=S,r=r.substring(0,r.length-g.raw.length)+S.raw,i=i.substring(0,i.length-b.raw.length)+S.raw,n=x.substring(s.at(-1).raw.length).split(`
|
|
223
|
+
`);continue}}return{type:"blockquote",raw:r,tokens:s,text:i}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),r=n.length>1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let s=this.rules.other.listItemRegex(n),o=!1;for(;t;){let u=!1,f="",h="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;f=e[0],t=t.substring(f.length);let m=lK(e[2].split(`
|
|
224
|
+
`,1)[0],e[1].length),g=t.split(`
|
|
225
|
+
`,1)[0],b=!m.trim(),x=0;if(this.options.pedantic?(x=2,h=m.trimStart()):b?x=e[1].length+1:(x=m.search(this.rules.other.nonSpaceChar),x=x>4?1:x,h=m.slice(x),x+=e[1].length),b&&this.rules.other.blankLine.test(g)&&(f+=g+`
|
|
226
|
+
`,t=t.substring(g.length+1),u=!0),!u){let S=this.rules.other.nextBulletRegex(x),k=this.rules.other.hrRegex(x),C=this.rules.other.fencesBeginRegex(x),A=this.rules.other.headingBeginRegex(x),R=this.rules.other.htmlBeginRegex(x),_=this.rules.other.blockquoteBeginRegex(x);for(;t;){let M=t.split(`
|
|
227
|
+
`,1)[0],O;if(g=M,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),O=g):O=g.replace(this.rules.other.tabCharGlobal," "),C.test(g)||A.test(g)||R.test(g)||_.test(g)||S.test(g)||k.test(g))break;if(O.search(this.rules.other.nonSpaceChar)>=x||!g.trim())h+=`
|
|
228
|
+
`+O.slice(x);else{if(b||m.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||C.test(m)||A.test(m)||k.test(m))break;h+=`
|
|
229
|
+
`+g}b=!g.trim(),f+=M+`
|
|
230
|
+
`,t=t.substring(M.length+1),m=O.slice(x)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(f)&&(o=!0)),i.items.push({type:"list_item",raw:f,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),i.raw+=f}let l=i.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let u of i.items){if(this.lexer.state.top=!1,u.tokens=this.lexer.blockTokens(u.text,[]),u.task){if(u.text=u.text.replace(this.rules.other.listReplaceTask,""),u.tokens[0]?.type==="text"||u.tokens[0]?.type==="paragraph"){u.tokens[0].raw=u.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),u.tokens[0].text=u.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let f=this.rules.other.listTaskCheckbox.exec(u.raw);if(f){let h={type:"checkbox",raw:f[0]+" ",checked:f[0]!=="[ ]"};u.checked=h.checked,i.loose?u.tokens[0]&&["paragraph","text"].includes(u.tokens[0].type)&&"tokens"in u.tokens[0]&&u.tokens[0].tokens?(u.tokens[0].raw=h.raw+u.tokens[0].raw,u.tokens[0].text=h.raw+u.tokens[0].text,u.tokens[0].tokens.unshift(h)):u.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):u.tokens.unshift(h)}}if(!i.loose){let f=u.tokens.filter(m=>m.type==="space"),h=f.length>0&&f.some(m=>this.rules.other.anyLine.test(m.raw));i.loose=h}}if(i.loose)for(let u of i.items){u.loose=!0;for(let f of u.tokens)f.type==="text"&&(f.type="paragraph")}return i}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),r=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",i=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:r,title:i}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=wR(e[1]),r=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),i=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
231
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let o of r)this.rules.other.tableAlignRight.test(o)?s.align.push("right"):this.rules.other.tableAlignCenter.test(o)?s.align.push("center"):this.rules.other.tableAlignLeft.test(o)?s.align.push("left"):s.align.push(null);for(let o=0;o<n.length;o++)s.header.push({text:n[o],tokens:this.lexer.inline(n[o]),header:!0,align:s.align[o]});for(let o of i)s.rows.push(wR(o,s.header.length).map((l,u)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[u]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
232
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Hu(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=aK(e[2],"()");if(s===-2)return;if(s>-1){let o=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,o).trim(),e[3]=""}}let r=e[2],i="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(r);s&&(r=s[1],i=s[3])}else i=e[3]?e[3].slice(1,-1):"";return r=r.trim(),this.rules.other.startAngleBracket.test(r)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?r=r.slice(1):r=r.slice(1,-1)),SR(e,{href:r&&r.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let r=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=e[r.toLowerCase()];if(!i){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return SR(n,i,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let r=this.rules.inline.emStrongLDelim.exec(t);if(!(!r||!r[1]&&!r[2]&&!r[3]&&!r[4]||r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[3])||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,l=i,u=0,f=r[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(f.lastIndex=0,e=e.slice(-1*t.length+i);(r=f.exec(e))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s)continue;if(o=[...s].length,r[3]||r[4]){l+=o;continue}else if((r[5]||r[6])&&i%3&&!((i+o)%3)){u+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l+u);let h=[...r[0]][0].length,m=t.slice(0,i+r.index+h+o);if(Math.min(i,o)%2){let b=m.slice(1,-1);return{type:"em",raw:m,text:b,tokens:this.lexer.inlineTokens(b)}}let g=m.slice(2,-2);return{type:"strong",raw:m,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),r=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return r&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let r=this.rules.inline.delLDelim.exec(t);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let i=[...r[0]].length-1,s,o,l=i,u=this.rules.inline.delRDelim;for(u.lastIndex=0,e=e.slice(-1*t.length+i);(r=u.exec(e))!==null;){if(s=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!s||(o=[...s].length,o!==i))continue;if(r[3]||r[4]){l+=o;continue}if(l-=o,l>0)continue;o=Math.min(o,o+l);let f=[...r[0]][0].length,h=t.slice(0,i+r.index+f+o),m=h.slice(i,-i);return{type:"del",raw:h,text:m,tokens:this.lexer.inlineTokens(m)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,r;return e[2]==="@"?(n=e[1],r="mailto:"+n):(n=e[1],r=n),{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,r;if(e[2]==="@")n=e[0],r="mailto:"+n;else{let i;do i=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(i!==e[0]);n=e[0],e[1]==="www."?r="http://"+e[0]:r=e[0]}return{type:"link",raw:e[0],text:n,href:r,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},li=class Ax{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||el,this.options.tokenizer=this.options.tokenizer||new Mm,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:Qn,block:$h.normal,inline:Vu.normal};this.options.pedantic?(n.block=$h.pedantic,n.inline=Vu.pedantic):this.options.gfm&&(n.block=$h.gfm,this.options.breaks?n.inline=Vu.breaks:n.inline=Vu.gfm),this.tokenizer.rules=n}static get rules(){return{block:$h,inline:Vu}}static lex(e,n){return new Ax(n).lex(e)}static lexInline(e,n){return new Ax(n).inlineTokens(e)}lex(e){e=e.replace(Qn.carriageReturn,`
|
|
233
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let r=this.inlineQueue[n];this.inlineTokens(r.src,r.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],r=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(Qn.tabCharGlobal," ").replace(Qn.spaceLine,""));e;){let i;if(this.options.extensions?.block?.some(o=>(i=o.call({lexer:this},e,n))?(e=e.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.space(e)){e=e.substring(i.raw.length);let o=n.at(-1);i.raw.length===1&&o!==void 0?o.raw+=`
|
|
234
|
+
`:n.push(i);continue}if(i=this.tokenizer.code(e)){e=e.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
235
|
+
`)?"":`
|
|
236
|
+
`)+i.raw,o.text+=`
|
|
237
|
+
`+i.text,this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(i=this.tokenizer.fences(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.heading(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.hr(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.blockquote(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.list(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.html(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.def(e)){e=e.substring(i.raw.length);let o=n.at(-1);o?.type==="paragraph"||o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
238
|
+
`)?"":`
|
|
239
|
+
`)+i.raw,o.text+=`
|
|
240
|
+
`+i.raw,this.inlineQueue.at(-1).src=o.text):this.tokens.links[i.tag]||(this.tokens.links[i.tag]={href:i.href,title:i.title},n.push(i));continue}if(i=this.tokenizer.table(e)){e=e.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.lheading(e)){e=e.substring(i.raw.length),n.push(i);continue}let s=e;if(this.options.extensions?.startBlock){let o=1/0,l=e.slice(1),u;this.options.extensions.startBlock.forEach(f=>{u=f.call({lexer:this},l),typeof u=="number"&&u>=0&&(o=Math.min(o,u))}),o<1/0&&o>=0&&(s=e.substring(0,o+1))}if(this.state.top&&(i=this.tokenizer.paragraph(s))){let o=n.at(-1);r&&o?.type==="paragraph"?(o.raw+=(o.raw.endsWith(`
|
|
241
|
+
`)?"":`
|
|
242
|
+
`)+i.raw,o.text+=`
|
|
243
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i),r=s.length!==e.length,e=e.substring(i.raw.length);continue}if(i=this.tokenizer.text(e)){e=e.substring(i.raw.length);let o=n.at(-1);o?.type==="text"?(o.raw+=(o.raw.endsWith(`
|
|
244
|
+
`)?"":`
|
|
245
|
+
`)+i.raw,o.text+=`
|
|
246
|
+
`+i.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):n.push(i);continue}if(e){let o="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(o);break}else throw new Error(o)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let r=e,i=null;if(this.tokens.links){let u=Object.keys(this.tokens.links);if(u.length>0)for(;(i=this.tokenizer.rules.inline.reflinkSearch.exec(r))!==null;)u.includes(i[0].slice(i[0].lastIndexOf("[")+1,-1))&&(r=r.slice(0,i.index)+"["+"a".repeat(i[0].length-2)+"]"+r.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(i=this.tokenizer.rules.inline.anyPunctuation.exec(r))!==null;)r=r.slice(0,i.index)+"++"+r.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(i=this.tokenizer.rules.inline.blockSkip.exec(r))!==null;)s=i[2]?i[2].length:0,r=r.slice(0,i.index+s)+"["+"a".repeat(i[0].length-s-2)+"]"+r.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);r=this.options.hooks?.emStrongMask?.call({lexer:this},r)??r;let o=!1,l="";for(;e;){o||(l=""),o=!1;let u;if(this.options.extensions?.inline?.some(h=>(u=h.call({lexer:this},e,n))?(e=e.substring(u.raw.length),n.push(u),!0):!1))continue;if(u=this.tokenizer.escape(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.tag(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.link(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(u.raw.length);let h=n.at(-1);u.type==="text"&&h?.type==="text"?(h.raw+=u.raw,h.text+=u.text):n.push(u);continue}if(u=this.tokenizer.emStrong(e,r,l)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.codespan(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.br(e)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.del(e,r,l)){e=e.substring(u.raw.length),n.push(u);continue}if(u=this.tokenizer.autolink(e)){e=e.substring(u.raw.length),n.push(u);continue}if(!this.state.inLink&&(u=this.tokenizer.url(e))){e=e.substring(u.raw.length),n.push(u);continue}let f=e;if(this.options.extensions?.startInline){let h=1/0,m=e.slice(1),g;this.options.extensions.startInline.forEach(b=>{g=b.call({lexer:this},m),typeof g=="number"&&g>=0&&(h=Math.min(h,g))}),h<1/0&&h>=0&&(f=e.substring(0,h+1))}if(u=this.tokenizer.inlineText(f)){e=e.substring(u.raw.length),u.raw.slice(-1)!=="_"&&(l=u.raw.slice(-1)),o=!0;let h=n.at(-1);h?.type==="text"?(h.raw+=u.raw,h.text+=u.text):n.push(u);continue}if(e){let h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return n}},Nm=class{options;parser;constructor(t){this.options=t||el}space(t){return""}code({text:t,lang:e,escaped:n}){let r=(e||"").match(Qn.notSpaceStart)?.[0],i=t.replace(Qn.endingNewline,"")+`
|
|
247
|
+
`;return r?'<pre><code class="language-'+_i(r)+'">'+(n?i:_i(i,!0))+`</code></pre>
|
|
248
|
+
`:"<pre><code>"+(n?i:_i(i,!0))+`</code></pre>
|
|
249
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
250
|
+
${this.parser.parse(t)}</blockquote>
|
|
251
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
252
|
+
`}hr(t){return`<hr>
|
|
253
|
+
`}list(t){let e=t.ordered,n=t.start,r="";for(let o=0;o<t.items.length;o++){let l=t.items[o];r+=this.listitem(l)}let i=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+i+s+`>
|
|
254
|
+
`+r+"</"+i+`>
|
|
255
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
256
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
257
|
+
`}table(t){let e="",n="";for(let i=0;i<t.header.length;i++)n+=this.tablecell(t.header[i]);e+=this.tablerow({text:n});let r="";for(let i=0;i<t.rows.length;i++){let s=t.rows[i];n="";for(let o=0;o<s.length;o++)n+=this.tablecell(s[o]);r+=this.tablerow({text:n})}return r&&(r=`<tbody>${r}</tbody>`),`<table>
|
|
258
|
+
<thead>
|
|
259
|
+
`+e+`</thead>
|
|
260
|
+
`+r+`</table>
|
|
261
|
+
`}tablerow({text:t}){return`<tr>
|
|
262
|
+
${t}</tr>
|
|
263
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
264
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${_i(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let r=this.parser.parseInline(n),i=xR(t);if(i===null)return r;t=i;let s='<a href="'+t+'"';return e&&(s+=' title="'+_i(e)+'"'),s+=">"+r+"</a>",s}image({href:t,title:e,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=xR(t);if(i===null)return _i(n);t=i;let s=`<img src="${t}" alt="${_i(n)}"`;return e&&(s+=` title="${_i(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:_i(t.text)}},IS=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},ci=class Rx{options;renderer;textRenderer;constructor(e){this.options=e||el,this.options.renderer=this.options.renderer||new Nm,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new IS}static parse(e,n){return new Rx(n).parse(e)}static parseInline(e,n){return new Rx(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=i,l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(o.type)){n+=l||"";continue}}let s=i;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let o='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let r="";for(let i=0;i<e.length;i++){let s=e[i];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){r+=l||"";continue}}let o=s;switch(o.type){case"escape":{r+=n.text(o);break}case"html":{r+=n.html(o);break}case"link":{r+=n.link(o);break}case"image":{r+=n.image(o);break}case"checkbox":{r+=n.checkbox(o);break}case"strong":{r+=n.strong(o);break}case"em":{r+=n.em(o);break}case"codespan":{r+=n.codespan(o);break}case"br":{r+=n.br(o);break}case"del":{r+=n.del(o);break}case"text":{r+=n.text(o);break}default:{let l='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return r}},ed=class{options;block;constructor(t){this.options=t||el}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?li.lex:li.lexInline}provideParser(t=this.block){return t?ci.parse:ci.parseInline}},uK=class{defaults=TS();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ci;Renderer=Nm;TextRenderer=IS;Lexer=li;Tokenizer=Mm;Hooks=ed;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let r of t)switch(n=n.concat(e.call(this,r)),r.type){case"table":{let i=r;for(let s of i.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of i.rows)for(let o of s)n=n.concat(this.walkTokens(o.tokens,e));break}case"list":{let i=r;n=n.concat(this.walkTokens(i.items,e));break}default:{let i=r;this.defaults.extensions?.childTokens?.[i.type]?this.defaults.extensions.childTokens[i.type].forEach(s=>{let o=i[s].flat(1/0);n=n.concat(this.walkTokens(o,e))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let r={...n};if(r.async=this.defaults.async||r.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let s=e.renderers[i.name];s?e.renderers[i.name]=function(...o){let l=i.renderer.apply(this,o);return l===!1&&(l=s.apply(this,o)),l}:e.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let s=e[i.level];s?s.unshift(i.tokenizer):e[i.level]=[i.tokenizer],i.start&&(i.level==="block"?e.startBlock?e.startBlock.push(i.start):e.startBlock=[i.start]:i.level==="inline"&&(e.startInline?e.startInline.push(i.start):e.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(e.childTokens[i.name]=i.childTokens)}),r.extensions=e),n.renderer){let i=this.defaults.renderer||new Nm(this.defaults);for(let s in n.renderer){if(!(s in i))throw new Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let o=s,l=n.renderer[o],u=i[o];i[o]=(...f)=>{let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h||""}}r.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new Mm(this.defaults);for(let s in n.tokenizer){if(!(s in i))throw new Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let o=s,l=n.tokenizer[o],u=i[o];i[o]=(...f)=>{let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h}}r.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new ed;for(let s in n.hooks){if(!(s in i))throw new Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let o=s,l=n.hooks[o],u=i[o];ed.passThroughHooks.has(s)?i[o]=f=>{if(this.defaults.async&&ed.passThroughHooksRespectAsync.has(s))return(async()=>{let m=await l.call(i,f);return u.call(i,m)})();let h=l.call(i,f);return u.call(i,h)}:i[o]=(...f)=>{if(this.defaults.async)return(async()=>{let m=await l.apply(i,f);return m===!1&&(m=await u.apply(i,f)),m})();let h=l.apply(i,f);return h===!1&&(h=u.apply(i,f)),h}}r.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,s=n.walkTokens;r.walkTokens=function(o){let l=[];return l.push(s.call(this,o)),i&&(l=l.concat(i.call(this,o))),l}}this.defaults={...this.defaults,...r}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return li.lex(t,e??this.defaults)}parser(t,e){return ci.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let r={...n},i={...this.defaults,...r},s=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return s(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=t),i.async)return(async()=>{let o=i.hooks?await i.hooks.preprocess(e):e,l=await(i.hooks?await i.hooks.provideLexer(t):t?li.lex:li.lexInline)(o,i),u=i.hooks?await i.hooks.processAllTokens(l):l;i.walkTokens&&await Promise.all(this.walkTokens(u,i.walkTokens));let f=await(i.hooks?await i.hooks.provideParser(t):t?ci.parse:ci.parseInline)(u,i);return i.hooks?await i.hooks.postprocess(f):f})().catch(s);try{i.hooks&&(e=i.hooks.preprocess(e));let o=(i.hooks?i.hooks.provideLexer(t):t?li.lex:li.lexInline)(e,i);i.hooks&&(o=i.hooks.processAllTokens(o)),i.walkTokens&&this.walkTokens(o,i.walkTokens);let l=(i.hooks?i.hooks.provideParser(t):t?ci.parse:ci.parseInline)(o,i);return i.hooks&&(l=i.hooks.postprocess(l)),l}catch(o){return s(o)}}}onError(t,e){return n=>{if(n.message+=`
|
|
265
|
+
Please report this to https://github.com/markedjs/marked.`,t){let r="<p>An error occurred:</p><pre>"+_i(n.message+"",!0)+"</pre>";return e?Promise.resolve(r):r}if(e)return Promise.reject(n);throw n}}},Ha=new uK;function Ct(t,e){return Ha.parse(t,e)}Ct.options=Ct.setOptions=function(t){return Ha.setOptions(t),Ct.defaults=Ha.defaults,jj(Ct.defaults),Ct};Ct.getDefaults=TS;Ct.defaults=el;Ct.use=function(...t){return Ha.use(...t),Ct.defaults=Ha.defaults,jj(Ct.defaults),Ct};Ct.walkTokens=function(t,e){return Ha.walkTokens(t,e)};Ct.parseInline=Ha.parseInline;Ct.Parser=ci;Ct.parser=ci.parse;Ct.Renderer=Nm;Ct.TextRenderer=IS;Ct.Lexer=li;Ct.lexer=li.lex;Ct.Tokenizer=Mm;Ct.Hooks=ed;Ct.parse=Ct;Ct.options;Ct.setOptions;Ct.use;Ct.walkTokens;Ct.parseInline;ci.parse;li.lex;var dK=/\n[^\S\n]*(?:\n[^\S\n]*)+$/;function fK(t){return t.flatMap((e,n)=>{var r;if(e.type==="space"||((r=t[n+1])==null?void 0:r.type)==="space")return[e];const i=(e.raw||"").match(dK);return i?[{...e,raw:(e.raw||"").slice(0,-i[0].length)},{type:"space",raw:i[0]}]:[e]})}function hK(t,e){const r=e.split(`
|
|
266
|
+
`).flatMap(i=>[i,""]).map(i=>`${t}${i}`).join(`
|
|
267
|
+
`);return r.slice(0,r.length-1)}function pK(t,e){const n=[];return Array.from(t.entries()).forEach(([r,i])=>{if(!e){n.push(r);return}(e.marks||[]).find(o=>o.type===r&&Ec(o.attrs,i.attrs))||n.push(r)}),n}function mK(t,e){const n=[];return Array.from(e.entries()).forEach(([r,i])=>{const s=t.get(r);(!s||!Ec(s.attrs,i.attrs))&&n.push({type:r,mark:i})}),n}function gK(t,e,n,r){const i=!n,s=n&&(!n.marks||n.marks.length===0),o=n&&n.marks&&!r(e,new Map(n.marks.map(u=>[u.type,u]))),l=[];return(i||s||o)&&(n&&n.marks?Array.from(t.entries()).reverse().forEach(([u,f])=>{n.marks.find(m=>m.type===u&&Ec(m.attrs,f.attrs))||l.push(u)}):(i||s)&&l.push(...Array.from(t.keys()).reverse())),l}function yK(t,e){let n="";return Array.from(t.keys()).reverse().forEach(r=>{const i=t.get(r),s=e(r,i);s&&(n=s+n)}),t.clear(),n}function bK(t,e,n){let r="";return Array.from(t.entries()).forEach(([i,s])=>{const o=n(i,s);o&&(r+=o),e.set(i,s)}),r}function Gv(t){const n=(t.raw||t.text||"").match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return n?{isTask:!0,checked:n[2].toLowerCase()==="x",indentLevel:n[1].length}:{isTask:!1,indentLevel:0}}function Bh(t,e){return typeof t!="string"?"json":e}var vK=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","circle","clippath","defs","ellipse","foreignobject","g","image","line","lineargradient","mask","path","polygon","polyline","radialgradient","rect","stop","switch","symbol","textpath","tspan","use","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),xK=/<\/?([a-zA-Z][\w-]*)/g;function wK(t){const e=[];let n;for(;(n=xK.exec(t))!==null;)e.push(n[1].toLowerCase());return e}function SK(t){const e=t.toLowerCase();return e.includes("-")?!1:!vK.has(e)}function kK(t,e){return wK(t).some(r=>SK(r)?!e.has(r):!1)}var CK=class{constructor(t){this.activeParseLexer=null,this.extensionRanks=new Map,this.baseExtensions=[],this.extensions=[],this.codeTypes=new Set,this.schemaParseDomTagsCache=null,this.lastParseResult=null;var e,n,r,i,s;this.markedInstance=(e=t?.marked)!=null?e:Ct,this.indentStyle=(r=(n=t?.indentation)==null?void 0:n.style)!=null?r:"space",this.indentSize=(s=(i=t?.indentation)==null?void 0:i.size)!=null?s:2,this.baseExtensions=t?.extensions||[],t?.markedOptions&&typeof this.markedInstance.setOptions=="function"&&this.markedInstance.setOptions(t.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,t?.extensions&&(this.baseExtensions=t.extensions,ac(ag(t.extensions)).forEach(l=>this.registerExtension(l)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle==="space"?" ":" "}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(t){var e,n;this.extensions.push(t);const r=mt(De(t,"code")),i=t.name;r&&this.codeTypes.add(i),this.extensionRanks.has(i)||this.extensionRanks.set(i,this.extensionRanks.size);const s=De(t,"markdownTokenName")||i,o=De(t,"parseMarkdown"),l=De(t,"renderMarkdown"),u=De(t,"markdownTokenizer"),f=(e=De(t,"markdownOptions"))!=null?e:null,h=(n=f?.indentsContent)!=null?n:!1,m=f?.htmlReopen,g={tokenName:s,nodeName:i,parseMarkdown:o,renderMarkdown:l,isIndenting:h,htmlReopen:m,tokenizer:u};if(s&&o){const b=this.registry.get(s)||[];b.push(g),this.registry.set(s,b)}if(l){const b=this.nodeTypeRegistry.get(i)||[];b.push(g),this.nodeTypeRegistry.set(i,b)}u&&this.hasMarked()&&this.registerTokenizer(u)}createLexer(){return new this.markedInstance.Lexer(this.markedInstance.defaults)}createTokenizerHelpers(t){return{inlineTokens:e=>t.inlineTokens(e),blockTokens:e=>t.blockTokens(e)}}tokenizeInline(t){var e;return((e=this.activeParseLexer)!=null?e:this.createLexer()).inlineTokens(t)}registerTokenizer(t){if(!this.hasMarked())return;const{name:e,start:n,level:r="inline",tokenize:i}=t,s=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this);let l;n?l=typeof n=="function"?n:f=>f.indexOf(n):l=f=>{const h=i(f,[],this.createTokenizerHelpers(this.createLexer()));return h&&h.raw?f.indexOf(h.raw):-1};const u={name:e,level:r,start:l,tokenizer(f,h){const m=this.lexer?s(this.lexer):s(o()),g=i(f,h,m);if(g&&g.type)return{...g,type:g.type||e,raw:g.raw||"",tokens:g.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[u]})}getHandlersForToken(t){try{return this.registry.get(t)||[]}catch{return[]}}getHandlerForToken(t){const e=this.getHandlersForToken(t);if(e.length>0)return e[0];const n=this.getHandlersForNodeType(t);return n.length>0?n[0]:void 0}getHandlersForNodeType(t){try{return this.nodeTypeRegistry.get(t)||[]}catch{return[]}}serialize(t){if(!t)return"";const e=this.renderNodes(t,t);return this.isEmptyOutput(e)?"":e}isEmptyOutput(t){return!t||t.trim()===""?!0:t.replace(/ /g,"").replace(/\u00A0/g,"").trim()===""}parse(t){if(!this.hasMarked())throw new Error("No marked instance available for parsing");const e=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{const r=n.lex(t);return{type:"doc",content:this.parseTokens(r,!0)}}finally{this.activeParseLexer=e}}parseTokens(t,e=!1){const n=e?fK(t):t,r=n.reduce((o,l,u)=>(l.type!=="space"&&o.push(u),o),[]);let i=-1,s=0;return n.flatMap((o,l)=>{for(var u;s<r.length&&r[s]<l;)i=r[s],s+=1;if(e&&o.type==="space"){const h=(u=r[s])!=null?u:-1;return this.createImplicitEmptyParagraphsFromSpace(o,i,h)}const f=this.parseToken(o,e);return f===null?[]:Array.isArray(f)?f:[f]})}createImplicitEmptyParagraphsFromSpace(t,e,n){const r=this.countParagraphSeparators(t.raw||"");if(r===0)return[];const s=Math.max(r-(e===-1||n===-1?0:1),0);return Array.from({length:s},()=>({type:"paragraph",content:[]}))}countParagraphSeparators(t){return(t.replace(/\r\n/g,`
|
|
268
|
+
`).match(/\n\n/g)||[]).length}parseToken(t,e=!1){if(!t.type)return null;if(t.type==="list")return this.parseListToken(t);const n=this.getHandlersForToken(t.type),r=this.createParseHelpers();if(n.find(s=>{if(!s.parseMarkdown)return!1;const o=s.parseMarkdown(t,r),l=this.normalizeParseResult(o);return l&&(!Array.isArray(l)||l.length>0)?(this.lastParseResult=l,!0):!1})&&this.lastParseResult){const s=this.lastParseResult;return this.lastParseResult=null,s}return this.parseFallbackToken(t,e)}parseListToken(t){if(!t.items||t.items.length===0)return this.parseTokenWithHandlers(t);const e=t.items.some(l=>Gv(l).isTask),n=t.items.some(l=>!Gv(l).isTask);if(!e||!n||this.getHandlersForToken("taskList").length===0)return this.parseTokenWithHandlers(t);const r=[];let i=[],s=null;for(let l=0;l<t.items.length;l+=1){const u=t.items[l],{isTask:f,checked:h,indentLevel:m}=Gv(u);let g=u;if(f){const S=(u.raw||u.text||"").split(`
|
|
269
|
+
`),k=S[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),C=k?k[2]:"";let A=[];if(S.length>1&&S.slice(1).join(`
|
|
270
|
+
`).trim()){const _=S.slice(1),M=_.filter(O=>O.trim());if(M.length>0){const O=Math.min(...M.map(P=>P.length-P.trimStart().length)),I=_.map(P=>P.trim()?P.slice(O):"").join(`
|
|
271
|
+
`).trim();I&&(A=this.markedInstance.lexer(`${I}
|
|
272
|
+
`))}}g={type:"taskItem",raw:"",mainContent:C,indentLevel:m,checked:h??!1,text:C,tokens:this.tokenizeInline(C),nestedTokens:A}}const b=f?"taskList":"list";s!==b?(i.length>0&&r.push({type:s,items:i}),i=[g],s=b):i.push(g)}i.length>0&&r.push({type:s,items:i});const o=[];for(let l=0;l<r.length;l+=1){const u=r[l],f={...t,type:u.type,items:u.items},h=this.parseToken(f);h&&(Array.isArray(h)?o.push(...h):o.push(h))}return o.length>0?o:null}parseTokenWithHandlers(t){if(!t.type)return null;const e=this.getHandlersForToken(t.type),n=this.createParseHelpers();if(e.find(i=>{if(!i.parseMarkdown)return!1;const s=i.parseMarkdown(t,n),o=this.normalizeParseResult(s);return o&&(!Array.isArray(o)||o.length>0)?(this.lastParseResult=o,!0):!1})&&this.lastParseResult){const i=this.lastParseResult;return this.lastParseResult=null,i}return this.parseFallbackToken(t)}createParseHelpers(){return{parseInline:t=>this.parseInlineTokens(t),tokenizeInline:t=>this.tokenizeInline(t),parseChildren:t=>this.parseTokens(t),parseBlockChildren:t=>this.parseTokens(t,!0),createTextNode:(t,e)=>({type:"text",text:t,marks:e||void 0}),createNode:(t,e,n)=>{const r={type:t,attrs:e||void 0,content:n||void 0};return(!e||Object.keys(e).length===0)&&delete r.attrs,r},applyMark:(t,e,n)=>({mark:t,content:e,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}parseInlineTokens(t){var e,n,r,i;const s=[];for(let o=0;o<t.length;o+=1){const l=t[o];if(l.type==="text")s.push({type:"text",text:WA(l.text||"")});else if(l.type==="escape")s.push({type:"text",text:l.text||""});else if(l.type==="html"){const u=((n=(e=l.raw)!=null?e:l.text)!=null?n:"").toString(),f=/^<\/[\s]*[\w-]+/i.test(u),h=u.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!f&&h&&!/\/>$/.test(u)){const g=h[1],b=this.escapeRegex(g),x=new RegExp(`^<\\/\\s*${b}\\b`,"i");let S=-1;const k=[u];for(let C=o+1;C<t.length;C+=1){const A=t[C],R=((i=(r=A.raw)!=null?r:A.text)!=null?i:"").toString();if(k.push(R),A.type==="html"&&x.test(R)){S=C;break}}if(S!==-1){const C=k.join(""),A={type:"html",raw:C,text:C,block:!1},R=this.parseHTMLToken(A);if(R){const _=this.normalizeParseResult(R);Array.isArray(_)?s.push(..._):_&&s.push(_)}o=S;continue}}const m=this.parseHTMLToken(l);if(m){const g=this.normalizeParseResult(m);Array.isArray(g)?s.push(...g):g&&s.push(g)}}else if(l.type){const u=this.getHandlerForToken(l.type);if(u&&u.parseMarkdown){const f=this.createParseHelpers(),h=u.parseMarkdown(l,f);if(this.isMarkResult(h)){const m=this.applyMarkToContent(h.mark,h.content,h.attrs);s.push(...m)}else{const m=this.normalizeParseResult(h);Array.isArray(m)?s.push(...m):m&&s.push(m)}}else l.tokens&&s.push(...this.parseInlineTokens(l.tokens))}}for(let o=s.length-1;o>0;o-=1){const l=s[o],u=s[o-1];if(l.type==="text"&&u.type==="text"){const f=l.marks||[],h=u.marks||[];z9(f,h)&&(u.text=(u.text||"")+(l.text||""),s.splice(o,1))}}return s}applyMarkToContent(t,e,n){return e.map(r=>{if(r.type==="text"){const i=r.marks||[],s=n?{type:t,attrs:n}:{type:t};return{...r,marks:[...i,s]}}return{...r,content:r.content?this.applyMarkToContent(t,r.content,n):void 0}})}isMarkResult(t){return t&&typeof t=="object"&&"mark"in t}normalizeParseResult(t){return t?this.isMarkResult(t)?t.content:t:null}parseFallbackToken(t,e=!1){switch(t.type){case"paragraph":return{type:"paragraph",content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"heading":return{type:"heading",attrs:{level:t.depth||1},content:t.tokens?this.parseInlineTokens(t.tokens):[]};case"text":return{type:"text",text:WA(t.text||"")};case"html":return this.parseHTMLToken(t);case"escape":return{type:"text",text:t.text||""};case"space":return null;default:return t.tokens?this.parseTokens(t.tokens,e):null}}parseHTMLToken(t){const e=t.text||t.raw||"";if(!e.trim())return null;if(this.isUnrecognizedHtml(e))return this.htmlAsLiteralText(e,!!t.block);if(typeof window>"u"||typeof window.DOMParser>"u")return this.htmlAsLiteralText(e,!!t.block);try{const n=Gq(e,this.baseExtensions);return n.type==="doc"&&n.content?t.block?n.content:n.content.length===1&&n.content[0].type==="paragraph"&&n.content[0].content?n.content[0].content:n.content:n}catch(n){throw new Error(`Failed to parse HTML in markdown: ${n}`)}}isUnrecognizedHtml(t){return kK(t,this.getSchemaParseDomTags())}getSchemaParseDomTags(){if(this.schemaParseDomTagsCache)return this.schemaParseDomTagsCache;const t=new Set;try{const e=wI(this.baseExtensions),n=r=>{const i=r?.parseDOM;Array.isArray(i)&&i.forEach(s=>{if(typeof s?.tag=="string"){const o=s.tag.match(/^[a-zA-Z][\w-]*/);o&&t.add(o[0].toLowerCase())}})};Object.values(e.nodes).forEach(r=>n(r.spec)),Object.values(e.marks).forEach(r=>n(r.spec))}catch{}return this.schemaParseDomTagsCache=t,t}htmlAsLiteralText(t,e){const n=t.replace(/\s+$/,"");return n?e?{type:"paragraph",content:[{type:"text",text:n}]}:{type:"text",text:n}:null}encodeTextForMarkdown(t,e,n){return n?.type!=null&&this.codeTypes.has(n.type)||(e.marks||[]).some(i=>this.codeTypes.has(typeof i=="string"?i:i.type))?t:this.escapeMarkdownSyntax(R9(t))}escapeMarkdownSyntax(t){return t.replace(/([\\`*_[\]~])/g,"\\$1")}renderNodeToMarkdown(t,e,n=0,r=0,i={}){var s;if(t.type==="text")return this.encodeTextForMarkdown(t.text||"",t,e);if(!t.type)return"";const o=this.getHandlerForToken(t.type);if(!o)return"";const l=Array.isArray(e?.content)&&n>0?e.content[n-1]:void 0,u={renderChildren:(m,g)=>{const b=o.isIndenting?r+1:r;return!Array.isArray(m)&&m.content?this.renderNodes(m.content,t,g||"",n,b):this.renderNodes(m,t,g||"",n,b)},renderChild:(m,g)=>{const b=o.isIndenting?r+1:r;return this.renderNodeToMarkdown(m,t,g,b)},indent:m=>this.indentString+m,wrapInBlock:hK},f={index:n,level:r,parentType:e?.type,previousNode:l,meta:{parentAttrs:e?.attrs,...i}};return((s=o.renderMarkdown)==null?void 0:s.call(o,t,u,f))||""}renderNodes(t,e,n="",r=0,i=0){return Array.isArray(t)?this.renderNodesWithMarkBoundaries(t,e,n,i):t.type?this.renderNodeToMarkdown(t,e,r,i):""}renderNodesWithMarkBoundaries(t,e,n="",r=0){const i=[],s=new Map,o=new Set,l=new Map;return t.forEach((u,f)=>{const h=f<t.length-1?t[f+1]:null;if(u.type)if(u.type==="text"){let m=this.encodeTextForMarkdown(u.text||"",u,e);const g=new Map((u.marks||[]).map(M=>[M.type,M])),b=this.getMarksToOpenForSerialization(s,g,h),x=pK(g,h),S=x.filter(M=>s.has(M)),k=S.length>0&&b.length>0;let C="";if(x.length>0&&!k){const M=m.match(/(\s+)$/);M&&(C=M[1],m=m.slice(0,-C.length))}k||x.slice().reverse().forEach(M=>{if(!s.has(M))return;const O=g.get(M),D=this.getMarkClosing(M,O,l.get(M));D&&(m+=D),s.has(M)&&(s.delete(M),l.delete(M))});let A="";if(b.length>0){const M=m.match(/^(\s+)/);M&&(A=M[1],m=m.slice(A.length))}b.forEach(({type:M,mark:O})=>{const D=o.has(M)?"html":"markdown",I=this.getMarkOpening(M,O,D);I&&(m=I+m),l.set(M,D),o.delete(M)}),k||b.slice().reverse().forEach(({type:M,mark:O})=>{s.set(M,O)}),m=A+m;let R;if(k){const M=new Set((h?.marks||[]).map(I=>I.type));b.forEach(({type:I})=>{M.has(I)&&this.getHtmlReopenTags(I)&&o.add(I)});const O=Array.from(s.keys()),D=S.slice().sort((I,P)=>O.indexOf(P)-O.indexOf(I));R=[...b.map(I=>I.type),...D]}else R=gK(s,g,h,this.markSetsEqual.bind(this));let _="";if(R.length>0){const M=m.match(/(\s+)$/);M&&(_=M[1],m=m.slice(0,-_.length))}R.forEach(M=>{var O;const D=(O=s.get(M))!=null?O:g.get(M),I=this.getMarkClosing(M,D,l.get(M));I&&(m+=I),s.delete(M),l.delete(M)}),m+=_,m+=C,i.push(m)}else{const m=new Set((u.marks||[]).map(C=>C.type)),g=new Map,b=new Map;s.forEach((C,A)=>{var R;m.has(A)&&(g.set(A,C),b.set(A,(R=l.get(A))!=null?R:"markdown"))});const x=yK(s,(C,A)=>this.getMarkClosing(C,A,l.get(C)));l.clear();const S=this.renderNodeToMarkdown(u,e,f,r),k=u.type==="hardBreak"?"":bK(g,s,(C,A)=>{var R;const _=(R=b.get(C))!=null?R:"markdown";return l.set(C,_),this.getMarkOpening(C,A,_)});i.push(x+S+k)}}),i.join(n)}getMarkOpening(t,e,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(t))==null?void 0:r.open)||"";const i=this.getHandlersForNodeType(t),s=i.length>0?i[0]:void 0;if(!s||!s.renderMarkdown)return"";const o="__TIPTAP_MARKDOWN_PLACEHOLDER__",l={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const u=s.renderMarkdown(l,{renderChildren:()=>o,renderChild:()=>o,indent:h=>h,wrapInBlock:(h,m)=>h+m},{index:0,level:0,parentType:"text",meta:{}}),f=u.indexOf(o);return f>=0?u.substring(0,f):""}catch(u){throw new Error(`Failed to get mark opening for ${t}: ${u}`)}}getMarkClosing(t,e,n="markdown"){var r;if(n==="html")return((r=this.getHtmlReopenTags(t))==null?void 0:r.close)||"";const i=this.getHandlersForNodeType(t),s=i.length>0?i[0]:void 0;if(!s||!s.renderMarkdown)return"";const o="__TIPTAP_MARKDOWN_PLACEHOLDER__",l={type:t,attrs:e.attrs||{},content:[{type:"text",text:o}]};try{const u=s.renderMarkdown(l,{renderChildren:()=>o,renderChild:()=>o,indent:m=>m,wrapInBlock:(m,g)=>m+g},{index:0,level:0,parentType:"text",meta:{}}),f=u.indexOf(o),h=f+o.length;return f>=0?u.substring(h):""}catch(u){throw new Error(`Failed to get mark closing for ${t}: ${u}`)}}getHtmlReopenTags(t){const e=this.getHandlersForNodeType(t),n=e.length>0?e[0]:void 0;return n?.htmlReopen}markSetsEqual(t,e){return t.size!==e.size?!1:Array.from(t.entries()).every(([n,r])=>{const i=e.get(n);return i&&Ec(r.attrs,i.attrs)})}getMarksToOpenForSerialization(t,e,n){const r=mK(t,e);if(r.length<=1)return r;const i=n?.marks||[],s=(f,h)=>i.some(m=>m.type===f&&Ec(m.attrs,h)),o=(f,h)=>{var m,g;const b=(m=this.extensionRanks.get(f.type))!=null?m:Number.MAX_SAFE_INTEGER,x=(g=this.extensionRanks.get(h.type))!=null?g:Number.MAX_SAFE_INTEGER;return b!==x?x-b:f.type.localeCompare(h.type)},l=r.filter(f=>!s(f.type,f.mark.attrs)).sort(o),u=r.filter(f=>s(f.type,f.mark.attrs)).sort(o);return[...l,...u]}},kR=CK,EK=Ft.create({name:"markdown",addOptions(){return{indentation:{style:"space",size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(t,e)=>{if(!e?.contentType||Bh(t,e?.contentType)!=="markdown"||!this.editor.markdown)return oi.setContent(t,e);const r=this.editor.markdown.parse(t);return oi.setContent(r,e)},insertContent:(t,e)=>{if(!e?.contentType||Bh(t,e?.contentType)!=="markdown"||!this.editor.markdown)return oi.insertContent(t,e);const r=this.editor.markdown.parse(t);return oi.insertContent(r,e)},insertContentAt:(t,e,n)=>{if(!n?.contentType||Bh(e,n?.contentType)!=="markdown"||!this.editor.markdown)return oi.insertContentAt(t,e,n);const i=this.editor.markdown.parse(e);return oi.insertContentAt(t,i,n)}}},addStorage(){return{manager:new kR({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){var t;if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new kR({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||Bh(this.editor.options.content,this.editor.options.contentType)!=="markdown")return;if(!this.editor.markdown)throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!="string")throw new Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');const n=this.editor.markdown.parse(this.editor.options.content);(t=n.content)!=null&&t.length&&(this.editor.options.content=n)}}),TK=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,_K=Tn.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",jt(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,i,s,o;const l=(n=(e=t.attrs)==null?void 0:e.src)!=null?n:"",u=(i=(r=t.attrs)==null?void 0:r.alt)!=null?i:"",f=(o=(s=t.attrs)==null?void 0:s.title)!=null?o:"";return f?``:``},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,i=new Set(["src","width","height"]);return({node:s,getPos:o,HTMLAttributes:l,editor:u})=>{const f=document.createElement("img");f.draggable=!1;const h=jt(this.options.HTMLAttributes,l);Object.entries(h).forEach(([k,C])=>{if(C!=null)switch(k){case"src":case"width":case"height":break;default:f.setAttribute(k,C);break}}),h.src!==null&&(f.src=h.src);let m={...l};const g=k=>{if(typeof k=="string"&&k!==""){f.getAttribute("src")!==k&&(f.src=k);return}f.hasAttribute("src")&&f.removeAttribute("src"),f.src!==""&&(f.src="")};g(l.src);const b=k=>{if(k.type!==s.type)return!1;const C=u.extensionManager.attributes.filter(R=>R.type===k.type.name),A=Cc(k,C);return Object.keys(m).forEach(R=>{!i.has(R)&&!(R in A)&&f.removeAttribute(R)}),Object.entries(A).forEach(([R,_])=>{i.has(R)||(_!=null?f.setAttribute(R,_):f.removeAttribute(R))}),g(A.src),m=A,!0},x=new X9({element:f,editor:u,node:s,getPos:o,onResize:(k,C)=>{f.style.width=`${k}px`,f.style.height=`${C}px`},onCommit:(k,C)=>{const A=o();A!==void 0&&this.editor.chain().setNodeSelection(A).updateAttributes(this.name,{width:k,height:C}).run()},onUpdate:b,options:{directions:t,min:{width:e,height:n},preserveAspectRatio:r===!0}}),S=x.dom;return S.style.visibility="hidden",S.style.pointerEvents="none",f.onload=()=>{S.style.visibility="",S.style.pointerEvents=""},x}},addCommands(){return{setImage:t=>({commands:e})=>e.insertContent({type:this.name,attrs:t})}},addInputRules(){return[FI({find:TK,type:this.type,getAttributes:t=>{const[,,e,n,r]=t;return{src:n,alt:e,title:r}}})]}}),AK=_K;let Mx,Nx;if(typeof WeakMap<"u"){let t=new WeakMap;Mx=e=>t.get(e),Nx=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;Mx=r=>{for(let i=0;i<t.length;i+=2)if(t[i]==r)return t[i+1]},Nx=(r,i)=>(n==10&&(n=0),t[n++]=r,t[n++]=i)}var Jt=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,i=e/this.width|0;let s=r+1,o=i+1;for(let l=1;s<this.width&&this.map[e+l]==n;l++)s++;for(let l=1;o<this.height&&this.map[e+this.width*l]==n;l++)o++;return{left:r,top:i,right:s,bottom:o}}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:i,top:s,bottom:o}=this.findCell(t);return e=="horiz"?(n<0?r==0:i==this.width)?null:this.map[s*this.width+(n<0?r-1:i)]:(n<0?s==0:o==this.height)?null:this.map[r+this.width*(n<0?s-1:o)]}rectBetween(t,e){const{left:n,right:r,top:i,bottom:s}=this.findCell(t),{left:o,right:l,top:u,bottom:f}=this.findCell(e);return{left:Math.min(n,o),top:Math.min(i,u),right:Math.max(r,l),bottom:Math.max(s,f)}}cellsInRect(t){const e=[],n={};for(let r=t.top;r<t.bottom;r++)for(let i=t.left;i<t.right;i++){const s=r*this.width+i,o=this.map[s];n[o]||(n[o]=!0,!(i==t.left&&i&&this.map[s-1]==o||r==t.top&&r&&this.map[s-this.width]==o)&&e.push(o))}return e}positionAt(t,e,n){for(let r=0,i=0;;r++){const s=i+n.child(r).nodeSize;if(r==t){let o=e+t*this.width;const l=(t+1)*this.width;for(;o<l&&this.map[o]<i;)o++;return o==l?s-1:this.map[o]}i=s}}static get(t){return Mx(t)||Nx(t,RK(t))}};function RK(t){if(t.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+t.type.name);const e=MK(t),n=t.childCount,r=[];let i=0,s=null;const o=[];for(let f=0,h=e*n;f<h;f++)r[f]=0;for(let f=0,h=0;f<n;f++){const m=t.child(f);h++;for(let x=0;;x++){for(;i<r.length&&r[i]!=0;)i++;if(x==m.childCount)break;const S=m.child(x),{colspan:k,rowspan:C,colwidth:A}=S.attrs;for(let R=0;R<C;R++){if(R+f>=n){(s||(s=[])).push({type:"overlong_rowspan",pos:h,n:C-R});break}const _=i+R*e;for(let M=0;M<k;M++){r[_+M]==0?r[_+M]=h:(s||(s=[])).push({type:"collision",row:f,pos:h,n:k-M});const O=A&&A[M];if(O){const D=(_+M)%e*2,I=o[D];I==null||I!=O&&o[D+1]==1?(o[D]=O,o[D+1]=1):I==O&&o[D+1]++}}}i+=k,h+=S.nodeSize}const g=(f+1)*e;let b=0;for(;i<g;)r[i++]==0&&b++;b&&(s||(s=[])).push({type:"missing",row:f,n:b}),h++}(e===0||n===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Jt(e,n,r,s);let u=!1;for(let f=0;!u&&f<o.length;f+=2)o[f]!=null&&o[f+1]<n&&(u=!0);return u&&NK(l,o,t),l}function MK(t){let e=-1,n=!1;for(let r=0;r<t.childCount;r++){const i=t.child(r);let s=0;if(n)for(let o=0;o<r;o++){const l=t.child(o);for(let u=0;u<l.childCount;u++){const f=l.child(u);o+f.attrs.rowspan>r&&(s+=f.attrs.colspan)}}for(let o=0;o<i.childCount;o++){const l=i.child(o);s+=l.attrs.colspan,l.attrs.rowspan>1&&(n=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function NK(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;i<t.map.length;i++){const s=t.map[i];if(r[s])continue;r[s]=!0;const o=n.nodeAt(s);if(!o)throw new RangeError(`No cell with offset ${s} found`);let l=null;const u=o.attrs;for(let f=0;f<u.colspan;f++){const h=e[(i+f)%t.width*2];h!=null&&(!u.colwidth||u.colwidth[f]!=h)&&((l||(l=OK(u)))[f]=h)}l&&t.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function OK(t){if(t.colwidth)return t.colwidth.slice();const e=[];for(let n=0;n<t.colspan;n++)e.push(0);return e}function Wn(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}const So=new Qt("selectingCells");function Ua(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 DK(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 vi(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 mg(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=Ua(e.$head)||IK(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function IK(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 Ox(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function jK(t){return t.node(0).resolve(t.pos+t.nodeAfter.nodeSize)}function jS(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function qj(t,e,n){const r=t.node(-1),i=Jt.get(r),s=t.start(-1),o=i.nextCell(t.pos-s,e,n);return o==null?null:t.node(0).resolve(s+o)}function Fa(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(i=>i>0)||(r.colwidth=null)),r}function Gj(t,e,n=1){const r={...t,colspan:t.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let i=0;i<n;i++)r.colwidth.splice(e,0,0)}return r}function LK(t,e,n){const r=Wn(e.type.schema).header_cell;for(let i=0;i<t.height;i++)if(e.nodeAt(t.map[n+i*t.width]).type!=r)return!1;return!0}var It=class fs extends Ke{constructor(e,n=e){const r=e.node(-1),i=Jt.get(r),s=e.start(-1),o=i.rectBetween(e.pos-s,n.pos-s),l=e.node(0),u=i.cellsInRect(o).filter(h=>h!=n.pos-s);u.unshift(n.pos-s);const f=u.map(h=>{const m=r.nodeAt(h);if(!m)throw new RangeError(`No cell with offset ${h} found`);const g=s+h+1;return new uD(l.resolve(g),l.resolve(g+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)),i=e.resolve(n.map(this.$headCell.pos));if(Ox(r)&&Ox(i)&&jS(r,i)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?fs.rowSelection(r,i):s&&this.isColSelection()?fs.colSelection(r,i):new fs(r,i)}return ze.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=Jt.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},o=[];for(let u=i.top;u<i.bottom;u++){const f=[];for(let h=u*n.width+i.left,m=i.left;m<i.right;m++,h++){const g=n.map[h];if(s[g])continue;s[g]=!0;const b=n.findCell(g);let x=e.nodeAt(g);if(!x)throw new RangeError(`No cell with offset ${g} found`);const S=i.left-b.left,k=b.right-i.right;if(S>0||k>0){let C=x.attrs;if(S>0&&(C=Fa(C,0,S)),k>0&&(C=Fa(C,C.colspan-k,k)),b.left<i.left){if(x=x.type.createAndFill(C),!x)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(C)}`)}else x=x.type.create(C,x.content)}if(b.top<i.top||b.bottom>i.bottom){const C={...x.attrs,rowspan:Math.min(b.bottom,i.bottom)-Math.max(b.top,i.top)};b.top<i.top?x=x.type.createAndFill(C):x=x.type.create(C,x.content)}f.push(x)}o.push(e.child(u).copy(de.from(f)))}const l=this.isColSelection()&&this.isRowSelection()?e:o;return new Ee(de.from(l),1,1)}replace(e,n=Ee.empty){const r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){const{$from:l,$to:u}=i[o],f=e.mapping.slice(r);e.replace(f.map(l.pos),f.map(u.pos),o?Ee.empty:n)}const s=Ke.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,n){this.replace(e,new Ee(de.from(n),0,0))}forEachCell(e){const n=this.$anchorCell.node(-1),r=Jt.get(n),i=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-i,this.$headCell.pos-i));for(let o=0;o<s.length;o++)e(n.nodeAt(s[o]),i+s[o])}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,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=Jt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),u=e.node(0);return o.top<=l.top?(o.top>0&&(e=u.resolve(s+i.map[o.left])),l.bottom<i.height&&(n=u.resolve(s+i.map[i.width*(i.height-1)+l.right-1]))):(l.top>0&&(n=u.resolve(s+i.map[l.left])),o.bottom<i.height&&(e=u.resolve(s+i.map[i.width*(i.height-1)+o.right-1]))),new fs(e,n)}isRowSelection(){const e=this.$anchorCell.node(-1),n=Jt.get(e),r=this.$anchorCell.start(-1),i=n.colCount(this.$anchorCell.pos-r),s=n.colCount(this.$headCell.pos-r);if(Math.min(i,s)>0)return!1;const o=i+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(o,l)==n.width}eq(e){return e instanceof fs&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=Jt.get(r),s=e.start(-1),o=i.findCell(e.pos-s),l=i.findCell(n.pos-s),u=e.node(0);return o.left<=l.left?(o.left>0&&(e=u.resolve(s+i.map[o.top*i.width])),l.right<i.width&&(n=u.resolve(s+i.map[i.width*(l.top+1)-1]))):(l.left>0&&(n=u.resolve(s+i.map[l.top*i.width])),o.right<i.width&&(e=u.resolve(s+i.map[i.width*(o.top+1)-1]))),new fs(e,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,n){return new fs(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){return new fs(e.resolve(n),e.resolve(r))}getBookmark(){return new PK(this.$anchorCell.pos,this.$headCell.pos)}};It.prototype.visible=!1;Ke.jsonID("cell",It);var PK=class Wj{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Wj(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&&jS(n,r)?new It(n,r):Ke.near(r,1)}};function zK(t){if(!(t.selection instanceof It))return null;const e=[];return t.selection.forEachCell((n,r)=>{e.push(Sn.node(r,r+n.nodeSize,{class:"selectedCell"}))}),kt.create(t.doc,e)}function $K({$from:t,$to:e}){if(t.pos==e.pos||t.pos<e.pos-6)return!1;let n=t.pos,r=e.pos,i=t.depth;for(;i>=0&&!(t.after(i+1)<t.end(i));i--,n++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function BK({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const s=t.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){n=s;break}}for(let i=e.depth;i>0;i--){const s=e.node(i);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return n!==r&&e.parentOffset===0}function VK(t,e,n){const r=(e||t).selection,i=(e||t).doc;let s,o;if(r instanceof He&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")s=It.create(i,r.from);else if(o=="row"){const l=i.resolve(r.from+1);s=It.rowSelection(l,l)}else if(!n){const l=Jt.get(r.node),u=r.from+1,f=u+l.map[l.width*l.height-1];s=It.create(i,u+1,f)}}else r instanceof ze&&$K(r)?s=ze.create(i,r.from):r instanceof ze&&BK(r)&&(s=ze.create(i,r.$from.start(),r.$from.end()));return s&&(e||(e=t.tr)).setSelection(s),e}const HK=new Qt("fix-tables");function Kj(t,e,n,r){const i=t.childCount,s=e.childCount;e:for(let o=0,l=0;o<s;o++){const u=e.child(o);for(let f=l,h=Math.min(i,o+3);f<h;f++)if(t.child(f)==u){l=f+1,n+=u.nodeSize;continue e}r(u,n),l<i&&t.child(l).sameMarkup(u)?Kj(t.child(l),u,n+1,r):u.nodesBetween(0,u.content.size,r,n+1),n+=u.nodeSize}}function Zj(t,e){let n;const r=(i,s)=>{i.type.spec.tableRole=="table"&&(n=UK(t,i,s,n))};return e?e.doc!=t.doc&&Kj(e.doc,t.doc,0,r):t.doc.descendants(r),n}function UK(t,e,n,r){const i=Jt.get(e);if(!i.problems)return r;r||(r=t.tr);const s=[];for(let u=0;u<i.height;u++)s.push(0);for(let u=0;u<i.problems.length;u++){const f=i.problems[u];if(f.type=="collision"){const h=e.nodeAt(f.pos);if(!h)continue;const m=h.attrs;for(let g=0;g<m.rowspan;g++)s[f.row+g]+=f.n;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,Fa(m,m.colspan-f.n,f.n))}else if(f.type=="missing")s[f.row]+=f.n;else if(f.type=="overlong_rowspan"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,rowspan:h.attrs.rowspan-f.n})}else if(f.type=="colwidth mismatch"){const h=e.nodeAt(f.pos);if(!h)continue;r.setNodeMarkup(r.mapping.map(n+1+f.pos),null,{...h.attrs,colwidth:f.colwidth})}else if(f.type=="zero_sized"){const h=r.mapping.map(n);r.delete(h,h+e.nodeSize)}}let o,l;for(let u=0;u<s.length;u++)s[u]&&(o==null&&(o=u),l=u);for(let u=0,f=n+1;u<i.height;u++){const h=e.child(u),m=f+h.nodeSize,g=s[u];if(g>0){let b="cell";h.firstChild&&(b=h.firstChild.type.spec.tableRole);const x=[];for(let k=0;k<g;k++){const C=Wn(t.schema)[b].createAndFill();C&&x.push(C)}const S=(u==0||o==u-1)&&l==u?f+1:m-1;r.insert(r.mapping.map(S),x)}f=m}return r.setMeta(HK,{fixTables:!0})}function Bi(t){const e=t.selection,n=mg(t),r=n.node(-1),i=n.start(-1),s=Jt.get(r);return{...e instanceof It?s.rectBetween(e.$anchorCell.pos-i,e.$headCell.pos-i):s.findCell(n.pos-i),tableStart:i,map:s,table:r}}function Yj(t,{map:e,tableStart:n,table:r},i){let s=i>0?-1:0;LK(e,r,i+s)&&(s=i==0||i==e.width?null:0);for(let o=0;o<e.height;o++){const l=o*e.width+i;if(i>0&&i<e.width&&e.map[l-1]==e.map[l]){const u=e.map[l],f=r.nodeAt(u);t.setNodeMarkup(t.mapping.map(n+u),null,Gj(f.attrs,i-e.colCount(u))),o+=f.attrs.rowspan-1}else{const u=s==null?Wn(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,f=e.positionAt(o,i,r);t.insert(t.mapping.map(n+f),u.createAndFill())}}return t}function FK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t);e(Yj(t.tr,n,n.left))}return!0}function qK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t);e(Yj(t.tr,n,n.right))}return!0}function GK(t,{map:e,table:n,tableStart:r},i){const s=t.mapping.maps.length;for(let o=0;o<e.height;){const l=o*e.width+i,u=e.map[l],f=n.nodeAt(u),h=f.attrs;if(i>0&&e.map[l-1]==u||i<e.width-1&&e.map[l+1]==u)t.setNodeMarkup(t.mapping.slice(s).map(r+u),null,Fa(h,i-e.colCount(u)));else{const m=t.mapping.slice(s).map(r+u);t.delete(m,m+f.nodeSize)}o+=h.rowspan}}function WK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t),r=t.tr;if(n.left==0&&n.right==n.map.width)return!1;for(let i=n.right-1;GK(r,n,i),i!=n.left;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=Jt.get(s)}e(r)}return!0}function KK(t,e,n){var r;const i=Wn(e.type.schema).header_cell;for(let s=0;s<t.width;s++)if(((r=e.nodeAt(t.map[s+n*t.width]))===null||r===void 0?void 0:r.type)!=i)return!1;return!0}function Xj(t,{map:e,tableStart:n,table:r},i){let s=n;for(let f=0;f<i;f++)s+=r.child(f).nodeSize;const o=[];let l=i>0?-1:0;KK(e,r,i+l)&&(l=i==0||i==e.height?null:0);for(let f=0,h=e.width*i;f<e.width;f++,h++)if(i>0&&i<e.height&&e.map[h]==e.map[h-e.width]){const m=e.map[h],g=r.nodeAt(m).attrs;t.setNodeMarkup(n+m,null,{...g,rowspan:g.rowspan+1}),f+=g.colspan-1}else{var u;const m=l==null?Wn(r.type.schema).cell:(u=r.nodeAt(e.map[h+l*e.width]))===null||u===void 0?void 0:u.type,g=m?.createAndFill();g&&o.push(g)}return t.insert(s,Wn(r.type.schema).row.create(null,o)),t}function ZK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t);e(Xj(t.tr,n,n.top))}return!0}function YK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t);e(Xj(t.tr,n,n.bottom))}return!0}function XK(t,{map:e,table:n,tableStart:r},i){let s=0;for(let f=0;f<i;f++)s+=n.child(f).nodeSize;const o=s+n.child(i).nodeSize,l=t.mapping.maps.length;t.delete(s+r,o+r);const u=new Set;for(let f=0,h=i*e.width;f<e.width;f++,h++){const m=e.map[h];if(!u.has(m)){if(u.add(m),i>0&&m==e.map[h-e.width]){const g=n.nodeAt(m).attrs;t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g,rowspan:g.rowspan-1}),f+=g.colspan-1}else if(i<e.height&&m==e.map[h+e.width]){const g=n.nodeAt(m),b=g.attrs,x=g.type.create({...b,rowspan:g.attrs.rowspan-1},g.content),S=e.positionAt(i+1,f,n);t.insert(t.mapping.slice(l).map(r+S),x),f+=b.colspan-1}}}}function JK(t,e){if(!vi(t))return!1;if(e){const n=Bi(t),r=t.tr;if(n.top==0&&n.bottom==n.map.height)return!1;for(let i=n.bottom-1;XK(r,n,i),i!=n.top;i--){const s=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!s)throw new RangeError("No table found");n.table=s,n.map=Jt.get(n.table)}e(r)}return!0}function CR(t){const e=t.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function QK({width:t,height:e,map:n},r){let i=r.top*t+r.left,s=i,o=(r.bottom-1)*t+r.left,l=i+(r.right-r.left-1);for(let u=r.top;u<r.bottom;u++){if(r.left>0&&n[s]==n[s-1]||r.right<t&&n[l]==n[l+1])return!0;s+=t,l+=t}for(let u=r.left;u<r.right;u++){if(r.top>0&&n[i]==n[i-t]||r.bottom<e&&n[o]==n[o+t])return!0;i++,o++}return!1}function ER(t,e){const n=t.selection;if(!(n instanceof It)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=Bi(t),{map:i}=r;if(QK(i,r))return!1;if(e){const s=t.tr,o={};let l=de.empty,u,f;for(let h=r.top;h<r.bottom;h++)for(let m=r.left;m<r.right;m++){const g=i.map[h*i.width+m],b=r.table.nodeAt(g);if(!(o[g]||!b))if(o[g]=!0,u==null)u=g,f=b;else{CR(b)||(l=l.append(b.content));const x=s.mapping.map(g+r.tableStart);s.delete(x,x+b.nodeSize)}}if(u==null||f==null)return!0;if(s.setNodeMarkup(u+r.tableStart,null,{...Gj(f.attrs,f.attrs.colspan,r.right-r.left-f.attrs.colspan),rowspan:r.bottom-r.top}),l.size>0){const h=u+1+f.content.size,m=CR(f)?u+1:h;s.replaceWith(m+r.tableStart,h+r.tableStart,l)}s.setSelection(new It(s.doc.resolve(u+r.tableStart))),e(s)}return!0}function TR(t,e){const n=Wn(t.schema);return eZ(({node:r})=>n[r.type.spec.tableRole])(t,e)}function eZ(t){return(e,n)=>{const r=e.selection;let i,s;if(r instanceof It){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{var o;if(i=DK(r.$from),!i)return!1;s=(o=Ua(r.$from))===null||o===void 0?void 0:o.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(n){let l=i.attrs;const u=[],f=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const h=Bi(e),m=e.tr;for(let b=0;b<h.right-h.left;b++)u.push(f?{...l,colwidth:f&&f[b]?[f[b]]:null}:l);let g;for(let b=h.top;b<h.bottom;b++){let x=h.map.positionAt(b,h.left,h.table);b==h.top&&(x+=i.nodeSize);for(let S=h.left,k=0;S<h.right;S++,k++)S==h.left&&b==h.top||m.insert(g=m.mapping.map(x+h.tableStart,1),t({node:i,row:b,col:S}).createAndFill(u[k]))}m.setNodeMarkup(s,t({node:i,row:h.top,col:h.left}),u[0]),r instanceof It&&m.setSelection(new It(m.doc.resolve(r.$anchorCell.pos),g?m.doc.resolve(g):void 0)),n(m)}return!0}}function tZ(t,e){return function(n,r){if(!vi(n))return!1;const i=mg(n);if(i.nodeAfter.attrs[t]===e)return!1;if(r){const s=n.tr;n.selection instanceof It?n.selection.forEachCell((o,l)=>{o.attrs[t]!==e&&s.setNodeMarkup(l,null,{...o.attrs,[t]:e})}):s.setNodeMarkup(i.pos,null,{...i.nodeAfter.attrs,[t]:e}),r(s)}return!0}}function nZ(t){return function(e,n){if(!vi(e))return!1;if(n){const r=Wn(e.schema),i=Bi(e),s=e.tr,o=i.map.cellsInRect(t=="column"?{left:i.left,top:0,right:i.right,bottom:i.map.height}:t=="row"?{left:0,top:i.top,right:i.map.width,bottom:i.bottom}:i),l=o.map(u=>i.table.nodeAt(u));for(let u=0;u<o.length;u++)l[u].type==r.header_cell&&s.setNodeMarkup(i.tableStart+o[u],r.cell,l[u].attrs);if(s.steps.length===0)for(let u=0;u<o.length;u++)s.setNodeMarkup(i.tableStart+o[u],r.header_cell,l[u].attrs);n(s)}return!0}}function _R(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 i=0;i<r.length;i++){const s=e.table.nodeAt(r[i]);if(s&&s.type!==n.header_cell)return!1}return!0}function zd(t,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?nZ(t):function(n,r){if(!vi(n))return!1;if(r){const i=Wn(n.schema),s=Bi(n),o=n.tr,l=_R("row",s,i),u=_R("column",s,i),f=(t==="column"?l:t==="row"&&u)?1:0,h=t=="column"?{left:0,top:f,right:1,bottom:s.map.height}:t=="row"?{left:f,top:0,right:s.map.width,bottom:1}:s,m=t=="column"?u?i.cell:i.header_cell:t=="row"?l?i.cell:i.header_cell:i.cell;s.map.cellsInRect(h).forEach(g=>{const b=g+s.tableStart,x=o.doc.nodeAt(b);x&&o.setNodeMarkup(b,m,x.attrs)}),r(o)}return!0}}zd("row",{useDeprecatedLogic:!0});zd("column",{useDeprecatedLogic:!0});const rZ=zd("cell",{useDeprecatedLogic:!0});function iZ(t,e){if(e<0){const n=t.nodeBefore;if(n)return t.pos-n.nodeSize;for(let r=t.index(-1)-1,i=t.before();r>=0;r--){const s=t.node(-1).child(r),o=s.lastChild;if(o)return i-1-o.nodeSize;i-=s.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),i=t.after();r<n.childCount;r++){const s=n.child(r);if(s.childCount)return i+1;i+=s.nodeSize}}return null}function AR(t){return function(e,n){if(!vi(e))return!1;const r=iZ(mg(e),t);if(r==null)return!1;if(n){const i=e.doc.resolve(r);n(e.tr.setSelection(ze.between(i,jK(i))).scrollIntoView())}return!0}}function sZ(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 Vh(t,e){const n=t.selection;if(!(n instanceof It))return!1;if(e){const r=t.tr,i=Wn(t.schema).cell.createAndFill().content;n.forEachCell((s,o)=>{s.content.eq(i)||r.replace(r.mapping.map(o+1),r.mapping.map(o+s.nodeSize-1),new Ee(i,0,0))}),r.docChanged&&e(r)}return!0}function oZ(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 i=e.child(0),s=i.type.spec.tableRole,o=i.type.schema,l=[];if(s=="row")for(let u=0;u<e.childCount;u++){let f=e.child(u).content;const h=u?0:Math.max(0,n-1),m=u<e.childCount-1?0:Math.max(0,r-1);(h||m)&&(f=Dx(Wn(o).row,new Ee(f,h,m)).content),l.push(f)}else if(s=="cell"||s=="header_cell")l.push(n||r?Dx(Wn(o).row,new Ee(e,n,r)).content:e);else return null;return aZ(o,l)}function aZ(t,e){const n=[];for(let i=0;i<e.length;i++){const s=e[i];for(let o=s.childCount-1;o>=0;o--){const{rowspan:l,colspan:u}=s.child(o).attrs;for(let f=i;f<i+l;f++)n[f]=(n[f]||0)+u}}let r=0;for(let i=0;i<n.length;i++)r=Math.max(r,n[i]);for(let i=0;i<n.length;i++)if(i>=e.length&&e.push(de.empty),n[i]<r){const s=Wn(t).cell.createAndFill(),o=[];for(let l=n[i];l<r;l++)o.push(s);e[i]=e[i].append(de.from(o))}return{height:e.length,width:r,rows:e}}function Dx(t,e){const n=t.createAndFill();return new $w(n).replace(0,n.content.size,e).doc}function lZ({width:t,height:e,rows:n},r,i){if(t!=r){const s=[],o=[];for(let l=0;l<n.length;l++){const u=n[l],f=[];for(let h=s[l]||0,m=0;h<r;m++){let g=u.child(m%u.childCount);h+g.attrs.colspan>r&&(g=g.type.createChecked(Fa(g.attrs,g.attrs.colspan,h+g.attrs.colspan-r),g.content)),f.push(g),h+=g.attrs.colspan;for(let b=1;b<g.attrs.rowspan;b++)s[l+b]=(s[l+b]||0)+g.attrs.colspan}o.push(de.from(f))}n=o,t=r}if(e!=i){const s=[];for(let o=0,l=0;o<i;o++,l++){const u=[],f=n[l%e];for(let h=0;h<f.childCount;h++){let m=f.child(h);o+m.attrs.rowspan>i&&(m=m.type.create({...m.attrs,rowspan:Math.max(1,i-m.attrs.rowspan)},m.content)),u.push(m)}s.push(de.from(u))}n=s,e=i}return{width:t,height:e,rows:n}}function cZ(t,e,n,r,i,s,o){const l=t.doc.type.schema,u=Wn(l);let f,h;if(i>e.width)for(let m=0,g=0;m<e.height;m++){const b=n.child(m);g+=b.nodeSize;const x=[];let S;b.lastChild==null||b.lastChild.type==u.cell?S=f||(f=u.cell.createAndFill()):S=h||(h=u.header_cell.createAndFill());for(let k=e.width;k<i;k++)x.push(S);t.insert(t.mapping.slice(o).map(g-1+r),x)}if(s>e.height){const m=[];for(let x=0,S=(e.height-1)*e.width;x<Math.max(e.width,i);x++){const k=x>=e.width?!1:n.nodeAt(e.map[S+x]).type==u.header_cell;m.push(k?h||(h=u.header_cell.createAndFill()):f||(f=u.cell.createAndFill()))}const g=u.row.create(null,de.from(m)),b=[];for(let x=e.height;x<s;x++)b.push(g);t.insert(t.mapping.slice(o).map(r+n.nodeSize-2),b)}return!!(f||h)}function RR(t,e,n,r,i,s,o,l){if(o==0||o==e.height)return!1;let u=!1;for(let f=i;f<s;f++){const h=o*e.width+f,m=e.map[h];if(e.map[h-e.width]==m){u=!0;const g=n.nodeAt(m),{top:b,left:x}=e.findCell(m);t.setNodeMarkup(t.mapping.slice(l).map(m+r),null,{...g.attrs,rowspan:o-b}),t.insert(t.mapping.slice(l).map(e.positionAt(o,x,n)),g.type.createAndFill({...g.attrs,rowspan:b+g.attrs.rowspan-o})),f+=g.attrs.colspan-1}}return u}function MR(t,e,n,r,i,s,o,l){if(o==0||o==e.width)return!1;let u=!1;for(let f=i;f<s;f++){const h=f*e.width+o,m=e.map[h];if(e.map[h-1]==m){u=!0;const g=n.nodeAt(m),b=e.colCount(m),x=t.mapping.slice(l).map(m+r);t.setNodeMarkup(x,null,Fa(g.attrs,o-b,g.attrs.colspan-(o-b))),t.insert(x+g.nodeSize,g.type.createAndFill(Fa(g.attrs,0,o-b))),f+=g.attrs.rowspan-1}}return u}function NR(t,e,n,r,i){let s=n?t.doc.nodeAt(n-1):t.doc;if(!s)throw new Error("No table found");let o=Jt.get(s);const{top:l,left:u}=r,f=u+i.width,h=l+i.height,m=t.tr;let g=0;function b(){if(s=n?m.doc.nodeAt(n-1):m.doc,!s)throw new Error("No table found");o=Jt.get(s),g=m.mapping.maps.length}cZ(m,o,s,n,f,h,g)&&b(),RR(m,o,s,n,u,f,l,g)&&b(),RR(m,o,s,n,u,f,h,g)&&b(),MR(m,o,s,n,l,h,u,g)&&b(),MR(m,o,s,n,l,h,f,g)&&b();for(let x=l;x<h;x++){const S=o.positionAt(x,u,s),k=o.positionAt(x,f,s);m.replace(m.mapping.slice(g).map(S+n),m.mapping.slice(g).map(k+n),new Ee(i.rows[x-l],0,0))}b(),m.setSelection(new It(m.doc.resolve(n+o.positionAt(l,u,s)),m.doc.resolve(n+o.positionAt(h-1,f-1,s)))),e(m)}const uZ=eS({ArrowLeft:Hh("horiz",-1),ArrowRight:Hh("horiz",1),ArrowUp:Hh("vert",-1),ArrowDown:Hh("vert",1),"Shift-ArrowLeft":Uh("horiz",-1),"Shift-ArrowRight":Uh("horiz",1),"Shift-ArrowUp":Uh("vert",-1),"Shift-ArrowDown":Uh("vert",1),Backspace:Vh,"Mod-Backspace":Vh,Delete:Vh,"Mod-Delete":Vh});function gp(t,e,n){return n.eq(t.selection)?!1:(e&&e(t.tr.setSelection(n).scrollIntoView()),!0)}function Hh(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof It)return gp(n,r,Ke.near(s.$headCell,e));if(t!="horiz"&&!s.empty)return!1;const o=Jj(i,t,e);if(o==null)return!1;if(t=="horiz")return gp(n,r,Ke.near(n.doc.resolve(s.head+e),e));{const l=n.doc.resolve(o),u=qj(l,t,e);let f;return u?f=Ke.near(u,1):e<0?f=Ke.near(n.doc.resolve(l.before(-1)),-1):f=Ke.near(n.doc.resolve(l.after(-1)),1),gp(n,r,f)}}}function Uh(t,e){return(n,r,i)=>{if(!i)return!1;const s=n.selection;let o;if(s instanceof It)o=s;else{const u=Jj(i,t,e);if(u==null)return!1;o=new It(n.doc.resolve(u))}const l=qj(o.$headCell,t,e);return l?gp(n,r,new It(o.$anchorCell,l)):!1}}function dZ(t,e){const n=t.state.doc,r=Ua(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new It(r))),!0):!1}function fZ(t,e,n){if(!vi(t.state))return!1;let r=oZ(n);const i=t.state.selection;if(i instanceof It){r||(r={width:1,height:1,rows:[de.from(Dx(Wn(t.state.schema).cell,n))]});const s=i.$anchorCell.node(-1),o=i.$anchorCell.start(-1),l=Jt.get(s).rectBetween(i.$anchorCell.pos-o,i.$headCell.pos-o);return r=lZ(r,l.right-l.left,l.bottom-l.top),NR(t.state,t.dispatch,o,l,r),!0}else if(r){const s=mg(t.state),o=s.start(-1);return NR(t.state,t.dispatch,o,Jt.get(s.node(-1)).findCell(s.pos-o),r),!0}else return!1}function hZ(t,e){var n;if(e.button!=0||e.ctrlKey||e.metaKey)return;const r=OR(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof It)s(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=Ua(t.state.selection.$anchor))!=null&&((n=Wv(t,e))===null||n===void 0?void 0:n.pos)!=i.pos)s(i,e),e.preventDefault();else if(!r)return;function s(u,f){let h=Wv(t,f);const m=So.getState(t.state)==null;if(!h||!jS(u,h))if(m)h=u;else return;const g=new It(u,h);if(m||!t.state.selection.eq(g)){const b=t.state.tr.setSelection(g);m&&b.setMeta(So,u.pos),t.dispatch(b)}}function o(){t.root.removeEventListener("mouseup",o),t.root.removeEventListener("dragstart",o),t.root.removeEventListener("mousemove",l),So.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(So,-1))}function l(u){const f=u,h=So.getState(t.state);let m;if(h!=null)m=t.state.doc.resolve(h);else if(OR(t,f.target)!=r&&(m=Wv(t,e),!m))return o();m&&s(m,f)}t.root.addEventListener("mouseup",o),t.root.addEventListener("dragstart",o),t.root.addEventListener("mousemove",l)}function Jj(t,e,n){if(!(t.state.selection instanceof ze))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const s=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const o=r.before(i),l=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(l)?o:null}}return null}function OR(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Wv(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});if(!n)return null;let{inside:r,pos:i}=n;return r>=0&&Ua(t.state.doc.resolve(r))||Ua(t.state.doc.resolve(i))}var pZ=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")),Ix(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,Ix(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ix(t,e,n,r,i,s){let o=0,l=!0,u=e.firstChild;const f=t.firstChild;if(f){for(let m=0,g=0;m<f.childCount;m++){const{colspan:b,colwidth:x}=f.child(m).attrs;for(let S=0;S<b;S++,g++){const k=i==g?s:x&&x[S],C=k?k+"px":"";if(o+=k||r,k||(l=!1),u)u.style.width!=C&&(u.style.width=C),u=u.nextSibling;else{const A=document.createElement("col");A.style.width=C,e.appendChild(A)}}}for(;u;){var h;const m=u.nextSibling;(h=u.parentNode)===null||h===void 0||h.removeChild(u),u=m}l?(n.style.width=o+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=o+"px")}}const Rr=new Qt("tableColumnResizing");function mZ({handleWidth:t=5,cellMinWidth:e=25,defaultCellMinWidth:n=100,View:r=pZ,lastColumnResizable:i=!0}={}){const s=new Lt({key:Rr,state:{init(o,l){var u;const f=(u=s.spec)===null||u===void 0||(u=u.props)===null||u===void 0?void 0:u.nodeViews,h=Wn(l.schema).table.name;return r&&f&&(f[h]=(m,g)=>new r(m,n,g)),new gZ(-1,!1)},apply(o,l){return l.apply(o)}},props:{attributes:o=>{const l=Rr.getState(o);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,l)=>{yZ(o,l,t,i)},mouseleave:o=>{bZ(o)},mousedown:(o,l)=>{vZ(o,l,e,n)}},decorations:o=>{const l=Rr.getState(o);if(l&&l.activeHandle>-1)return CZ(o,l.activeHandle)},nodeViews:{}}});return s}var gZ=class yp{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(Rr);if(r&&r.setHandle!=null)return new yp(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new yp(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Ox(e.doc.resolve(i))||(i=-1),new yp(i,n.dragging)}return n}};function yZ(t,e,n,r){if(!t.editable)return;const i=Rr.getState(t.state);if(i&&!i.dragging){const s=wZ(e.target);let o=-1;if(s){const{left:l,right:u}=s.getBoundingClientRect();e.clientX-l<=n?o=DR(t,e,"left",n):u-e.clientX<=n&&(o=DR(t,e,"right",n))}if(o!=i.activeHandle){if(!r&&o!==-1){const l=t.state.doc.resolve(o),u=l.node(-1),f=Jt.get(u),h=l.start(-1);if(f.colCount(l.pos-h)+l.nodeAfter.attrs.colspan-1==f.width-1)return}Qj(t,o)}}}function bZ(t){if(!t.editable)return;const e=Rr.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Qj(t,-1)}function vZ(t,e,n,r){var i;if(!t.editable)return!1;const s=(i=t.dom.ownerDocument.defaultView)!==null&&i!==void 0?i:window,o=Rr.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const l=t.state.doc.nodeAt(o.activeHandle),u=xZ(t,o.activeHandle,l.attrs);t.dispatch(t.state.tr.setMeta(Rr,{setDragging:{startX:e.clientX,startWidth:u}}));function f(m){s.removeEventListener("mouseup",f),s.removeEventListener("mousemove",h);const g=Rr.getState(t.state);g?.dragging&&(SZ(t,g.activeHandle,IR(g.dragging,m,n)),t.dispatch(t.state.tr.setMeta(Rr,{setDragging:null})))}function h(m){if(!m.which)return f(m);const g=Rr.getState(t.state);if(g&&g.dragging){const b=IR(g.dragging,m,n);jR(t,g.activeHandle,b,r)}}return jR(t,o.activeHandle,u,r),s.addEventListener("mouseup",f),s.addEventListener("mousemove",h),e.preventDefault(),!0}function xZ(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const s=t.domAtPos(e);let o=s.node.childNodes[s.offset].offsetWidth,l=n;if(r)for(let u=0;u<n;u++)r[u]&&(o-=r[u],l--);return o/l}function wZ(t){for(;t&&t.nodeName!="TD"&&t.nodeName!="TH";)t=t.classList&&t.classList.contains("ProseMirror")?null:t.parentNode;return t}function DR(t,e,n,r){const i=n=="right"?-r:r,s=t.posAtCoords({left:e.clientX+i,top:e.clientY});if(!s)return-1;const{pos:o}=s,l=Ua(t.state.doc.resolve(o));if(!l)return-1;if(n=="right")return l.pos;const u=Jt.get(l.node(-1)),f=l.start(-1),h=u.map.indexOf(l.pos-f);return h%u.width==0?-1:f+u.map[h-1]}function IR(t,e,n){const r=e.clientX-t.startX;return Math.max(n,t.startWidth+r)}function Qj(t,e){t.dispatch(t.state.tr.setMeta(Rr,{setHandle:e}))}function SZ(t,e,n){const r=t.state.doc.resolve(e),i=r.node(-1),s=Jt.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,u=t.state.tr;for(let f=0;f<s.height;f++){const h=f*s.width+l;if(f&&s.map[h]==s.map[h-s.width])continue;const m=s.map[h],g=i.nodeAt(m).attrs,b=g.colspan==1?0:l-s.colCount(m);if(g.colwidth&&g.colwidth[b]==n)continue;const x=g.colwidth?g.colwidth.slice():kZ(g.colspan);x[b]=n,u.setNodeMarkup(o+m,null,{...g,colwidth:x})}u.docChanged&&t.dispatch(u)}function jR(t,e,n,r){const i=t.state.doc.resolve(e),s=i.node(-1),o=i.start(-1),l=Jt.get(s).colCount(i.pos-o)+i.nodeAfter.attrs.colspan-1;let u=t.domAtPos(i.start(-1)).node;for(;u&&u.nodeName!="TABLE";)u=u.parentNode;u&&Ix(s,u.firstChild,u,r,l,n)}function kZ(t){return Array(t).fill(0)}function CZ(t,e){const n=[],r=t.doc.resolve(e),i=r.node(-1);if(!i)return kt.empty;const s=Jt.get(i),o=r.start(-1),l=s.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1;for(let f=0;f<s.height;f++){const h=l+f*s.width;if((l==s.width-1||s.map[h]!=s.map[h+1])&&(f==0||s.map[h]!=s.map[h-s.width])){var u;const m=s.map[h],g=o+m+i.nodeAt(m).nodeSize-1,b=document.createElement("div");b.className="column-resize-handle",!((u=Rr.getState(t))===null||u===void 0)&&u.dragging&&n.push(Sn.node(o+m,o+m+i.nodeAt(m).nodeSize,{class:"column-resize-dragging"})),n.push(Sn.widget(g,b))}}return kt.create(t.doc,n)}function EZ({allowTableNodeSelection:t=!1}={}){return new Lt({key:So,state:{init(){return null},apply(e,n){const r=e.getMeta(So);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:s}=e.mapping.mapResult(n);return i?null:s}},props:{decorations:zK,handleDOMEvents:{mousedown:hZ},createSelectionBetween(e){return So.getState(e.state)!=null?e.state.selection:null},handleTripleClick:dZ,handleKeyDown:uZ,handlePaste:fZ},appendTransaction(e,n,r){return VK(r,Zj(r,n),t)}})}function Om(t){return t==="left"||t==="right"||t==="center"?t:null}function TZ(t){const e=(t.style.textAlign||"").trim().toLowerCase(),n=(t.getAttribute("align")||"").trim().toLowerCase();return Om(e||n)}function _Z(t){return Om(t?.align)}function eL(){return{default:null,parseHTML:t=>TZ(t),renderHTML:t=>t.align?{style:`text-align: ${t.align}`}:{}}}function AZ(t){var e;const n=t.parentElement,r=t.closest("table");if(!n||!r)return null;const i=Array.from(n.children).indexOf(t),s=(e=r.querySelectorAll("colgroup > col")[i])==null?void 0:e.getAttribute("width");return s?[parseInt(s,10)]:null}function tL(t){const e=t.getAttribute("colwidth");return e?e.split(",").map(n=>parseInt(n,10)):AZ(t)}var RZ=/[ \t\r\n\f]+/g;function nL(t){var e;return t.children.length>0?!1:((e=t.textContent)!=null?e:"").replace(RZ,"")===""}function rL(t){const e=t.createAndFill();if(!e)throw new Error(`[tiptap error]: "${t.name}" has no default content to backfill.`);return e.content}var MZ=Tn.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:tL},align:eL()}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td",getAttrs:t=>nL(t)?{}:!1,getContent:(t,e)=>rL(e.nodes[this.name])},{tag:"td"}]},renderHTML({HTMLAttributes:t}){return["td",jt(this.options.HTMLAttributes,t),0]}}),NZ=Tn.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:tL},align:eL()}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th",getAttrs:t=>nL(t)?{}:!1,getContent:(t,e)=>rL(e.nodes[this.name])},{tag:"th"}]},renderHTML({HTMLAttributes:t}){return["th",jt(this.options.HTMLAttributes,t),0]}}),OZ=Tn.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:t}){return["tr",jt(this.options.HTMLAttributes,t),0]}});function jx(t,e){return e?["width",`${Math.max(e,t)}px`]:["min-width",`${t}px`]}function LR(t,e,n,r,i,s){var o;let l=0,u=!0,f=e.firstChild;const h=t.firstChild;if(h!==null)for(let g=0,b=0;g<h.childCount;g+=1){const{colspan:x,colwidth:S}=h.child(g).attrs;for(let k=0;k<x;k+=1,b+=1){const C=i===b?s:S&&S[k],A=C?`${C}px`:"";if(l+=C||r,C||(u=!1),f){if(f.style.width!==A){const[R,_]=jx(r,C);f.style.setProperty(R,_)}f=f.nextSibling}else{const R=document.createElement("col"),[_,M]=jx(r,C);R.style.setProperty(_,M),e.appendChild(R)}}}for(;f;){const g=f.nextSibling;(o=f.parentNode)==null||o.removeChild(f),f=g}const m=t.attrs.style&&typeof t.attrs.style=="string"&&/\bwidth\s*:/i.test(t.attrs.style);u&&!m?(n.style.width=`${l}px`,n.style.minWidth=""):(n.style.width="",n.style.minWidth=`${l}px`)}var DZ=class{constructor(t,e,n,r={}){this.node=t,this.cellMinWidth=e,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table"));for(const[i,s]of Object.entries(r))s!=null&&(i==="style"?this.table.style.cssText=String(s):this.table.setAttribute(i,String(s)));t.attrs.style&&(this.table.style.cssText=t.attrs.style),this.colgroup=this.table.appendChild(document.createElement("colgroup")),LR(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,LR(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 IZ(t,e,n,r){let i=0,s=!0;const o=[],l=t.firstChild;if(!l)return{};for(let m=0,g=0;m<l.childCount;m+=1){const{colspan:b,colwidth:x}=l.child(m).attrs;for(let S=0;S<b;S+=1,g+=1){const k=n===g?r:x&&x[S];i+=k||e,k||(s=!1);const[C,A]=jx(e,k);o.push(["col",{style:`${C}: ${A}`}])}}const u=s?`${i}px`:"",f=s?"":`${i}px`;return{colgroup:["colgroup",{},...o],tableWidth:u,tableMinWidth:f}}function PR(t,e){return t.createAndFill()}function jZ(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 LZ(t,e,n,r,i){const s=jZ(t),o=[],l=[];for(let f=0;f<n;f+=1){const h=PR(s.cell);if(h&&l.push(h),r){const m=PR(s.header_cell);m&&o.push(m)}}const u=[];for(let f=0;f<e;f+=1)u.push(s.row.createChecked(null,r&&f===0?o:l));return s.table.createChecked(null,u)}function PZ(t){return t instanceof It}var Fh=({editor:t})=>{const{selection:e}=t.state;if(!PZ(e))return!1;let n=0;const r=yI(e.ranges[0].$from,s=>s.type.name==="table");return r?.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(n+=1)}),n===e.ranges.length?(t.commands.deleteTable(),!0):!1},zZ="";function $Z(t){let e="",n=0;for(;n<t.length;){if(t[n]==="\\"&&n+1<t.length){e+=t[n]+t[n+1],n+=2;continue}if(t[n]!=="`"){e+=t[n++];continue}let r=0;for(;n+r<t.length&&t[n+r]==="`";)r+=1;let i=n+r,s=!1;for(;i<t.length;){if(t[i]!=="`"){i+=1;continue}let o=0;for(;i+o<t.length&&t[i+o]==="`";)o+=1;if(o===r){const l=t.slice(n+r,i);e+=t.slice(n,n+r)+l.replace(new RegExp("(?<!\\\\)\\|","g"),"\\|")+t.slice(i,i+r),n=i+r,s=!0;break}i+=o}s||(e+=t.slice(n,n+r),n+=r)}return e}function BZ(t){return t.split(`
|
|
273
|
+
`).map(e=>!e.includes("|")||!e.includes("`")?e:$Z(e)).join(`
|
|
274
|
+
`)}function VZ(t){return(t||"").replace(/\s+/g," ").trim()}function HZ(t,e,n={}){var r;const i=(r=n.cellLineSeparator)!=null?r:zZ;if(!t||!t.content||t.content.length===0)return"";const s=[];t.content.forEach(S=>{const k=[];S.content&&S.content.forEach(C=>{let A="";C.content&&Array.isArray(C.content)&&C.content.length>1?A=C.content.map(D=>e.renderChildren(D)).join(i):A=C.content?e.renderChildren(C.content):"";const R=VZ(A.split(i).join(`
|
|
275
|
+
`).replace(/[ \t]*\r?\n[ \t]*/g,"<br>")),_=C.type==="tableHeader",M=_Z(C.attrs);k.push({text:R,isHeader:_,align:M})}),s.push(k)});const o=s.reduce((S,k)=>Math.max(S,k.length),0);if(o===0)return"";const l=Array.from({length:o}).fill(0);s.forEach(S=>{var k;for(let C=0;C<o;C+=1){const R=(((k=S[C])==null?void 0:k.text)||"").length;R>l[C]&&(l[C]=R),l[C]<3&&(l[C]=3)}});const u=(S,k)=>S+" ".repeat(Math.max(0,k-S.length)),f=s[0],h=f.some(S=>S.isHeader),m=Array.from({length:o}).fill(null);s.forEach(S=>{var k;for(let C=0;C<o;C+=1)!m[C]&&((k=S[C])!=null&&k.align)&&(m[C]=S[C].align)});let g=`
|
|
276
|
+
`;const b=Array.from({length:o}).map((S,k)=>h&&f[k]&&f[k].text||"");return g+=`| ${b.map((S,k)=>u(S,l[k])).join(" | ")} |
|
|
277
|
+
`,g+=`| ${l.map((S,k)=>{const C=Math.max(3,S),A=m[k];return A==="left"?`:${"-".repeat(C)}`:A==="right"?`${"-".repeat(C)}:`:A==="center"?`:${"-".repeat(C)}:`:"-".repeat(C)}).join(" | ")} |
|
|
278
|
+
`,(h?s.slice(1):s).forEach(S=>{g+=`| ${Array.from({length:o}).fill(0).map((k,C)=>u(S[C]&&S[C].text||"",l[C])).join(" | ")} |
|
|
279
|
+
`}),g}var UZ=HZ,FZ=Tn.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,renderWrapper:!1,handleWidth:5,cellMinWidth:25,View:DZ,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:i}=IZ(t,this.options.cellMinWidth),s=e.style;function o(){return s||(r?`width: ${r}`:`min-width: ${i}`)}const l=["table",jt(this.options.HTMLAttributes,e,{style:o()}),n,["tbody",0]];return this.options.renderWrapper?["div",{class:"tableWrapper"},l]:l},parseMarkdown:(t,e)=>{const n=[],r=Array.isArray(t.align)?t.align:[];if(t.header){const i=[];t.header.forEach((s,o)=>{var l;const u=Om((l=r[o])!=null?l:s.align),f=u?{align:u}:{};i.push(e.createNode("tableHeader",f,[{type:"paragraph",content:e.parseInline(s.tokens)}]))}),n.push(e.createNode("tableRow",{},i))}return t.rows&&t.rows.forEach(i=>{const s=[];i.forEach((o,l)=>{var u;const f=Om((u=r[l])!=null?u:o.align),h=f?{align:f}:{};s.push(e.createNode("tableCell",h,[{type:"paragraph",content:e.parseInline(o.tokens)}]))}),n.push(e.createNode("tableRow",{},s))}),e.createNode("table",void 0,n)},renderMarkdown:(t,e)=>UZ(t,e),markdownTokenizer:{name:"table",level:"block",start:t=>{const e=t.split(`
|
|
280
|
+
`);if(e.length<2)return-1;const n=e[1];return!/^[ \t|:]*-[ \t|:-]*$/.test(n)||!n.includes("|")?-1:e[0].includes("|")?0:-1},tokenize(t,e,n){const r=t.indexOf(`
|
|
281
|
+
|
|
282
|
+
`),i=r>=0?t.slice(0,r):t,s=i.split(`
|
|
283
|
+
`);if(s.length<2)return;const o=s[1];if(!/^[ \t|:]*-[ \t|:-]*$/.test(o)||!o.includes("|"))return;const l=BZ(i);if(l===i)return;const f=n.blockTokens(l)[0];if(f?.type!=="table"||!f.raw)return;const h=f.raw.split(`
|
|
284
|
+
`).length,m=t.split(`
|
|
285
|
+
`).slice(0,h).join(`
|
|
286
|
+
`);return{...f,raw:m}}},addCommands(){return{insertTable:({rows:t=3,cols:e=3,withHeaderRow:n=!0}={})=>({tr:r,dispatch:i,editor:s})=>{const o=LZ(s.schema,t,e,n);if(i){const l=r.selection.from+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(ze.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:t,dispatch:e})=>FK(t,e),addColumnAfter:()=>({state:t,dispatch:e})=>qK(t,e),deleteColumn:()=>({state:t,dispatch:e})=>WK(t,e),addRowBefore:()=>({state:t,dispatch:e})=>ZK(t,e),addRowAfter:()=>({state:t,dispatch:e})=>YK(t,e),deleteRow:()=>({state:t,dispatch:e})=>JK(t,e),deleteTable:()=>({state:t,dispatch:e})=>sZ(t,e),mergeCells:()=>({state:t,dispatch:e})=>ER(t,e),splitCell:()=>({state:t,dispatch:e})=>TR(t,e),toggleHeaderColumn:()=>({state:t,dispatch:e})=>zd("column")(t,e),toggleHeaderRow:()=>({state:t,dispatch:e})=>zd("row")(t,e),toggleHeaderCell:()=>({state:t,dispatch:e})=>rZ(t,e),mergeOrSplit:()=>({state:t,dispatch:e})=>ER(t,e)?!0:TR(t,e),setCellAttribute:(t,e)=>({state:n,dispatch:r})=>tZ(t,e)(n,r),goToNextCell:()=>({state:t,dispatch:e})=>AR(1)(t,e),goToPreviousCell:()=>({state:t,dispatch:e})=>AR(-1)(t,e),fixTables:()=>({state:t,dispatch:e})=>(e&&Zj(t),!0),setCellSelection:t=>({tr:e,dispatch:n})=>{if(n){const r=It.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:Fh,"Mod-Backspace":Fh,Delete:Fh,"Mod-Delete":Fh}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[mZ({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],EZ({allowTableNodeSelection:this.options.allowTableNodeSelection})]},addNodeView(){const t=this.options.resizable&&this.editor.isEditable,e=this.options.View;return t||!e?null:({node:n,view:r,HTMLAttributes:i})=>{const s=jt(this.options.HTMLAttributes,i);return new e(n,this.options.cellMinWidth,r,s)}},extendNodeSchema(t){const e={name:t.name,options:t.options,storage:t.storage};return{tableRole:mt(De(t,"tableRole",e))}}}),qZ=Ft.create({name:"tableKit",addExtensions(){const t=[];return this.options.table!==!1&&t.push(FZ.configure(this.options.table)),this.options.tableCell!==!1&&t.push(MZ.configure(this.options.tableCell)),this.options.tableHeader!==!1&&t.push(NZ.configure(this.options.tableHeader)),this.options.tableRow!==!1&&t.push(OZ.configure(this.options.tableRow)),t}});function GZ({recordImages:t=[],galleryUpload:e,onListGallery:n,onUploadGallery:r,onClose:i,onInsert:s}){const o=!!n,[l,u]=E.useState(t.length?"record":"gallery"),[f,h]=E.useState([]),[m,g]=E.useState(!1),[b,x]=E.useState(null),[S,k]=E.useState({}),[C,A]=E.useState("");E.useEffect(()=>{const B=K=>{K.key==="Escape"&&i()};window.addEventListener("keydown",B);const re=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",B),document.body.style.overflow=re}},[i]),E.useEffect(()=>{if(!o)return;let B=!1;return g(!0),x(null),n().then(re=>{B||h(re)}).catch(re=>{B||x(re instanceof Error?re.message:"Could not load gallery")}).finally(()=>{B||g(!1)}),()=>{B=!0}},[o,n]);const R=E.useMemo(()=>t.map(B=>({id:`record:${B.id}`,url:B.url,name:B.name,source:"record"})),[t]),_=E.useMemo(()=>f.map(B=>({id:`gallery:${B.id}`,url:B.url,name:B.name??B.id,source:"gallery"})),[f]),M=l==="record"?R:_,O=Object.values(S),D=!!(e&&r),I=B=>{k(re=>{const K={...re};return K[B.id]?delete K[B.id]:K[B.id]=B,K})},P=()=>{const B=C.trim();if(!B)return;const re={id:`url:${B}`,url:B,name:"Image",source:"url"};k(K=>({...K,[re.id]:re})),A("")};return y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:i,children:y.jsxs("div",{className:"vertebr-modal",role:"dialog","aria-modal":"true","aria-label":"Insert images",onClick:B=>B.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:"Media"}),y.jsx("h2",{children:"Insert images"})]}),y.jsx("button",{type:"button",className:"vertebr-btn",onClick:i,children:"Close"})]}),y.jsxs("div",{className:"vertebr-modal-body vertebr-picker-body",children:[t.length>0&&o?y.jsxs("div",{className:"vertebr-picker-tabs",role:"tablist",children:[y.jsxs("button",{type:"button",role:"tab","aria-selected":l==="record","data-active":l==="record"||void 0,onClick:()=>u("record"),children:["Product photos",y.jsx("span",{children:R.length})]}),y.jsxs("button",{type:"button",role:"tab","aria-selected":l==="gallery","data-active":l==="gallery"||void 0,onClick:()=>u("gallery"),children:["Gallery",y.jsx("span",{children:m?"…":_.length})]})]}):null,l==="gallery"&&D?y.jsx(Nc,{meta:{field:"gallery",accept:e.accept,maxBytes:e.maxBytes},multiple:!0,label:"Drop images to add them to the gallery",onUpload:async B=>{const re=await r(B);h(K=>[...re,...K]),k(K=>{const ee={...K};for(const Q of re){const fe={id:`gallery:${Q.id}`,url:Q.url,name:Q.name??Q.id,source:"gallery"};ee[fe.id]=fe}return ee})}}):null,y.jsxs("label",{className:"vertebr-field",children:[y.jsx("span",{children:"Or paste an image URL"}),y.jsxs("div",{className:"vertebr-picker-url",children:[y.jsx("input",{type:"url",value:C,placeholder:"https://",onChange:B=>A(B.target.value),onKeyDown:B=>{B.key==="Enter"&&(B.preventDefault(),P())}}),y.jsx("button",{type:"button",className:"vertebr-btn",disabled:!C.trim(),onClick:P,children:"Add"})]})]}),b?y.jsx("p",{className:"vertebr-status","data-tone":"danger",children:b}):null,m&&l==="gallery"?y.jsx("div",{className:"vertebr-empty",children:"Loading gallery…"}):M.length===0?y.jsx("div",{className:"vertebr-empty",children:l==="record"?"No product photos on this record yet.":o?"No images in the gallery yet.":"No gallery is configured. Paste a URL or add product photos."}):y.jsx("div",{className:"vertebr-picker-grid",children:M.map(B=>{const re=!!S[B.id];return y.jsxs("button",{type:"button",className:"vertebr-picker-tile","data-selected":re||void 0,onClick:()=>I(B),children:[y.jsx("span",{className:"vertebr-picker-thumb",children:y.jsx("img",{src:B.url,alt:""})}),y.jsx("span",{className:"vertebr-picker-name",children:B.name})]},B.id)})})]}),y.jsxs("footer",{className:"vertebr-picker-foot",children:[y.jsxs("span",{className:"vertebr-picker-count",children:[O.length," selected"]}),y.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:O.length===0,onClick:()=>s(O),children:["Insert ",O.length||"",O.length===1?" image":" images"]})]})]})})}function zR(t,e){t&&(typeof t=="function"?t(e):t.current=e)}function Xn({active:t,disabled:e,title:n,onClick:r,children:i}){return y.jsx("button",{type:"button",className:"vertebr-md-btn","data-active":t||void 0,disabled:e,title:n,onMouseDown:s=>s.preventDefault(),onClick:r,children:i})}function WZ({id:t,name:e,value:n,readOnly:r,placeholder:i="Write a description…",recordImages:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,onBlur:f,onChange:h,inputRef:m}){const g=typeof n=="string"?n:"",b=E.useRef(h),x=E.useRef(f),S=E.useRef(g),[k,C]=E.useState(!1);b.current=h,x.current=f;const A=YG({immediatelyRender:!1,shouldRerenderOnTransaction:!1,content:g,contentType:"markdown",editable:!r,extensions:[k7.configure({heading:{levels:[2,3]},underline:!1,link:{openOnClick:!1,defaultProtocol:"https"}}),AK.configure({inline:!1,allowBase64:!1}),qZ.configure({table:{resizable:!1}}),m7.configure({placeholder:i}),EK.configure({markedOptions:{gfm:!0}})],editorProps:{attributes:{id:t,class:"vertebr-md-content"}},onUpdate:({editor:I})=>{const P=I.getMarkdown();S.current=P,b.current(P)},onBlur:()=>{x.current?.()}});E.useEffect(()=>{if(A)return zR(m,A.view.dom),()=>zR(m,null)},[A,m]),E.useEffect(()=>{A&&A.setEditable(!r)},[A,r]),E.useEffect(()=>{if(A&&g!==S.current){if(g===A.getMarkdown()){S.current=g;return}A.commands.setContent(g,{contentType:"markdown",emitUpdate:!1}),S.current=g}},[A,g]);const R=KI({editor:A,selector:({editor:I})=>({bold:I?.isActive("bold")??!1,italic:I?.isActive("italic")??!1,strike:I?.isActive("strike")??!1,code:I?.isActive("code")??!1,codeBlock:I?.isActive("codeBlock")??!1,heading:I?.isActive("heading")??!1,quote:I?.isActive("blockquote")??!1,bullet:I?.isActive("bulletList")??!1,ordered:I?.isActive("orderedList")??!1,table:I?.isActive("table")??!1,link:I?.isActive("link")??!1,stats:M_(I?.getText()??g)})}),_=R?.stats??M_(g),M=r||!A,O=()=>{if(!A||r)return;const I=A.getAttributes("link").href,P=window.prompt("Link URL",typeof I=="string"&&I?I:"https://");if(P!==null){if(!P.trim()){A.chain().focus().extendMarkRange("link").unsetLink().run();return}A.chain().focus().extendMarkRange("link").setLink({href:P.trim()}).run()}},D=I=>{!A||I.length===0||(A.chain().focus().insertContent(I.map(P=>({type:"image",attrs:{src:P.url,alt:P.name}}))).run(),C(!1))};return y.jsxs("div",{className:"vertebr-field-prose",onKeyDown:I=>{(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"&&(I.preventDefault(),O())},children:[e?y.jsx("input",{type:"hidden",name:e,value:g,readOnly:!0}):null,y.jsxs("div",{className:"vertebr-md-toolbar",role:"toolbar","aria-label":"Format",children:[y.jsx(Xn,{active:R?.bold,disabled:M,title:"Bold",onClick:()=>A?.chain().focus().toggleBold().run(),children:y.jsx("span",{className:"vertebr-md-glyph",children:"B"})}),y.jsx(Xn,{active:R?.italic,disabled:M,title:"Italic",onClick:()=>A?.chain().focus().toggleItalic().run(),children:y.jsx("span",{className:"vertebr-md-glyph vertebr-md-italic",children:"I"})}),y.jsx(Xn,{active:R?.strike,disabled:M,title:"Strikethrough",onClick:()=>A?.chain().focus().toggleStrike().run(),children:y.jsx("span",{className:"vertebr-md-glyph vertebr-md-strike",children:"S"})}),y.jsx(Xn,{active:R?.code,disabled:M,title:"Inline code",onClick:()=>A?.chain().focus().toggleCode().run(),children:"</>"}),y.jsx(Xn,{active:R?.codeBlock,disabled:M,title:"Code block",onClick:()=>A?.chain().focus().toggleCodeBlock().run(),children:"{ }"}),y.jsx("span",{className:"vertebr-md-sep","aria-hidden":"true"}),y.jsx(Xn,{active:R?.heading,disabled:M,title:"Heading",onClick:()=>A?.chain().focus().toggleHeading({level:2}).run(),children:"H"}),y.jsx(Xn,{active:R?.quote,disabled:M,title:"Quote",onClick:()=>A?.chain().focus().toggleBlockquote().run(),children:"“"}),y.jsx(Xn,{active:R?.bullet,disabled:M,title:"Bulleted list",onClick:()=>A?.chain().focus().toggleBulletList().run(),children:"•"}),y.jsx(Xn,{active:R?.ordered,disabled:M,title:"Numbered list",onClick:()=>A?.chain().focus().toggleOrderedList().run(),children:"1."}),y.jsx("span",{className:"vertebr-md-sep","aria-hidden":"true"}),y.jsx(Xn,{active:R?.table,disabled:M,title:"Table",onClick:()=>A?.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),children:"Table"}),R?.table?y.jsxs(y.Fragment,{children:[y.jsx(Xn,{disabled:M,title:"Add column",onClick:()=>A?.chain().focus().addColumnAfter().run(),children:"+Col"}),y.jsx(Xn,{disabled:M,title:"Add row",onClick:()=>A?.chain().focus().addRowAfter().run(),children:"+Row"}),y.jsx(Xn,{disabled:M,title:"Delete table",onClick:()=>A?.chain().focus().deleteTable().run(),children:"Del"})]}):null,y.jsx(Xn,{active:R?.link,disabled:M,title:"Link",onClick:O,children:"Link"}),y.jsx(Xn,{disabled:M,title:"Insert images",onClick:()=>C(!0),children:"Image"})]}),y.jsx(WI,{editor:A}),y.jsxs("p",{className:"vertebr-field-prose-meta",children:["Markdown",y.jsx("span",{"aria-hidden":"true",children:" · "}),_.words," ",_.words===1?"word":"words",y.jsx("span",{"aria-hidden":"true",children:" · "}),_.characters," ",_.characters===1?"character":"characters"]}),k?y.jsx(GZ,{recordImages:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,onClose:()=>C(!1),onInsert:D}):null]})}var KZ=Object.defineProperty,ZZ=(t,e)=>KZ(t,"name",{value:e,configurable:!0});function Lx(t,[e,n]){return Math.min(n,Math.max(e,t))}ZZ(Lx,"clamp");var YZ=Object.defineProperty,wn=(t,e)=>YZ(t,"name",{value:e,configurable:!0});function iL(t){const e=t+"CollectionProvider",[n,r]=Ic(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=wn(S=>{const{scope:k,children:C}=S,A=E.useRef(null),R=E.useRef(new Map).current;return y.jsx(i,{scope:k,itemMap:R,collectionRef:A,children:C})},"CollectionProvider");o.displayName=e;const l=t+"CollectionSlot",u=Pa(l),f=E.forwardRef((S,k)=>{const{scope:C,children:A}=S,R=s(l,C),_=rn(k,R.collectionRef);return y.jsx(u,{ref:_,children:A})});f.displayName=l;const h=t+"CollectionItemSlot",m="data-radix-collection-item",g=Pa(h),b=E.forwardRef((S,k)=>{const{scope:C,children:A,...R}=S,_=E.useRef(null),M=rn(k,_),O=s(h,C);return E.useEffect(()=>(O.itemMap.set(_,{ref:_,...R}),()=>{O.itemMap.delete(_)})),y.jsx(g,{[m]:"",ref:M,children:A})});b.displayName=h;function x(S){const k=s(t+"CollectionConsumer",S);return E.useCallback(()=>{const A=k.collectionRef.current;if(!A)return[];const R=Array.from(A.querySelectorAll(`[${m}]`));return Array.from(k.itemMap.values()).sort((O,D)=>R.indexOf(O.ref.current)-R.indexOf(D.ref.current))},[k.collectionRef,k.itemMap])}return wn(x,"useCollection"),[{Provider:o,Slot:f,ItemSlot:b},x,r]}wn(iL,"createCollection");var $R=new WeakMap,cn,Er,Kv=(Er=class extends Map{constructor(n){super(n);nT(this,cn);Kb(this,cn,[...super.keys()]),$R.set(this,!0)}set(n,r){return $R.get(this)&&(this.has(n)?Vn(this,cn)[Vn(this,cn).indexOf(n)]=n:Vn(this,cn).push(n)),super.set(n,r),this}insert(n,r,i){const s=this.has(r),o=Vn(this,cn).length,l=LS(n);let u=l>=0?l:o+l;const f=u<0||u>=o?-1:u;if(f===this.size||s&&f===this.size-1||f===-1)return this.set(r,i),this;const h=this.size+(s?0:1);l<0&&u++;const m=[...Vn(this,cn)];let g,b=!1;for(let x=u;x<h;x++)if(u===x){let S=m[x];m[x]===r&&(S=m[x+1]),s&&this.delete(r),g=this.get(S),this.set(r,i)}else{!b&&m[x-1]===r&&(b=!0);const S=m[b?x:x-1],k=g;g=this.get(S),this.delete(S),this.set(S,k)}return this}with(n,r,i){const s=new Er(this);return s.insert(n,r,i),s}before(n){const r=Vn(this,cn).indexOf(n)-1;if(!(r<0))return this.entryAt(r)}setBefore(n,r,i){const s=Vn(this,cn).indexOf(n);return s===-1?this:this.insert(s,r,i)}after(n){let r=Vn(this,cn).indexOf(n);if(r=r===-1||r===this.size-1?-1:r+1,r!==-1)return this.entryAt(r)}setAfter(n,r,i){const s=Vn(this,cn).indexOf(n);return s===-1?this:this.insert(s+1,r,i)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return Kb(this,cn,[]),super.clear()}delete(n){const r=super.delete(n);return r&&Vn(this,cn).splice(Vn(this,cn).indexOf(n),1),r}deleteAt(n){const r=this.keyAt(n);return r!==void 0?this.delete(r):!1}at(n){const r=bp(Vn(this,cn),n);if(r!==void 0)return this.get(r)}entryAt(n){const r=bp(Vn(this,cn),n);if(r!==void 0)return[r,this.get(r)]}indexOf(n){return Vn(this,cn).indexOf(n)}keyAt(n){return bp(Vn(this,cn),n)}from(n,r){const i=this.indexOf(n);if(i===-1)return;let s=i+r;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.at(s)}keyFrom(n,r){const i=this.indexOf(n);if(i===-1)return;let s=i+r;return s<0&&(s=0),s>=this.size&&(s=this.size-1),this.keyAt(s)}find(n,r){let i=0;for(const s of this){if(Reflect.apply(n,r,[s,i,this]))return s;i++}}findIndex(n,r){let i=0;for(const s of this){if(Reflect.apply(n,r,[s,i,this]))return i;i++}return-1}filter(n,r){const i=[];let s=0;for(const o of this)Reflect.apply(n,r,[o,s,this])&&i.push(o),s++;return new Er(i)}map(n,r){const i=[];let s=0;for(const o of this)i.push([o[0],Reflect.apply(n,r,[o,s,this])]),s++;return new Er(i)}reduce(...n){const[r,i]=n;let s=0,o=i??this.at(0);for(const l of this)s===0&&n.length===1?o=l:o=Reflect.apply(r,this,[o,l,s,this]),s++;return o}reduceRight(...n){const[r,i]=n;let s=i??this.at(-1);for(let o=this.size-1;o>=0;o--){const l=this.at(o);o===this.size-1&&n.length===1?s=l:s=Reflect.apply(r,this,[s,l,o,this])}return s}toSorted(n){const r=[...this.entries()].sort(n);return new Er(r)}toReversed(){const n=new Er;for(let r=this.size-1;r>=0;r--){const i=this.keyAt(r),s=this.get(i);n.set(i,s)}return n}toSpliced(...n){const r=[...this.entries()];return r.splice(...n),new Er(r)}slice(n,r){const i=new Er;let s=this.size-1;if(n===void 0)return i;n<0&&(n=n+this.size),r!==void 0&&r>0&&(s=r-1);for(let o=n;o<=s;o++){const l=this.keyAt(o),u=this.get(l);i.set(l,u)}return i}every(n,r){let i=0;for(const s of this){if(!Reflect.apply(n,r,[s,i,this]))return!1;i++}return!0}some(n,r){let i=0;for(const s of this){if(Reflect.apply(n,r,[s,i,this]))return!0;i++}return!1}},cn=new WeakMap,wn(Er,"OrderedDict"),Er);function bp(t,e){if("at"in Array.prototype)return Array.prototype.at.call(t,e);const n=sL(t,e);return n===-1?void 0:t[n]}wn(bp,"at");function sL(t,e){const n=t.length,r=LS(e),i=r>=0?r:n+r;return i<0||i>=n?-1:i}wn(sL,"toSafeIndex");function LS(t){return t!==t||t===0?0:Math.trunc(t)}wn(LS,"toSafeInteger");function XZ(t){const e=t+"CollectionProvider",[n,r]=Ic(e),[i,s]=n(e,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new Kv,setItemMap:wn(()=>{},"setItemMap")}),o=wn(({state:R,..._})=>R?y.jsx(u,{..._,state:R}):y.jsx(l,{..._}),"CollectionProvider");o.displayName=e;const l=wn(R=>{const _=k();return y.jsx(u,{...R,state:_})},"CollectionInit");l.displayName=e+"Init";const u=wn(R=>{const{scope:_,children:M,state:O}=R,D=E.useRef(null),[I,P]=E.useState(null),B=rn(D,P),[re,K]=O;return E.useEffect(()=>{if(!I)return;const ee=lL(()=>{});return ee.observe(I,{childList:!0,subtree:!0}),()=>{ee.disconnect()}},[I]),y.jsx(i,{scope:_,itemMap:re,setItemMap:K,collectionRef:B,collectionRefObject:D,collectionElement:I,children:M})},"CollectionProviderImpl");u.displayName=e+"Impl";const f=t+"CollectionSlot",h=Pa(f),m=E.forwardRef((R,_)=>{const{scope:M,children:O}=R,D=s(f,M),I=rn(_,D.collectionRef);return y.jsx(h,{ref:I,children:O})});m.displayName=f;const g=t+"CollectionItemSlot",b="data-radix-collection-item",x=Pa(g),S=E.forwardRef((R,_)=>{const{scope:M,children:O,...D}=R,I=E.useRef(null),[P,B]=E.useState(null),re=rn(_,I,B),K=s(g,M),{setItemMap:ee}=K,Q=E.useRef(D);oL(Q.current,D)||(Q.current=D);const fe=Q.current;return E.useEffect(()=>{const z=fe;return ee(L=>P?L.has(P)?L.set(P,{...z,element:P}).toSorted(Px):(L.set(P,{...z,element:P}),L.toSorted(Px)):L),()=>{ee(L=>!P||!L.has(P)?L:(L.delete(P),new Kv(L)))}},[P,fe,ee]),y.jsx(x,{[b]:"",ref:re,children:O})});S.displayName=g;function k(){return E.useState(new Kv)}wn(k,"useInitCollection");function C(R){const{itemMap:_}=s(t+"CollectionConsumer",R);return _}return wn(C,"useCollection"),[{Provider:o,Slot:m,ItemSlot:S},{createCollectionScope:r,useCollection:C,useInitCollection:k}]}wn(XZ,"createCollection");function oL(t,e){if(t===e)return!0;if(typeof t!="object"||typeof e!="object"||t==null||e==null)return!1;const n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(const i of n)if(!Object.prototype.hasOwnProperty.call(e,i)||t[i]!==e[i])return!1;return!0}wn(oL,"shallowEqual");function aL(t,e){return!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING)}wn(aL,"isElementPreceding");function Px(t,e){return!t[1].element||!e[1].element?0:aL(t[1].element,e[1].element)?-1:1}wn(Px,"sortByDocumentPosition");function lL(t){return new MutationObserver(n=>{for(const r of n)if(r.type==="childList"){t();return}})}wn(lL,"getChildListObserver");var JZ=Object.defineProperty,QZ=(t,e)=>JZ(t,"name",{value:e,configurable:!0}),eY=E.createContext(void 0);function cL(t){const e=E.useContext(eY);return t||e||"ltr"}QZ(cL,"useDirection");var tY=Object.defineProperty,nY=(t,e)=>tY(t,"name",{value:e,configurable:!0});function Pi(t){const e=E.useRef(t);return E.useEffect(()=>{e.current=t}),E.useMemo(()=>((...n)=>e.current?.(...n)),[])}nY(Pi,"useCallbackRef");var rY=Object.defineProperty,xn=(t,e)=>rY(t,"name",{value:e,configurable:!0}),zx="dismissableLayer.update",iY="dismissableLayer.pointerDownOutside",sY="dismissableLayer.focusOutside",BR,uL=E.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),oY=E.forwardRef(xn(function(e,n){const{disableOutsidePointerEvents:r=!1,deferPointerDownOutside:i=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:l,onInteractOutside:u,onDismiss:f,...h}=e,m=E.useContext(uL),[g,b]=E.useState(null),x=g?.ownerDocument??globalThis?.document,[,S]=E.useState({}),k=rn(n,b),C=Array.from(m.layers),[A]=[...m.layersWithOutsidePointerEventsDisabled].slice(-1),R=A?C.indexOf(A):-1,_=g?C.indexOf(g):-1,M=m.layersWithOutsidePointerEventsDisabled.size>0,O=_>=R,D=E.useRef(!1),I=dL(K=>{o?.(K),u?.(K),K.defaultPrevented||f?.()},{ownerDocument:x,deferPointerDownOutside:i,isDeferredPointerDownOutsideRef:D,dismissableSurfaces:m.dismissableSurfaces,shouldHandlePointerDownOutside:E.useCallback(K=>{if(!(K instanceof Node))return!1;const ee=[...m.branches].some(Q=>Q.contains(K));return O&&!ee},[m.branches,O])}),P=fL(K=>{if(i&&D.current)return;const ee=K.target;[...m.branches].some(fe=>fe.contains(ee))||(l?.(K),u?.(K),K.defaultPrevented||f?.())},x),B=g?_===C.length-1:!1,re=Pi(K=>{K.key==="Escape"&&(s?.(K),!K.defaultPrevented&&f&&(K.preventDefault(),f()))});return E.useEffect(()=>{if(B)return x.addEventListener("keydown",re,{capture:!0}),()=>x.removeEventListener("keydown",re,{capture:!0})},[x,B,re]),E.useEffect(()=>{if(g)return r&&(m.layersWithOutsidePointerEventsDisabled.size===0&&(BR=x.body.style.pointerEvents,x.body.style.pointerEvents="none"),m.layersWithOutsidePointerEventsDisabled.add(g)),m.layers.add(g),$x(),()=>{r&&(m.layersWithOutsidePointerEventsDisabled.delete(g),m.layersWithOutsidePointerEventsDisabled.size===0&&(x.body.style.pointerEvents=BR))}},[g,x,r,m]),E.useEffect(()=>()=>{g&&(m.layers.delete(g),m.layersWithOutsidePointerEventsDisabled.delete(g),$x())},[g,m]),E.useEffect(()=>{const K=xn(()=>S({}),"handleUpdate");return document.addEventListener(zx,K),()=>document.removeEventListener(zx,K)},[]),y.jsx(En.div,{...h,ref:k,style:{pointerEvents:M?O?"auto":"none":void 0,...e.style},onFocusCapture:dn(e.onFocusCapture,P.onFocusCapture),onBlurCapture:dn(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:dn(e.onPointerDownCapture,I.onPointerDownCapture)})},"DismissableLayer"));function aY(){const t=E.useContext(uL),[e,n]=E.useState(null);return E.useEffect(()=>{if(e)return t.dismissableSurfaces.add(e),()=>{t.dismissableSurfaces.delete(e)}},[e,t.dismissableSurfaces]),n}xn(aY,"useDismissableLayerSurface");var lY=xn(()=>!0,"IS_TRUE");function dL(t,e){const{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s,shouldHandlePointerDownOutside:o=lY}=e,l=Pi(t),u=E.useRef(!1),f=E.useRef(!1),h=E.useRef(new Map),m=E.useRef(()=>{});return E.useEffect(()=>{function g(){f.current=!1,i.current=!1,h.current.clear()}xn(g,"resetOutsideInteraction");function b(){return Array.from(h.current.values()).some(Boolean)}xn(b,"isOutsideInteractionIntercepted");function x(R){if(!f.current)return;const _=R.target;_ instanceof Node&&[...s].some(O=>O.contains(_))||h.current.set(R.type,!0),R.type==="click"&&window.setTimeout(()=>{f.current&&m.current()},0)}xn(x,"handleInteractionCapture");function S(R){f.current&&h.current.set(R.type,!1)}xn(S,"handleInteractionBubble");const k=xn(R=>{if(R.target&&!u.current){let _=function(){n.removeEventListener("click",m.current);const O=b();g(),O||PS(iY,l,M,{discrete:!0})};if(xn(_,"handleAndDispatchPointerDownOutsideEvent"),!o(R.target)){n.removeEventListener("click",m.current),g(),u.current=!1;return}const M={originalEvent:R};f.current=!0,i.current=r&&R.button===0,h.current.clear(),!r||R.button!==0?_():(n.removeEventListener("click",m.current),m.current=_,n.addEventListener("click",m.current,{once:!0}))}else n.removeEventListener("click",m.current),g();u.current=!1},"handlePointerDown"),C=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const R of C)n.addEventListener(R,x,!0),n.addEventListener(R,S);const A=window.setTimeout(()=>{n.addEventListener("pointerdown",k)},0);return()=>{window.clearTimeout(A),n.removeEventListener("pointerdown",k),n.removeEventListener("click",m.current);for(const R of C)n.removeEventListener(R,x,!0),n.removeEventListener(R,S)}},[n,l,r,i,s,o]),{onPointerDownCapture:xn(()=>u.current=!0,"onPointerDownCapture")}}xn(dL,"usePointerDownOutside");function fL(t,e=globalThis?.document){const n=Pi(t),r=E.useRef(!1);return E.useEffect(()=>{const i=xn(s=>{s.target&&!r.current&&PS(sY,n,{originalEvent:s},{discrete:!1})},"handleFocus");return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:xn(()=>r.current=!0,"onFocusCapture"),onBlurCapture:xn(()=>r.current=!1,"onBlurCapture")}}xn(fL,"useFocusOutside");function $x(){const t=new CustomEvent(zx);document.dispatchEvent(t)}xn($x,"dispatchUpdate");function PS(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?pO(i,s):i.dispatchEvent(s)}xn(PS,"handleAndDispatchCustomEvent");var cY=Object.defineProperty,zS=(t,e)=>cY(t,"name",{value:e,configurable:!0}),qh=0,Ul=null;function uY(t){return $S(),t.children}zS(uY,"FocusGuards");function $S(){E.useEffect(()=>{Ul||(Ul={start:Bx(),end:Bx()});const{start:t,end:e}=Ul;return document.body.firstElementChild!==t&&document.body.insertAdjacentElement("afterbegin",t),document.body.lastElementChild!==e&&document.body.insertAdjacentElement("beforeend",e),qh++,()=>{qh===1&&(Ul?.start.remove(),Ul?.end.remove(),Ul=null),qh=Math.max(0,qh-1)}},[])}zS($S,"useFocusGuards");function Bx(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}zS(Bx,"createFocusGuard");var dY=Object.defineProperty,er=(t,e)=>dY(t,"name",{value:e,configurable:!0}),Zv="focusScope.autoFocusOnMount",Yv="focusScope.autoFocusOnUnmount",VR={bubbles:!1,cancelable:!0},fY=E.forwardRef(er(function(e,n){const{loop:r=!1,trapped:i=!1,onMountAutoFocus:s,onUnmountAutoFocus:o,...l}=e,[u,f]=E.useState(null),h=Pi(s),m=Pi(o),g=E.useRef(null),b=rn(n,f),x=E.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;E.useEffect(()=>{if(i){let k=function(_){if(x.paused||!u)return;const M=_.target;u.contains(M)?g.current=M:ps(g.current,{select:!0})},C=function(_){if(x.paused||!u)return;const M=_.relatedTarget;M!==null&&(u.contains(M)||ps(g.current,{select:!0}))},A=function(_){if(document.activeElement===document.body)for(const O of _)O.removedNodes.length>0&&ps(u)};er(k,"handleFocusIn"),er(C,"handleFocusOut"),er(A,"handleMutations"),document.addEventListener("focusin",k),document.addEventListener("focusout",C);const R=new MutationObserver(A);return u&&R.observe(u,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",k),document.removeEventListener("focusout",C),R.disconnect()}}},[i,u,x.paused]),E.useEffect(()=>{if(u){HR.add(x);const k=document.activeElement;if(!u.contains(k)){const A=new CustomEvent(Zv,VR);u.addEventListener(Zv,h),u.dispatchEvent(A),A.defaultPrevented||(hL(bL(BS(u)),{select:!0}),document.activeElement===k&&ps(u))}return()=>{u.removeEventListener(Zv,h),setTimeout(()=>{const A=new CustomEvent(Yv,VR);u.addEventListener(Yv,m),u.dispatchEvent(A),A.defaultPrevented||ps(k??document.body,{select:!0}),u.removeEventListener(Yv,m),HR.remove(x)},0)}}},[u,h,m,x]);const S=E.useCallback(k=>{if(!r&&!i||x.paused)return;const C=k.key==="Tab"&&!k.altKey&&!k.ctrlKey&&!k.metaKey,A=document.activeElement;if(C&&A){const R=k.currentTarget,[_,M]=pL(R);_&&M?!k.shiftKey&&A===M?(k.preventDefault(),r&&ps(_,{select:!0})):k.shiftKey&&A===_&&(k.preventDefault(),r&&ps(M,{select:!0})):A===R&&k.preventDefault()}},[r,i,x.paused]);return y.jsx(En.div,{tabIndex:-1,...l,ref:b,onKeyDown:S})},"FocusScope"));function hL(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(ps(r,{select:e}),document.activeElement!==n)return}er(hL,"focusFirst");function pL(t){const e=BS(t),n=Vx(e,t),r=Vx(e.reverse(),t);return[n,r]}er(pL,"getTabbableEdges");function BS(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:er(r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},"acceptNode")});for(;n.nextNode();)e.push(n.currentNode);return e}er(BS,"getTabbableCandidates");function Vx(t,e){const n=typeof e.checkVisibility=="function"&&e.checkVisibility({checkVisibilityCSS:!0});for(const r of t)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):mL(r,{upTo:e})))return r}er(Vx,"findVisible");function mL(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}er(mL,"isHidden");function gL(t){return t instanceof HTMLInputElement&&"select"in t}er(gL,"isSelectableInput");function ps(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&gL(t)&&e&&t.select()}}er(ps,"focus");var HR=yL();function yL(){let t=[];return{add(e){const n=t[0];e!==n&&n?.pause(),t=Hx(t,e),t.unshift(e)},remove(e){t=Hx(t,e),t[0]?.resume()}}}er(yL,"createFocusScopesStack");function Hx(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}er(Hx,"arrayRemove");function bL(t){return t.filter(e=>e.tagName!=="A")}er(bL,"removeLinks");var hY=Object.defineProperty,pY=(t,e)=>hY(t,"name",{value:e,configurable:!0}),mY=Hd[" useId ".trim().toString()]||(()=>{}),gY=0;function VS(t){const[e,n]=E.useState(mY());return tr(()=>{t||n(r=>r??String(gY++))},[t]),t||(e?`radix-${e}`:"")}pY(VS,"useId");const yY=["top","right","bottom","left"],Uo=Math.min,_s=Math.max,Dm=Math.round,Gh=Math.floor,As=t=>({x:t,y:t}),bY={left:"right",right:"left",bottom:"top",top:"bottom"};function vL(t,e,n){return _s(t,Uo(e,n))}function Os(t,e){return typeof t=="function"?t(e):t}function Fo(t){return t.split("-")[0]}function Pc(t){return t.split("-")[1]}function HS(t){return t==="x"?"y":"x"}function US(t){return t==="y"?"height":"width"}function Di(t){const e=t[0];return e==="t"||e==="b"?"y":"x"}function FS(t){return HS(Di(t))}function vY(t,e,n){n===void 0&&(n=!1);const r=Pc(t),i=FS(t),s=US(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=Im(o)),[o,Im(o)]}function xY(t){const e=Im(t);return[Ux(t),e,Ux(e)]}function Ux(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const UR=["left","right"],FR=["right","left"],wY=["top","bottom"],SY=["bottom","top"];function kY(t,e,n){switch(t){case"top":case"bottom":return n?e?FR:UR:e?UR:FR;case"left":case"right":return e?wY:SY;default:return[]}}function CY(t,e,n,r){const i=Pc(t);let s=kY(Fo(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(Ux)))),s}function Im(t){const e=Fo(t);return bY[e]+t.slice(e.length)}function EY(t){var e,n,r,i;return{top:(e=t.top)!=null?e:0,right:(n=t.right)!=null?n:0,bottom:(r=t.bottom)!=null?r:0,left:(i=t.left)!=null?i:0}}function xL(t){return typeof t!="number"?EY(t):{top:t,right:t,bottom:t,left:t}}function jm(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function qR(t,e,n){let{reference:r,floating:i}=t;const s=Di(e),o=FS(e),l=US(o),u=Fo(e),f=s==="y",h=r.x+r.width/2-i.width/2,m=r.y+r.height/2-i.height/2,g=r[l]/2-i[l]/2;let b;switch(u){case"top":b={x:h,y:r.y-i.height};break;case"bottom":b={x:h,y:r.y+r.height};break;case"right":b={x:r.x+r.width,y:m};break;case"left":b={x:r.x-i.width,y:m};break;default:b={x:r.x,y:r.y}}const x=Pc(e);return x&&(b[o]+=g*(x==="end"?1:-1)*(n&&f?-1:1)),b}async function TY(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:l,strategy:u}=t,{boundary:f="clippingAncestors",rootBoundary:h="viewport",elementContext:m="floating",altBoundary:g=!1,padding:b=0}=Os(e,t),x=xL(b),k=l[g?m==="floating"?"reference":"floating":m],C=jm(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:f,rootBoundary:h,strategy:u})),A=m==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,R=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(R))&&await(s.getScale==null?void 0:s.getScale(R))||{x:1,y:1},M=jm(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:A,offsetParent:R,strategy:u}):A);return{top:(C.top-M.top+x.top)/_.y,bottom:(M.bottom-C.bottom+x.bottom)/_.y,left:(C.left-M.left+x.left)/_.x,right:(M.right-C.right+x.right)/_.x}}const _Y=50,AY=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,l=o.detectOverflow?o:{...o,detectOverflow:TY},u=await(o.isRTL==null?void 0:o.isRTL(e));let f=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:h,y:m}=qR(f,r,u),g=r,b=0;const x={};for(let S=0;S<s.length;S++){const k=s[S];if(!k)continue;const{name:C,fn:A}=k,{x:R,y:_,data:M,reset:O}=await A({x:h,y:m,initialPlacement:r,placement:g,strategy:i,middlewareData:x,rects:f,platform:l,elements:{reference:t,floating:e}});h=R??h,m=_??m,x[C]={...x[C],...M},O&&b<_Y&&(b++,typeof O=="object"&&(O.placement&&(g=O.placement),O.rects&&(f=O.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):O.rects),{x:h,y:m}=qR(f,g,u)),S=-1)}return{x:h,y:m,placement:g,strategy:i,middlewareData:x}},RY=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:l,middlewareData:u}=e,{element:f,padding:h=0}=Os(t,e)||{};if(f==null)return{};const m=xL(h),g={x:n,y:r},b=FS(i),x=US(b),S=await o.getDimensions(f),k=b==="y",C=k?"top":"left",A=k?"bottom":"right",R=k?"clientHeight":"clientWidth",_=s.reference[x]+s.reference[b]-g[b]-s.floating[x],M=g[b]-s.reference[b],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(f));let D=O?O[R]:0;(!D||!await(o.isElement==null?void 0:o.isElement(O)))&&(D=l.floating[R]||s.floating[x]);const I=_/2-M/2,P=D/2-S[x]/2-1,B=Uo(m[C],P),re=Uo(m[A],P),K=D-S[x]-re,ee=D/2-S[x]/2+I,Q=vL(B,ee,K),fe=!u.arrow&&Pc(i)!=null&&ee!==Q&&s.reference[x]/2-(ee<B?B:re)-S[x]/2<0,z=fe?ee<B?ee-B:ee-K:0;return{[b]:g[b]+z,data:{[b]:Q,centerOffset:ee-Q-z,...fe&&{alignmentOffset:z}},reset:fe}}}),MY=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:l,platform:u,elements:f}=e,{mainAxis:h=!0,crossAxis:m=!0,fallbackPlacements:g,fallbackStrategy:b="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:S=!0,...k}=Os(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const C=Fo(i),A=Di(l),R=Fo(l)===l,_=await(u.isRTL==null?void 0:u.isRTL(f.floating)),M=g||(R||!S?[Im(l)]:xY(l)),O=x!=="none";!g&&O&&M.push(...CY(l,S,x,_));const D=[l,...M],I=await u.detectOverflow(e,k),P=[];let B=((r=s.flip)==null?void 0:r.overflows)||[];if(h&&P.push(I[C]),m){const Q=vY(i,o,_);P.push(I[Q[0]],I[Q[1]])}if(B=[...B,{placement:i,overflows:P}],!P.every(Q=>Q<=0)){var re,K;const Q=(((re=s.flip)==null?void 0:re.index)||0)+1,fe=D[Q];if(fe&&(!(m==="alignment"?A!==Di(fe):!1)||B.every(G=>Di(G.placement)===A?G.overflows[0]>0:!0)))return{data:{index:Q,overflows:B},reset:{placement:fe}};let z=(K=B.filter(L=>L.overflows[0]<=0).sort((L,G)=>L.overflows[1]-G.overflows[1])[0])==null?void 0:K.placement;if(!z)switch(b){case"bestFit":{var ee;const L=(ee=B.filter(G=>{if(O){const he=Di(G.placement);return he===A||he==="y"}return!0}).map(G=>[G.placement,G.overflows.filter(he=>he>0).reduce((he,ke)=>he+ke,0)]).sort((G,he)=>G[1]-he[1])[0])==null?void 0:ee[0];L&&(z=L);break}case"initialPlacement":z=l;break}if(i!==z)return{reset:{placement:z}}}return{}}}};function GR(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function WR(t){return yY.some(e=>t[e]>=0)}const NY=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:r}=e,{strategy:i="referenceHidden",...s}=Os(t,e);switch(i){case"referenceHidden":{const o=await r.detectOverflow(e,{...s,elementContext:"reference"}),l=GR(o,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:WR(l)}}}case"escaped":{const o=await r.detectOverflow(e,{...s,altBoundary:!0}),l=GR(o,n.floating);return{data:{escapedOffsets:l,escaped:WR(l)}}}default:return{}}}}},wL=new Set(["left","top"]);async function OY(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=Fo(n),l=Pc(n),u=Di(n)==="y",f=wL.has(o)?-1:1,h=s&&u?-1:1,m=Os(e,t);let{mainAxis:g,crossAxis:b,alignmentAxis:x}=typeof m=="number"?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return l&&typeof x=="number"&&(b=l==="end"?x*-1:x),u?{x:b*h,y:g*f}:{x:g*f,y:b*h}}const DY=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:l}=e,u=await OY(e,t);return o===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+u.x,y:s+u.y,data:{...u,placement:o}}}}},IY=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i,platform:s}=e,{mainAxis:o=!0,crossAxis:l=!1,limiter:u={fn:A=>{let{x:R,y:_}=A;return{x:R,y:_}}},...f}=Os(t,e),h={x:n,y:r},m=await s.detectOverflow(e,f),g=Di(i),b=HS(g);let x=h[b],S=h[g];const k=(A,R)=>vL(R+m[A==="y"?"top":"left"],R,R-m[A==="y"?"bottom":"right"]);o&&(x=k(b,x)),l&&(S=k(g,S));const C=u.fn({...e,[b]:x,[g]:S});return{...C,data:{x:C.x-n,y:C.y-r,enabled:{[b]:o,[g]:l}}}}}},jY=function(t){return t===void 0&&(t={}),{options:t,fn(e){var n,r;const{x:i,y:s,placement:o,rects:l,middlewareData:u}=e,{offset:f=0,mainAxis:h=!0,crossAxis:m=!0}=Os(t,e),g={x:i,y:s},b=Di(o),x=HS(b);let S=g[x],k=g[b];const C=Os(f,e),A=typeof C=="number"?{mainAxis:C,crossAxis:0}:{mainAxis:(n=C.mainAxis)!=null?n:0,crossAxis:(r=C.crossAxis)!=null?r:0};if(h){const M=x==="y"?"height":"width",O=l.reference[x]-l.floating[M]+A.mainAxis,D=l.reference[x]+l.reference[M]-A.mainAxis;S<O?S=O:S>D&&(S=D)}if(m){var R,_;const M=x==="y"?"width":"height",O=wL.has(Fo(o)),D=l.reference[b]-l.floating[M]+(O&&((R=u.offset)==null?void 0:R[b])||0)+(O?0:A.crossAxis),I=l.reference[b]+l.reference[M]+(O?0:((_=u.offset)==null?void 0:_[b])||0)-(O?A.crossAxis:0);k<D?k=D:k>I&&(k=I)}return{[x]:S,[b]:k}}}},LY=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:i,elements:s}=e,{apply:o=()=>{},...l}=Os(t,e),u=await i.detectOverflow(e,l),f=Fo(n),h=Pc(n),m=Di(n)==="y",{width:g,height:b}=r.floating;let x,S;f==="top"||f==="bottom"?(x=f,S=h===(await(i.isRTL==null?void 0:i.isRTL(s.floating))?"start":"end")?"left":"right"):(S=f,x=h==="end"?"top":"bottom");const k=b-u.top-u.bottom,C=g-u.left-u.right,A=Uo(b-u[x],k),R=Uo(g-u[S],C),_=e.middlewareData.shift,M=!_;let O=A,D=R;_!=null&&_.enabled.x&&(D=C),_!=null&&_.enabled.y&&(O=k),M&&!h&&(m?D=g-2*_s(u.left,u.right):O=b-2*_s(u.top,u.bottom)),await o({...e,availableWidth:D,availableHeight:O});const I=await i.getDimensions(s.floating);return g!==I.width||b!==I.height?{reset:{rects:!0}}:{}}}};function gg(){return typeof window<"u"}function zc(t){return SL(t)?(t.nodeName||"").toLowerCase():"#document"}function gr(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Ls(t){var e;return(e=(SL(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function SL(t){return gg()?t instanceof Node||t instanceof gr(t).Node:!1}function zi(t){return gg()?t instanceof Element||t instanceof gr(t).Element:!1}function Xo(t){return gg()?t instanceof HTMLElement||t instanceof gr(t).HTMLElement:!1}function KR(t){return!gg()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof gr(t).ShadowRoot}function yg(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=$i(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&i!=="inline"&&i!=="contents"}function PY(t){return/^(table|td|th)$/.test(zc(t))}function bg(t){try{if(t.matches(":popover-open"))return!0}catch{}try{return t.matches(":modal")}catch{return!1}}const zY=/transform|translate|scale|rotate|perspective|filter/,$Y=/paint|layout|strict|content/,ga=t=>!!t&&t!=="none";let Xv;function qS(t){const e=zi(t)?$i(t):t;return ga(e.transform)||ga(e.translate)||ga(e.scale)||ga(e.rotate)||ga(e.perspective)||!GS()&&(ga(e.backdropFilter)||ga(e.filter))||zY.test(e.willChange||"")||$Y.test(e.contain||"")}function BY(t){let e=qa(t);for(;Xo(e)&&!$d(e);){if(qS(e))return e;if(bg(e))return null;e=qa(e)}return null}function GS(){return Xv==null&&(Xv=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Xv}function $d(t){return/^(html|body|#document)$/.test(zc(t))}function $i(t){return gr(t).getComputedStyle(t)}function vg(t){return zi(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function qa(t){if(zc(t)==="html")return t;const e=t.assignedSlot||t.parentNode||KR(t)&&t.host||Ls(t);return KR(e)?e.host:e}function kL(t){const e=qa(t);return $d(e)?(t.ownerDocument||t).body:Xo(e)&&yg(e)?e:kL(e)}function Bd(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=kL(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=gr(i);if(s){const l=Fx(o);return e.concat(o,o.visualViewport||[],yg(i)?i:[],l&&n?Bd(l):[])}else return e.concat(i,Bd(i,[],n))}function Fx(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function CL(t){const e=$i(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Xo(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,l=Dm(n)!==s||Dm(r)!==o;return l&&(n=s,r=o),{width:n,height:r,$:l}}function WS(t){return zi(t)?t:t.contextElement}function lc(t){const e=WS(t);if(!Xo(e))return As(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=CL(e);let o=(s?Dm(n.width):n.width)/r,l=(s?Dm(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!l||!Number.isFinite(l))&&(l=1),{x:o,y:l}}const VY=As(0);function EL(t){const e=gr(t);return!GS()||!e.visualViewport?VY:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function HY(t,e,n){return e===void 0&&(e=!1),!!n&&e&&n===gr(t)}function Ga(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=WS(t);let o=As(1);e&&(r?zi(r)&&(o=lc(r)):o=lc(t));const l=HY(s,n,r)?EL(s):As(0);let u=(i.left+l.x)/o.x,f=(i.top+l.y)/o.y,h=i.width/o.x,m=i.height/o.y;if(s&&r){const g=gr(s),b=zi(r)?gr(r):r;let x=g,S=Fx(x);for(;S&&b!==x;){const k=lc(S),C=S.getBoundingClientRect(),A=$i(S),R=C.left+(S.clientLeft+parseFloat(A.paddingLeft))*k.x,_=C.top+(S.clientTop+parseFloat(A.paddingTop))*k.y;u*=k.x,f*=k.y,h*=k.x,m*=k.y,u+=R,f+=_,x=gr(S),S=Fx(x)}}return jm({width:h,height:m,x:u,y:f})}function xg(t,e){const n=vg(t).scrollLeft;return e?e.left+n:Ga(Ls(t)).left+n}function TL(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-xg(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function UY(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Ls(r),l=e?bg(e.floating):!1;if(r===o||l&&s)return n;let u={scrollLeft:0,scrollTop:0},f=As(1);const h=As(0),m=Xo(r);if((m||!s)&&((zc(r)!=="body"||yg(o))&&(u=vg(r)),m)){const b=Ga(r);f=lc(r),h.x=b.x+r.clientLeft,h.y=b.y+r.clientTop}const g=o&&!m&&!s?TL(o,u):As(0);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-u.scrollLeft*f.x+h.x+g.x,y:n.y*f.y-u.scrollTop*f.y+h.y+g.y}}function FY(t){return t.getClientRects?Array.from(t.getClientRects()):[]}function qY(t){const e=vg(t),n=t.ownerDocument.body,r=_s(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),i=_s(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let s=-e.scrollLeft+xg(t);const o=-e.scrollTop;return $i(n).direction==="rtl"&&(s+=_s(t.clientWidth,n.clientWidth)-r),{width:r,height:i,x:s,y:o}}const GY=25;function WY(t,e,n){n===void 0&&(n="viewport");const r=n==="layoutViewport",i=gr(t),s=Ls(t),o=i.visualViewport;let l=s.clientWidth,u=s.clientHeight,f=0,h=0;if(o){const g=!GS()||e==="fixed";r?g||(f=-o.offsetLeft,h=-o.offsetTop):(l=o.width,u=o.height,g&&(f=o.offsetLeft,h=o.offsetTop))}if(xg(s)<=0){const g=s.ownerDocument,b=g.body,x=getComputedStyle(b),S=g.compatMode==="CSS1Compat"&&parseFloat(x.marginLeft)+parseFloat(x.marginRight)||0,k=Math.abs(s.clientWidth-b.clientWidth-S),C=getComputedStyle(s).scrollbarGutter==="stable both-edges"?k/2:k;C<=GY&&(l-=C)}return{width:l,height:u,x:f,y:h}}function KY(t,e){const n=Ga(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=lc(t),o=t.clientWidth*s.x,l=t.clientHeight*s.y,u=i*s.x,f=r*s.y;return{width:o,height:l,x:u,y:f}}function ZR(t,e,n){let r;if(e==="viewport"||e==="layoutViewport")r=WY(t,n,e);else if(e==="document")r=qY(Ls(t));else if(zi(e))r=KY(e,n);else{const i=EL(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return jm(r)}function ZY(t,e){const n=e.get(t);if(n)return n;let r=Bd(t,[],!1).filter(l=>zi(l)&&zc(l)!=="body"),i=null;const s=$i(t).position==="fixed";let o=s?qa(t):t;for(;zi(o)&&!$d(o);){const l=$i(o),u=qS(o),f=i?i.position:s?"fixed":"";!u&&(f==="fixed"||f==="absolute"&&l.position==="static")?r=r.filter(m=>m!==o):i=l,o=qa(o)}return e.set(t,r),r}function YY(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?bg(e)?[]:ZY(e,this._c):[].concat(n),r],l=ZR(e,o[0],i);let u=l.top,f=l.right,h=l.bottom,m=l.left;for(let g=1;g<o.length;g++){const b=ZR(e,o[g],i);u=_s(b.top,u),f=Uo(b.right,f),h=Uo(b.bottom,h),m=_s(b.left,m)}return{width:f-m,height:h-u,x:m,y:u}}function XY(t){const{width:e,height:n}=CL(t);return{width:e,height:n}}function JY(t,e,n){const r=Xo(e),i=Ls(e),s=n==="fixed",o=Ga(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const u=As(0);if((r||!s)&&((zc(e)!=="body"||yg(i))&&(l=vg(e)),r)){const g=Ga(e,!0,s,e);u.x=g.x+e.clientLeft,u.y=g.y+e.clientTop}!r&&i&&(u.x=xg(i));const f=i&&!r&&!s?TL(i,l):As(0),h=o.left+l.scrollLeft-u.x-f.x,m=o.top+l.scrollTop-u.y-f.y;return{x:h,y:m,width:o.width,height:o.height}}function Jv(t){return $i(t).position==="static"}function YR(t,e){if(!Xo(t)||$i(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Ls(t)===n&&(n=n.ownerDocument.body),n}function _L(t,e){const n=gr(t);if(bg(t))return n;if(!Xo(t)){let i=qa(t);for(;i&&!$d(i);){if(zi(i)&&!Jv(i))return i;i=qa(i)}return n}let r=YR(t,e);for(;r&&PY(r)&&Jv(r);)r=YR(r,e);return r&&$d(r)&&Jv(r)&&!qS(r)?n:r||BY(t)||n}const QY=async function(t){const e=this.getOffsetParent||_L,n=this.getDimensions,r=await n(t.floating);return{reference:JY(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function eX(t){return $i(t).direction==="rtl"}const tX={convertOffsetParentRelativeRectToViewportRelativeRect:UY,getDocumentElement:Ls,getClippingRect:YY,getOffsetParent:_L,getElementRects:QY,getClientRects:FY,getDimensions:XY,getScale:lc,isElement:zi,isRTL:eX};function AL(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function nX(t,e,n){let r=null,i;const s=Ls(t);function o(){var h;clearTimeout(i),(h=r)==null||h.disconnect(),r=null}function l(h,m){h===void 0&&(h=!1),m===void 0&&(m=1),o();const g=t.getBoundingClientRect(),{left:b,top:x,width:S,height:k}=g;if(h||e(),!S||!k)return;const C=Gh(x),A=Gh(s.clientWidth-(b+S)),R=Gh(s.clientHeight-(x+k)),_=Gh(b),O={rootMargin:-C+"px "+-A+"px "+-R+"px "+-_+"px",threshold:_s(0,Uo(1,m))||1};let D=!0;function I(P){const B=P[0].intersectionRatio;if(!AL(g,t.getBoundingClientRect()))return l();if(B!==m){if(!D)return l();B?l(!1,B):i=setTimeout(()=>{l(!1,1e-7)},1e3)}D=!1}try{r=new IntersectionObserver(I,{...O,root:s.ownerDocument})}catch{r=new IntersectionObserver(I,O)}r.observe(t)}const u=gr(t),f=()=>l(n);return u.addEventListener("resize",f),l(!0),()=>{u.removeEventListener("resize",f),o()}}function rX(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,f=WS(t),h=i||s?[...f?Bd(f):[],...e?Bd(e):[]]:[];h.forEach(C=>{i&&C.addEventListener("scroll",n),s&&C.addEventListener("resize",n)});const m=f&&l?nX(f,n,s):null;let g=-1,b=null;o&&(b=new ResizeObserver(C=>{let[A]=C;A&&A.target===f&&b&&e&&(b.unobserve(e),cancelAnimationFrame(g),g=requestAnimationFrame(()=>{var R;(R=b)==null||R.observe(e)})),n()}),f&&!u&&b.observe(f),e&&b.observe(e));let x,S=u?Ga(t):null;u&&k();function k(){const C=Ga(t);S&&!AL(S,C)&&n(),S=C,x=requestAnimationFrame(k)}return n(),()=>{var C;h.forEach(A=>{i&&A.removeEventListener("scroll",n),s&&A.removeEventListener("resize",n)}),m?.(),(C=b)==null||C.disconnect(),b=null,u&&cancelAnimationFrame(x)}}const iX=DY,sX=IY,oX=MY,aX=LY,lX=NY,XR=RY,cX=jY,uX=(t,e,n)=>{const r=new Map,i=n??{},s={...tX,...i.platform,_c:r};return AY(t,e,{...i,platform:s})};var dX=typeof document<"u",fX=function(){},vp=dX?E.useLayoutEffect:fX;function Lm(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!Lm(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!Lm(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function RL(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function JR(t,e){const n=RL(t);return Math.round(e*n)/n}function Qv(t){const e=E.useRef(t);return vp(()=>{e.current=t}),e}function hX(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:l=!0,whileElementsMounted:u,open:f}=t,[h,m]=E.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[g,b]=E.useState(r);Lm(g,r)||b(r);const[x,S]=E.useState(null),[k,C]=E.useState(null),A=E.useCallback(G=>{G!==O.current&&(O.current=G,S(G))},[]),R=E.useCallback(G=>{G!==D.current&&(D.current=G,C(G))},[]),_=s||x,M=o||k,O=E.useRef(null),D=E.useRef(null),I=E.useRef(h),P=u!=null,B=Qv(u),re=Qv(i),K=Qv(f),ee=E.useCallback(()=>{if(!O.current||!D.current)return;const G={placement:e,strategy:n,middleware:g};re.current&&(G.platform=re.current),uX(O.current,D.current,G).then(he=>{const ke={...he,isPositioned:K.current!==!1};Q.current&&!Lm(I.current,ke)&&(I.current=ke,Oc.flushSync(()=>{m(ke)}))})},[g,e,n,re,K]);vp(()=>{f===!1&&I.current.isPositioned&&(I.current.isPositioned=!1,m(G=>({...G,isPositioned:!1})))},[f]);const Q=E.useRef(!1);vp(()=>(Q.current=!0,()=>{Q.current=!1}),[]),vp(()=>{if(_&&(O.current=_),M&&(D.current=M),_&&M){if(B.current)return B.current(_,M,ee);ee()}},[_,M,ee,B,P]);const fe=E.useMemo(()=>({reference:O,floating:D,setReference:A,setFloating:R}),[A,R]),z=E.useMemo(()=>({reference:_,floating:M}),[_,M]),L=E.useMemo(()=>{const G={position:n,left:0,top:0};if(!z.floating)return G;const he=JR(z.floating,h.x),ke=JR(z.floating,h.y);return l?{...G,transform:"translate("+he+"px, "+ke+"px)",...RL(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:he,top:ke}},[n,l,z.floating,h.x,h.y]);return E.useMemo(()=>({...h,update:ee,refs:fe,elements:z,floatingStyles:L}),[h,ee,fe,z,L])}const pX=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?XR({element:r.current,padding:i}).fn(n):{}:r?XR({element:r,padding:i}).fn(n):{}}}},mX=(t,e)=>{const n=iX(t);return{name:n.name,fn:n.fn,options:[t,e]}},gX=(t,e)=>{const n=sX(t);return{name:n.name,fn:n.fn,options:[t,e]}},yX=(t,e)=>({fn:cX(t).fn,options:[t,e]}),bX=(t,e)=>{const n=oX(t);return{name:n.name,fn:n.fn,options:[t,e]}},vX=(t,e)=>{const n=aX(t);return{name:n.name,fn:n.fn,options:[t,e]}},xX=(t,e)=>{const n=lX(t);return{name:n.name,fn:n.fn,options:[t,e]}},wX=(t,e)=>{const n=pX(t);return{name:n.name,fn:n.fn,options:[t,e]}};var SX=Object.defineProperty,Lo=(t,e)=>SX(t,"name",{value:e,configurable:!0}),ML="Popper",[NL,OL]=Ic(ML),[kX,DL]=NL(ML),CX=Lo(t=>{const{__scopePopper:e,children:n}=t,[r,i]=E.useState(null),[s,o]=E.useState(void 0);return y.jsx(kX,{scope:e,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:o,children:n})},"Popper"),EX="PopperAnchor",TX=E.forwardRef(Lo(function(e,n){const{__scopePopper:r,virtualRef:i,...s}=e,o=DL(EX,r),l=E.useRef(null),u=o.onAnchorChange,f=E.useCallback(S=>{l.current=S,S&&u(S)},[u]),h=rn(n,f),m=E.useRef(null);E.useEffect(()=>{if(!i)return;const S=m.current;m.current=i.current,S!==m.current&&u(m.current)});const g=o.placementState&&wg(o.placementState),b=g?.[0],x=g?.[1];return i?null:y.jsx(En.div,{"data-radix-popper-side":b,"data-radix-popper-align":x,...s,ref:h})},"PopperAnchor")),IL="PopperContent",[_X,Gte]=NL(IL),AX=E.forwardRef(Lo(function(e,n){const{__scopePopper:r,side:i="bottom",sideOffset:s=0,align:o="center",alignOffset:l=0,arrowPadding:u=0,avoidCollisions:f=!0,collisionBoundary:h=[],collisionPadding:m=0,sticky:g="partial",hideWhenDetached:b=!1,updatePositionStrategy:x="optimized",onPlaced:S,...k}=e,C=DL(IL,r),[A,R]=E.useState(null),_=rn(n,R),[M,O]=E.useState(null),D=Nw(M),I=D?.width??0,P=D?.height??0,B=i+(o!=="center"?"-"+o:""),re=typeof m=="number"?m:{top:0,right:0,bottom:0,left:0,...m},K=Array.isArray(h)?h:[h],ee=K.length>0,Q={padding:re,boundary:K.filter(jL),altBoundary:ee},{refs:fe,floatingStyles:z,placement:L,isPositioned:G,middlewareData:he}=hX({strategy:"fixed",placement:B,whileElementsMounted:Lo((...ae)=>rX(...ae,{animationFrame:x==="always"}),"whileElementsMounted"),elements:{reference:C.anchor},middleware:[mX({mainAxis:s+P,alignmentAxis:l}),f&&gX({mainAxis:!0,crossAxis:!1,limiter:g==="partial"?yX():void 0,...Q}),f&&bX({...Q}),vX({...Q,apply:Lo(({elements:ae,rects:me,availableWidth:Ie,availableHeight:Ue})=>{const{width:Ze,height:ct}=me.reference,yt=ae.floating.style;yt.setProperty("--radix-popper-available-width",`${Ie}px`),yt.setProperty("--radix-popper-available-height",`${Ue}px`),yt.setProperty("--radix-popper-anchor-width",`${Ze}px`),yt.setProperty("--radix-popper-anchor-height",`${ct}px`)},"apply")}),M&&wX({element:M,padding:u}),RX({arrowWidth:I,arrowHeight:P}),b&&xX({strategy:"referenceHidden",...Q,boundary:ee?Q.boundary:void 0})]}),ke=C.setPlacementState;tr(()=>(ke(L),()=>{ke(void 0)}),[L,ke]);const[H,Z]=wg(L),pe=Pi(S);tr(()=>{G&&pe?.()},[G,pe]);const ve=he.arrow?.x,Ae=he.arrow?.y,Re=he.arrow?.centerOffset!==0,[$e,_e]=E.useState();return tr(()=>{A&&_e(window.getComputedStyle(A).zIndex)},[A]),y.jsx("div",{ref:fe.setFloating,"data-radix-popper-content-wrapper":"",style:{...z,transform:G?z.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:$e,"--radix-popper-transform-origin":[he.transformOrigin?.x,he.transformOrigin?.y].join(" "),...he.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:y.jsx(_X,{scope:r,placedSide:H,placedAlign:Z,onArrowChange:O,arrowX:ve,arrowY:Ae,shouldHideArrow:Re,children:y.jsx(En.div,{"data-side":H,"data-align":Z,...k,ref:_,style:{...k.style,animation:G?k.style?.animation:"none"}})})})},"PopperContent"));function jL(t){return t!==null}Lo(jL,"isNotNull");var RX=Lo(t=>({name:"transformOrigin",options:t,fn(e){const{placement:n,rects:r,middlewareData:i}=e,o=i.arrow?.centerOffset!==0,l=o?0:t.arrowWidth,u=o?0:t.arrowHeight,[f,h]=wg(n),m={start:"0%",center:"50%",end:"100%"}[h],g=(i.arrow?.x??0)+l/2,b=(i.arrow?.y??0)+u/2;let x="",S="";return f==="bottom"?(x=o?m:`${g}px`,S=`${-u}px`):f==="top"?(x=o?m:`${g}px`,S=`${r.floating.height+u}px`):f==="right"?(x=`${-u}px`,S=o?m:`${b}px`):f==="left"&&(x=`${r.floating.width+u}px`,S=o?m:`${b}px`),{data:{x,y:S}}}}),"transformOrigin");function wg(t){const[e,n="center"]=t.split("-");return[e,n]}Lo(wg,"getSideAndAlignFromPlacement");var MX=CX,NX=TX,OX=AX,DX=Object.defineProperty,IX=(t,e)=>DX(t,"name",{value:e,configurable:!0}),jX=E.forwardRef(IX(function(e,n){const{container:r,...i}=e,[s,o]=E.useState(!1);tr(()=>o(!0),[]);const l=r||s&&globalThis?.document?.body;return l?Oc.createPortal(y.jsx(En.div,{...i,ref:n}),l):null},"Portal")),LX=Object.defineProperty,Ds=(t,e)=>LX(t,"name",{value:e,configurable:!0});function LL(t,e){return E.useReducer((n,r)=>e[n][r]??n,t)}Ds(LL,"useStateMachine");var PX=Ds(t=>{const{present:e,children:n}=t,r=PL(e),i=typeof n=="function"?n({present:r.isPresent}):E.Children.only(n),s=zL(r.ref,$L(i));return typeof n=="function"||r.isPresent?E.cloneElement(i,{ref:s}):null},"Presence");function PL(t){const[e,n]=E.useState(),r=E.useRef(null),i=E.useRef(t),s=E.useRef("none"),o=E.useRef(void 0),l=t?"mounted":"unmounted",[u,f]=LL(l,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return E.useEffect(()=>{u==="mounted"?(s.current=o.current??tc(r.current),o.current=void 0):s.current="none"},[u]),tr(()=>{const h=r.current,m=i.current;if(m!==t){const b=s.current,x=tc(h);t?(o.current=x,f("MOUNT")):x==="none"||h?.display==="none"?f("UNMOUNT"):f(m&&b!==x?"ANIMATION_OUT":"UNMOUNT"),i.current=t}},[t,f]),tr(()=>{if(e){let h;const m=e.ownerDocument.defaultView??window,g=Ds(x=>{const k=tc(r.current).includes(CSS.escape(x.animationName));if(x.target===e&&k&&(f("ANIMATION_END"),!i.current)){const C=e.style.animationFillMode;e.style.animationFillMode="forwards",h=m.setTimeout(()=>{e.style.animationFillMode==="forwards"&&(e.style.animationFillMode=C)})}},"handleAnimationEnd"),b=Ds(x=>{x.target===e&&(s.current=tc(r.current))},"handleAnimationStart");return e.addEventListener("animationstart",b),e.addEventListener("animationcancel",g),e.addEventListener("animationend",g),()=>{m.clearTimeout(h),e.removeEventListener("animationstart",b),e.removeEventListener("animationcancel",g),e.removeEventListener("animationend",g)}}else f("ANIMATION_END")},[e,f]),{isPresent:["mounted","unmountSuspended"].includes(u),ref:E.useCallback(h=>{if(h){const m=getComputedStyle(h);r.current=m,o.current=tc(m)}else r.current=null;n(h)},[])}}Ds(PL,"usePresence");function qx(t,e){if(typeof t=="function")return t(e);t!=null&&(t.current=e)}Ds(qx,"setRef");function zL(...t){const e=E.useRef(t);return e.current=t,E.useCallback(n=>{const r=e.current;let i=!1;const s=r.map(o=>{const l=qx(o,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let o=0;o<s.length;o++){const l=s[o];typeof l=="function"?l():qx(r[o],null)}}},[])}Ds(zL,"useStableComposedRefs");function tc(t){return t?.animationName||"none"}Ds(tc,"getAnimationName");function $L(t){let e=Object.getOwnPropertyDescriptor(t.props,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning;return n?t.ref:(e=Object.getOwnPropertyDescriptor(t,"ref")?.get,n=e&&"isReactWarning"in e&&e.isReactWarning,n?t.props.ref:t.props.ref||t.ref)}Ds($L,"getElementRef");var zX=Object.defineProperty,$X=(t,e)=>zX(t,"name",{value:e,configurable:!0});function BL(t){const e=E.useRef({value:t,previous:t});return E.useMemo(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}$X(BL,"usePrevious");var BX=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),VX=function(t){if(typeof document>"u")return null;var e=Array.isArray(t)?t[0]:t;return e.ownerDocument.body},Fl=new WeakMap,Wh=new WeakMap,Kh={},e0=0,VL=function(t){return t&&(t.host||VL(t.parentNode))},HX=function(t,e){return e.map(function(n){if(t.contains(n))return n;var r=VL(n);return r&&t.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)}).filter(function(n){return!!n})},UX=function(t,e,n,r){var i=HX(e,Array.isArray(t)?t:[t]);Kh[n]||(Kh[n]=new WeakMap);var s=Kh[n],o=[],l=new Set,u=new Set(i),f=function(m){!m||l.has(m)||(l.add(m),f(m.parentNode))};i.forEach(f);var h=function(m){!m||u.has(m)||Array.prototype.forEach.call(m.children,function(g){if(l.has(g))h(g);else try{var b=g.getAttribute(r),x=b!==null&&b!=="false",S=(Fl.get(g)||0)+1,k=(s.get(g)||0)+1;Fl.set(g,S),s.set(g,k),o.push(g),S===1&&x&&Wh.set(g,!0),k===1&&g.setAttribute(n,"true"),x||g.setAttribute(r,"true")}catch(C){console.error("aria-hidden: cannot operate on ",g,C)}})};return h(e),l.clear(),e0++,function(){o.forEach(function(m){var g=Fl.get(m)-1,b=s.get(m)-1;Fl.set(m,g),s.set(m,b),g||(Wh.has(m)||m.removeAttribute(r),Wh.delete(m)),b||m.removeAttribute(n)}),e0--,e0||(Fl=new WeakMap,Fl=new WeakMap,Wh=new WeakMap,Kh={})}},FX=function(t,e,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(t)?t:[t]),i=VX(t);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),UX(r,i,n,"aria-hidden")):function(){return null}},Oi=function(){return Oi=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Oi.apply(this,arguments)};function HL(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function qX(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var xp="right-scroll-bar-position",wp="width-before-scroll-bar",GX="with-scroll-bars-hidden",WX="--removed-body-scroll-bar-size";function t0(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function KX(t,e){var n=E.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var ZX=typeof window<"u"?E.useLayoutEffect:E.useEffect,QR=new WeakMap;function YX(t,e){var n=KX(null,function(r){return t.forEach(function(i){return t0(i,r)})});return ZX(function(){var r=QR.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(l){s.has(l)||t0(l,null)}),s.forEach(function(l){i.has(l)||t0(l,o)})}QR.set(n,t)},[t]),n}function XX(t){return t}function JX(t,e){e===void 0&&(e=XX);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(l){return l!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var l=n;n=[],l.forEach(s),o=n}var u=function(){var h=o;o=[],h.forEach(s)},f=function(){return Promise.resolve().then(u)};f(),n={push:function(h){o.push(h),f()},filter:function(h){return o=o.filter(h),n}}}};return i}function QX(t){t===void 0&&(t={});var e=JX(null);return e.options=Oi({async:!0,ssr:!1},t),e}var UL=function(t){var e=t.sideCar,n=HL(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return E.createElement(r,Oi({},n))};UL.isSideCarExport=!0;function eJ(t,e){return t.useMedium(e),UL}var FL=QX(),n0=function(){},Sg=E.forwardRef(function(t,e){var n=E.useRef(null),r=E.useState({onScrollCapture:n0,onWheelCapture:n0,onTouchMoveCapture:n0}),i=r[0],s=r[1],o=t.forwardProps,l=t.children,u=t.className,f=t.removeScrollBar,h=t.enabled,m=t.shards,g=t.sideCar,b=t.noRelative,x=t.noIsolation,S=t.inert,k=t.allowPinchZoom,C=t.as,A=C===void 0?"div":C,R=t.gapMode,_=HL(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),M=g,O=YX([n,e]),D=Oi(Oi({},_),i);return E.createElement(E.Fragment,null,h&&E.createElement(M,{sideCar:FL,removeScrollBar:f,shards:m,noRelative:b,noIsolation:x,inert:S,setCallbacks:s,allowPinchZoom:!!k,lockRef:n,gapMode:R}),o?E.cloneElement(E.Children.only(l),Oi(Oi({},D),{ref:O})):E.createElement(A,Oi({},D,{className:u,ref:O}),l))});Sg.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Sg.classNames={fullWidth:wp,zeroRight:xp};var tJ=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function nJ(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=tJ();return e&&t.setAttribute("nonce",e),t}function rJ(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function iJ(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var sJ=function(){var t=0,e=null;return{add:function(n){t==0&&(e=nJ())&&(rJ(e,n),iJ(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},oJ=function(){var t=sJ();return function(e,n){E.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},qL=function(){var t=oJ(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},aJ={left:0,top:0,right:0,gap:0},r0=function(t){return parseInt(t||"",10)||0},lJ=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[r0(n),r0(r),r0(i)]},cJ=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return aJ;var e=lJ(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},uJ=qL(),cc="data-scroll-locked",dJ=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,l=t.gap;return n===void 0&&(n="margin"),`
|
|
287
|
+
.`.concat(GX,` {
|
|
288
|
+
overflow: hidden `).concat(r,`;
|
|
289
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
290
|
+
}
|
|
291
|
+
body[`).concat(cc,`] {
|
|
292
|
+
overflow: hidden `).concat(r,`;
|
|
293
|
+
overscroll-behavior: contain;
|
|
294
|
+
`).concat([e&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
295
|
+
padding-left: `.concat(i,`px;
|
|
296
|
+
padding-top: `).concat(s,`px;
|
|
297
|
+
padding-right: `).concat(o,`px;
|
|
298
|
+
margin-left:0;
|
|
299
|
+
margin-top:0;
|
|
300
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
301
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.`).concat(xp,` {
|
|
305
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.`).concat(wp,` {
|
|
309
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.`).concat(xp," .").concat(xp,` {
|
|
313
|
+
right: 0 `).concat(r,`;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
.`).concat(wp," .").concat(wp,` {
|
|
317
|
+
margin-right: 0 `).concat(r,`;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
body[`).concat(cc,`] {
|
|
321
|
+
`).concat(WX,": ").concat(l,`px;
|
|
322
|
+
}
|
|
323
|
+
`)},eM=function(){var t=parseInt(document.body.getAttribute(cc)||"0",10);return isFinite(t)?t:0},fJ=function(){E.useEffect(function(){return document.body.setAttribute(cc,(eM()+1).toString()),function(){var t=eM()-1;t<=0?document.body.removeAttribute(cc):document.body.setAttribute(cc,t.toString())}},[])},hJ=function(t){var e=t.noRelative,n=t.noImportant,r=t.gapMode,i=r===void 0?"margin":r;fJ();var s=E.useMemo(function(){return cJ(i)},[i]);return E.createElement(uJ,{styles:dJ(s,!e,i,n?"":"!important")})},Gx=!1;if(typeof window<"u")try{var Zh=Object.defineProperty({},"passive",{get:function(){return Gx=!0,!0}});window.addEventListener("test",Zh,Zh),window.removeEventListener("test",Zh,Zh)}catch{Gx=!1}var ql=Gx?{passive:!1}:!1,pJ=function(t){return t.tagName==="TEXTAREA"},GL=function(t,e){if(!(t instanceof Element))return!1;var n=window.getComputedStyle(t);return n[e]!=="hidden"&&!(n.overflowY===n.overflowX&&!pJ(t)&&n[e]==="visible")},mJ=function(t){return GL(t,"overflowY")},gJ=function(t){return GL(t,"overflowX")},tM=function(t,e){var n=e.ownerDocument,r=e;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=WL(t,r);if(i){var s=KL(t,r),o=s[1],l=s[2];if(o>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},yJ=function(t){var e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;return[e,n,r]},bJ=function(t){var e=t.scrollLeft,n=t.scrollWidth,r=t.clientWidth;return[e,n,r]},WL=function(t,e){return t==="v"?mJ(e):gJ(e)},KL=function(t,e){return t==="v"?yJ(e):bJ(e)},vJ=function(t,e){return t==="h"&&e==="rtl"?-1:1},xJ=function(t,e,n,r,i){var s=vJ(t,window.getComputedStyle(e).direction),o=s*r,l=n.target,u=e.contains(l),f=!1,h=o>0,m=0,g=0;do{if(!l)break;var b=KL(t,l),x=b[0],S=b[1],k=b[2],C=S-k-s*x;(x||C)&&WL(t,l)&&(m+=C,g+=x);var A=l.parentNode;l=A&&A.nodeType===Node.DOCUMENT_FRAGMENT_NODE?A.host:A}while(!u&&l!==document.body||u&&(e.contains(l)||e===l));return(h&&Math.abs(m)<1||!h&&Math.abs(g)<1)&&(f=!0),f},Yh=function(t){return"changedTouches"in t?[t.changedTouches[0].clientX,t.changedTouches[0].clientY]:[0,0]},nM=function(t){return[t.deltaX,t.deltaY]},rM=function(t){return t&&"current"in t?t.current:t},wJ=function(t,e){return t[0]===e[0]&&t[1]===e[1]},SJ=function(t){return`
|
|
324
|
+
.block-interactivity-`.concat(t,` {pointer-events: none;}
|
|
325
|
+
.allow-interactivity-`).concat(t,` {pointer-events: all;}
|
|
326
|
+
`)},kJ=0,Gl=[];function CJ(t){var e=E.useRef([]),n=E.useRef([0,0]),r=E.useRef(),i=E.useState(kJ++)[0],s=E.useState(qL)[0],o=E.useRef(t);E.useEffect(function(){o.current=t},[t]),E.useEffect(function(){if(t.inert){document.body.classList.add("block-interactivity-".concat(i));var S=qX([t.lockRef.current],(t.shards||[]).map(rM),!0).filter(Boolean);return S.forEach(function(k){return k.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),S.forEach(function(k){return k.classList.remove("allow-interactivity-".concat(i))})}}},[t.inert,t.lockRef.current,t.shards]);var l=E.useCallback(function(S,k){if("touches"in S&&S.touches.length===2||S.type==="wheel"&&S.ctrlKey)return!o.current.allowPinchZoom;var C=Yh(S),A=n.current,R="deltaX"in S?S.deltaX:A[0]-C[0],_="deltaY"in S?S.deltaY:A[1]-C[1],M,O=S.target,D=Math.abs(R)>Math.abs(_)?"h":"v";if("touches"in S&&D==="h"&&O.type==="range")return!1;var I=window.getSelection(),P=I&&I.anchorNode,B=P?P===O||P.contains(O):!1;if(B)return!1;var re=tM(D,O);if(!re)return!0;if(re?M=D:(M=D==="v"?"h":"v",re=tM(D,O)),!re)return!1;if(!r.current&&"changedTouches"in S&&(R||_)&&(r.current=M),!M)return!0;var K=r.current||M;return xJ(K,k,S,K==="h"?R:_)},[]),u=E.useCallback(function(S){var k=S;if(!(!Gl.length||Gl[Gl.length-1]!==s)){var C="deltaY"in k?nM(k):Yh(k),A=e.current.filter(function(M){return M.name===k.type&&(M.target===k.target||k.target===M.shadowParent)&&wJ(M.delta,C)})[0];if(A&&A.should){k.cancelable&&k.preventDefault();return}if(!A){var R=(o.current.shards||[]).map(rM).filter(Boolean).filter(function(M){return M.contains(k.target)}),_=R.length>0?l(k,R[0]):!o.current.noIsolation;_&&k.cancelable&&k.preventDefault()}}},[]),f=E.useCallback(function(S,k,C,A){var R={name:S,delta:k,target:C,should:A,shadowParent:EJ(C)};e.current.push(R),setTimeout(function(){e.current=e.current.filter(function(_){return _!==R})},1)},[]),h=E.useCallback(function(S){n.current=Yh(S),r.current=void 0},[]),m=E.useCallback(function(S){f(S.type,nM(S),S.target,l(S,t.lockRef.current))},[]),g=E.useCallback(function(S){f(S.type,Yh(S),S.target,l(S,t.lockRef.current))},[]);E.useEffect(function(){return Gl.push(s),t.setCallbacks({onScrollCapture:m,onWheelCapture:m,onTouchMoveCapture:g}),document.addEventListener("wheel",u,ql),document.addEventListener("touchmove",u,ql),document.addEventListener("touchstart",h,ql),function(){Gl=Gl.filter(function(S){return S!==s}),document.removeEventListener("wheel",u,ql),document.removeEventListener("touchmove",u,ql),document.removeEventListener("touchstart",h,ql)}},[]);var b=t.removeScrollBar,x=t.inert;return E.createElement(E.Fragment,null,x?E.createElement(s,{styles:SJ(i)}):null,b?E.createElement(hJ,{noRelative:t.noRelative,gapMode:t.gapMode}):null)}function EJ(t){for(var e=null;t!==null;)t instanceof ShadowRoot&&(e=t.host,t=t.host),t=t.parentNode;return e}const TJ=eJ(FL,CJ);var ZL=E.forwardRef(function(t,e){return E.createElement(Sg,Oi({},t,{ref:e,sideCar:TJ}))});ZL.classNames=Sg.classNames;var _J=Object.defineProperty,Rt=(t,e)=>_J(t,"name",{value:e,configurable:!0}),AJ=[" ","Enter","ArrowUp","ArrowDown"],RJ=[" ","Enter"],_c="Select",[kg,KS,MJ]=iL(_c),[tl,Wte]=Ic(_c,[MJ,OL]),ZS=OL(),[NJ,Jo]=tl(_c),[OJ,DJ]=tl(_c);function YL(t){const{__scopeSelect:e,children:n,open:r,defaultOpen:i,onOpenChange:s,value:o,defaultValue:l,onValueChange:u,dir:f,name:h,autoComplete:m,disabled:g,required:b,form:x,internal_do_not_use_render:S}=t,k=ZS(e),[C,A]=E.useState(null),[R,_]=E.useState(null),[M,O]=E.useState(!1),D=cL(f),[I,P]=$p({prop:r,defaultProp:i??!1,onChange:s,caller:_c}),[B,re]=$p({prop:o,defaultProp:l,onChange:u,caller:_c}),K=E.useRef(null),ee=E.useRef(B);E.useEffect(()=>{const Z=x?C?.ownerDocument.getElementById(x):C?.form;if(Z instanceof HTMLFormElement){const pe=Rt(()=>re(ee.current),"reset");return Z.addEventListener("reset",pe),()=>Z.removeEventListener("reset",pe)}},[x,C,re]);const Q=C?!!x||!!C.closest("form"):!0,[fe,z]=E.useState(new Set),L=VS(),G=Array.from(fe).map(Z=>Z.props.value).join(";"),he=E.useCallback(Z=>{z(pe=>new Set(pe).add(Z))},[]),ke=E.useCallback(Z=>{z(pe=>{const ve=new Set(pe);return ve.delete(Z),ve})},[]),H={required:b,trigger:C,onTriggerChange:A,valueNode:R,onValueNodeChange:_,valueNodeHasChildren:M,onValueNodeHasChildrenChange:O,contentId:L,value:B,onValueChange:re,open:I,onOpenChange:P,dir:D,triggerPointerDownPosRef:K,disabled:g,name:h,autoComplete:m,form:x,nativeOptions:fe,nativeSelectKey:G,isFormControl:Q};return y.jsx(MX,{...k,children:y.jsx(NJ,{scope:e,...H,children:y.jsx(kg.Provider,{scope:e,children:y.jsx(OJ,{scope:e,onNativeOptionAdd:he,onNativeOptionRemove:ke,children:QL(S)?S(H):n})})})})}Rt(YL,"SelectProvider");var Cg=Rt(t=>{const{__scopeSelect:e,children:n,...r}=t;return y.jsx(YL,{__scopeSelect:e,...r,internal_do_not_use_render:({isFormControl:i})=>y.jsxs(y.Fragment,{children:[n,i?y.jsx(ZJ,{__scopeSelect:e}):null]})})},"Select"),IJ="SelectTrigger",Eg=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,disabled:i=!1,...s}=e,o=ZS(r),l=Jo(IJ,r),u=l.disabled||i,f=rn(n,l.onTriggerChange),h=KS(r),m=E.useRef("touch"),[g,b,x]=YS(k=>{const C=h().filter(_=>!_.disabled),A=C.find(_=>_.value===l.value),R=XS(C,k,A);R!==void 0&&l.onValueChange(R.value)}),S=Rt(k=>{u||(l.onOpenChange(!0),x()),k&&(l.triggerPointerDownPosRef.current={x:Math.round(k.pageX),y:Math.round(k.pageY)})},"handleOpen");return y.jsx(NX,{asChild:!0,...o,children:y.jsx(En.button,{type:"button",role:"combobox","aria-controls":l.open?l.contentId:void 0,"aria-expanded":l.open,"aria-required":l.required,"aria-autocomplete":"none",dir:l.dir,"data-state":l.open?"open":"closed",disabled:u,"data-disabled":u?"":void 0,"data-placeholder":lf(l.value)?"":void 0,...s,ref:f,onClick:dn(s.onClick,k=>{k.currentTarget.focus(),m.current!=="mouse"&&S(k)}),onPointerDown:dn(s.onPointerDown,k=>{m.current=k.pointerType;const C=k.target;C.hasPointerCapture(k.pointerId)&&C.releasePointerCapture(k.pointerId),k.button===0&&k.ctrlKey===!1&&k.pointerType==="mouse"&&(S(k),k.preventDefault())}),onKeyDown:dn(s.onKeyDown,k=>{const C=g.current!=="";!(k.ctrlKey||k.altKey||k.metaKey)&&k.key.length===1&&b(k.key),!(C&&k.key===" ")&&AJ.includes(k.key)&&(S(),k.preventDefault())})})})},"SelectTrigger")),jJ="SelectValue",Tg=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,className:i,style:s,children:o,placeholder:l="",...u}=e,f=Jo(jJ,r),{onValueNodeHasChildrenChange:h}=f,m=o!==void 0,g=rn(n,f.onValueNodeChange);tr(()=>{h(m)},[h,m]);const b=lf(f.value);return y.jsx(En.span,{...u,asChild:b?!1:u.asChild,ref:g,style:{pointerEvents:"none"},children:y.jsx(E.Fragment,{children:b?l:o},b?"placeholder":"value")})},"SelectValue")),_g=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,children:i,...s}=e;return y.jsx(En.span,{"aria-hidden":!0,...s,ref:n,children:i||"▼"})},"SelectIcon")),LJ="SelectPortal",[PJ,zJ]=tl(LJ,{forceMount:void 0}),Ag=Rt(t=>{const{__scopeSelect:e,forceMount:n,...r}=t;return y.jsx(PJ,{scope:t.__scopeSelect,forceMount:n,children:y.jsx(jX,{asChild:!0,...r})})},"SelectPortal"),Wa="SelectContent",Rg=E.forwardRef(Rt(function(e,n){const r=zJ(Wa,e.__scopeSelect),{forceMount:i=r.forceMount,...s}=e,o=Jo(Wa,e.__scopeSelect),[l,u]=E.useState();return tr(()=>{u(new DocumentFragment)},[]),y.jsx(PX,{present:i||o.open,children:({present:f})=>f?y.jsx(VJ,{...s,ref:n}):y.jsx($J,{...s,fragment:l})})},"SelectContent")),$J=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,children:i,fragment:s}=e;return s?Oc.createPortal(y.jsx(XL,{scope:r,children:y.jsx(kg.Slot,{scope:r,children:y.jsx("div",{ref:n,children:i})})}),s):null},"SelectContentFragment")),ai=10,[XL,Mg]=tl(Wa),BJ=Pa("SelectContent.RemoveScroll"),VJ=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r}=e,{position:i="item-aligned",onCloseAutoFocus:s,onEscapeKeyDown:o,onPointerDownOutside:l,side:u,sideOffset:f,align:h,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:x,sticky:S,hideWhenDetached:k,avoidCollisions:C,...A}=e,R=Jo(Wa,r),[_,M]=E.useState(null),[O,D]=E.useState(null),I=rn(n,M),[P,B]=E.useState(null),[re,K]=E.useState(null),ee=KS(r),[Q,fe]=E.useState(!1),z=E.useRef(!1);E.useEffect(()=>{if(_)return FX(_)},[_]),$S();const L=E.useCallback(_e=>{const[ae,...me]=ee().map(Ze=>Ze.ref.current),[Ie]=me.slice(-1),Ue=document.activeElement;for(const Ze of _e)if(Ze===Ue||(Ze?.scrollIntoView({block:"nearest"}),Ze===ae&&O&&(O.scrollTop=0),Ze===Ie&&O&&(O.scrollTop=O.scrollHeight),Ze?.focus(),document.activeElement!==Ue))return},[ee,O]),G=E.useCallback(()=>L([P,_]),[L,P,_]);E.useEffect(()=>{Q&&G()},[Q,G]);const{onOpenChange:he,triggerPointerDownPosRef:ke}=R;E.useEffect(()=>{if(_){let _e={x:0,y:0};const ae=Rt(Ie=>{_e={x:Math.abs(Math.round(Ie.pageX)-(ke.current?.x??0)),y:Math.abs(Math.round(Ie.pageY)-(ke.current?.y??0))}},"handlePointerMove"),me=Rt(Ie=>{_e.x<=10&&_e.y<=10?Ie.preventDefault():Ie.composedPath().includes(_)||he(!1),document.removeEventListener("pointermove",ae),ke.current=null},"handlePointerUp");return ke.current!==null&&(document.addEventListener("pointermove",ae),document.addEventListener("pointerup",me,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",ae),document.removeEventListener("pointerup",me,{capture:!0})}}},[_,he,ke]),E.useEffect(()=>{const _e=Rt(()=>he(!1),"close");return window.addEventListener("blur",_e),window.addEventListener("resize",_e),()=>{window.removeEventListener("blur",_e),window.removeEventListener("resize",_e)}},[he]);const[H,Z]=YS(_e=>{const ae=ee().filter(Ue=>!Ue.disabled),me=ae.find(Ue=>Ue.ref.current===document.activeElement),Ie=XS(ae,_e,me);Ie&&setTimeout(()=>Ie.ref.current?.focus())}),pe=E.useCallback((_e,ae,me)=>{const Ie=!z.current&&!me;(R.value!==void 0&&R.value===ae||Ie)&&(B(_e),Ie&&(z.current=!0))},[R.value]),ve=E.useCallback(()=>_?.focus(),[_]),Ae=E.useCallback((_e,ae,me)=>{const Ie=!z.current&&!me;(R.value!==void 0&&R.value===ae||Ie)&&K(_e)},[R.value]),Re=i==="popper"?iM:HJ,$e=Re===iM?{side:u,sideOffset:f,align:h,alignOffset:m,arrowPadding:g,collisionBoundary:b,collisionPadding:x,sticky:S,hideWhenDetached:k,avoidCollisions:C}:{};return y.jsx(XL,{scope:r,content:_,viewport:O,onViewportChange:D,itemRefCallback:pe,selectedItem:P,onItemLeave:ve,itemTextRefCallback:Ae,focusSelectedItem:G,selectedItemText:re,position:i,isPositioned:Q,searchRef:H,children:y.jsx(ZL,{as:BJ,allowPinchZoom:!0,children:y.jsx(fY,{asChild:!0,trapped:R.open,onMountAutoFocus:_e=>{_e.preventDefault()},onUnmountAutoFocus:dn(s,_e=>{R.trigger?.focus({preventScroll:!0}),_e.preventDefault()}),children:y.jsx(oY,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:o,onPointerDownOutside:l,onFocusOutside:_e=>_e.preventDefault(),onDismiss:()=>R.onOpenChange(!1),children:y.jsx(Re,{role:"listbox",id:R.contentId,"data-state":R.open?"open":"closed",dir:R.dir,onContextMenu:_e=>_e.preventDefault(),...A,...$e,onPlaced:()=>fe(!0),ref:I,style:{display:"flex",flexDirection:"column",outline:"none",...A.style},onKeyDown:dn(A.onKeyDown,_e=>{const ae=_e.ctrlKey||_e.altKey||_e.metaKey;if(_e.key==="Tab"&&_e.preventDefault(),!ae&&_e.key.length===1&&Z(_e.key),["ArrowUp","ArrowDown","Home","End"].includes(_e.key)){let Ie=ee().filter(Ue=>!Ue.disabled).map(Ue=>Ue.ref.current);if(["ArrowUp","End"].includes(_e.key)&&(Ie=Ie.slice().reverse()),["ArrowUp","ArrowDown"].includes(_e.key)){const Ue=_e.target,Ze=Ie.indexOf(Ue);Ie=Ie.slice(Ze+1)}setTimeout(()=>L(Ie)),_e.preventDefault()}})})})})})})},"SelectContentImpl")),HJ=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,onPlaced:i,...s}=e,o=Jo(Wa,r),l=Mg(Wa,r),[u,f]=E.useState(null),[h,m]=E.useState(null),g=rn(n,m),b=KS(r),x=E.useRef(!1),S=E.useRef(!0),{viewport:k,selectedItem:C,selectedItemText:A,focusSelectedItem:R}=l,_=E.useCallback(()=>{if(o.trigger&&o.valueNode&&u&&h&&k&&C&&A){const I=o.trigger.getBoundingClientRect(),P=h.getBoundingClientRect(),B=o.valueNode.getBoundingClientRect(),re=A.getBoundingClientRect();if(o.dir!=="rtl"){const Ue=re.left-P.left,Ze=B.left-Ue,ct=I.left-Ze,yt=I.width+ct,Pt=Math.max(yt,P.width),mn=window.innerWidth-ai,Wt=Lx(Ze,[ai,Math.max(ai,mn-Pt)]);u.style.minWidth=yt+"px",u.style.left=Wt+"px"}else{const Ue=P.right-re.right,Ze=window.innerWidth-B.right-Ue,ct=window.innerWidth-I.right-Ze,yt=I.width+ct,Pt=Math.max(yt,P.width),mn=window.innerWidth-ai,Wt=Lx(Ze,[ai,Math.max(ai,mn-Pt)]);u.style.minWidth=yt+"px",u.style.right=Wt+"px"}const K=b(),ee=window.innerHeight-ai*2,Q=k.scrollHeight,fe=window.getComputedStyle(h),z=parseInt(fe.borderTopWidth,10),L=parseInt(fe.paddingTop,10),G=parseInt(fe.borderBottomWidth,10),he=parseInt(fe.paddingBottom,10),ke=z+L+Q+he+G,H=Math.min(C.offsetHeight*5,ke),Z=window.getComputedStyle(k),pe=parseInt(Z.paddingTop,10),ve=parseInt(Z.paddingBottom,10),Ae=I.top+I.height/2-ai,Re=ee-Ae,$e=C.offsetHeight/2,_e=C.offsetTop+$e,ae=z+L+_e,me=ke-ae;if(ae<=Ae){const Ue=K.length>0&&C===K[K.length-1].ref.current;u.style.bottom="0px";const Ze=h.clientHeight-k.offsetTop-k.offsetHeight,ct=Math.max(Re,$e+(Ue?ve:0)+Ze+G),yt=ae+ct;u.style.height=yt+"px"}else{const Ue=K.length>0&&C===K[0].ref.current;u.style.top="0px";const ct=Math.max(Ae,z+k.offsetTop+(Ue?pe:0)+$e)+me;u.style.height=ct+"px",k.scrollTop=ae-Ae+k.offsetTop}u.style.margin=`${ai}px 0`,u.style.minHeight=H+"px",u.style.maxHeight=ee+"px",i?.(),requestAnimationFrame(()=>x.current=!0)}},[b,o.trigger,o.valueNode,u,h,k,C,A,o.dir,i]);tr(()=>_(),[_]);const[M,O]=E.useState();tr(()=>{h&&O(window.getComputedStyle(h).zIndex)},[h]);const D=E.useCallback(I=>{I&&S.current===!0&&(_(),R?.(),S.current=!1)},[_,R]);return y.jsx(UJ,{scope:r,contentWrapper:u,shouldExpandOnScrollRef:x,onScrollButtonChange:D,children:y.jsx("div",{ref:f,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:M},children:y.jsx(En.div,{...s,ref:g,style:{boxSizing:"border-box",maxHeight:"100%",...s.style}})})})},"SelectItemAlignedPosition")),iM=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,align:i="start",collisionPadding:s=ai,...o}=e,l=ZS(r);return y.jsx(OX,{...l,...o,ref:n,align:i,collisionPadding:s,style:{boxSizing:"border-box",...o.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[UJ,FJ]=tl(Wa,{}),sM="SelectViewport",Ng=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,nonce:i,...s}=e,o=Mg(sM,r),l=FJ(sM,r),u=rn(n,o.onViewportChange),f=E.useRef(0);return y.jsxs(y.Fragment,{children:[y.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:i}),y.jsx(kg.Slot,{scope:r,children:y.jsx(En.div,{"data-radix-select-viewport":"",role:"presentation",...s,ref:u,style:{position:"relative",flex:1,overflow:"hidden auto",...s.style},onScroll:dn(s.onScroll,h=>{const m=h.currentTarget,{contentWrapper:g,shouldExpandOnScrollRef:b}=l;if(b?.current&&g){const x=Math.abs(f.current-m.scrollTop);if(x>0){const S=window.innerHeight-ai*2,k=parseFloat(g.style.minHeight),C=parseFloat(g.style.height),A=Math.max(k,C);if(A<S){const R=A+x,_=Math.min(S,R),M=R-_;g.style.height=_+"px",g.style.bottom==="0px"&&(m.scrollTop=M>0?M:0,g.style.justifyContent="flex-end")}}}f.current=m.scrollTop})})})]})},"SelectViewport")),qJ="SelectGroup",[Kte,Zte]=tl(qJ),Wx="SelectItem",[GJ,JL]=tl(Wx),Og=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,value:i,disabled:s=!1,textValue:o,...l}=e,u=Jo(Wx,r),f=Mg(Wx,r),h=u.value===i,[m,g]=E.useState(o??""),[b,x]=E.useState(!1),S=Pi(_=>f.itemRefCallback?.(_,i,s)),k=rn(n,S),C=VS(),A=E.useRef("touch"),R=Rt(()=>{s||(u.onValueChange(i),u.onOpenChange(!1))},"handleSelect");return y.jsx(GJ,{scope:r,value:i,disabled:s,textId:C,isSelected:h,onItemTextChange:E.useCallback(_=>{g(M=>M||(_?.textContent??"").trim())},[]),children:y.jsx(kg.ItemSlot,{scope:r,value:i,disabled:s,textValue:m,children:y.jsx(En.div,{role:"option","aria-labelledby":C,"data-highlighted":b?"":void 0,"aria-selected":h&&b,"data-state":h?"checked":"unchecked","aria-disabled":s||void 0,"data-disabled":s?"":void 0,tabIndex:s?void 0:-1,...l,ref:k,onFocus:dn(l.onFocus,()=>x(!0)),onBlur:dn(l.onBlur,()=>x(!1)),onClick:dn(l.onClick,()=>{A.current!=="mouse"&&R()}),onPointerUp:dn(l.onPointerUp,()=>{A.current==="mouse"&&R()}),onPointerDown:dn(l.onPointerDown,_=>{A.current=_.pointerType}),onPointerMove:dn(l.onPointerMove,_=>{A.current=_.pointerType,s?f.onItemLeave?.():A.current==="mouse"&&_.currentTarget.focus({preventScroll:!0})}),onPointerLeave:dn(l.onPointerLeave,_=>{_.currentTarget===document.activeElement&&f.onItemLeave?.()}),onKeyDown:dn(l.onKeyDown,_=>{s||_.target!==_.currentTarget||f.searchRef?.current!==""&&_.key===" "||(RJ.includes(_.key)&&R(),_.key===" "&&_.preventDefault())})})})})},"SelectItem")),Xh="SelectItemText",Dg=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,className:i,style:s,...o}=e,l=Jo(Xh,r),u=Mg(Xh,r),f=JL(Xh,r),h=DJ(Xh,r),[m,g]=E.useState(null),b=Pi(R=>u.itemTextRefCallback?.(R,f.value,f.disabled)),x=rn(n,g,f.onItemTextChange,b),S=m?.textContent,k=E.useMemo(()=>y.jsx("option",{value:f.value,disabled:f.disabled,children:S},f.value),[f.disabled,f.value,S]),{onNativeOptionAdd:C,onNativeOptionRemove:A}=h;return tr(()=>(C(k),()=>A(k)),[C,A,k]),y.jsxs(y.Fragment,{children:[y.jsx(En.span,{id:f.textId,...o,ref:x}),f.isSelected&&l.valueNode&&!l.valueNodeHasChildren&&!lf(l.value)?Oc.createPortal(o.children,l.valueNode):null]})},"SelectItemText")),WJ="SelectItemIndicator",Ig=E.forwardRef(Rt(function(e,n){const{__scopeSelect:r,...i}=e;return JL(WJ,r).isSelected?y.jsx(En.span,{"aria-hidden":!0,...i,ref:n}):null},"SelectItemIndicator")),KJ="SelectBubbleInput",ZJ=E.forwardRef(Rt(function({__scopeSelect:e,...n},r){const i=Jo(KJ,e),{value:s,onValueChange:o,required:l,disabled:u,name:f,autoComplete:h,form:m}=i,{nativeOptions:g,nativeSelectKey:b}=i,x=E.useRef(null),S=rn(r,x),k=s??"",C=BL(k),A=Array.from(g).some(R=>(R.props.value??"")==="");return E.useEffect(()=>{const R=x.current;if(!R)return;const _=window.HTMLSelectElement.prototype,O=Object.getOwnPropertyDescriptor(_,"value").set;if(C!==k&&O){const D=new Event("change",{bubbles:!0});O.call(R,k),R.dispatchEvent(D)}},[C,k]),y.jsxs(En.select,{"aria-hidden":!0,required:l,tabIndex:-1,name:f,autoComplete:h,disabled:u,form:m,onChange:R=>o(R.target.value),...n,style:{...BX,...n.style},ref:S,defaultValue:k,children:[lf(s)&&!A?y.jsx("option",{value:""}):null,Array.from(g)]},b)},"SelectBubbleInput"));function QL(t){return typeof t=="function"}Rt(QL,"isFunction");function lf(t){return t===""||t===void 0}Rt(lf,"shouldShowPlaceholder");function YS(t){const e=Pi(t),n=E.useRef(""),r=E.useRef(0),i=E.useCallback(o=>{const l=n.current+o;e(l),Rt((function u(f){n.current=f,window.clearTimeout(r.current),f!==""&&(r.current=window.setTimeout(()=>u(""),1e3))}),"updateSearch")(l)},[e]),s=E.useCallback(()=>{n.current="",window.clearTimeout(r.current)},[]);return E.useEffect(()=>()=>window.clearTimeout(r.current),[]),[n,i,s]}Rt(YS,"useTypeaheadSearch");function XS(t,e,n){const i=e.length>1&&Array.from(e).every(f=>f===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=e2(t,Math.max(s,0));i.length===1&&(o=o.filter(f=>f!==n));const u=o.find(f=>f.textValue.toLowerCase().startsWith(i.toLowerCase()));return u!==n?u:void 0}Rt(XS,"findNextItem");function e2(t,e){return t.map((n,r)=>t[(e+r)%t.length])}Rt(e2,"wrapArray");function JS({id:t,value:e,field:n,readOnly:r,onChange:i}){const s=n.options?.filter(Boolean)??[],o=typeof e=="string"&&s.includes(e)?e:s[0]??"";return s.length===0?y.jsx("input",{id:t,type:"text",readOnly:r,value:o,disabled:!0}):y.jsxs(Cg,{value:o,onValueChange:i,disabled:r,children:[y.jsxs(Eg,{id:t,className:"vertebr-select-trigger",children:[y.jsx("span",{className:"vertebr-select-value",children:y.jsx(Tg,{children:id(o,n)})}),y.jsx(_g,{className:"vertebr-select-icon",children:y.jsx(YJ,{})})]}),y.jsx(Ag,{children:y.jsx(Rg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:y.jsx(Ng,{className:"vertebr-select-viewport",children:s.map(l=>y.jsxs(Og,{value:l,className:"vertebr-select-item",children:[y.jsx(Dg,{children:id(l,n)}),y.jsx(Ig,{className:"vertebr-select-check",children:y.jsx(XJ,{})})]},l))})})})]})}function YJ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function XJ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 6.2 5 8.7 9.5 3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function JJ(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(Boolean):[]}function QJ(t,e){const n=new Set(t),r=e.filter(s=>n.has(s)),i=t.filter(s=>!r.includes(s));return[...r.map(s=>({id:s,on:!0})),...i.map(s=>({id:s,on:!1}))]}function eQ({id:t,value:e,field:n,readOnly:r,onChange:i}){const s=n.options?.filter(Boolean)??[],o=JJ(e),l=QJ(s,o),u=f=>{i(f.filter(h=>h.on).map(h=>h.id))};return y.jsx("ul",{id:t,className:"vertebr-enum-list",children:l.map((f,h)=>y.jsxs("li",{className:"vertebr-enum-list-row","data-on":f.on,children:[y.jsxs("label",{className:"vertebr-enum-list-label",children:[y.jsx("input",{type:"checkbox",checked:f.on,disabled:r,onChange:m=>{const g=l.map(b=>b.id===f.id?{...b,on:m.target.checked}:b);u(g)}}),y.jsx("span",{children:id(f.id,n)})]}),y.jsxs("div",{className:"vertebr-enum-list-move",children:[y.jsx("button",{type:"button","aria-label":`Move ${id(f.id,n)} up`,disabled:r||h===0,onClick:()=>{if(h===0)return;const m=[...l],g=m[h];m[h]=m[h-1],m[h-1]=g,u(m)},children:"↑"}),y.jsx("button",{type:"button","aria-label":`Move ${id(f.id,n)} down`,disabled:r||h===l.length-1,onClick:()=>{if(h>=l.length-1)return;const m=[...l],g=m[h];m[h]=m[h+1],m[h+1]=g,u(m)},children:"↓"})]})]},f.id))})}function tQ({id:t,name:e,value:n,asCents:r=!0,readOnly:i,onBlur:s,onChange:o,inputRef:l}){const[u,f]=E.useState(()=>hv(n,r));E.useEffect(()=>{f(hv(n,r))},[n,r]);const h=typeof n=="number"&&Number.isFinite(n)?G0(n,{asCents:r}):null;return y.jsxs("div",{className:"vertebr-field-money",children:[y.jsx("span",{className:"vertebr-field-money-prefix","aria-hidden":"true",children:"$"}),y.jsx("input",{id:t,name:e,ref:l,type:"text",inputMode:"decimal",autoComplete:"off",readOnly:i,value:u,placeholder:"0.00","aria-label":h?`Price ${h}`:"Price",onChange:m=>{const g=m.target.value;f(g),o(VF(g,r))},onBlur:()=>{f(hv(n,r)),s?.()}})]})}function Pm({fieldKey:t,field:e,groupLabel:n,variant:r,schema:i,watched:s,form:o,uploads:l,onUpload:u,galleryUpload:f,onListGallery:h,onUploadGallery:m,fonts:g,fontsLoading:b,onListFonts:x,onRefreshFonts:S,hideImagePreview:k,hideUpload:C,visibilityGroup:A,settingsRow:R}){const _=$U(t,e,n),M=XU(t,i,A??n),O=!M||s?.[M]!==!1,D=!k&&e.type!=="file[]"&&La(t,e)&&!!zp(s?.[t]);return e.type==="boolean"?R?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsxs("li",{className:"vertebr-settings-list-row","data-on":I.value?"true":"false",children:[y.jsxs("div",{className:"vertebr-settings-list-copy",children:[y.jsx(fv,{htmlFor:t,children:_}),e.description?y.jsx("p",{className:"vertebr-settings-list-desc",children:e.description}):null]}),y.jsx(j_,{className:"vertebr-switch",id:t,checked:!!I.value,onCheckedChange:I.onChange,children:y.jsx(L_,{className:"vertebr-switch-thumb"})})]})}):y.jsxs("div",{className:"vertebr-switch-row",children:[y.jsxs("div",{className:"vertebr-switch-row-copy",children:[y.jsx(fv,{htmlFor:t,children:_}),e.description?y.jsx("p",{className:"vertebr-switch-row-desc",children:e.description}):null]}),y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(j_,{className:"vertebr-switch",id:t,checked:!!I.value,onCheckedChange:I.onChange,children:y.jsx(L_,{className:"vertebr-switch-thumb"})})})]}):y.jsxs("div",{className:"vertebr-field","data-span":FU(t,e,r),"data-kind":La(t,e)?"image":void 0,"data-storefront":M?O?"on":"off":void 0,children:[y.jsxs("div",{className:"vertebr-field-head",children:[y.jsx(fv,{htmlFor:t,children:_}),M?y.jsx(CO,{name:M,label:_,form:o}):null]}),D?y.jsxs("div",{className:"vertebr-field-media",children:[y.jsx("img",{src:zp(s[t])??"",alt:""}),y.jsx("input",{id:t,type:"text",readOnly:e.readOnly,...o.register(t)})]}):e.type==="richtext"||sO(t,e)?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(WZ,{id:t,name:I.name,inputRef:I.ref,value:typeof I.value=="string"?I.value:"",readOnly:e.readOnly,recordImages:VU(i,s),galleryUpload:f,onListGallery:h,onUploadGallery:m,onBlur:I.onBlur,onChange:I.onChange})}):e.type==="file[]"?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>{const P=V0(I.value);return y.jsx("div",{className:"vertebr-field-files",children:P.length>0?y.jsx("ul",{className:"vertebr-field-files-list",children:P.map(B=>y.jsxs("li",{children:[y.jsx("img",{src:B,alt:""}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>I.onChange(P.filter(re=>re!==B)),children:"Remove"})]},B))}):y.jsx("p",{className:"vertebr-field-files-empty",children:"No photos yet"})})}}):e.type==="number"&&TO(t,e)?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(tQ,{id:t,name:I.name,inputRef:I.ref,value:I.value,asCents:jw(t,e)||/^pricing$/i.test(n),readOnly:e.readOnly,onBlur:I.onBlur,onChange:I.onChange})}):e.type==="number"?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx("input",{id:t,type:"number",readOnly:e.readOnly,value:typeof I.value=="number"&&Number.isFinite(I.value)?I.value:"",onBlur:I.onBlur,onChange:P=>{const B=P.target.value;I.onChange(B===""?void 0:Number(B))},name:I.name,ref:I.ref})}):e.type==="enum"?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(JS,{id:t,value:I.value,field:e,readOnly:e.readOnly,onChange:I.onChange})}):e.type==="enum[]"?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(eQ,{id:t,value:I.value,field:e,readOnly:e.readOnly,onChange:I.onChange})}):e.type==="font"?y.jsx(ss,{control:o.control,name:t,render:({field:I})=>y.jsx(HF,{id:t,value:I.value,label:e.label,description:e.description,readOnly:e.readOnly,fonts:g??[],loading:b,onChange:I.onChange,onRefreshFonts:S})}):aO(t,e)?y.jsx("textarea",{id:t,rows:5,readOnly:e.readOnly,...o.register(t)}):y.jsx("input",{id:t,type:"text",readOnly:e.readOnly,...o.register(t)}),!C&&l?.[t]&&u&&!e.readOnly?y.jsx(Nc,{meta:l[t],multiple:e.type==="file[]",onUpload:async I=>{const B=(await u(t,I)).map(re=>re.url).filter(Boolean);if(B.length){if(e.type==="file[]"){o.setValue(t,[...V0(o.getValues(t)),...B],{shouldDirty:!0,shouldTouch:!0});return}o.setValue(t,B[0],{shouldDirty:!0,shouldTouch:!0})}}}):null]})}function t2({form:t,isDirty:e,status:n,tone:r,onDiscard:i,submitLabel:s="Save changes"}){return y.jsxs("div",{className:"vertebr-actions",children:[y.jsx("button",{className:"vertebr-btn vertebr-btn-primary",type:"submit",disabled:t.formState.isSubmitting||!e,children:t.formState.isSubmitting?"Saving…":s}),e?y.jsx("button",{className:"vertebr-btn",type:"button",onClick:i,children:"Discard"}):null,e?y.jsx("span",{className:"vertebr-dirty",children:"Unsaved"}):n?y.jsx("span",{className:"vertebr-status","data-tone":r,children:n}):null,y.jsx("span",{className:"vertebr-actions-spacer"}),y.jsx("span",{className:"vertebr-kbd",children:"⌘S"})]})}function nQ({schema:t,groups:e,watched:n,form:r,uploads:i,onUpload:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,onSubmit:f,isDirty:h,status:m,tone:g,onDiscard:b,submitLabel:x,hideActions:S}){const k=nF(t,n),C=k?zp(n?.[k])??"":"",A=e.filter(M=>/^(Media|Display|Status)$/i.test(M.id)),R=e.filter(M=>!/^(Media|Display|Status)$/i.test(M.id)),_={variant:"record",schema:t,watched:n,form:r,uploads:i,onUpload:s,galleryUpload:o,onListGallery:l,onUploadGallery:u};return y.jsxs("form",{className:"vertebr-form","data-variant":"record",onSubmit:f,children:[y.jsx("div",{className:"vertebr-form-scroll",children:y.jsxs("div",{className:"vertebr-record-layout",children:[y.jsxs("aside",{className:"vertebr-record-aside",children:[y.jsx("div",{className:"vertebr-record-preview",children:C&&_d(C)?y.jsx("img",{src:C,alt:""}):y.jsx("div",{className:"vertebr-record-preview-empty",children:"No image"})}),k&&i?.[k]&&s?y.jsx(Nc,{meta:i[k],label:"Drop a new image or browse",onUpload:async M=>{const[O]=await s(k,M);O?.url&&r.setValue(k,O.url,{shouldDirty:!0,shouldTouch:!0})}}):null,A.map(M=>y.jsxs("div",{className:"vertebr-record-block","data-layout":/^inventory$/i.test(M.id)?"chips":void 0,children:[y.jsx(oM,{groupId:M.id,label:M.label,schema:t,form:r}),y.jsx("div",{className:"vertebr-form-fields","data-layout":UU(M.fields[0]?.[0]??"",M.fields[0]?.[1])?"chips":void 0,children:M.fields.map(([O,D])=>y.jsx(Pm,{fieldKey:O,field:D,groupLabel:M.label,visibilityGroup:M.id,hideImagePreview:!0,hideUpload:O===k,..._},O))})]},M.id))]}),y.jsx("div",{className:"vertebr-record-main",children:R.map(M=>{const O=/^inventory$/i.test(M.id),D=/^specs$/i.test(M.id),I=Rw(M.id,t),P=!I||n?.[I]!==!1;return y.jsxs("div",{className:"vertebr-record-block","data-layout":O?"chips":D?"specs":void 0,"data-storefront":I?P?"on":"off":void 0,children:[y.jsx(oM,{groupId:M.id,label:M.label,schema:t,form:r}),y.jsx("div",{className:"vertebr-form-fields","data-layout":O?"chips":D?"specs":void 0,children:M.fields.map(([B,re])=>y.jsx(Pm,{fieldKey:B,field:re,groupLabel:M.label,visibilityGroup:M.id,..._},B))})]},M.id)})})]})}),S?null:y.jsx(t2,{form:r,isDirty:h,status:m,tone:g,onDiscard:b,submitLabel:x})]})}function oM({groupId:t,label:e,schema:n,form:r}){const i=Rw(t,n);return y.jsxs("div",{className:"vertebr-record-block-label",children:[y.jsx("span",{children:e}),i?y.jsx(CO,{name:i,label:e,form:r}):null]})}function rQ({schema:t,groups:e,watched:n,form:r,uploads:i,onUpload:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:f,fontsLoading:h,onListFonts:m,onRefreshFonts:g,onSubmit:b,isDirty:x,status:S,tone:k,onDiscard:C,submitLabel:A,hideActions:R}){const _=e.length===1;return y.jsxs("form",{className:"vertebr-form","data-variant":"config",onSubmit:b,children:[y.jsx("div",{className:"vertebr-form-scroll",children:e.map(M=>{const O=HU(M.fields),D=!_||M.id!=="General"&&M.fields.length>0;return y.jsxs("div",{className:"vertebr-form-section","data-plain":_&&!D?"true":void 0,children:[D?y.jsxs("div",{className:"vertebr-form-section-head",children:[y.jsx("h3",{children:M.label}),y.jsx("span",{className:"vertebr-form-section-count",children:M.fields.length})]}):null,y.jsx("div",{className:"vertebr-form-fields","data-layout":O?"settings":void 0,children:O?y.jsx("ul",{className:"vertebr-settings-list",children:M.fields.map(([I,P])=>y.jsx(Pm,{fieldKey:I,field:P,groupLabel:M.label,variant:"config",schema:t,watched:n,form:r,uploads:i,onUpload:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:f,fontsLoading:h,onListFonts:m,onRefreshFonts:g,settingsRow:!0},I))}):M.fields.map(([I,P])=>y.jsx(Pm,{fieldKey:I,field:P,groupLabel:M.label,variant:"config",schema:t,watched:n,form:r,uploads:i,onUpload:s,galleryUpload:o,onListGallery:l,onUploadGallery:u,fonts:f,fontsLoading:h,onListFonts:m,onRefreshFonts:g},I))})]},M.id)})}),R?null:y.jsx(t2,{form:r,isDirty:x,status:S,tone:k,onDiscard:C,submitLabel:A})]})}function jg({schema:t,value:e,onSave:n,submitLabel:r,variant:i="config",uploads:s,onUpload:o,galleryUpload:l,onListGallery:u,onUploadGallery:f,fonts:h,fontsLoading:m,onListFonts:g,onRefreshFonts:b,onChange:x,hideActions:S}){const k=E.useMemo(()=>i==="record"?qU(t):t,[t,i]),C=E.useMemo(()=>i==="record"?GU(k,e):e,[k,e,i]),A=E.useMemo(()=>PU(k),[k]),R=E.useMemo(()=>tF(k,i),[k,i]),[_,M]=E.useState(null),[O,D]=E.useState(),I=nU({resolver:oU(A),defaultValues:C}),P=UN({control:I.control});E.useEffect(()=>{x?.(P??{})},[P,x]),E.useEffect(()=>{I.reset(C)},[C,I]);const B=I.handleSubmit(async Q=>{M("Saving…"),D(void 0);try{await n(Q),M("Saved"),D("ok")}catch(fe){M(fe instanceof Error?fe.message:"Save failed"),D("danger")}}),re=I.formState.isDirty;E.useEffect(()=>{const Q=fe=>{(fe.metaKey||fe.ctrlKey)&&fe.key.toLowerCase()==="s"&&(fe.preventDefault(),B())};return window.addEventListener("keydown",Q),()=>window.removeEventListener("keydown",Q)},[B]);const ee={schema:k,groups:R,watched:P,form:I,uploads:s,onUpload:o,galleryUpload:l,onListGallery:u,onUploadGallery:f,fonts:h,fontsLoading:m,onListFonts:g,onRefreshFonts:b,onSubmit:B,isDirty:re,status:_,tone:O,onDiscard:()=>{I.reset(C),M(null),D(void 0)},submitLabel:r,hideActions:S};return i==="record"?y.jsx(nQ,{...ee}):y.jsx(rQ,{...ee})}function aM(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function i0(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>typeof n=="string"?[e,{type:n,label:aM(e),required:!0}]:[e,{...n,label:n.label??aM(e),required:n.required??!0}]))}function QS(t){return Object.fromEntries(Object.entries(t).map(([e,n])=>n.type==="boolean"?[e,!1]:n.type==="number"?[e,0]:n.type==="enum"&&n.options?.length?[e,n.default??n.options[0]??""]:[e,n.default??""]))}function lM({title:t,count:e=0,eyebrow:n,schema:r,submitLabel:i,onClose:s,onSubmit:o}){return E.useEffect(()=>{const l=f=>{f.key==="Escape"&&s()};window.addEventListener("keydown",l);const u=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",l),document.body.style.overflow=u}},[s]),y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:s,children:y.jsxs("div",{className:"vertebr-modal vertebr-modal-form",role:"dialog","aria-modal":"true","aria-label":t,onClick:l=>l.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:n??(e===1?"1 person":`${e} people`)}),y.jsx("h2",{children:t})]}),y.jsx("div",{className:"vertebr-modal-actions",children:y.jsx("button",{type:"button",className:"vertebr-btn",onClick:s,"aria-label":"Close",children:"Close"})})]}),y.jsx("div",{className:"vertebr-modal-body",children:y.jsx(jg,{variant:"config",schema:r,value:QS(r),submitLabel:i,onSave:async l=>{await o(l),s()}})})]})})}function Wl(t){return t.trim()}function zm({options:t,value:e,loading:n,disabled:r,placeholder:i="Select…",emptyLabel:s="Nothing available",searchPlaceholder:o="Search…",onChange:l}){const u=E.useId(),f=E.useRef(null),[h,m]=E.useState(!1),[g,b]=E.useState(""),x=E.useMemo(()=>new Set(e.map(Wl)),[e]),S=E.useMemo(()=>{const _=g.trim().toLowerCase();return _?t.filter(M=>`${M.label} ${M.secondary??""} ${M.id}`.toLowerCase().includes(_)):t},[t,g]);E.useEffect(()=>{if(!h)return;const _=O=>{f.current?.contains(O.target)||m(!1)},M=O=>{O.key==="Escape"&&m(!1)};return window.addEventListener("mousedown",_),window.addEventListener("keydown",M),()=>{window.removeEventListener("mousedown",_),window.removeEventListener("keydown",M)}},[h]);const k=_=>{const M=Wl(_),O=new Set(x);O.has(M)?O.delete(M):O.add(M),l(t.map(D=>Wl(D.id)).filter(D=>O.has(D)))},C=()=>{const _=new Set(x);for(const M of S)_.add(Wl(M.id));l(t.map(M=>Wl(M.id)).filter(M=>_.has(M)))},A=()=>l([]),R=e.length===0?n?"Loading…":t.length===0?s:i:e.length===1?t.find(_=>_.id===e[0])?.label??e[0]:`${e.length} selected`;return y.jsxs("div",{className:"vertebr-email-select",ref:f,"data-open":h?"true":void 0,children:[y.jsxs("button",{type:"button",className:"vertebr-select-trigger vertebr-email-select-trigger","aria-haspopup":"listbox","aria-expanded":h,"aria-controls":u,disabled:r||n||t.length===0,onClick:()=>m(_=>!_),children:[y.jsx("span",{className:"vertebr-select-value",children:R}),y.jsx("span",{className:"vertebr-select-icon","aria-hidden":"true",children:y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",children:y.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),h?y.jsxs("div",{className:"vertebr-email-select-panel",id:u,role:"listbox",children:[t.length>6?y.jsxs("div",{className:"vertebr-email-select-toolbar",children:[y.jsx("input",{type:"search",value:g,placeholder:o,"aria-label":"Search",onChange:_=>b(_.target.value)}),y.jsxs("div",{className:"vertebr-email-select-actions",children:[y.jsx("button",{type:"button",onClick:C,children:"All"}),y.jsx("button",{type:"button",onClick:A,disabled:e.length===0,children:"Clear"})]})]}):y.jsx("div",{className:"vertebr-email-select-toolbar vertebr-email-select-toolbar-compact",children:y.jsxs("div",{className:"vertebr-email-select-actions",children:[y.jsx("button",{type:"button",onClick:C,children:"All"}),y.jsx("button",{type:"button",onClick:A,disabled:e.length===0,children:"Clear"})]})}),y.jsx("ul",{className:"vertebr-email-select-list",children:S.length===0?y.jsx("li",{className:"vertebr-email-select-empty",children:"No matches"}):S.map(_=>{const M=x.has(Wl(_.id));return y.jsx("li",{children:y.jsxs("label",{"data-on":M?"true":void 0,"data-media":_.imageUrl?"true":void 0,children:[y.jsx("input",{type:"checkbox",checked:M,onChange:()=>k(_.id)}),_.imageUrl?y.jsx("img",{className:"vertebr-email-select-thumb",src:_.imageUrl,alt:"",loading:"lazy"}):null,y.jsxs("span",{className:"vertebr-email-select-copy",children:[y.jsx("span",{className:"vertebr-email-select-primary",children:_.label}),_.secondary?y.jsx("span",{className:"vertebr-email-select-secondary",children:_.secondary}):null]})]})},_.id)})})]}):null]})}function iQ({options:t,value:e,loading:n,disabled:r,onChange:i}){const s=t.map(o=>({id:o.email.trim().toLowerCase(),label:o.email,secondary:o.label}));return y.jsx(zm,{options:s,value:e,loading:n,disabled:r,placeholder:"Select emails…",emptyLabel:"No emails on this list",searchPlaceholder:"Search emails…",onChange:i})}function cM(t){const e=Date.parse(t);return Number.isFinite(e)?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e):t}function sQ(t){return t.replace(/^library:/i,"").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function oQ(t){return t==="row"?"Row":t==="campaign"?"Schedule":"Board"}function n2(t){const e=t.reference?.trim();if(e&&e.toUpperCase()!=="MM-PENDING")return e;const i=(t.subject??"").match(/(?:—|-|–)\s*((?:MM|ORD|ORDER)[-_][A-Z0-9-]+|[A-Z]{2,}[-_][A-Z0-9-]{3,})\s*$/i)?.[1]?.trim();return!i||i.toUpperCase()==="MM-PENDING"?"":i}function aQ(t){const e=n2(t),n=t.subject?.trim()??"";if(!n)return t.templateLabel??"Email";let r=n;return e&&(r=r.replace(new RegExp(`\\s*[—\\-–]\\s*${e}\\s*$`,"i"),"").trim()),r.replace(/\s*[—\-–]\s*MM-PENDING\s*$/i,"").trim()||n}function lQ(t){if(t.recipients?.[0]){const e=Math.max(0,t.recipientCount-1);return e>0?`${t.recipients[0]} +${e}`:t.recipients[0]}return t.recipientCount>1?`${t.recipientCount} recipients`:""}function cQ(t){return t.failed&&t.failed>0?`${t.sent} / ${t.failed} failed`:`${t.sent} / ${t.recipientCount}`}function uM(t){return t==="sent"?{label:"Sent",tone:"ok"}:t==="partial"?{label:"Partial"}:t==="failed"?{label:"Failed"}:{label:"Scheduled",tone:"neutral"}}function Kl(){return y.jsx("span",{className:"vertebr-cell-empty",children:"—"})}function uQ({campaigns:t,history:e,canSchedule:n,canHistory:r,busy:i,onCancel:s}){const[o,l]=E.useState("all"),u=E.useMemo(()=>t.filter(b=>b.status==="scheduled").slice().sort((b,x)=>Date.parse(b.sendAt)-Date.parse(x.sendAt)),[t]),f=E.useMemo(()=>{const b=u.map(S=>({kind:"scheduled",id:S.id,campaign:S})),x=e.map(S=>({kind:"history",id:S.id,entry:S}));return o==="scheduled"?b:o==="history"?x:[...b,...x]},[o,u,e]),h=!!s&&o!=="history",m=async b=>{s&&window.confirm(`Cancel scheduled email to ${b.resourceLabel??b.resourceId}?`)&&await s(b.id)},g=o==="scheduled"?n?"No drops scheduled yet.":"Host has not enabled scheduling.":o==="history"?r?"No sends recorded yet.":"Host has not enabled send history.":!n&&!r?"Host has not enabled activity.":"No activity yet.";return y.jsxs("div",{className:"vertebr-emails-activity",children:[y.jsxs("div",{className:"vertebr-table-toolbar",children:[y.jsx("div",{className:"vertebr-table-toolbar-start",children:y.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Activity",children:[y.jsx("button",{type:"button","data-active":o==="all"?"true":void 0,onClick:()=>l("all"),children:"All"}),y.jsx("button",{type:"button","data-active":o==="scheduled"?"true":void 0,onClick:()=>l("scheduled"),children:"Scheduled"}),y.jsx("button",{type:"button","data-active":o==="history"?"true":void 0,onClick:()=>l("history"),children:"History"})]})}),y.jsx("span",{className:"vertebr-count",children:f.length})]}),f.length===0?y.jsx("div",{className:"vertebr-empty",children:g}):y.jsx("div",{className:"vertebr-table-wrap",children:y.jsxs("table",{className:"vertebr-table",children:[y.jsx("thead",{children:y.jsxs("tr",{children:[y.jsx("th",{children:"When"}),y.jsx("th",{children:"Status"}),y.jsx("th",{children:"Subject"}),y.jsx("th",{children:"Confirmation"}),y.jsx("th",{children:"To"}),y.jsx("th",{children:"Audience"}),y.jsx("th",{children:"Template"}),y.jsx("th",{children:"Via"}),y.jsx("th",{children:"Delivery"}),h?y.jsx("th",{className:"vertebr-col-actions",children:"Actions"}):null]})}),y.jsx("tbody",{children:f.map(b=>{if(b.kind==="scheduled"){const A=b.campaign,R=uM("scheduled");return y.jsxs("tr",{children:[y.jsx("td",{children:y.jsx("span",{className:"vertebr-cell-datetime",children:cM(A.sendAt)})}),y.jsx("td",{children:y.jsx("span",{className:"vertebr-badge","data-tone":R.tone,children:R.label})}),y.jsx("td",{children:A.subject?.trim()||y.jsx(Kl,{})}),y.jsx("td",{children:y.jsx(Kl,{})}),y.jsx("td",{children:A.recipientCount??y.jsx(Kl,{})}),y.jsx("td",{children:A.resourceLabel??A.resourceId}),y.jsx("td",{children:A.templateLabel??A.templateId}),y.jsx("td",{children:"Schedule"}),y.jsx("td",{children:y.jsx(Kl,{})}),h?y.jsx("td",{className:"vertebr-col-actions",children:y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:i,onClick:()=>{m(A)},children:"Cancel"})}):null]},`scheduled:${b.id}`)}const x=b.entry,S=uM(x.status),k=n2(x),C=lQ(x);return y.jsxs("tr",{children:[y.jsx("td",{children:y.jsx("span",{className:"vertebr-cell-datetime",children:cM(x.at)})}),y.jsx("td",{children:y.jsx("span",{className:"vertebr-badge","data-tone":S.tone,children:S.label})}),y.jsx("td",{children:aQ(x)}),y.jsx("td",{children:k||y.jsx(Kl,{})}),y.jsx("td",{children:C||y.jsx(Kl,{})}),y.jsx("td",{children:x.resourceLabel??x.resourceId}),y.jsx("td",{children:x.templateLabel??sQ(x.templateId)}),y.jsx("td",{children:oQ(x.source)}),y.jsx("td",{children:cQ(x)}),h?y.jsx("td",{className:"vertebr-col-actions"}):null]},`history:${b.id}`)})})]})})]})}function dQ({value:t,options:e,onChange:n,ariaLabel:r,size:i="md"}){const[s,o]=E.useState(!1),l=E.useRef(null),u=E.useId(),f=e.find(h=>h.id===t)??e[0];return E.useEffect(()=>{if(!s)return;const h=g=>{l.current?.contains(g.target)||o(!1)},m=g=>{g.key==="Escape"&&o(!1)};return document.addEventListener("mousedown",h),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",m)}},[s]),y.jsxs("div",{className:"vertebr-emails-nav","data-size":i,"data-open":s||void 0,ref:l,children:[y.jsxs("button",{type:"button",className:"vertebr-emails-nav-trigger","aria-label":r,"aria-haspopup":"listbox","aria-expanded":s,"aria-controls":u,onClick:()=>o(h=>!h),children:[y.jsxs("span",{className:"vertebr-emails-nav-current",children:[y.jsx("span",{className:"vertebr-emails-nav-label",children:f?.label}),f?.count!=null?y.jsx("span",{className:"vertebr-emails-nav-count",children:f.count}):null]}),y.jsx("span",{className:"vertebr-emails-nav-chevron","aria-hidden":"true",children:"▾"})]}),s?y.jsx("ul",{id:u,className:"vertebr-emails-nav-menu",role:"listbox","aria-label":r,children:e.map(h=>{const m=h.id===t;return y.jsx("li",{role:"presentation",children:y.jsxs("button",{type:"button",role:"option","aria-selected":m,"data-active":m||void 0,className:"vertebr-emails-nav-option",onClick:()=>{n(h.id),o(!1)},children:[y.jsxs("span",{className:"vertebr-emails-nav-option-main",children:[y.jsx("span",{className:"vertebr-emails-nav-label",children:h.label}),h.count!=null?y.jsx("span",{className:"vertebr-emails-nav-count",children:h.count}):null]}),h.hint?y.jsx("span",{className:"vertebr-emails-nav-hint",children:h.hint}):null]})},h.id)})}):null]})}const fQ=new Set(["custom","promo","custom_discount"]);function hQ(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim()}function pQ(t){const e=new Set,n=[];for(const r of t){const i=r.input?.preset;if(!(!i||typeof i=="string")&&!(i.type!=="enum"||!i.options?.length))for(const s of i.options)!s||fQ.has(s)||s.startsWith("library:")||e.has(s)||(e.add(s),n.push({id:s,label:i.optionLabels?.[s]?.trim()||hQ(s)}))}return n}function s0(t){return{id:t?.id??`lib_${crypto.randomUUID().replace(/-/g,"").slice(0,12)}`,label:t?.label??"",subject:t?.subject??"",body:t?.body??"",productIds:t?.productIds??[],discountId:t?.discountId,discountCode:t?.discountCode??"",discountOffer:t?.discountOffer??"",discountExpires:t?.discountExpires??"",fromPreset:t?.fromPreset,kind:t?.kind,eyebrow:t?.eyebrow??"",headline:t?.headline??"",confirmationLabel:t?.confirmationLabel??"",shippingNote:t?.shippingNote??"",footer:t?.footer??"",signOff:t?.signOff??"",createdAt:t?.createdAt}}function mQ(t){return/order_?confirm|receipt|invoice/i.test(t)?"order":/discount|offer|sale|flash/i.test(t)?"discount":/promo|drop|restock/i.test(t)?"promo":"account"}function gQ(t){return Array.isArray(t)?t.join(", "):t}function yQ(t,e){return{preset:e?`library:${t.id}`:t.kind==="discount"?"custom_discount":t.kind==="promo"?"promo":"custom",kind:t.kind,subject:t.subject,body:t.body,productIds:t.productIds,discountId:t.discountId,discountCode:t.discountCode,discountOffer:t.discountOffer,discountExpires:t.discountExpires,eyebrow:t.eyebrow,headline:t.headline,confirmationLabel:t.confirmationLabel,shippingNote:t.shippingNote,footer:t.footer,signOff:t.signOff}}function bQ(t){return t.kind==="order"?!0:!t.subject.trim()||!t.body.trim()?!1:t.kind==="discount"?!!(t.discountCode.trim()&&t.discountOffer.trim()):!0}function vQ({templates:t,library:e,products:n,discounts:r=[],canLibrary:i,busy:s,previewResourceId:o,previewTemplateId:l,onPreview:u,onSaveLibrary:f,onDeleteLibrary:h}){const m=E.useMemo(()=>pQ(t),[t]),[g,b]=E.useState(null),[x,S]=E.useState(!1),[k,C]=E.useState(null),[A,R]=E.useState("all"),[_,M]=E.useState(null),[O,D]=E.useState(!1),I=!!(g&&e.some(L=>L.id===g.id)),P=E.useMemo(()=>n.map(L=>({id:L.id,label:L.label,secondary:L.priceLabel,imageUrl:L.imageUrl})),[n]),B=E.useCallback(async()=>{if(!g||!u||!o||!l){M(null);return}if(!bQ(g)){M(null);return}D(!0);try{const L=await u({resourceId:o,templateId:l,input:yQ(g,I)});M(L)}catch{M(null)}finally{D(!1)}},[g,u,o,l,I]);E.useEffect(()=>{const L=window.setTimeout(()=>{B()},280);return()=>window.clearTimeout(L)},[B]);const re=L=>{C(null),b(s0({label:`${L.label} copy`,fromPreset:L.id,kind:mQ(L.id)}))},K=L=>{C(null),b(s0({id:L.id,label:L.label,subject:L.subject,body:L.body,productIds:L.productIds??[],discountId:L.discountId,discountCode:L.discountCode??"",discountOffer:L.discountOffer??"",discountExpires:L.discountExpires??"",fromPreset:L.fromPreset,kind:L.kind,eyebrow:L.eyebrow??"",headline:L.headline??"",confirmationLabel:L.confirmationLabel??"",shippingNote:L.shippingNote??"",footer:L.footer??"",signOff:L.signOff??"",createdAt:L.createdAt}))},ee=()=>{C(null),b(s0({kind:"promo"}))},Q=async()=>{if(!g||!f)return;const L=g.label.trim(),G=g.subject.trim(),he=g.body.trim();if(!L||!G||!he){C("Label, subject, and body are required.");return}if(g.kind==="discount"&&(!g.discountCode.trim()||!g.discountOffer.trim())){C("Discount templates need a code and offer label.");return}S(!0),C(null);try{const ke=new Date().toISOString();await f({id:g.id,label:L,subject:G,body:he,productIds:g.productIds.length?g.productIds:void 0,discountId:g.kind==="discount"&&g.discountId||void 0,discountCode:g.kind==="discount"&&g.discountCode.trim()||void 0,discountOffer:g.kind==="discount"&&g.discountOffer.trim()||void 0,discountExpires:g.kind==="discount"&&g.discountExpires.trim()||void 0,fromPreset:g.fromPreset,kind:g.kind,eyebrow:g.kind==="order"&&g.eyebrow.trim()||void 0,headline:g.kind==="order"&&g.headline.trim()||void 0,confirmationLabel:g.kind==="order"&&g.confirmationLabel.trim()||void 0,shippingNote:g.kind==="order"&&g.shippingNote.trim()||void 0,footer:g.kind==="order"&&g.footer.trim()||void 0,signOff:g.kind==="order"&&g.signOff.trim()||void 0,createdAt:g.createdAt??ke,updatedAt:ke}),b(null)}catch(ke){C(ke instanceof Error?ke.message:"Save failed")}finally{S(!1)}},fe=async L=>{if(h&&window.confirm(`Delete template “${L.label}”?`)){S(!0),C(null);try{await h(L.id),g?.id===L.id&&b(null)}catch(G){C(G instanceof Error?G.message:"Delete failed")}finally{S(!1)}}},z=s||x||!i||!f;return y.jsx("div",{className:"vertebr-emails-library","data-editing":g?"true":void 0,children:g?y.jsxs("div",{className:"vertebr-emails-library-editor",children:[y.jsxs("header",{children:[y.jsx("h3",{children:I?"Edit template":"Save as custom"}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:x,onClick:()=>{b(null),M(null)},children:"Close"})]}),y.jsxs("div",{className:"vertebr-emails-layout",children:[y.jsxs("div",{className:"vertebr-emails-compose",children:[y.jsxs("div",{className:"vertebr-emails-fields",children:[y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Label"}),y.jsx("input",{type:"text",value:g.label,disabled:x,onChange:L=>b(G=>G&&{...G,label:L.target.value})})]}),y.jsx("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Kind",children:[["account","Account"],["promo","Promo"],["discount","Discount"],["order","Order"]].map(([L,G])=>y.jsx("button",{type:"button","data-active":g.kind===L?"true":void 0,disabled:x||g.kind==="order",onClick:()=>b(he=>he&&{...he,kind:L}),children:G},L))}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Subject"}),y.jsx("input",{type:"text",value:g.subject,disabled:x,onChange:L=>b(G=>G&&{...G,subject:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:g.kind==="order"?"Intro":"Body"}),y.jsx("textarea",{rows:g.kind==="order"?4:7,value:g.body,disabled:x,onChange:L=>b(G=>G&&{...G,body:L.target.value})})]}),g.kind==="order"?y.jsxs(y.Fragment,{children:[y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Eyebrow"}),y.jsx("input",{type:"text",value:g.eyebrow,disabled:x,onChange:L=>b(G=>G&&{...G,eyebrow:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Headline"}),y.jsx("input",{type:"text",value:g.headline,disabled:x,onChange:L=>b(G=>G&&{...G,headline:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Confirmation label"}),y.jsx("input",{type:"text",value:g.confirmationLabel,disabled:x,onChange:L=>b(G=>G&&{...G,confirmationLabel:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Shipping note"}),y.jsx("textarea",{rows:2,value:g.shippingNote,disabled:x,onChange:L=>b(G=>G&&{...G,shippingNote:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Footer"}),y.jsx("textarea",{rows:2,value:g.footer,disabled:x,onChange:L=>b(G=>G&&{...G,footer:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Sign-off"}),y.jsx("input",{type:"text",value:g.signOff,disabled:x,onChange:L=>b(G=>G&&{...G,signOff:L.target.value})})]}),y.jsxs("p",{className:"vertebr-mail-compose-hint",children:["Tokens: ","{{confirmationNumber}}",", ","{{email}}",","," ","{{total}}"]})]}):null,g.kind==="discount"?y.jsxs(y.Fragment,{children:[r.length>0?y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Discount"}),y.jsxs("select",{value:g.discountId??"",disabled:x,onChange:L=>{const G=L.target.value,he=r.find(ke=>ke.id===G);b(ke=>ke&&{...ke,discountId:G||void 0,discountCode:he?.code??ke.discountCode,discountOffer:he?.offerLabel??he?.label??ke.discountOffer,discountExpires:he?.expiresLabel??ke.discountExpires})},children:[y.jsx("option",{value:"",children:"Manual code…"}),r.map(L=>y.jsxs("option",{value:L.id,children:[L.label,L.code?` (${L.code})`:""]},L.id))]})]}):null,y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Discount code"}),y.jsx("input",{type:"text",value:g.discountCode,disabled:x,placeholder:"WELCOME20",onChange:L=>b(G=>G&&{...G,discountCode:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Offer label"}),y.jsx("input",{type:"text",value:g.discountOffer,disabled:x,placeholder:"20% off",onChange:L=>b(G=>G&&{...G,discountOffer:L.target.value})})]}),y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Expires (optional)"}),y.jsx("input",{type:"text",value:g.discountExpires,disabled:x,placeholder:"Expires Mar 1",onChange:L=>b(G=>G&&{...G,discountExpires:L.target.value})})]})]}):null,P.length>0?y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Products"}),y.jsx(zm,{options:P,value:g.productIds,disabled:x,placeholder:"Add products with photos…",emptyLabel:"No products",onChange:L=>b(G=>G&&{...G,productIds:L})})]}):null,g.fromPreset?y.jsxs("p",{className:"vertebr-emails-library-meta",children:["From system preset ",y.jsx("code",{children:g.fromPreset})]}):null,k?y.jsx("p",{className:"vertebr-mail-compose-error",children:k}):null]}),y.jsx("div",{className:"vertebr-mail-compose-foot",children:y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:x||!f,onClick:()=>{Q()},children:x?"Saving…":"Save template"})})]}),y.jsx("div",{className:"vertebr-emails-side",children:y.jsxs("div",{className:"vertebr-mail-preview",children:[y.jsxs("div",{className:"vertebr-mail-preview-meta",children:[y.jsxs("p",{children:[y.jsx("span",{children:"To"}),y.jsx("strong",{children:_?gQ(_.to):O?"Updating…":"Sample recipient"})]}),y.jsxs("p",{children:[y.jsx("span",{children:"Subject"}),y.jsx("strong",{children:_?.subject??(O?"Updating…":g.subject||"—")})]})]}),y.jsx("div",{className:"vertebr-mail-preview-stage",children:y.jsx("div",{className:"vertebr-mail-preview-frame",children:_?.html?y.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:_.html}):_?.text?y.jsx("pre",{children:_.text}):y.jsx("div",{className:"vertebr-mail-preview-empty",children:O?"Rendering host template…":!o||!l?"No sample audience to preview against.":g.kind==="discount"&&(!g.discountCode.trim()||!g.discountOffer.trim())?"Add a discount code and offer to preview.":"Write a subject and body to preview."})})})]})})]})]}):y.jsxs(y.Fragment,{children:[y.jsxs("div",{className:"vertebr-emails-subnav",children:[y.jsx(dQ,{size:"sm",ariaLabel:"Templates subsection",value:A,onChange:R,options:[{id:"all",label:"All templates",count:m.length+e.length,hint:"Presets and saved"},{id:"system",label:"System presets",count:m.length,hint:"Built-in starting points"},{id:"saved",label:"Saved templates",count:e.length,hint:"Owner-edited copies"}]}),i&&f&&A!=="system"?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:ee,children:"New"}):null]}),y.jsxs("div",{className:"vertebr-emails-library-cols","data-section":A,children:[A!=="saved"?y.jsxs("section",{className:"vertebr-emails-library-section",children:[y.jsxs("header",{children:[y.jsx("h3",{children:"System presets"}),y.jsx("span",{className:"vertebr-count",children:m.length})]}),m.length===0?y.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"No system presets exposed on template inputs."}):y.jsx("ul",{children:m.map(L=>y.jsxs("li",{children:[y.jsxs("div",{children:[y.jsx("strong",{children:L.label}),y.jsx("span",{children:L.id})]}),i&&f?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>re(L),children:"Duplicate"}):null]},L.id))})]}):null,A!=="system"?y.jsxs("section",{className:"vertebr-emails-library-section",children:[y.jsxs("header",{children:[y.jsx("h3",{children:"Saved templates"}),y.jsx("span",{className:"vertebr-count",children:e.length})]}),i?e.length===0?y.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"No saved templates yet. Duplicate a system preset or create one."}):y.jsx("ul",{children:e.map(L=>y.jsxs("li",{children:[y.jsxs("div",{children:[y.jsx("strong",{children:L.label}),y.jsxs("span",{children:[L.fromPreset?`from ${L.fromPreset}`:"custom",L.kind==="discount"?" · discount":"",L.kind==="order"?" · order":"",L.discountCode?` · ${L.discountCode}`:"",L.productIds?.length?` · ${L.productIds.length} products`:""]}),L.subject?y.jsx("span",{className:"vertebr-emails-campaign-subject",children:L.subject}):null]}),y.jsxs("div",{className:"vertebr-emails-library-actions",children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>K(L),children:"Edit"}),h&&L.kind!=="order"?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:z,onClick:()=>{fe(L)},children:"Delete"}):null]})]},L.id))}):y.jsx("p",{className:"vertebr-emails-campaigns-empty",children:"Host has not enabled the template library."})]}):null]})]})})}const xQ=new Set(["custom","promo","custom_discount"]),wQ=new Set(["discount","welcome_offer","flash_sale","custom_discount"]),SQ=new Set(["discountId","discountCode","discountOffer","discountExpires"]);function Ac(t){return typeof t=="string"?t:String(t??"")}function ek(t){return t.startsWith("library:")}function kQ(t){return xQ.has(t)||ek(t)}function tk(t,e){if(wQ.has(t))return!0;if(!ek(t))return!1;const n=t.slice(8);return e.some(r=>r.id===n&&r.kind==="discount")}function CQ(t,e){const n=`${t} ${e.label??""}`;return e.type==="richtext"||/(body|message|html|notes)/i.test(n)}function r2(t,e){if(!t.preset)return!0;const n=Ac(e.preset);return!n||kQ(n)}function i2(t,e,n,r=[]){if(t==="subject"||t==="body")return r2(e,n);if(SQ.has(t)){const i=Ac(n.preset);return!(!tk(i,r)||t==="discountId"&&!e.discountId?.options?.length)}return!0}function dM(t,e,n=[]){return Object.entries(t).every(([r,i])=>{if(!i2(r,t,e,n))return!0;const s=(r==="subject"||r==="body")&&r2(t,e),o=(r==="discountCode"||r==="discountOffer")&&tk(Ac(e.preset),n);return i.required===!1&&!s&&!o?!0:i.type==="enum[]"?i.required===!1?!0:Array.isArray(e[r])&&e[r].length>0:i.type!=="string"&&i.type!=="richtext"&&i.type!=="enum"?!0:!!Ac(e[r]).trim()})}function EQ(t){return t?Object.fromEntries(Object.entries(t).map(([e,n])=>typeof n=="string"?[e,{type:n,label:e,required:!0}]:[e,n])):{}}function TQ(t,e,n,r){const i={...t};if(i.preset?.type==="enum"&&e.length>0){const s=e.map(u=>`library:${u.id}`),o=Object.fromEntries(e.map(u=>[`library:${u.id}`,u.label])),l=[...i.preset.options??[]];for(const u of s)l.includes(u)||l.push(u);i.preset={...i.preset,options:l,optionLabels:{...i.preset.optionLabels??{},...o}}}if(i.productIds&&n&&n.length>0){const s=n.map(l=>l.id),o=Object.fromEntries(n.map(l=>[l.id,l.label]));i.productIds={...i.productIds,type:"enum[]",options:s,optionLabels:{...i.productIds.optionLabels??{},...o},default:Array.isArray(i.productIds.default)?i.productIds.default:[]}}if(i.discountId&&r&&r.length>0){const s=r.map(l=>l.id),o=Object.fromEntries(r.map(l=>[l.id,l.offerLabel?`${l.label}${l.code?` (${l.code})`:""}`:l.label]));i.discountId={...i.discountId,type:"enum",options:s,optionLabels:{...i.discountId.optionLabels??{},...o},required:!1}}return i}function _Q(t){const e=QS(t);for(const[n,r]of Object.entries(t))r.type==="enum[]"&&!Array.isArray(e[n])&&(e[n]=Array.isArray(r.default)?r.default:[]);return e}function AQ(t,e,n,r){if(!ek(e))return t;const i=e.slice(8),s=n.find(o=>o.id===i);return s?{...t,preset:e,subject:s.subject,body:s.body,...r.productIds?{productIds:s.productIds??[]}:{},...r.discountId?{discountId:s.discountId??""}:{},...r.discountCode?{discountCode:s.discountCode??""}:{},...r.discountOffer?{discountOffer:s.discountOffer??""}:{},...r.discountExpires?{discountExpires:s.discountExpires??""}:{}}:t}function RQ(t){return Array.isArray(t)?t.join(", "):t}function MQ(t){const e=Date.parse(t);return Number.isFinite(e)?new Intl.DateTimeFormat(void 0,{dateStyle:"medium",timeStyle:"short"}).format(e):t}function NQ(){const t=new Date(Date.now()+36e5);t.setMinutes(0,0,0);const e=n=>String(n).padStart(2,"0");return`${t.getFullYear()}-${e(t.getMonth()+1)}-${e(t.getDate())}T${e(t.getHours())}:${e(t.getMinutes())}`}function OQ(t){return Array.isArray(t)?t.map(e=>String(e).trim()).filter(Boolean):[]}function DQ({data:t,loading:e,tab:n,onRefresh:r,onLoadRecipients:i,onPreview:s,onSend:o,onSchedule:l,onCancel:u,onSaveLibrary:f,onDeleteLibrary:h}){const m=t.audiences,g=t.library??[],b=t.products??[],x=t.discounts??[],S=t.history??[],[k]=E.useState("compose"),C=n??k,A=E.useMemo(()=>m.map(ge=>({id:ge.id,label:ge.label})),[m]),[R,_]=E.useState(()=>m[0]?[m[0].id]:[]),M=E.useMemo(()=>m.filter(ge=>R.includes(ge.id)),[m,R]),O=E.useMemo(()=>M.length===0?[]:t.templates.filter(ge=>M.every(Ne=>Ne.templates.includes(ge.id))),[t.templates,M]),[D,I]=E.useState(O[0]?.id??""),P=O.find(ge=>ge.id===D)??O[0],B=E.useMemo(()=>TQ(EQ(P?.input),g,b,x),[x,g,b,P]),re=E.useMemo(()=>_Q(B),[B]),[K,ee]=E.useState(re),[Q,fe]=E.useState("all"),[z,L]=E.useState([]),[G,he]=E.useState([]),[ke,H]=E.useState(!1),[Z,pe]=E.useState("now"),[ve,Ae]=E.useState(NQ),[Re,$e]=E.useState(null),[_e,ae]=E.useState(!1),[me,Ie]=E.useState(!1),[Ue,Ze]=E.useState(null),[ct,yt]=E.useState(null);E.useEffect(()=>{_(ge=>{const Ne=ge.filter(j=>m.some($=>$.id===j));return Ne.length>0?Ne:m[0]?[m[0].id]:[]})},[m]),E.useEffect(()=>{if(!P){I("");return}O.some(ge=>ge.id===D)||I(P.id)},[P,D,O]),E.useEffect(()=>{ee(re)},[re]),E.useEffect(()=>{L([])},[R]);const Pt=M.map(ge=>ge.id).join("|");E.useEffect(()=>{if(M.length===0){he([]);return}let ge=!1;return H(!0),Promise.all(M.map(async Ne=>(await i(Ne.id)).map($=>({...$,resourceId:Ne.id,label:$.label?`${$.label} · ${Ne.label}`:Ne.label})))).then(Ne=>{if(ge)return;const j=new Set,$=[];for(const U of Ne)for(const ie of U){const le=ie.email.trim().toLowerCase();!le||j.has(le)||(j.add(le),$.push({...ie,email:le}))}$.sort((U,ie)=>U.email.localeCompare(ie.email)),he($)}).catch(Ne=>{ge||(he([]),Ze(Ne instanceof Error?Ne.message:"Failed to load emails"))}).finally(()=>{ge||H(!1)}),()=>{ge=!0}},[Pt,i,M]);const mn=M[0],Wt=M.length>0&&!!P&&(!Object.keys(B).length||dM(B,K,g))&&(Q==="all"||z.length>0)&&(Z==="now"||!!ve)&&!me,yn=E.useMemo(()=>{if(Q!=="emails"||z.length===0)return;const ge=G.find(Ne=>Ne.email.trim().toLowerCase()===z[0]?.toLowerCase());return ge?.id??ge?.email??z[0]},[G,Q,z]),$n=E.useMemo(()=>{if(Q==="emails"&&z[0]){const ge=G.find(Ne=>Ne.email.trim().toLowerCase()===z[0]?.toLowerCase());if(ge?.resourceId)return ge.resourceId}return mn?.id},[mn?.id,G,Q,z]),Dr=E.useCallback(async()=>{if(C==="compose"){if(!$n||!P){$e(null);return}if(Object.keys(B).length&&!dM(B,K,g)){$e(null);return}ae(!0),Ze(null);try{const ge=await s({resourceId:$n,templateId:P.id,rowId:yn,input:Object.keys(B).length?K:void 0});$e(ge)}catch(ge){$e(null),Ze(ge instanceof Error?ge.message:"Preview failed")}finally{ae(!1)}}},[K,s,$n,yn,B,C,P]);E.useEffect(()=>{const ge=window.setTimeout(()=>{Dr()},280);return()=>window.clearTimeout(ge)},[Dr]);const sr=ge=>{const Ne=G.find(j=>j.email.trim().toLowerCase()===ge.toLowerCase());return Ne?.resourceId?[Ne.resourceId]:M.map(j=>j.id)},Ir=async()=>{if(!(!Wt||!P||M.length===0)){Ie(!0),Ze(null),yt(null);try{const ge=Object.keys(B).length?K:void 0;if(Z==="later"){if(!l)throw new Error("Scheduling is not available.");const Ne=new Date(ve).toISOString();if(Q==="all")for(const j of M)await l({resourceId:j.id,templateId:P.id,input:ge,audience:{mode:"all"},sendAt:Ne});else{const j=new Map;for(const $ of z)for(const U of sr($)){const ie=j.get(U)??[];ie.push($),j.set(U,ie)}for(const[$,U]of j)await l({resourceId:$,templateId:P.id,input:ge,audience:{mode:"emails",emails:U},sendAt:Ne})}yt(`Scheduled for ${MQ(Ne)}.`)}else{let Ne=0,j=0;if(Q==="all")for(const $ of M){const U=await o({resourceId:$.id,templateId:P.id,input:ge,audience:{mode:"all"}});Ne+=U.sent,j+=U.failed}else{const $=new Map;for(const U of z)for(const ie of sr(U)){const le=$.get(ie)??[];le.push(U),$.set(ie,le)}for(const[U,ie]of $){const le=await o({resourceId:U,templateId:P.id,input:ge,audience:{mode:"emails",emails:ie}});Ne+=le.sent,j+=le.failed}}yt(j>0?`Sent ${Ne}. ${j} failed.`:`Sent ${Ne}.`)}await r()}catch(ge){Ze(ge instanceof Error?ge.message:"Request failed")}finally{Ie(!1)}}},Ht=async ge=>{if(u){Ie(!0),Ze(null);try{await u(ge),await r()}catch(Ne){Ze(Ne instanceof Error?Ne.message:"Cancel failed")}finally{Ie(!1)}}},xi=async ge=>{f&&(await f(ge),await r())},yr=async ge=>{h&&(await h(ge),await r())},ei=Object.entries(B).filter(([ge])=>i2(ge,B,K,g)),Bn=(ge,Ne)=>{ee(j=>{let $={...j,[ge]:Ne};if(ge==="preset"&&typeof Ne=="string"){$=AQ($,Ne,g,B);const U=Ne==="drop_live"||Ne==="restock"||Ne==="promo"||tk(Ne,g)||g.some(le=>`library:${le.id}`===Ne&&(le.kind==="promo"||(le.productIds?.length??0)>0)),ie=Array.isArray($.productIds)?$.productIds:[];U&&ie.length===0&&b[0]&&B.productIds&&($={...$,productIds:[b[0].id]})}if(ge==="discountId"&&typeof Ne=="string"){const U=x.find(ie=>ie.id===Ne);U&&($={...$,discountCode:U.code??$.discountCode??"",discountOffer:U.offerLabel??U.label??$.discountOffer??"",discountExpires:U.expiresLabel??$.discountExpires??""})}return $})};return m.length===0?y.jsxs("div",{className:"vertebr-emails",children:[y.jsx("div",{className:"vertebr-panel-head",children:y.jsx("h2",{children:t.label})}),y.jsxs("div",{className:"vertebr-empty",children:["No mail-enabled resources yet. Opt a resource in with"," ",y.jsx("code",{children:'mail: ["sendEmail"]'}),"."]})]}):y.jsxs("div",{className:"vertebr-emails",children:[y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:t.label}),y.jsx("div",{className:"vertebr-panel-head-actions",children:y.jsx("button",{type:"button",className:"vertebr-btn",onClick:()=>{r()},disabled:e||me,children:e?"Refreshing…":"Refresh"})})]}),C==="compose"?y.jsxs("div",{className:"vertebr-emails-layout",children:[y.jsxs("form",{className:"vertebr-emails-compose",onSubmit:ge=>{ge.preventDefault(),Ir()},children:[y.jsxs("div",{className:"vertebr-emails-fields",children:[y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Audience"}),y.jsx(zm,{options:A,value:R,disabled:me,placeholder:"Select audiences…",emptyLabel:"No audiences",onChange:ge=>{if(ge.length===0&&m[0]){_([m[0].id]);return}_(ge)}})]}),y.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"Scope",children:[y.jsx("button",{type:"button","data-active":Q==="all"?"true":void 0,onClick:()=>fe("all"),children:"Entire list"}),y.jsx("button",{type:"button","data-active":Q==="emails"?"true":void 0,onClick:()=>fe("emails"),children:"Specific emails"})]}),Q==="emails"?y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Emails"}),y.jsx(iQ,{options:G,value:z,loading:ke,disabled:me,onChange:L})]}):null,y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Template"}),y.jsx("select",{value:P?.id??"",onChange:ge=>I(ge.target.value),children:O.map(ge=>y.jsx("option",{value:ge.id,children:ge.label},ge.id))})]}),ei.map(([ge,Ne])=>{const j=CQ(ge,Ne);return y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:Ne.label??ge}),Ne.type==="enum"?y.jsx(JS,{id:`emails-${ge}`,value:K[ge],field:Ne,onChange:$=>Bn(ge,$)}):Ne.type==="enum[]"?y.jsx(zm,{options:(Ne.options??[]).map($=>{const U=ge==="productIds"?b.find(ie=>ie.id===$):void 0;return{id:$,label:Ne.optionLabels?.[$]??$,secondary:U?.priceLabel,imageUrl:U?.imageUrl}}),value:OQ(K[ge]),disabled:me,placeholder:ge==="productIds"?"Add products with photos…":`Select ${Ne.label??ge}…`,emptyLabel:"Nothing available",onChange:$=>Bn(ge,$)}):j?y.jsx("textarea",{rows:6,value:Ac(K[ge]),onChange:$=>Bn(ge,$.target.value)}):y.jsx("input",{type:"text",value:Ac(K[ge]),onChange:$=>Bn(ge,$.target.value)})]},ge)}),y.jsxs("div",{className:"vertebr-emails-segment",role:"group","aria-label":"When",children:[y.jsx("button",{type:"button","data-active":Z==="now"?"true":void 0,onClick:()=>pe("now"),children:"Send now"}),y.jsx("button",{type:"button","data-active":Z==="later"?"true":void 0,disabled:!t.canSchedule||!l,onClick:()=>pe("later"),children:"Schedule"})]}),Z==="later"?y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:"Send at"}),y.jsx("input",{type:"datetime-local",value:ve,onChange:ge=>Ae(ge.target.value)})]}):null,Ue?y.jsx("p",{className:"vertebr-mail-compose-error",children:Ue}):null,ct?y.jsx("p",{className:"vertebr-emails-notice",children:ct}):null]}),y.jsx("div",{className:"vertebr-mail-compose-foot",children:y.jsx("button",{type:"submit",className:"vertebr-btn vertebr-btn-primary",disabled:!Wt,children:me?Z==="later"?"Scheduling…":"Sending…":Z==="later"?"Schedule email":Q==="all"?"Send to list":"Send"})})]}),y.jsx("div",{className:"vertebr-emails-side",children:y.jsxs("div",{className:"vertebr-mail-preview",children:[y.jsxs("div",{className:"vertebr-mail-preview-meta",children:[y.jsxs("p",{children:[y.jsx("span",{children:"To"}),y.jsx("strong",{children:Re?RQ(Re.to):Q==="all"?M.length===0?"—":M.length===1?`Everyone on ${M[0]?.label}`:`Everyone on ${M.length} lists`:z.length>0?z.length===1?z[0]:`${z.length} selected`:"—"})]}),y.jsxs("p",{children:[y.jsx("span",{children:"Subject"}),y.jsx("strong",{children:Re?.subject??(_e?"Updating…":"—")})]})]}),y.jsx("div",{className:"vertebr-mail-preview-stage",children:y.jsx("div",{className:"vertebr-mail-preview-frame",children:Re?.html?y.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:Re.html}):Re?.text?y.jsx("pre",{children:Re.text}):y.jsx("div",{className:"vertebr-mail-preview-empty",children:_e?"Rendering host template…":"Pick an audience and template to preview."})})})]})})]}):null,C==="templates"?y.jsx(vQ,{templates:t.templates,library:g,products:b,discounts:x,canLibrary:t.canLibrary,busy:me,previewResourceId:t.audiences[0]?.id,previewTemplateId:t.templates.find(ge=>ge.id==="sendEmail")?.id??t.templates[0]?.id,onPreview:s,onSaveLibrary:f?xi:void 0,onDeleteLibrary:h?yr:void 0}):null,C==="activity"?y.jsx(uQ,{campaigns:t.campaigns,history:S,canSchedule:t.canSchedule,canHistory:t.canHistory,busy:me,onCancel:u?Ht:void 0}):null]})}function IQ(t){return`https://fonts.googleapis.com/css2?family=${encodeURIComponent(t)}:wght@400;600;700&display=swap`}function s2({open:t,title:e,subtitle:n,family:r,files:i,googleFamily:s,bodyWeight:o,headingWeight:l,onClose:u,onConfirm:f,confirmLabel:h="Use this font"}){const m=E.useId().replace(/:/g,""),g=E.useMemo(()=>i?.length?LN({family:r,files:i}):"",[i,r,e]);if(E.useEffect(()=>{if(!t)return;let S=null;return s&&!i?.length&&(S=document.createElement("link"),S.rel="stylesheet",S.href=IQ(s),document.head.appendChild(S)),()=>{S?.remove()}},[t,s,i?.length]),E.useEffect(()=>{if(!t)return;const S=k=>{k.key==="Escape"&&u()};return window.addEventListener("keydown",S),()=>window.removeEventListener("keydown",S)},[t,u]),!t)return null;const b=o??i?.find(S=>S.weight>=400&&S.weight<600)?.weight??i?.[0]?.weight??400,x=l??i?.find(S=>S.weight>=600)?.weight??i?.[i.length-1]?.weight??700;return y.jsxs("div",{className:"vertebr-font-preview-modal-backdrop",onClick:u,children:[g?y.jsx("style",{id:m,dangerouslySetInnerHTML:{__html:g}}):null,y.jsxs("div",{className:"vertebr-font-preview-modal",role:"dialog","aria-modal":"true","aria-labelledby":`${m}-title`,onClick:S=>S.stopPropagation(),children:[y.jsxs("div",{className:"vertebr-font-preview-modal-head",children:[y.jsxs("div",{children:[y.jsx("h3",{id:`${m}-title`,children:e}),n?y.jsx("p",{children:n}):null]}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:u,children:"Close"})]}),y.jsx("div",{className:"vertebr-font-preview-modal-body",children:y.jsx(up,{family:r,bodyWeight:b,headingWeight:x})}),f?y.jsxs("div",{className:"vertebr-font-preview-modal-actions",children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:u,children:"Cancel"}),y.jsx("button",{type:"button",className:"vertebr-btn",onClick:f,children:h})]}):null]})]})}function jQ({disabled:t,existingFamilies:e,onImport:n}){const[r,i]=E.useState(""),[s,o]=E.useState(null),[l,u]=E.useState(null),[f,h]=E.useState(null),m=E.useMemo(()=>{const b=r.trim().toLowerCase();return b?XT.filter(x=>x.family.toLowerCase().includes(b)||x.category.includes(b)):XT},[r]),g=async b=>{if(!(t||s)){o(b.family),u(null);try{await n({family:b.family,weights:b.weights}),h(null)}catch(x){u(x instanceof Error?x.message:"Import failed")}finally{o(null)}}};return y.jsxs("section",{className:"vertebr-google-fonts",children:[y.jsxs("div",{className:"vertebr-google-fonts-head",children:[y.jsxs("div",{children:[y.jsx("h3",{children:"Google Fonts"}),y.jsx("p",{children:"Browse and add open-source fonts to your library."})]}),y.jsx("input",{type:"search",className:"vertebr-google-fonts-search",placeholder:"Search fonts…",value:r,onChange:b=>i(b.target.value)})]}),l?y.jsx("div",{className:"vertebr-error-inline",children:l}):null,y.jsx("div",{className:"vertebr-google-fonts-grid-scroll",children:y.jsx("div",{className:"vertebr-google-fonts-grid",children:m.map(b=>{const x=e.includes(b.family.toLowerCase());return y.jsxs("article",{className:"vertebr-google-fonts-card",children:[y.jsxs("button",{type:"button",className:"vertebr-google-fonts-preview-btn",onClick:()=>h(b),title:`Preview ${b.family}`,children:[y.jsxs("div",{className:"vertebr-google-fonts-card-copy",children:[y.jsx("strong",{children:b.family}),y.jsx("span",{children:b.category.replace("-"," ")}),y.jsx("span",{children:b.weights.join(", ")})]}),y.jsx("span",{className:"vertebr-font-library-preview-hint",children:"Click to preview"})]}),y.jsx("button",{type:"button",className:"vertebr-btn",disabled:t||x||s===b.family,onClick:()=>{g(b)},children:x?"In library":s===b.family?"Adding…":"Add to library"})]},b.family)})})}),y.jsx(s2,{open:f!=null,title:f?.family??"Font preview",subtitle:f?`${f.category.replace("-"," ")} · weights ${f.weights.join(", ")}`:void 0,family:f?.family??"",googleFamily:f?.family,onClose:()=>h(null),onConfirm:f&&!e.includes(f.family.toLowerCase())?()=>{g(f)}:void 0,confirmLabel:f&&e.includes(f.family.toLowerCase())?"Already in library":"Add to library"})]})}function LQ(t){const e=t.files.find(n=>n.weight>=600)??t.files[0];return{fontFamily:`"${t.family}", ui-sans-serif, sans-serif`,fontWeight:e?.weight??400}}function PQ({label:t="Font Library",data:e,loading:n,onRefresh:r,onUpload:i,onImportGoogle:s,onDelete:o}){const[l,u]=E.useState(null),f={field:"fonts",accept:e.accept,maxBytes:e.maxBytes};return y.jsxs("div",{className:"vertebr-font-library",children:[y.jsx(AO,{items:e.items}),y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:t}),y.jsxs("div",{className:"vertebr-font-library-head-actions",children:[y.jsx("span",{className:"vertebr-count",children:e.items.length}),r?y.jsx("button",{type:"button",className:"vertebr-btn",onClick:r,disabled:n,children:n?"Refreshing…":"Refresh"}):null]})]}),y.jsxs("div",{className:"vertebr-font-library-body",children:[e.canImportGoogle&&s?y.jsx(jQ,{disabled:n,onImport:s,existingFamilies:e.items.map(h=>h.family.toLowerCase())}):null,y.jsx(Nc,{meta:f,multiple:!0,label:"Drop .woff2 / .woff / .ttf files here or browse to upload",onUpload:async h=>{for(const m of h){const g=m.name.replace(/\.[^.]+$/,""),b=/(?:^|[\s_-])(100|200|300|400|500|600|700|800|900)(?:[\s_-]|$)/i.exec(g),x=g.replace(/(?:^|[\s_-])(100|200|300|400|500|600|700|800|900)(?:[\s_-]|$)/gi," ").replace(/[\s_-]+/g," ").trim();await i([m],{family:x||void 0,weight:b?Number(b[1]):400})}}}),y.jsx("p",{className:"vertebr-font-library-note",children:"Upload only fonts you have the right to use. Click a font card to preview before using it in Brand typography."}),e.items.length===0?y.jsx("div",{className:"vertebr-empty",children:"No fonts in the library yet."}):y.jsx("div",{className:"vertebr-font-library-grid",children:e.items.map(h=>y.jsxs("article",{className:"vertebr-font-library-card",children:[y.jsxs("button",{type:"button",className:"vertebr-font-library-preview-btn",onClick:()=>u(h),title:`Preview ${h.label}`,children:[y.jsxs("div",{className:"vertebr-font-library-preview",style:LQ(h),children:[y.jsx("span",{className:"vertebr-font-library-ag",children:"Ag"}),y.jsx("p",{children:"The quick brown fox jumps over the lazy dog."})]}),y.jsx("span",{className:"vertebr-font-library-preview-hint",children:"Click to preview"})]}),y.jsxs("div",{className:"vertebr-font-library-meta",children:[y.jsx("strong",{title:h.label,children:h.label}),y.jsxs("span",{children:[h.source==="google"?"Google Fonts":"Upload"," ·"," ",h.files.length," file",h.files.length===1?"":"s"]}),y.jsx("code",{children:h.id})]}),e.canDelete&&o?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-danger-quiet",onClick:()=>{window.confirm(`Delete "${h.label}" from the font library?`)&&o(h.id)},children:"Delete"}):null]},h.id))})]}),y.jsx(s2,{open:l!=null,title:l?.label??"Font preview",subtitle:l?`${l.source==="google"?"Google Fonts":"Upload"} · ${l.family}`:void 0,family:l?.family??"",files:l?.files,onClose:()=>u(null)})]})}function zQ({label:t="Gallery",items:e,accept:n,maxBytes:r,canDelete:i,loading:s,onRefresh:o,onUpload:l,onDelete:u}){const f={field:"gallery",accept:n,maxBytes:r};return y.jsxs("div",{className:"vertebr-gallery",children:[y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:t}),y.jsxs("div",{className:"vertebr-gallery-head-actions",children:[y.jsx("span",{className:"vertebr-count",children:e.length}),o?y.jsx("button",{type:"button",className:"vertebr-btn",onClick:o,disabled:s,children:s?"Refreshing…":"Refresh"}):null]})]}),y.jsxs("div",{className:"vertebr-gallery-body",children:[y.jsx(Nc,{meta:f,multiple:!0,label:"Drop images here or browse to add to the gallery",onUpload:l}),e.length===0?y.jsx("div",{className:"vertebr-empty",children:"No images in the gallery yet."}):y.jsx("div",{className:"vertebr-gallery-grid",children:e.map(h=>y.jsxs("article",{className:"vertebr-gallery-card",children:[y.jsx("a",{className:"vertebr-gallery-thumb",href:h.url,target:"_blank",rel:"noreferrer",title:h.name??h.url,children:y.jsx("img",{src:h.url,alt:h.name??"",loading:"lazy"})}),y.jsxs("div",{className:"vertebr-gallery-meta",children:[y.jsx("strong",{title:h.name??h.id,children:h.name??h.id}),y.jsx("a",{href:h.url,target:"_blank",rel:"noreferrer",children:h.url.replace(/^https?:\/\//i,"")})]}),i&&u?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-danger-quiet",onClick:()=>{window.confirm("Delete this image from the gallery?")&&u(h.id)},children:"Delete"}):null]},h.id))})]})]})}const o0=3;function $Q(t){const e=Math.max(0,...t),n=Math.min(0,...t),r=e-n||1;return{min:n,max:e,span:r}}function BQ(t,e){if(!(t>0))return e==="usd"?100:4;if(e!=="usd"){const o=Math.ceil(t);return o<=4?4:o<=6?6:o<=8?8:o<=10?10:Math.ceil(o/5)*5}const n=t*1.08,r=10**Math.floor(Math.log10(n)),i=n/r;return(i<=1?1:i<=2?2:i<=2.5?2.5:i<=5?5:10)*r}function VQ(t,e){if(e==="usd")return[0,t/2,t];const n=t<=4||t<=10?2:t/4,r=[];for(let i=0;i<t-1e-9;i+=n)r.push(i);return r.push(t),r}function yd(t){return t[0]?t.map((n,r)=>`${r===0?"M":"L"} ${n.x} ${n.y}`).join(" "):""}function HQ({series:t,tone:e="neutral"}){if(t.length<2)return null;const n=72,r=28,{min:i,span:s}=$Q(t),o=t.map((f,h)=>({x:h/(t.length-1)*n,y:r-(f-i)/s*(r-2)-1})),l=o[o.length-1],u=l?`${yd(o)} L ${l.x} ${r} L 0 ${r} Z`:"";return y.jsxs("svg",{className:"vertebr-sparkline","data-tone":e,viewBox:`0 0 ${n} ${r}`,width:n,height:r,"aria-hidden":"true",children:[u?y.jsx("path",{d:u,fill:"currentColor",opacity:"0.16"}):null,y.jsx("path",{d:yd(o),fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinejoin:"round",strokeLinecap:"round"})]})}function UQ(t,e){return e==="usd"?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:Number.isInteger(t)||Math.abs(t)>=100?0:2}).format(t):new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(t)}function FQ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function qQ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function GQ({charts:t,value:e,onChange:n}){return y.jsxs(Cg,{value:e,onValueChange:n,children:[y.jsxs(Eg,{className:"vertebr-select-trigger vertebr-chart-series","aria-label":"Chart series",children:[y.jsx("span",{className:"vertebr-select-value",children:y.jsx(Tg,{})}),y.jsx(_g,{className:"vertebr-select-icon",children:y.jsx(FQ,{})})]}),y.jsx(Ag,{children:y.jsx(Rg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:y.jsx(Ng,{className:"vertebr-select-viewport",children:t.map(r=>y.jsxs(Og,{value:r.id,className:"vertebr-select-item",children:[y.jsx(Dg,{children:r.label}),y.jsx(Ig,{className:"vertebr-select-check",children:y.jsx(qQ,{})})]},r.id))})})})]})}function WQ({charts:t,chartId:e,onChartIdChange:n,compareLabel:r="Previous period"}){const i=t.find(ae=>ae.id===e)??t[0],s=i?.unit,o=E.useMemo(()=>t.filter(ae=>ae.id!==i?.id&&(ae.unit??"count")===(s??"count")),[t,i?.id,s]),l=o.length>0,[u,f]=E.useState("period"),[h,m]=E.useState([]),[g,b]=E.useState(null);if(E.useEffect(()=>{b(null)},[i?.id,u,h.join("|")]),E.useEffect(()=>{!l&&u==="metrics"&&f("period")},[l,u]),E.useEffect(()=>{m(ae=>ae.filter(me=>o.some(Ie=>Ie.id===me)))},[o]),!i)return y.jsx("article",{className:"vertebr-chart",children:y.jsx("p",{className:"vertebr-chart-empty",children:"No activity in this window."})});const x=u==="metrics"&&l,S=o.filter(ae=>h.includes(ae.id)).slice(0,o0-1),k=x?[i,...S]:[i],C=i.points.map(ae=>ae.label),A=960,R=220,_={top:12,right:16,bottom:28,left:52},M=A-_.left-_.right,O=R-_.top-_.bottom,D=k.flatMap(ae=>ae.points.map(me=>me.value)),I=x?[]:(i.comparePoints??[]).map(ae=>ae.value),P=!x&&I.length>0,B=BQ(Math.max(0,...D,...I),i.unit),re=(ae,me)=>_.left+(me<=1?M/2:ae/(me-1)*M),K=k.map(ae=>ae.points.map((me,Ie)=>{const Ue=re(Ie,C.length||ae.points.length),Ze=_.top+O-Math.max(0,me.value)/B*O;return{x:Ue,y:Ze,value:me.value,label:me.label}})),ee=K[0]??[],Q=I.map((ae,me)=>{const Ie=re(me,C.length||I.length),Ue=_.top+O-Math.max(0,ae)/B*O;return{x:Ie,y:Ue,value:ae,label:i.comparePoints?.[me]?.label??""}}),fe=VQ(B,i.unit),z=Math.max(1,Math.ceil(ee.length/7)),L=i.points.reduce((ae,me)=>ae+me.value,0),G=ee.length===0||k.every(ae=>ae.points.every(me=>me.value===0)),he=g??(ee.length>0?ee.length-1:null),ke=`vb-chart-fill-${i.id}`,H=ae=>UQ(ae,i.unit),Z=P&&he!=null?Q[he]:void 0,pe=yd(ee),ve=ee[0],Ae=ee[ee.length-1],Re=_.top+O,$e=!x&&ve&&Ae?`${pe} L ${Ae.x} ${Re} L ${ve.x} ${Re} Z`:"",_e=ae=>{m(me=>me.includes(ae)?me.filter(Ie=>Ie!==ae):me.length>=o0-1?me:[...me,ae])};return y.jsxs("article",{className:"vertebr-chart","data-empty":G?"true":void 0,"data-mode":x?"metrics":"period",children:[y.jsxs("div",{className:"vertebr-chart-head",children:[y.jsxs("div",{className:"vertebr-chart-head-start",children:[t.length>1?y.jsx(GQ,{charts:t,value:i.id,onChange:n}):y.jsx("p",{className:"vertebr-chart-kicker",children:i.label}),l?y.jsxs("div",{className:"vertebr-chart-mode",role:"group","aria-label":"Chart mode",children:[y.jsx("button",{type:"button",className:"vertebr-chart-mode-btn","data-active":u==="period"?"true":void 0,onClick:()=>f("period"),children:"vs previous"}),y.jsx("button",{type:"button",className:"vertebr-chart-mode-btn","data-active":u==="metrics"?"true":void 0,onClick:()=>{f("metrics"),m(ae=>ae.length>0?ae:o.slice(0,1).map(me=>me.id))},children:"Compare metrics"})]}):null,x?y.jsx("div",{className:"vertebr-chart-metric-toggles",children:o.map(ae=>{const me=h.includes(ae.id),Ie=!me&&S.length>=o0-1;return y.jsx("button",{type:"button",className:"vertebr-chart-metric-toggle","data-on":me?"true":void 0,disabled:Ie,onClick:()=>_e(ae.id),children:ae.label},ae.id)})}):P?y.jsxs("p",{className:"vertebr-chart-legend",children:[y.jsxs("span",{children:[y.jsx("i",{"data-series":"current"}),"Current"]}),y.jsxs("span",{children:[y.jsx("i",{"data-series":"previous"}),r]})]}):null,x?y.jsx("p",{className:"vertebr-chart-legend",children:k.map((ae,me)=>y.jsxs("span",{children:[y.jsx("i",{"data-series":`m${me}`}),ae.label]},ae.id))}):null]}),y.jsx("p",{className:"vertebr-chart-total",children:x?"—":H(L)})]}),ee.length===0?y.jsx("p",{className:"vertebr-chart-empty",children:"No activity in this window."}):y.jsxs("div",{className:"vertebr-chart-plot",children:[y.jsxs("svg",{className:"vertebr-chart-svg",viewBox:`0 0 ${A} ${R}`,role:"img","aria-label":x?k.map(ae=>ae.label).join(" vs "):i.label,onMouseLeave:()=>b(null),onMouseMove:ae=>{const me=ae.currentTarget.getBoundingClientRect(),Ie=(ae.clientX-me.left)/me.width*A;let Ue=0,Ze=1/0;ee.forEach((ct,yt)=>{const Pt=Math.abs(ct.x-Ie);Pt<Ze&&(Ze=Pt,Ue=yt)}),b(Ue)},children:[y.jsx("defs",{children:y.jsxs("linearGradient",{id:ke,x1:"0",y1:"0",x2:"0",y2:"1",children:[y.jsx("stop",{offset:"0%",stopColor:"var(--vb-accent)",stopOpacity:"0.32"}),y.jsx("stop",{offset:"100%",stopColor:"var(--vb-accent)",stopOpacity:"0"})]})}),fe.map((ae,me)=>{const Ie=_.top+O-ae/B*O;return y.jsxs("g",{children:[y.jsx("line",{className:ae===0?"vertebr-chart-baseline":"vertebr-chart-grid",x1:_.left,x2:A-_.right,y1:Ie,y2:Ie}),y.jsx("text",{className:"vertebr-chart-axis",x:_.left-8,y:Ie+3,textAnchor:"end",children:H(ae)})]},`${ae}-${me}`)}),$e?y.jsx("path",{className:"vertebr-chart-area",d:$e,fill:`url(#${ke})`}):null,P?y.jsx("path",{className:"vertebr-chart-line-compare",d:yd(Q),fill:"none"}):null,K.map((ae,me)=>y.jsx("path",{className:me===0&&!x?"vertebr-chart-line":"vertebr-chart-line-metric","data-series":x||me>0?`m${me}`:void 0,d:yd(ae),fill:"none"},k[me]?.id??me)),he!=null?y.jsx("line",{className:"vertebr-chart-crosshair",x1:ee[he]?.x,x2:ee[he]?.x,y1:_.top,y2:_.top+O}):null,ee.map((ae,me)=>me%z===0||me===ee.length-1?y.jsx("text",{className:"vertebr-chart-axis",x:ae.x,y:R-8,textAnchor:me===0?"start":me===ee.length-1?"end":"middle",children:ae.label},`label-${ae.label}-${me}`):null),K.map((ae,me)=>ae.map((Ie,Ue)=>he===Ue?y.jsx("circle",{className:me===0&&!x?"vertebr-chart-dot":"vertebr-chart-dot-metric","data-series":x||me>0?`m${me}`:void 0,"data-active":"true",cx:Ie.x,cy:Ie.y,r:me===0?4.2:3.4},`dot-${k[me]?.id}-${Ue}`):null)),Z?y.jsx("circle",{className:"vertebr-chart-dot-compare",cx:Z.x,cy:Z.y,r:3.4}):null]}),he!=null&&ee[he]?y.jsxs("div",{className:"vertebr-chart-tooltip",style:{left:`${Math.min(88,Math.max(12,ee[he].x/A*100))}%`},children:[y.jsx("span",{children:ee[he].label}),x?k.map((ae,me)=>y.jsxs("strong",{className:"vertebr-chart-tooltip-row","data-series":`m${me}`,children:[ae.label," ",H(ae.points[he]?.value??0)]},ae.id)):y.jsxs(y.Fragment,{children:[y.jsx("strong",{children:H(ee[he].value)}),Z?y.jsxs("span",{className:"vertebr-chart-tooltip-compare",children:["Prev ",H(Z.value),Z.label?` · ${Z.label}`:""]}):null]})]}):null]})]})}function KQ(t){const e=Math.abs(t),n=e>=10?e.toFixed(0):e.toFixed(1);return t>0?`+${n}%`:t<0?`−${n}%`:"0%"}function ZQ(t){return t>0?"up":t<0?"down":"flat"}function fM({value:t}){return t==null?y.jsx("span",{className:"vertebr-metrics-table-empty",children:"—"}):y.jsx("span",{className:"vertebr-metric-delta","data-dir":ZQ(t),children:KQ(t)})}function YQ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function XQ(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function JQ({value:t,onChange:e,disabled:n}){return y.jsxs(Cg,{value:t,onValueChange:r=>e(r),disabled:n,children:[y.jsxs(Eg,{className:"vertebr-select-trigger vertebr-metrics-range","aria-label":"Metrics range",children:[y.jsx("span",{className:"vertebr-select-value",children:y.jsx(Tg,{})}),y.jsx(_g,{className:"vertebr-select-icon",children:y.jsx(XQ,{})})]}),y.jsx(Ag,{children:y.jsx(Rg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:y.jsx(Ng,{className:"vertebr-select-viewport",children:PN.map(r=>y.jsxs(Og,{value:r.id,className:"vertebr-select-item",children:[y.jsx(Dg,{children:r.label}),y.jsx(Ig,{className:"vertebr-select-check",children:y.jsx(YQ,{})})]},r.id))})})})]})}function QQ({label:t="Overview",windowLabel:e,compareLabel:n,metrics:r,charts:i=[],range:s,onRangeChange:o,onRefresh:l,loading:u}){const f=r.filter(R=>R.featured).slice(0,4),h=f.length>0?f:r.slice(0,4),m=new Set(h.map(R=>R.id)),g=r.filter(R=>!m.has(R.id)),[b,x]=E.useState(!0),S=E.useMemo(()=>new Set(i.map(R=>R.id)),[i]),[k,C]=E.useState(()=>i[0]?.id??""),A=S.has(k)?k:i[0]?.id??"";return y.jsxs("div",{className:"vertebr-metrics",children:[y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsxs("div",{children:[y.jsx("h2",{children:t}),e?y.jsx("p",{className:"vertebr-metrics-window",children:e}):null]}),o||l?y.jsxs("div",{className:"vertebr-panel-head-actions",children:[o&&s?y.jsx(JQ,{value:s,onChange:o,disabled:u}):null,l?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:l,disabled:u,children:u?"Refreshing…":"Refresh"}):null]}):null]}),r.length===0&&i.length===0?y.jsx("div",{className:"vertebr-empty",children:"No metrics registered yet."}):y.jsxs("div",{className:"vertebr-metrics-body",children:[h.length>0?y.jsx("section",{className:"vertebr-metrics-block",children:y.jsx("div",{className:"vertebr-metrics-kpis",children:h.map(R=>{const _=S.has(R.id);return y.jsxs("article",{className:"vertebr-kpi","data-tone":R.tone??"neutral","data-selectable":_?"true":void 0,"data-active":_&&R.id===A?"true":void 0,role:_?"button":void 0,tabIndex:_?0:void 0,onClick:_?()=>C(R.id):void 0,onKeyDown:_?M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),C(R.id))}:void 0,children:[y.jsxs("div",{className:"vertebr-kpi-top",children:[y.jsx("p",{className:"vertebr-metric-label",children:R.label}),R.series&&R.series.length>1?y.jsx(HQ,{series:R.series,tone:R.tone}):null]}),y.jsx("p",{className:"vertebr-kpi-value",children:R.value}),y.jsxs("div",{className:"vertebr-kpi-foot",children:[R.delta!=null?y.jsx(fM,{value:R.delta}):null,R.hint?y.jsx("span",{className:"vertebr-metric-hint",children:R.hint}):null]})]},R.id)})})}):null,i.length>0&&A?y.jsx("section",{className:"vertebr-metrics-block",children:y.jsx(WQ,{charts:i,chartId:A,onChartIdChange:C,compareLabel:n})}):null,g.length>0?y.jsx("section",{className:"vertebr-metrics-block",children:y.jsxs("div",{className:"vertebr-metrics-table-wrap","data-collapsed":b?void 0:"true",children:[y.jsxs("button",{type:"button",className:"vertebr-metrics-table-head","aria-expanded":b,onClick:()=>x(R=>!R),children:[y.jsx("p",{className:"vertebr-chart-kicker",children:"Breakdown"}),y.jsx("span",{className:"vertebr-metrics-chevron","aria-hidden":"true"})]}),b?y.jsxs("table",{className:"vertebr-table vertebr-metrics-table",children:[y.jsx("thead",{children:y.jsxs("tr",{children:[y.jsx("th",{children:"Metric"}),y.jsx("th",{children:"Value"}),y.jsx("th",{children:"Change"}),y.jsx("th",{children:"Notes"})]})}),y.jsx("tbody",{children:g.map(R=>y.jsxs("tr",{"data-tone":R.tone??"neutral",children:[y.jsxs("td",{children:[y.jsx("span",{className:"vertebr-metrics-table-label",children:R.label}),R.section?y.jsx("span",{className:"vertebr-metrics-table-section",children:R.section}):null]}),y.jsx("td",{className:"vertebr-metrics-table-value",children:R.value}),y.jsx("td",{children:y.jsx(fM,{value:R.delta})}),y.jsx("td",{className:"vertebr-metrics-table-notes",children:R.hint??"—"})]},R.id))})]}):null]})}):null]})]})}function _o(t,e){return typeof t=="function"?t(e):t}function Or(t,e){return n=>{e.setState(r=>({...r,[t]:_o(n,r[t])}))}}function Lg(t){return t instanceof Function}function eee(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}function tee(t,e){const n=[],r=i=>{i.forEach(s=>{n.push(s);const o=e(s);o!=null&&o.length&&r(o)})};return r(t),n}function Ye(t,e,n){let r=[],i;return s=>{let o;n.key&&n.debug&&(o=Date.now());const l=t(s);if(!(l.length!==r.length||l.some((h,m)=>r[m]!==h)))return i;r=l;let f;if(n.key&&n.debug&&(f=Date.now()),i=e(...l),n==null||n.onChange==null||n.onChange(i),n.key&&n.debug&&n!=null&&n.debug()){const h=Math.round((Date.now()-o)*100)/100,m=Math.round((Date.now()-f)*100)/100,g=m/16,b=(x,S)=>{for(x=String(x);x.length<S;)x=" "+x;return x};console.info(`%c⏱ ${b(m,5)} /${b(h,5)} ms`,`
|
|
327
|
+
font-size: .6rem;
|
|
328
|
+
font-weight: bold;
|
|
329
|
+
color: hsl(${Math.max(0,Math.min(120-120*g,120))}deg 100% 31%);`,n?.key)}return i}}function Xe(t,e,n,r){return{debug:()=>{var i;return(i=t?.debugAll)!=null?i:t[e]},key:!1,onChange:r}}function nee(t,e,n,r){const i=()=>{var o;return(o=s.getValue())!=null?o:t.options.renderFallbackValue},s={id:`${e.id}_${n.id}`,row:e,column:n,getValue:()=>e.getValue(r),renderValue:i,getContext:Ye(()=>[t,n,e,s],(o,l,u,f)=>({table:o,column:l,row:u,cell:f,getValue:f.getValue,renderValue:f.renderValue}),Xe(t.options,"debugCells"))};return t._features.forEach(o=>{o.createCell==null||o.createCell(s,n,e,t)},{}),s}function ree(t,e,n,r){var i,s;const l={...t._getDefaultColumnDef(),...e},u=l.accessorKey;let f=(i=(s=l.id)!=null?s:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?i:typeof l.header=="string"?l.header:void 0,h;if(l.accessorFn?h=l.accessorFn:u&&(u.includes(".")?h=g=>{let b=g;for(const S of u.split(".")){var x;b=(x=b)==null?void 0:x[S]}return b}:h=g=>g[l.accessorKey]),!f)throw new Error;let m={id:`${String(f)}`,accessorFn:h,parent:r,depth:n,columnDef:l,columns:[],getFlatColumns:Ye(()=>[!0],()=>{var g;return[m,...(g=m.columns)==null?void 0:g.flatMap(b=>b.getFlatColumns())]},Xe(t.options,"debugColumns")),getLeafColumns:Ye(()=>[t._getOrderColumnsFn()],g=>{var b;if((b=m.columns)!=null&&b.length){let x=m.columns.flatMap(S=>S.getLeafColumns());return g(x)}return[m]},Xe(t.options,"debugColumns"))};for(const g of t._features)g.createColumn==null||g.createColumn(m,t);return m}const Un="debugHeaders";function hM(t,e,n){var r;let s={id:(r=n.id)!=null?r:e.id,column:e,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:()=>{const o=[],l=u=>{u.subHeaders&&u.subHeaders.length&&u.subHeaders.map(l),o.push(u)};return l(s),o},getContext:()=>({table:t,header:s,column:e})};return t._features.forEach(o=>{o.createHeader==null||o.createHeader(s,t)}),s}const iee={createTable:t=>{t.getHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r,i)=>{var s,o;const l=(s=r?.map(m=>n.find(g=>g.id===m)).filter(Boolean))!=null?s:[],u=(o=i?.map(m=>n.find(g=>g.id===m)).filter(Boolean))!=null?o:[],f=n.filter(m=>!(r!=null&&r.includes(m.id))&&!(i!=null&&i.includes(m.id)));return Jh(e,[...l,...f,...u],t)},Xe(t.options,Un)),t.getCenterHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r,i)=>(n=n.filter(s=>!(r!=null&&r.includes(s.id))&&!(i!=null&&i.includes(s.id))),Jh(e,n,t,"center")),Xe(t.options,Un)),t.getLeftHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left],(e,n,r)=>{var i;const s=(i=r?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?i:[];return Jh(e,s,t,"left")},Xe(t.options,Un)),t.getRightHeaderGroups=Ye(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right],(e,n,r)=>{var i;const s=(i=r?.map(o=>n.find(l=>l.id===o)).filter(Boolean))!=null?i:[];return Jh(e,s,t,"right")},Xe(t.options,Un)),t.getFooterGroups=Ye(()=>[t.getHeaderGroups()],e=>[...e].reverse(),Xe(t.options,Un)),t.getLeftFooterGroups=Ye(()=>[t.getLeftHeaderGroups()],e=>[...e].reverse(),Xe(t.options,Un)),t.getCenterFooterGroups=Ye(()=>[t.getCenterHeaderGroups()],e=>[...e].reverse(),Xe(t.options,Un)),t.getRightFooterGroups=Ye(()=>[t.getRightHeaderGroups()],e=>[...e].reverse(),Xe(t.options,Un)),t.getFlatHeaders=Ye(()=>[t.getHeaderGroups()],e=>e.map(n=>n.headers).flat(),Xe(t.options,Un)),t.getLeftFlatHeaders=Ye(()=>[t.getLeftHeaderGroups()],e=>e.map(n=>n.headers).flat(),Xe(t.options,Un)),t.getCenterFlatHeaders=Ye(()=>[t.getCenterHeaderGroups()],e=>e.map(n=>n.headers).flat(),Xe(t.options,Un)),t.getRightFlatHeaders=Ye(()=>[t.getRightHeaderGroups()],e=>e.map(n=>n.headers).flat(),Xe(t.options,Un)),t.getCenterLeafHeaders=Ye(()=>[t.getCenterFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Xe(t.options,Un)),t.getLeftLeafHeaders=Ye(()=>[t.getLeftFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Xe(t.options,Un)),t.getRightLeafHeaders=Ye(()=>[t.getRightFlatHeaders()],e=>e.filter(n=>{var r;return!((r=n.subHeaders)!=null&&r.length)}),Xe(t.options,Un)),t.getLeafHeaders=Ye(()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()],(e,n,r)=>{var i,s,o,l,u,f;return[...(i=(s=e[0])==null?void 0:s.headers)!=null?i:[],...(o=(l=n[0])==null?void 0:l.headers)!=null?o:[],...(u=(f=r[0])==null?void 0:f.headers)!=null?u:[]].map(h=>h.getLeafHeaders()).flat()},Xe(t.options,Un))}};function Jh(t,e,n,r){var i,s;let o=0;const l=function(g,b){b===void 0&&(b=1),o=Math.max(o,b),g.filter(x=>x.getIsVisible()).forEach(x=>{var S;(S=x.columns)!=null&&S.length&&l(x.columns,b+1)},0)};l(t);let u=[];const f=(g,b)=>{const x={depth:b,id:[r,`${b}`].filter(Boolean).join("_"),headers:[]},S=[];g.forEach(k=>{const C=[...S].reverse()[0],A=k.column.depth===x.depth;let R,_=!1;if(A&&k.column.parent?R=k.column.parent:(R=k.column,_=!0),C&&C?.column===R)C.subHeaders.push(k);else{const M=hM(n,R,{id:[r,b,R.id,k?.id].filter(Boolean).join("_"),isPlaceholder:_,placeholderId:_?`${S.filter(O=>O.column===R).length}`:void 0,depth:b,index:S.length});M.subHeaders.push(k),S.push(M)}x.headers.push(k),k.headerGroup=x}),u.push(x),b>0&&f(S,b-1)},h=e.map((g,b)=>hM(n,g,{depth:o,index:b}));f(h,o-1),u.reverse();const m=g=>g.filter(x=>x.column.getIsVisible()).map(x=>{let S=0,k=0,C=[0];x.subHeaders&&x.subHeaders.length?(C=[],m(x.subHeaders).forEach(R=>{let{colSpan:_,rowSpan:M}=R;S+=_,C.push(M)})):S=1;const A=Math.min(...C);return k=k+A,x.colSpan=S,x.rowSpan=k,{colSpan:S,rowSpan:k}});return m((i=(s=u[0])==null?void 0:s.headers)!=null?i:[]),u}const see=(t,e,n,r,i,s,o)=>{let l={id:e,index:r,original:n,depth:i,parentId:o,_valuesCache:{},_uniqueValuesCache:{},getValue:u=>{if(l._valuesCache.hasOwnProperty(u))return l._valuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return l._valuesCache[u]=f.accessorFn(l.original,r),l._valuesCache[u]},getUniqueValues:u=>{if(l._uniqueValuesCache.hasOwnProperty(u))return l._uniqueValuesCache[u];const f=t.getColumn(u);if(f!=null&&f.accessorFn)return f.columnDef.getUniqueValues?(l._uniqueValuesCache[u]=f.columnDef.getUniqueValues(l.original,r),l._uniqueValuesCache[u]):(l._uniqueValuesCache[u]=[l.getValue(u)],l._uniqueValuesCache[u])},renderValue:u=>{var f;return(f=l.getValue(u))!=null?f:t.options.renderFallbackValue},subRows:[],getLeafRows:()=>tee(l.subRows,u=>u.subRows),getParentRow:()=>l.parentId?t.getRow(l.parentId,!0):void 0,getParentRows:()=>{let u=[],f=l;for(;;){const h=f.getParentRow();if(!h)break;u.push(h),f=h}return u.reverse()},getAllCells:Ye(()=>[t.getAllLeafColumns()],u=>u.map(f=>nee(t,l,f,f.id)),Xe(t.options,"debugRows")),_getAllCellsByColumnId:Ye(()=>[l.getAllCells()],u=>u.reduce((f,h)=>(f[h.column.id]=h,f),{}),Xe(t.options,"debugRows"))};for(let u=0;u<t._features.length;u++){const f=t._features[u];f==null||f.createRow==null||f.createRow(l,t)}return l},oee={createColumn:(t,e)=>{t._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,t.id),t.getFacetedRowModel=()=>t._getFacetedRowModel?t._getFacetedRowModel():e.getPreFilteredRowModel(),t._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,t.id),t.getFacetedUniqueValues=()=>t._getFacetedUniqueValues?t._getFacetedUniqueValues():new Map,t._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,t.id),t.getFacetedMinMaxValues=()=>{if(t._getFacetedMinMaxValues)return t._getFacetedMinMaxValues()}}},o2=(t,e,n)=>{var r,i;const s=n==null||(r=n.toString())==null?void 0:r.toLowerCase();return!!(!((i=t.getValue(e))==null||(i=i.toString())==null||(i=i.toLowerCase())==null)&&i.includes(s))};o2.autoRemove=t=>yi(t);const a2=(t,e,n)=>{var r;return!!(!((r=t.getValue(e))==null||(r=r.toString())==null)&&r.includes(n))};a2.autoRemove=t=>yi(t);const l2=(t,e,n)=>{var r;return((r=t.getValue(e))==null||(r=r.toString())==null?void 0:r.toLowerCase())===n?.toLowerCase()};l2.autoRemove=t=>yi(t);const c2=(t,e,n)=>{var r;return(r=t.getValue(e))==null?void 0:r.includes(n)};c2.autoRemove=t=>yi(t);const u2=(t,e,n)=>!n.some(r=>{var i;return!((i=t.getValue(e))!=null&&i.includes(r))});u2.autoRemove=t=>yi(t)||!(t!=null&&t.length);const d2=(t,e,n)=>n.some(r=>{var i;return(i=t.getValue(e))==null?void 0:i.includes(r)});d2.autoRemove=t=>yi(t)||!(t!=null&&t.length);const f2=(t,e,n)=>t.getValue(e)===n;f2.autoRemove=t=>yi(t);const h2=(t,e,n)=>t.getValue(e)==n;h2.autoRemove=t=>yi(t);const nk=(t,e,n)=>{let[r,i]=n;const s=t.getValue(e);return s>=r&&s<=i};nk.resolveFilterValue=t=>{let[e,n]=t,r=typeof e!="number"?parseFloat(e):e,i=typeof n!="number"?parseFloat(n):n,s=e===null||Number.isNaN(r)?-1/0:r,o=n===null||Number.isNaN(i)?1/0:i;if(s>o){const l=s;s=o,o=l}return[s,o]};nk.autoRemove=t=>yi(t)||yi(t[0])&&yi(t[1]);const ms={includesString:o2,includesStringSensitive:a2,equalsString:l2,arrIncludes:c2,arrIncludesAll:u2,arrIncludesSome:d2,equals:f2,weakEquals:h2,inNumberRange:nk};function yi(t){return t==null||t===""}const aee={getDefaultColumnDef:()=>({filterFn:"auto"}),getInitialState:t=>({columnFilters:[],...t}),getDefaultOptions:t=>({onColumnFiltersChange:Or("columnFilters",t),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),createColumn:(t,e)=>{t.getAutoFilterFn=()=>{const n=e.getCoreRowModel().flatRows[0],r=n?.getValue(t.id);return typeof r=="string"?ms.includesString:typeof r=="number"?ms.inNumberRange:typeof r=="boolean"||r!==null&&typeof r=="object"?ms.equals:Array.isArray(r)?ms.arrIncludes:ms.weakEquals},t.getFilterFn=()=>{var n,r;return Lg(t.columnDef.filterFn)?t.columnDef.filterFn:t.columnDef.filterFn==="auto"?t.getAutoFilterFn():(n=(r=e.options.filterFns)==null?void 0:r[t.columnDef.filterFn])!=null?n:ms[t.columnDef.filterFn]},t.getCanFilter=()=>{var n,r,i;return((n=t.columnDef.enableColumnFilter)!=null?n:!0)&&((r=e.options.enableColumnFilters)!=null?r:!0)&&((i=e.options.enableFilters)!=null?i:!0)&&!!t.accessorFn},t.getIsFiltered=()=>t.getFilterIndex()>-1,t.getFilterValue=()=>{var n;return(n=e.getState().columnFilters)==null||(n=n.find(r=>r.id===t.id))==null?void 0:n.value},t.getFilterIndex=()=>{var n,r;return(n=(r=e.getState().columnFilters)==null?void 0:r.findIndex(i=>i.id===t.id))!=null?n:-1},t.setFilterValue=n=>{e.setColumnFilters(r=>{const i=t.getFilterFn(),s=r?.find(h=>h.id===t.id),o=_o(n,s?s.value:void 0);if(pM(i,o,t)){var l;return(l=r?.filter(h=>h.id!==t.id))!=null?l:[]}const u={id:t.id,value:o};if(s){var f;return(f=r?.map(h=>h.id===t.id?u:h))!=null?f:[]}return r!=null&&r.length?[...r,u]:[u]})}},createRow:(t,e)=>{t.columnFilters={},t.columnFiltersMeta={}},createTable:t=>{t.setColumnFilters=e=>{const n=t.getAllLeafColumns(),r=i=>{var s;return(s=_o(e,i))==null?void 0:s.filter(o=>{const l=n.find(u=>u.id===o.id);if(l){const u=l.getFilterFn();if(pM(u,o.value,l))return!1}return!0})};t.options.onColumnFiltersChange==null||t.options.onColumnFiltersChange(r)},t.resetColumnFilters=e=>{var n,r;t.setColumnFilters(e?[]:(n=(r=t.initialState)==null?void 0:r.columnFilters)!=null?n:[])},t.getPreFilteredRowModel=()=>t.getCoreRowModel(),t.getFilteredRowModel=()=>(!t._getFilteredRowModel&&t.options.getFilteredRowModel&&(t._getFilteredRowModel=t.options.getFilteredRowModel(t)),t.options.manualFiltering||!t._getFilteredRowModel?t.getPreFilteredRowModel():t._getFilteredRowModel())}};function pM(t,e,n){return(t&&t.autoRemove?t.autoRemove(e,n):!1)||typeof e>"u"||typeof e=="string"&&!e}const lee=(t,e,n)=>n.reduce((r,i)=>{const s=i.getValue(t);return r+(typeof s=="number"?s:0)},0),cee=(t,e,n)=>{let r;return n.forEach(i=>{const s=i.getValue(t);s!=null&&(r>s||r===void 0&&s>=s)&&(r=s)}),r},uee=(t,e,n)=>{let r;return n.forEach(i=>{const s=i.getValue(t);s!=null&&(r<s||r===void 0&&s>=s)&&(r=s)}),r},dee=(t,e,n)=>{let r,i;return n.forEach(s=>{const o=s.getValue(t);o!=null&&(r===void 0?o>=o&&(r=i=o):(r>o&&(r=o),i<o&&(i=o)))}),[r,i]},fee=(t,e)=>{let n=0,r=0;if(e.forEach(i=>{let s=i.getValue(t);s!=null&&(s=+s)>=s&&(++n,r+=s)}),n)return r/n},hee=(t,e)=>{if(!e.length)return;const n=e.map(s=>s.getValue(t));if(!eee(n))return;if(n.length===1)return n[0];const r=Math.floor(n.length/2),i=n.sort((s,o)=>s-o);return n.length%2!==0?i[r]:(i[r-1]+i[r])/2},pee=(t,e)=>Array.from(new Set(e.map(n=>n.getValue(t))).values()),mee=(t,e)=>new Set(e.map(n=>n.getValue(t))).size,gee=(t,e)=>e.length,a0={sum:lee,min:cee,max:uee,extent:dee,mean:fee,median:hee,unique:pee,uniqueCount:mee,count:gee},yee={getDefaultColumnDef:()=>({aggregatedCell:t=>{var e,n;return(e=(n=t.getValue())==null||n.toString==null?void 0:n.toString())!=null?e:null},aggregationFn:"auto"}),getInitialState:t=>({grouping:[],...t}),getDefaultOptions:t=>({onGroupingChange:Or("grouping",t),groupedColumnMode:"reorder"}),createColumn:(t,e)=>{t.toggleGrouping=()=>{e.setGrouping(n=>n!=null&&n.includes(t.id)?n.filter(r=>r!==t.id):[...n??[],t.id])},t.getCanGroup=()=>{var n,r;return((n=t.columnDef.enableGrouping)!=null?n:!0)&&((r=e.options.enableGrouping)!=null?r:!0)&&(!!t.accessorFn||!!t.columnDef.getGroupingValue)},t.getIsGrouped=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.includes(t.id)},t.getGroupedIndex=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.indexOf(t.id)},t.getToggleGroupingHandler=()=>{const n=t.getCanGroup();return()=>{n&&t.toggleGrouping()}},t.getAutoAggregationFn=()=>{const n=e.getCoreRowModel().flatRows[0],r=n?.getValue(t.id);if(typeof r=="number")return a0.sum;if(Object.prototype.toString.call(r)==="[object Date]")return a0.extent},t.getAggregationFn=()=>{var n,r;if(!t)throw new Error;return Lg(t.columnDef.aggregationFn)?t.columnDef.aggregationFn:t.columnDef.aggregationFn==="auto"?t.getAutoAggregationFn():(n=(r=e.options.aggregationFns)==null?void 0:r[t.columnDef.aggregationFn])!=null?n:a0[t.columnDef.aggregationFn]}},createTable:t=>{t.setGrouping=e=>t.options.onGroupingChange==null?void 0:t.options.onGroupingChange(e),t.resetGrouping=e=>{var n,r;t.setGrouping(e?[]:(n=(r=t.initialState)==null?void 0:r.grouping)!=null?n:[])},t.getPreGroupedRowModel=()=>t.getFilteredRowModel(),t.getGroupedRowModel=()=>(!t._getGroupedRowModel&&t.options.getGroupedRowModel&&(t._getGroupedRowModel=t.options.getGroupedRowModel(t)),t.options.manualGrouping||!t._getGroupedRowModel?t.getPreGroupedRowModel():t._getGroupedRowModel())},createRow:(t,e)=>{t.getIsGrouped=()=>!!t.groupingColumnId,t.getGroupingValue=n=>{if(t._groupingValuesCache.hasOwnProperty(n))return t._groupingValuesCache[n];const r=e.getColumn(n);return r!=null&&r.columnDef.getGroupingValue?(t._groupingValuesCache[n]=r.columnDef.getGroupingValue(t.original),t._groupingValuesCache[n]):t.getValue(n)},t._groupingValuesCache={}},createCell:(t,e,n,r)=>{t.getIsGrouped=()=>e.getIsGrouped()&&e.id===n.groupingColumnId,t.getIsPlaceholder=()=>!t.getIsGrouped()&&e.getIsGrouped(),t.getIsAggregated=()=>{var i;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!!((i=n.subRows)!=null&&i.length)}}};function bee(t,e,n){if(!(e!=null&&e.length)||!n)return t;const r=t.filter(s=>!e.includes(s.id));return n==="remove"?r:[...e.map(s=>t.find(o=>o.id===s)).filter(Boolean),...r]}const vee={getInitialState:t=>({columnOrder:[],...t}),getDefaultOptions:t=>({onColumnOrderChange:Or("columnOrder",t)}),createColumn:(t,e)=>{t.getIndex=Ye(n=>[bd(e,n)],n=>n.findIndex(r=>r.id===t.id),Xe(e.options,"debugColumns")),t.getIsFirstColumn=n=>{var r;return((r=bd(e,n)[0])==null?void 0:r.id)===t.id},t.getIsLastColumn=n=>{var r;const i=bd(e,n);return((r=i[i.length-1])==null?void 0:r.id)===t.id}},createTable:t=>{t.setColumnOrder=e=>t.options.onColumnOrderChange==null?void 0:t.options.onColumnOrderChange(e),t.resetColumnOrder=e=>{var n;t.setColumnOrder(e?[]:(n=t.initialState.columnOrder)!=null?n:[])},t._getOrderColumnsFn=Ye(()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode],(e,n,r)=>i=>{let s=[];if(!(e!=null&&e.length))s=i;else{const o=[...e],l=[...i];for(;l.length&&o.length;){const u=o.shift(),f=l.findIndex(h=>h.id===u);f>-1&&s.push(l.splice(f,1)[0])}s=[...s,...l]}return bee(s,n,r)},Xe(t.options,"debugTable"))}},l0=()=>({left:[],right:[]}),xee={getInitialState:t=>({columnPinning:l0(),...t}),getDefaultOptions:t=>({onColumnPinningChange:Or("columnPinning",t)}),createColumn:(t,e)=>{t.pin=n=>{const r=t.getLeafColumns().map(i=>i.id).filter(Boolean);e.setColumnPinning(i=>{var s,o;if(n==="right"){var l,u;return{left:((l=i?.left)!=null?l:[]).filter(m=>!(r!=null&&r.includes(m))),right:[...((u=i?.right)!=null?u:[]).filter(m=>!(r!=null&&r.includes(m))),...r]}}if(n==="left"){var f,h;return{left:[...((f=i?.left)!=null?f:[]).filter(m=>!(r!=null&&r.includes(m))),...r],right:((h=i?.right)!=null?h:[]).filter(m=>!(r!=null&&r.includes(m)))}}return{left:((s=i?.left)!=null?s:[]).filter(m=>!(r!=null&&r.includes(m))),right:((o=i?.right)!=null?o:[]).filter(m=>!(r!=null&&r.includes(m)))}})},t.getCanPin=()=>t.getLeafColumns().some(r=>{var i,s,o;return((i=r.columnDef.enablePinning)!=null?i:!0)&&((s=(o=e.options.enableColumnPinning)!=null?o:e.options.enablePinning)!=null?s:!0)}),t.getIsPinned=()=>{const n=t.getLeafColumns().map(l=>l.id),{left:r,right:i}=e.getState().columnPinning,s=n.some(l=>r?.includes(l)),o=n.some(l=>i?.includes(l));return s?"left":o?"right":!1},t.getPinnedIndex=()=>{var n,r;const i=t.getIsPinned();return i?(n=(r=e.getState().columnPinning)==null||(r=r[i])==null?void 0:r.indexOf(t.id))!=null?n:-1:0}},createRow:(t,e)=>{t.getCenterVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,r,i)=>{const s=[...r??[],...i??[]];return n.filter(o=>!s.includes(o.column.id))},Xe(e.options,"debugRows")),t.getLeftVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left],(n,r)=>(r??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"left"})),Xe(e.options,"debugRows")),t.getRightVisibleCells=Ye(()=>[t._getAllVisibleCells(),e.getState().columnPinning.right],(n,r)=>(r??[]).map(s=>n.find(o=>o.column.id===s)).filter(Boolean).map(s=>({...s,position:"right"})),Xe(e.options,"debugRows"))},createTable:t=>{t.setColumnPinning=e=>t.options.onColumnPinningChange==null?void 0:t.options.onColumnPinningChange(e),t.resetColumnPinning=e=>{var n,r;return t.setColumnPinning(e?l0():(n=(r=t.initialState)==null?void 0:r.columnPinning)!=null?n:l0())},t.getIsSomeColumnsPinned=e=>{var n;const r=t.getState().columnPinning;if(!e){var i,s;return!!((i=r.left)!=null&&i.length||(s=r.right)!=null&&s.length)}return!!((n=r[e])!=null&&n.length)},t.getLeftLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left],(e,n)=>(n??[]).map(r=>e.find(i=>i.id===r)).filter(Boolean),Xe(t.options,"debugColumns")),t.getRightLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.right],(e,n)=>(n??[]).map(r=>e.find(i=>i.id===r)).filter(Boolean),Xe(t.options,"debugColumns")),t.getCenterLeafColumns=Ye(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,r)=>{const i=[...n??[],...r??[]];return e.filter(s=>!i.includes(s.id))},Xe(t.options,"debugColumns"))}};function wee(t){return t||(typeof document<"u"?document:null)}const Qh={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},c0=()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),See={getDefaultColumnDef:()=>Qh,getInitialState:t=>({columnSizing:{},columnSizingInfo:c0(),...t}),getDefaultOptions:t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:Or("columnSizing",t),onColumnSizingInfoChange:Or("columnSizingInfo",t)}),createColumn:(t,e)=>{t.getSize=()=>{var n,r,i;const s=e.getState().columnSizing[t.id];return Math.min(Math.max((n=t.columnDef.minSize)!=null?n:Qh.minSize,(r=s??t.columnDef.size)!=null?r:Qh.size),(i=t.columnDef.maxSize)!=null?i:Qh.maxSize)},t.getStart=Ye(n=>[n,bd(e,n),e.getState().columnSizing],(n,r)=>r.slice(0,t.getIndex(n)).reduce((i,s)=>i+s.getSize(),0),Xe(e.options,"debugColumns")),t.getAfter=Ye(n=>[n,bd(e,n),e.getState().columnSizing],(n,r)=>r.slice(t.getIndex(n)+1).reduce((i,s)=>i+s.getSize(),0),Xe(e.options,"debugColumns")),t.resetSize=()=>{e.setColumnSizing(n=>{let{[t.id]:r,...i}=n;return i})},t.getCanResize=()=>{var n,r;return((n=t.columnDef.enableResizing)!=null?n:!0)&&((r=e.options.enableColumnResizing)!=null?r:!0)},t.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===t.id},createHeader:(t,e)=>{t.getSize=()=>{let n=0;const r=i=>{if(i.subHeaders.length)i.subHeaders.forEach(r);else{var s;n+=(s=i.column.getSize())!=null?s:0}};return r(t),n},t.getStart=()=>{if(t.index>0){const n=t.headerGroup.headers[t.index-1];return n.getStart()+n.getSize()}return 0},t.getResizeHandler=n=>{const r=e.getColumn(t.column.id),i=r?.getCanResize();return s=>{if(!r||!i||(s.persist==null||s.persist(),u0(s)&&s.touches&&s.touches.length>1))return;const o=t.getSize(),l=t?t.getLeafHeaders().map(C=>[C.column.id,C.column.getSize()]):[[r.id,r.getSize()]],u=u0(s)?Math.round(s.touches[0].clientX):s.clientX,f={},h=(C,A)=>{typeof A=="number"&&(e.setColumnSizingInfo(R=>{var _,M;const O=e.options.columnResizeDirection==="rtl"?-1:1,D=(A-((_=R?.startOffset)!=null?_:0))*O,I=Math.max(D/((M=R?.startSize)!=null?M:0),-.999999);return R.columnSizingStart.forEach(P=>{let[B,re]=P;f[B]=Math.round(Math.max(re+re*I,0)*100)/100}),{...R,deltaOffset:D,deltaPercentage:I}}),(e.options.columnResizeMode==="onChange"||C==="end")&&e.setColumnSizing(R=>({...R,...f})))},m=C=>h("move",C),g=C=>{h("end",C),e.setColumnSizingInfo(A=>({...A,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},b=wee(n),x={moveHandler:C=>m(C.clientX),upHandler:C=>{b?.removeEventListener("mousemove",x.moveHandler),b?.removeEventListener("mouseup",x.upHandler),g(C.clientX)}},S={moveHandler:C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),m(C.touches[0].clientX),!1),upHandler:C=>{var A;b?.removeEventListener("touchmove",S.moveHandler),b?.removeEventListener("touchend",S.upHandler),C.cancelable&&(C.preventDefault(),C.stopPropagation()),g((A=C.touches[0])==null?void 0:A.clientX)}},k=kee()?{passive:!1}:!1;u0(s)?(b?.addEventListener("touchmove",S.moveHandler,k),b?.addEventListener("touchend",S.upHandler,k)):(b?.addEventListener("mousemove",x.moveHandler,k),b?.addEventListener("mouseup",x.upHandler,k)),e.setColumnSizingInfo(C=>({...C,startOffset:u,startSize:o,deltaOffset:0,deltaPercentage:0,columnSizingStart:l,isResizingColumn:r.id}))}}},createTable:t=>{t.setColumnSizing=e=>t.options.onColumnSizingChange==null?void 0:t.options.onColumnSizingChange(e),t.setColumnSizingInfo=e=>t.options.onColumnSizingInfoChange==null?void 0:t.options.onColumnSizingInfoChange(e),t.resetColumnSizing=e=>{var n;t.setColumnSizing(e?{}:(n=t.initialState.columnSizing)!=null?n:{})},t.resetHeaderSizeInfo=e=>{var n;t.setColumnSizingInfo(e?c0():(n=t.initialState.columnSizingInfo)!=null?n:c0())},t.getTotalSize=()=>{var e,n;return(e=(n=t.getHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?e:0},t.getLeftTotalSize=()=>{var e,n;return(e=(n=t.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?e:0},t.getCenterTotalSize=()=>{var e,n;return(e=(n=t.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?e:0},t.getRightTotalSize=()=>{var e,n;return(e=(n=t.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((r,i)=>r+i.getSize(),0))!=null?e:0}}};let ep=null;function kee(){if(typeof ep=="boolean")return ep;let t=!1;try{const e={get passive(){return t=!0,!1}},n=()=>{};window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return ep=t,ep}function u0(t){return t.type==="touchstart"}const Cee={getInitialState:t=>({columnVisibility:{},...t}),getDefaultOptions:t=>({onColumnVisibilityChange:Or("columnVisibility",t)}),createColumn:(t,e)=>{t.toggleVisibility=n=>{t.getCanHide()&&e.setColumnVisibility(r=>({...r,[t.id]:n??!t.getIsVisible()}))},t.getIsVisible=()=>{var n,r;const i=t.columns;return(n=i.length?i.some(s=>s.getIsVisible()):(r=e.getState().columnVisibility)==null?void 0:r[t.id])!=null?n:!0},t.getCanHide=()=>{var n,r;return((n=t.columnDef.enableHiding)!=null?n:!0)&&((r=e.options.enableHiding)!=null?r:!0)},t.getToggleVisibilityHandler=()=>n=>{t.toggleVisibility==null||t.toggleVisibility(n.target.checked)}},createRow:(t,e)=>{t._getAllVisibleCells=Ye(()=>[t.getAllCells(),e.getState().columnVisibility],n=>n.filter(r=>r.column.getIsVisible()),Xe(e.options,"debugRows")),t.getVisibleCells=Ye(()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()],(n,r,i)=>[...n,...r,...i],Xe(e.options,"debugRows"))},createTable:t=>{const e=(n,r)=>Ye(()=>[r(),r().filter(i=>i.getIsVisible()).map(i=>i.id).join("_")],i=>i.filter(s=>s.getIsVisible==null?void 0:s.getIsVisible()),Xe(t.options,"debugColumns"));t.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>t.getAllFlatColumns()),t.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>t.getAllLeafColumns()),t.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>t.getLeftLeafColumns()),t.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>t.getRightLeafColumns()),t.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>t.getCenterLeafColumns()),t.setColumnVisibility=n=>t.options.onColumnVisibilityChange==null?void 0:t.options.onColumnVisibilityChange(n),t.resetColumnVisibility=n=>{var r;t.setColumnVisibility(n?{}:(r=t.initialState.columnVisibility)!=null?r:{})},t.toggleAllColumnsVisible=n=>{var r;n=(r=n)!=null?r:!t.getIsAllColumnsVisible(),t.setColumnVisibility(t.getAllLeafColumns().reduce((i,s)=>({...i,[s.id]:n||!(s.getCanHide!=null&&s.getCanHide())}),{}))},t.getIsAllColumnsVisible=()=>!t.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),t.getIsSomeColumnsVisible=()=>t.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),t.getToggleAllColumnsVisibilityHandler=()=>n=>{var r;t.toggleAllColumnsVisible((r=n.target)==null?void 0:r.checked)}}};function bd(t,e){return e?e==="center"?t.getCenterVisibleLeafColumns():e==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}const Eee={createTable:t=>{t._getGlobalFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,"__global__"),t.getGlobalFacetedRowModel=()=>t.options.manualFiltering||!t._getGlobalFacetedRowModel?t.getPreFilteredRowModel():t._getGlobalFacetedRowModel(),t._getGlobalFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,"__global__"),t.getGlobalFacetedUniqueValues=()=>t._getGlobalFacetedUniqueValues?t._getGlobalFacetedUniqueValues():new Map,t._getGlobalFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,"__global__"),t.getGlobalFacetedMinMaxValues=()=>{if(t._getGlobalFacetedMinMaxValues)return t._getGlobalFacetedMinMaxValues()}}},Tee={getInitialState:t=>({globalFilter:void 0,...t}),getDefaultOptions:t=>({onGlobalFilterChange:Or("globalFilter",t),globalFilterFn:"auto",getColumnCanGlobalFilter:e=>{var n;const r=(n=t.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[e.id])==null?void 0:n.getValue();return typeof r=="string"||typeof r=="number"}}),createColumn:(t,e)=>{t.getCanGlobalFilter=()=>{var n,r,i,s;return((n=t.columnDef.enableGlobalFilter)!=null?n:!0)&&((r=e.options.enableGlobalFilter)!=null?r:!0)&&((i=e.options.enableFilters)!=null?i:!0)&&((s=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(t))!=null?s:!0)&&!!t.accessorFn}},createTable:t=>{t.getGlobalAutoFilterFn=()=>ms.includesString,t.getGlobalFilterFn=()=>{var e,n;const{globalFilterFn:r}=t.options;return Lg(r)?r:r==="auto"?t.getGlobalAutoFilterFn():(e=(n=t.options.filterFns)==null?void 0:n[r])!=null?e:ms[r]},t.setGlobalFilter=e=>{t.options.onGlobalFilterChange==null||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}}},_ee={getInitialState:t=>({expanded:{},...t}),getDefaultOptions:t=>({onExpandedChange:Or("expanded",t),paginateExpandedRows:!0}),createTable:t=>{let e=!1,n=!1;t._autoResetExpanded=()=>{var r,i;if(!e){t._queue(()=>{e=!0});return}if((r=(i=t.options.autoResetAll)!=null?i:t.options.autoResetExpanded)!=null?r:!t.options.manualExpanding){if(n)return;n=!0,t._queue(()=>{t.resetExpanded(),n=!1})}},t.setExpanded=r=>t.options.onExpandedChange==null?void 0:t.options.onExpandedChange(r),t.toggleAllRowsExpanded=r=>{r??!t.getIsAllRowsExpanded()?t.setExpanded(!0):t.setExpanded({})},t.resetExpanded=r=>{var i,s;t.setExpanded(r?{}:(i=(s=t.initialState)==null?void 0:s.expanded)!=null?i:{})},t.getCanSomeRowsExpand=()=>t.getPrePaginationRowModel().flatRows.some(r=>r.getCanExpand()),t.getToggleAllRowsExpandedHandler=()=>r=>{r.persist==null||r.persist(),t.toggleAllRowsExpanded()},t.getIsSomeRowsExpanded=()=>{const r=t.getState().expanded;return r===!0||Object.values(r).some(Boolean)},t.getIsAllRowsExpanded=()=>{const r=t.getState().expanded;return typeof r=="boolean"?r===!0:!(!Object.keys(r).length||t.getRowModel().flatRows.some(i=>!i.getIsExpanded()))},t.getExpandedDepth=()=>{let r=0;return(t.getState().expanded===!0?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach(s=>{const o=s.split(".");r=Math.max(r,o.length)}),r},t.getPreExpandedRowModel=()=>t.getSortedRowModel(),t.getExpandedRowModel=()=>(!t._getExpandedRowModel&&t.options.getExpandedRowModel&&(t._getExpandedRowModel=t.options.getExpandedRowModel(t)),t.options.manualExpanding||!t._getExpandedRowModel?t.getPreExpandedRowModel():t._getExpandedRowModel())},createRow:(t,e)=>{t.toggleExpanded=n=>{e.setExpanded(r=>{var i;const s=r===!0?!0:!!(r!=null&&r[t.id]);let o={};if(r===!0?Object.keys(e.getRowModel().rowsById).forEach(l=>{o[l]=!0}):o=r,n=(i=n)!=null?i:!s,!s&&n)return{...o,[t.id]:!0};if(s&&!n){const{[t.id]:l,...u}=o;return u}return r})},t.getIsExpanded=()=>{var n;const r=e.getState().expanded;return!!((n=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(t))!=null?n:r===!0||r?.[t.id])},t.getCanExpand=()=>{var n,r,i;return(n=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(t))!=null?n:((r=e.options.enableExpanding)!=null?r:!0)&&!!((i=t.subRows)!=null&&i.length)},t.getIsAllParentsExpanded=()=>{let n=!0,r=t;for(;n&&r.parentId;)r=e.getRow(r.parentId,!0),n=r.getIsExpanded();return n},t.getToggleExpandedHandler=()=>{const n=t.getCanExpand();return()=>{n&&t.toggleExpanded()}}}},Kx=0,Zx=10,d0=()=>({pageIndex:Kx,pageSize:Zx}),Aee={getInitialState:t=>({...t,pagination:{...d0(),...t?.pagination}}),getDefaultOptions:t=>({onPaginationChange:Or("pagination",t)}),createTable:t=>{let e=!1,n=!1;t._autoResetPageIndex=()=>{var r,i;if(!e){t._queue(()=>{e=!0});return}if((r=(i=t.options.autoResetAll)!=null?i:t.options.autoResetPageIndex)!=null?r:!t.options.manualPagination){if(n)return;n=!0,t._queue(()=>{t.resetPageIndex(),n=!1})}},t.setPagination=r=>{const i=s=>_o(r,s);return t.options.onPaginationChange==null?void 0:t.options.onPaginationChange(i)},t.resetPagination=r=>{var i;t.setPagination(r?d0():(i=t.initialState.pagination)!=null?i:d0())},t.setPageIndex=r=>{t.setPagination(i=>{let s=_o(r,i.pageIndex);const o=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return s=Math.max(0,Math.min(s,o)),{...i,pageIndex:s}})},t.resetPageIndex=r=>{var i,s;t.setPageIndex(r?Kx:(i=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageIndex)!=null?i:Kx)},t.resetPageSize=r=>{var i,s;t.setPageSize(r?Zx:(i=(s=t.initialState)==null||(s=s.pagination)==null?void 0:s.pageSize)!=null?i:Zx)},t.setPageSize=r=>{t.setPagination(i=>{const s=Math.max(1,_o(r,i.pageSize)),o=i.pageSize*i.pageIndex,l=Math.floor(o/s);return{...i,pageIndex:l,pageSize:s}})},t.setPageCount=r=>t.setPagination(i=>{var s;let o=_o(r,(s=t.options.pageCount)!=null?s:-1);return typeof o=="number"&&(o=Math.max(-1,o)),{...i,pageCount:o}}),t.getPageOptions=Ye(()=>[t.getPageCount()],r=>{let i=[];return r&&r>0&&(i=[...new Array(r)].fill(null).map((s,o)=>o)),i},Xe(t.options,"debugTable")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{const{pageIndex:r}=t.getState().pagination,i=t.getPageCount();return i===-1?!0:i===0?!1:r<i-1},t.previousPage=()=>t.setPageIndex(r=>r-1),t.nextPage=()=>t.setPageIndex(r=>r+1),t.firstPage=()=>t.setPageIndex(0),t.lastPage=()=>t.setPageIndex(t.getPageCount()-1),t.getPrePaginationRowModel=()=>t.getExpandedRowModel(),t.getPaginationRowModel=()=>(!t._getPaginationRowModel&&t.options.getPaginationRowModel&&(t._getPaginationRowModel=t.options.getPaginationRowModel(t)),t.options.manualPagination||!t._getPaginationRowModel?t.getPrePaginationRowModel():t._getPaginationRowModel()),t.getPageCount=()=>{var r;return(r=t.options.pageCount)!=null?r:Math.ceil(t.getRowCount()/t.getState().pagination.pageSize)},t.getRowCount=()=>{var r;return(r=t.options.rowCount)!=null?r:t.getPrePaginationRowModel().rows.length}}},f0=()=>({top:[],bottom:[]}),Ree={getInitialState:t=>({rowPinning:f0(),...t}),getDefaultOptions:t=>({onRowPinningChange:Or("rowPinning",t)}),createRow:(t,e)=>{t.pin=(n,r,i)=>{const s=r?t.getLeafRows().map(u=>{let{id:f}=u;return f}):[],o=i?t.getParentRows().map(u=>{let{id:f}=u;return f}):[],l=new Set([...o,t.id,...s]);e.setRowPinning(u=>{var f,h;if(n==="bottom"){var m,g;return{top:((m=u?.top)!=null?m:[]).filter(S=>!(l!=null&&l.has(S))),bottom:[...((g=u?.bottom)!=null?g:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)]}}if(n==="top"){var b,x;return{top:[...((b=u?.top)!=null?b:[]).filter(S=>!(l!=null&&l.has(S))),...Array.from(l)],bottom:((x=u?.bottom)!=null?x:[]).filter(S=>!(l!=null&&l.has(S)))}}return{top:((f=u?.top)!=null?f:[]).filter(S=>!(l!=null&&l.has(S))),bottom:((h=u?.bottom)!=null?h:[]).filter(S=>!(l!=null&&l.has(S)))}})},t.getCanPin=()=>{var n;const{enableRowPinning:r,enablePinning:i}=e.options;return typeof r=="function"?r(t):(n=r??i)!=null?n:!0},t.getIsPinned=()=>{const n=[t.id],{top:r,bottom:i}=e.getState().rowPinning,s=n.some(l=>r?.includes(l)),o=n.some(l=>i?.includes(l));return s?"top":o?"bottom":!1},t.getPinnedIndex=()=>{var n,r;const i=t.getIsPinned();if(!i)return-1;const s=(n=i==="top"?e.getTopRows():e.getBottomRows())==null?void 0:n.map(o=>{let{id:l}=o;return l});return(r=s?.indexOf(t.id))!=null?r:-1}},createTable:t=>{t.setRowPinning=e=>t.options.onRowPinningChange==null?void 0:t.options.onRowPinningChange(e),t.resetRowPinning=e=>{var n,r;return t.setRowPinning(e?f0():(n=(r=t.initialState)==null?void 0:r.rowPinning)!=null?n:f0())},t.getIsSomeRowsPinned=e=>{var n;const r=t.getState().rowPinning;if(!e){var i,s;return!!((i=r.top)!=null&&i.length||(s=r.bottom)!=null&&s.length)}return!!((n=r[e])!=null&&n.length)},t._getPinnedRows=(e,n,r)=>{var i;return((i=t.options.keepPinnedRows)==null||i?(n??[]).map(o=>{const l=t.getRow(o,!0);return l.getIsAllParentsExpanded()?l:null}):(n??[]).map(o=>e.find(l=>l.id===o))).filter(Boolean).map(o=>({...o,position:r}))},t.getTopRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top],(e,n)=>t._getPinnedRows(e,n,"top"),Xe(t.options,"debugRows")),t.getBottomRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.bottom],(e,n)=>t._getPinnedRows(e,n,"bottom"),Xe(t.options,"debugRows")),t.getCenterRows=Ye(()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom],(e,n,r)=>{const i=new Set([...n??[],...r??[]]);return e.filter(s=>!i.has(s.id))},Xe(t.options,"debugRows"))}},Mee={getInitialState:t=>({rowSelection:{},...t}),getDefaultOptions:t=>({onRowSelectionChange:Or("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),createTable:t=>{t.setRowSelection=e=>t.options.onRowSelectionChange==null?void 0:t.options.onRowSelectionChange(e),t.resetRowSelection=e=>{var n;return t.setRowSelection(e?{}:(n=t.initialState.rowSelection)!=null?n:{})},t.toggleAllRowsSelected=e=>{t.setRowSelection(n=>{e=typeof e<"u"?e:!t.getIsAllRowsSelected();const r={...n},i=t.getPreGroupedRowModel().flatRows;return e?i.forEach(s=>{s.getCanSelect()&&(r[s.id]=!0)}):i.forEach(s=>{delete r[s.id]}),r})},t.toggleAllPageRowsSelected=e=>t.setRowSelection(n=>{const r=typeof e<"u"?e:!t.getIsAllPageRowsSelected(),i={...n};return t.getRowModel().rows.forEach(s=>{Yx(i,s.id,r,!0,t)}),i}),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getCoreRowModel()],(e,n)=>Object.keys(e).length?h0(t,n):{rows:[],flatRows:[],rowsById:{}},Xe(t.options,"debugTable")),t.getFilteredSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getFilteredRowModel()],(e,n)=>Object.keys(e).length?h0(t,n):{rows:[],flatRows:[],rowsById:{}},Xe(t.options,"debugTable")),t.getGroupedSelectedRowModel=Ye(()=>[t.getState().rowSelection,t.getSortedRowModel()],(e,n)=>Object.keys(e).length?h0(t,n):{rows:[],flatRows:[],rowsById:{}},Xe(t.options,"debugTable")),t.getIsAllRowsSelected=()=>{const e=t.getFilteredRowModel().flatRows,{rowSelection:n}=t.getState();let r=!!(e.length&&Object.keys(n).length);return r&&e.some(i=>i.getCanSelect()&&!n[i.id])&&(r=!1),r},t.getIsAllPageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows.filter(i=>i.getCanSelect()),{rowSelection:n}=t.getState();let r=!!e.length;return r&&e.some(i=>!n[i.id])&&(r=!1),r},t.getIsSomeRowsSelected=()=>{var e;const n=Object.keys((e=t.getState().rowSelection)!=null?e:{}).length;return n>0&&n<t.getFilteredRowModel().flatRows.length},t.getIsSomePageRowsSelected=()=>{const e=t.getPaginationRowModel().flatRows;return t.getIsAllPageRowsSelected()?!1:e.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},t.getToggleAllRowsSelectedHandler=()=>e=>{t.toggleAllRowsSelected(e.target.checked)},t.getToggleAllPageRowsSelectedHandler=()=>e=>{t.toggleAllPageRowsSelected(e.target.checked)}},createRow:(t,e)=>{t.toggleSelected=(n,r)=>{const i=t.getIsSelected();e.setRowSelection(s=>{var o;if(n=typeof n<"u"?n:!i,t.getCanSelect()&&i===n)return s;const l={...s};return Yx(l,t.id,n,(o=r?.selectChildren)!=null?o:!0,e),l})},t.getIsSelected=()=>{const{rowSelection:n}=e.getState();return rk(t,n)},t.getIsSomeSelected=()=>{const{rowSelection:n}=e.getState();return Xx(t,n)==="some"},t.getIsAllSubRowsSelected=()=>{const{rowSelection:n}=e.getState();return Xx(t,n)==="all"},t.getCanSelect=()=>{var n;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(t):(n=e.options.enableRowSelection)!=null?n:!0},t.getCanSelectSubRows=()=>{var n;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(t):(n=e.options.enableSubRowSelection)!=null?n:!0},t.getCanMultiSelect=()=>{var n;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(t):(n=e.options.enableMultiRowSelection)!=null?n:!0},t.getToggleSelectedHandler=()=>{const n=t.getCanSelect();return r=>{var i;n&&t.toggleSelected((i=r.target)==null?void 0:i.checked)}}}},Yx=(t,e,n,r,i)=>{var s;const o=i.getRow(e,!0);n?(o.getCanMultiSelect()||Object.keys(t).forEach(l=>delete t[l]),o.getCanSelect()&&(t[e]=!0)):delete t[e],r&&(s=o.subRows)!=null&&s.length&&o.getCanSelectSubRows()&&o.subRows.forEach(l=>Yx(t,l.id,n,r,i))};function h0(t,e){const n=t.getState().rowSelection,r=[],i={},s=function(o,l){return o.map(u=>{var f;const h=rk(u,n);if(h&&(r.push(u),i[u.id]=u),(f=u.subRows)!=null&&f.length&&(u={...u,subRows:s(u.subRows)}),h)return u}).filter(Boolean)};return{rows:s(e.rows),flatRows:r,rowsById:i}}function rk(t,e){var n;return(n=e[t.id])!=null?n:!1}function Xx(t,e,n){var r;if(!((r=t.subRows)!=null&&r.length))return!1;let i=!0,s=!1;return t.subRows.forEach(o=>{if(!(s&&!i)&&(o.getCanSelect()&&(rk(o,e)?s=!0:i=!1),o.subRows&&o.subRows.length)){const l=Xx(o,e);l==="all"?s=!0:(l==="some"&&(s=!0),i=!1)}}),i?"all":s?"some":!1}const Jx=/([0-9]+)/gm,Nee=(t,e,n)=>p2(qo(t.getValue(n)).toLowerCase(),qo(e.getValue(n)).toLowerCase()),Oee=(t,e,n)=>p2(qo(t.getValue(n)),qo(e.getValue(n))),Dee=(t,e,n)=>ik(qo(t.getValue(n)).toLowerCase(),qo(e.getValue(n)).toLowerCase()),Iee=(t,e,n)=>ik(qo(t.getValue(n)),qo(e.getValue(n))),jee=(t,e,n)=>{const r=t.getValue(n),i=e.getValue(n);return r>i?1:r<i?-1:0},Lee=(t,e,n)=>ik(t.getValue(n),e.getValue(n));function ik(t,e){return t===e?0:t>e?1:-1}function qo(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}function p2(t,e){const n=t.split(Jx).filter(Boolean),r=e.split(Jx).filter(Boolean);for(;n.length&&r.length;){const i=n.shift(),s=r.shift(),o=parseInt(i,10),l=parseInt(s,10),u=[o,l].sort();if(isNaN(u[0])){if(i>s)return 1;if(s>i)return-1;continue}if(isNaN(u[1]))return isNaN(o)?-1:1;if(o>l)return 1;if(l>o)return-1}return n.length-r.length}const Uu={alphanumeric:Nee,alphanumericCaseSensitive:Oee,text:Dee,textCaseSensitive:Iee,datetime:jee,basic:Lee},Pee={getInitialState:t=>({sorting:[],...t}),getDefaultColumnDef:()=>({sortingFn:"auto",sortUndefined:1}),getDefaultOptions:t=>({onSortingChange:Or("sorting",t),isMultiSortEvent:e=>e.shiftKey}),createColumn:(t,e)=>{t.getAutoSortingFn=()=>{const n=e.getFilteredRowModel().flatRows.slice(10);let r=!1;for(const i of n){const s=i?.getValue(t.id);if(Object.prototype.toString.call(s)==="[object Date]")return Uu.datetime;if(typeof s=="string"&&(r=!0,s.split(Jx).length>1))return Uu.alphanumeric}return r?Uu.text:Uu.basic},t.getAutoSortDir=()=>{const n=e.getFilteredRowModel().flatRows[0];return typeof n?.getValue(t.id)=="string"?"asc":"desc"},t.getSortingFn=()=>{var n,r;if(!t)throw new Error;return Lg(t.columnDef.sortingFn)?t.columnDef.sortingFn:t.columnDef.sortingFn==="auto"?t.getAutoSortingFn():(n=(r=e.options.sortingFns)==null?void 0:r[t.columnDef.sortingFn])!=null?n:Uu[t.columnDef.sortingFn]},t.toggleSorting=(n,r)=>{const i=t.getNextSortingOrder(),s=typeof n<"u"&&n!==null;e.setSorting(o=>{const l=o?.find(b=>b.id===t.id),u=o?.findIndex(b=>b.id===t.id);let f=[],h,m=s?n:i==="desc";if(o!=null&&o.length&&t.getCanMultiSort()&&r?l?h="toggle":h="add":o!=null&&o.length&&u!==o.length-1?h="replace":l?h="toggle":h="replace",h==="toggle"&&(s||i||(h="remove")),h==="add"){var g;f=[...o,{id:t.id,desc:m}],f.splice(0,f.length-((g=e.options.maxMultiSortColCount)!=null?g:Number.MAX_SAFE_INTEGER))}else h==="toggle"?f=o.map(b=>b.id===t.id?{...b,desc:m}:b):h==="remove"?f=o.filter(b=>b.id!==t.id):f=[{id:t.id,desc:m}];return f})},t.getFirstSortDir=()=>{var n,r;return((n=(r=t.columnDef.sortDescFirst)!=null?r:e.options.sortDescFirst)!=null?n:t.getAutoSortDir()==="desc")?"desc":"asc"},t.getNextSortingOrder=n=>{var r,i;const s=t.getFirstSortDir(),o=t.getIsSorted();return o?o!==s&&((r=e.options.enableSortingRemoval)==null||r)&&(!(n&&(i=e.options.enableMultiRemove)!=null)||i)?!1:o==="desc"?"asc":"desc":s},t.getCanSort=()=>{var n,r;return((n=t.columnDef.enableSorting)!=null?n:!0)&&((r=e.options.enableSorting)!=null?r:!0)&&!!t.accessorFn},t.getCanMultiSort=()=>{var n,r;return(n=(r=t.columnDef.enableMultiSort)!=null?r:e.options.enableMultiSort)!=null?n:!!t.accessorFn},t.getIsSorted=()=>{var n;const r=(n=e.getState().sorting)==null?void 0:n.find(i=>i.id===t.id);return r?r.desc?"desc":"asc":!1},t.getSortIndex=()=>{var n,r;return(n=(r=e.getState().sorting)==null?void 0:r.findIndex(i=>i.id===t.id))!=null?n:-1},t.clearSorting=()=>{e.setSorting(n=>n!=null&&n.length?n.filter(r=>r.id!==t.id):[])},t.getToggleSortingHandler=()=>{const n=t.getCanSort();return r=>{n&&(r.persist==null||r.persist(),t.toggleSorting==null||t.toggleSorting(void 0,t.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(r):!1))}}},createTable:t=>{t.setSorting=e=>t.options.onSortingChange==null?void 0:t.options.onSortingChange(e),t.resetSorting=e=>{var n,r;t.setSorting(e?[]:(n=(r=t.initialState)==null?void 0:r.sorting)!=null?n:[])},t.getPreSortedRowModel=()=>t.getGroupedRowModel(),t.getSortedRowModel=()=>(!t._getSortedRowModel&&t.options.getSortedRowModel&&(t._getSortedRowModel=t.options.getSortedRowModel(t)),t.options.manualSorting||!t._getSortedRowModel?t.getPreSortedRowModel():t._getSortedRowModel())}},zee=[iee,Cee,vee,xee,oee,aee,Eee,Tee,Pee,yee,_ee,Aee,Ree,Mee,See];function $ee(t){var e,n;const r=[...zee,...(e=t._features)!=null?e:[]];let i={_features:r};const s=i._features.reduce((g,b)=>Object.assign(g,b.getDefaultOptions==null?void 0:b.getDefaultOptions(i)),{}),o=g=>i.options.mergeOptions?i.options.mergeOptions(s,g):{...s,...g};let u={...{},...(n=t.initialState)!=null?n:{}};i._features.forEach(g=>{var b;u=(b=g.getInitialState==null?void 0:g.getInitialState(u))!=null?b:u});const f=[];let h=!1;const m={_features:r,options:{...s,...t},initialState:u,_queue:g=>{f.push(g),h||(h=!0,Promise.resolve().then(()=>{for(;f.length;)f.shift()();h=!1}).catch(b=>setTimeout(()=>{throw b})))},reset:()=>{i.setState(i.initialState)},setOptions:g=>{const b=_o(g,i.options);i.options=o(b)},getState:()=>i.options.state,setState:g=>{i.options.onStateChange==null||i.options.onStateChange(g)},_getRowId:(g,b,x)=>{var S;return(S=i.options.getRowId==null?void 0:i.options.getRowId(g,b,x))!=null?S:`${x?[x.id,b].join("."):b}`},getCoreRowModel:()=>(i._getCoreRowModel||(i._getCoreRowModel=i.options.getCoreRowModel(i)),i._getCoreRowModel()),getRowModel:()=>i.getPaginationRowModel(),getRow:(g,b)=>{let x=(b?i.getPrePaginationRowModel():i.getRowModel()).rowsById[g];if(!x&&(x=i.getCoreRowModel().rowsById[g],!x))throw new Error;return x},_getDefaultColumnDef:Ye(()=>[i.options.defaultColumn],g=>{var b;return g=(b=g)!=null?b:{},{header:x=>{const S=x.header.column.columnDef;return S.accessorKey?S.accessorKey:S.accessorFn?S.id:null},cell:x=>{var S,k;return(S=(k=x.renderValue())==null||k.toString==null?void 0:k.toString())!=null?S:null},...i._features.reduce((x,S)=>Object.assign(x,S.getDefaultColumnDef==null?void 0:S.getDefaultColumnDef()),{}),...g}},Xe(t,"debugColumns")),_getColumnDefs:()=>i.options.columns,getAllColumns:Ye(()=>[i._getColumnDefs()],g=>{const b=function(x,S,k){return k===void 0&&(k=0),x.map(C=>{const A=ree(i,C,k,S),R=C;return A.columns=R.columns?b(R.columns,A,k+1):[],A})};return b(g)},Xe(t,"debugColumns")),getAllFlatColumns:Ye(()=>[i.getAllColumns()],g=>g.flatMap(b=>b.getFlatColumns()),Xe(t,"debugColumns")),_getAllFlatColumnsById:Ye(()=>[i.getAllFlatColumns()],g=>g.reduce((b,x)=>(b[x.id]=x,b),{}),Xe(t,"debugColumns")),getAllLeafColumns:Ye(()=>[i.getAllColumns(),i._getOrderColumnsFn()],(g,b)=>{let x=g.flatMap(S=>S.getLeafColumns());return b(x)},Xe(t,"debugColumns")),getColumn:g=>i._getAllFlatColumnsById()[g]};Object.assign(i,m);for(let g=0;g<i._features.length;g++){const b=i._features[g];b==null||b.createTable==null||b.createTable(i)}return i}function Bee(){return t=>Ye(()=>[t.options.data],e=>{const n={rows:[],flatRows:[],rowsById:{}},r=function(i,s,o){s===void 0&&(s=0);const l=[];for(let f=0;f<i.length;f++){const h=see(t,t._getRowId(i[f],f,o),i[f],f,s,void 0,o?.id);if(n.flatRows.push(h),n.rowsById[h.id]=h,l.push(h),t.options.getSubRows){var u;h.originalSubRows=t.options.getSubRows(i[f],f),(u=h.originalSubRows)!=null&&u.length&&(h.subRows=r(h.originalSubRows,s+1,h))}}return l};return n.rows=r(e),n},Xe(t.options,"debugTable","getRowModel",()=>t._autoResetPageIndex()))}function mM(t,e){return t?Vee(t)?E.createElement(t,e):t:null}function Vee(t){return Hee(t)||typeof t=="function"||Uee(t)}function Hee(t){return typeof t=="function"&&(()=>{const e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}function Uee(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}function Fee(t){const e={state:{},onStateChange:()=>{},renderFallbackValue:null,...t},[n]=E.useState(()=>({current:$ee(e)})),[r,i]=E.useState(()=>n.current.initialState);return n.current.setOptions(s=>({...s,...t,state:{...r,...t.state},onStateChange:o=>{i(o),t.onStateChange==null||t.onStateChange(o)}})),n.current}function qee({uploads:t,canCreate:e,fieldLabels:n,onClose:r,onUpload:i,onCreateFromUploads:s}){const o=E.useMemo(()=>Object.keys(t),[t]),[l,u]=E.useState(o[0]??""),[f,h]=E.useState(!!e),[m,g]=E.useState([]),[b,x]=E.useState(null),S=t[l];return E.useEffect(()=>{!o.includes(l)&&o[0]&&u(o[0])},[l,o]),E.useEffect(()=>{const k=A=>{A.key==="Escape"&&r()};window.addEventListener("keydown",k);const C=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",k),document.body.style.overflow=C}},[r]),S?y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:r,children:y.jsxs("div",{className:"vertebr-modal vertebr-modal-sm",role:"dialog","aria-modal":"true","aria-label":"Bulk image upload",onClick:k=>k.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:"Media"}),y.jsx("h2",{children:"Bulk image upload"})]}),y.jsx("button",{type:"button",className:"vertebr-btn",onClick:r,children:"Close"})]}),y.jsxs("div",{className:"vertebr-modal-body",children:[o.length>1?y.jsxs("label",{className:"vertebr-field",children:[y.jsx("span",{children:"Target field"}),y.jsx("select",{className:"vertebr-native-select",value:l,onChange:k=>{u(k.target.value),g([]),x(null)},children:o.map(k=>y.jsx("option",{value:k,children:n[k]??k},k))})]}):null,e&&s?y.jsxs("label",{className:"vertebr-upload-check",children:[y.jsx("input",{type:"checkbox",checked:f,onChange:k=>h(k.target.checked)}),y.jsx("span",{children:"Create a record for each uploaded image"})]}):null,y.jsx(Nc,{meta:S,multiple:!0,onUpload:async k=>{x(`Uploading ${k.length} image${k.length===1?"":"s"}…`);const C=await i(l,k);g(C),f&&s?(x("Creating records…"),await s(l,C),x(`Uploaded ${C.length} and created records.`)):x(`Uploaded ${C.length} image${C.length===1?"":"s"}.`)}}),b?y.jsx("p",{className:"vertebr-upload-status",children:b}):null,m.length>0?y.jsx("ul",{className:"vertebr-upload-results",children:m.map(k=>y.jsxs("li",{children:[y.jsx("img",{src:k.url,alt:""}),y.jsxs("div",{children:[y.jsx("strong",{children:k.name??"Image"}),y.jsx("a",{href:k.url,target:"_blank",rel:"noreferrer",children:k.url})]})]},k.url))}):null]})]})}):null}function Gee({columns:t,visibility:e,onChange:n}){const[r,i]=E.useState(!1),s=E.useRef(null),o=E.useId(),l=t.filter(f=>e[f.id]===!1).length;E.useEffect(()=>{if(!r)return;const f=m=>{s.current?.contains(m.target)||i(!1)},h=m=>{m.key==="Escape"&&i(!1)};return window.addEventListener("mousedown",f),window.addEventListener("keydown",h),()=>{window.removeEventListener("mousedown",f),window.removeEventListener("keydown",h)}},[r]);const u=t.length-l;return y.jsxs("div",{className:"vertebr-col-menu",ref:s,children:[y.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet","aria-expanded":r,"aria-controls":o,onClick:()=>i(f=>!f),children:["Columns",l>0?y.jsx("span",{className:"vertebr-col-menu-count",children:u}):null]}),r?y.jsxs("div",{className:"vertebr-col-menu-panel",id:o,role:"menu",children:[y.jsxs("div",{className:"vertebr-col-menu-head",children:[y.jsx("span",{children:"Visible fields"}),y.jsx("button",{type:"button",className:"vertebr-link-btn",onClick:()=>{const f={};for(const h of t)f[h.id]=!0;n(f)},children:"Show all"})]}),y.jsx("ul",{className:"vertebr-col-menu-list",children:t.map(f=>{const h=e[f.id]!==!1;return y.jsx("li",{children:y.jsxs("label",{className:"vertebr-col-menu-item",children:[y.jsx("input",{type:"checkbox",checked:h,disabled:h&&u<=1,onChange:()=>{const m={...e,[f.id]:!h};n(m)}}),y.jsx("span",{children:f.label})]})},f.id)})})]}):null]})}const Wee=/(url|href|link|src)/i,Kee=/\.(png|jpe?g|gif|webp|svg|avif)(\?|#|$)/i;function m2(t){return/^https?:\/\//i.test(t)||t.startsWith("//")}function Zee(t){return m2(t)?Kee.test(t)?!0:/(image|img|media|cdn|photo)/i.test(t):!1}function gM(t){if(t instanceof Date&&!Number.isNaN(t.getTime()))return t.toLocaleString();if(t&&typeof t=="object"&&"toDate"in t&&typeof t.toDate=="function")try{return t.toDate().toLocaleString()}catch{return null}if(typeof t=="string"||typeof t=="number"){const e=new Date(t);if(!Number.isNaN(e.getTime()))return e.toLocaleString()}return null}function Sp({fieldKey:t,field:e,value:n,variant:r="table"}){const i=r==="detail";if(n==null||n==="")return y.jsx("span",{className:"vertebr-cell-empty",children:"—"});const s=e?.type;if(s==="boolean"||typeof n=="boolean"){const u=!!n;return y.jsx("span",{className:"vertebr-badge","data-tone":u?"ok":"neutral",children:Yee(t,e,u)})}if(s==="datetime"){const u=gM(n);if(u)return y.jsx("span",{className:"vertebr-cell-datetime",children:u})}if((s==="number"||typeof n=="number")&&typeof n=="number"&&Number.isFinite(n))return jw(t,e)?y.jsx("span",{className:"vertebr-cell-money",children:G0(n,{asCents:!0})}):TO(t,e)?y.jsx("span",{className:"vertebr-cell-money",children:G0(n,{asCents:!1})}):y.jsx("span",{className:"vertebr-cell-number",children:new Intl.NumberFormat().format(n)});const o=V0(n);if(o.length>0&&(s==="file[]"||La(t,e)||o.every(Zee)))return y.jsx(Xee,{urls:o,detail:i});if(Array.isArray(n)){if(n.length===0)return y.jsx("span",{className:"vertebr-cell-empty",children:"—"});if(n.every(u=>typeof u=="string"))return y.jsx("div",{className:"vertebr-chip-row",children:n.map(u=>y.jsx("span",{className:"vertebr-chip",title:u,children:u},u))})}if(typeof n=="string")return Wee.test(t)||m2(n)?y.jsx("a",{className:"vertebr-cell-link",href:n.startsWith("//")?`https:${n}`:n,target:"_blank",rel:"noreferrer",title:n,onClick:u=>u.stopPropagation(),children:i?n:n.replace(/^https?:\/\//i,"")}):!i&&(s==="richtext"||n.length>80)?y.jsx("span",{className:"vertebr-cell-clamp",title:n,children:n}):i&&(s==="richtext"||n.length>80)?y.jsx("p",{className:"vertebr-cell-prose",children:n}):y.jsx("span",{className:"vertebr-cell-text",children:n});const l=gM(n);return l?y.jsx("span",{className:"vertebr-cell-datetime",children:l}):typeof n=="object"?y.jsx("code",{className:"vertebr-cell-json",title:JSON.stringify(n),children:JSON.stringify(n)}):y.jsx("span",{className:"vertebr-cell-text",children:String(n)})}function Yee(t,e,n){const r=`${t} ${e?.label??""}`;return/^show[A-Z]/.test(t)||/\bshow\b/i.test(e?.label??"")?n?"Shown":"Hidden":/\bactive\b/i.test(r)||/\bvisible\b/i.test(r)?n?"Visible":"Hidden":n?"On":"Off"}function Xee({urls:t,detail:e}){if(e)return y.jsx("div",{className:"vertebr-cell-thumbs vertebr-cell-thumbs-detail",children:t.map((i,s)=>y.jsxs("a",{className:"vertebr-cell-media vertebr-cell-media-detail",href:i,target:"_blank",rel:"noreferrer",title:i,onClick:o=>o.stopPropagation(),children:[y.jsx("img",{src:i,alt:"",loading:"lazy"}),y.jsx("span",{className:"vertebr-cell-link",children:i})]},`${i}:${s}`))});const n=t.slice(0,3),r=t.length-n.length;return y.jsxs("div",{className:"vertebr-cell-thumbs",title:t[0],children:[n.map((i,s)=>y.jsx("img",{src:i,alt:"",loading:"lazy"},`${i}:${s}`)),r>0?y.jsxs("span",{className:"vertebr-cell-thumbs-more",children:["+",r]}):null]})}function Jee({title:t,schema:e,value:n,uploads:r,onUpload:i,galleryUpload:s,onListGallery:o,onUploadGallery:l,onClose:u,onCreate:f}){return E.useEffect(()=>{const h=g=>{g.key==="Escape"&&u()};window.addEventListener("keydown",h);const m=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",h),document.body.style.overflow=m}},[u]),y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:u,children:y.jsxs("div",{className:"vertebr-modal vertebr-modal-form",role:"dialog","aria-modal":"true","aria-label":t,onClick:h=>h.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:"New record"}),y.jsx("h2",{children:t})]}),y.jsx("div",{className:"vertebr-modal-actions",children:y.jsx("button",{type:"button",className:"vertebr-btn",onClick:u,"aria-label":"Close",children:"Close"})})]}),y.jsx("div",{className:"vertebr-modal-body",children:y.jsx(jg,{variant:"record",schema:e,value:n,uploads:r,onUpload:i,galleryUpload:s,onListGallery:o,onUploadGallery:l,submitLabel:t,onSave:async h=>{await f(h),u()}})})]})})}const Qee=new Set(["custom","promo","custom_discount"]),ete=new Set(["discount","welcome_offer","flash_sale","custom_discount"]),tte=new Set(["discountId","discountCode","discountOffer","discountExpires"]);function nte(t){return Array.isArray(t)?t.join(", "):t}function Rc(t){return typeof t=="string"?t:String(t??"")}function rte(t,e){const n=`${t} ${e.label??""}`;return e.type==="richtext"||/(body|message|html|notes)/i.test(n)}function $m(t,e){if(!t.preset)return!0;const n=Rc(e.preset);return!n||Qee.has(n)}function g2(t){return ete.has(t)}function y2(t,e,n){if(t==="subject"||t==="body")return $m(e,n);if(tte.has(t)){const r=Rc(n.preset);return!(!g2(r)||t==="discountId"&&!e.discountId?.options?.length)}return!0}function yM(t,e){return Object.entries(t).every(([n,r])=>{if(!y2(n,t,e))return!0;const i=(n==="subject"||n==="body")&&$m(t,e),s=(n==="discountCode"||n==="discountOffer")&&g2(Rc(e.preset));return r.required===!1&&!i&&!s||r.type!=="string"&&r.type!=="richtext"&&r.type!=="enum"?!0:!!Rc(e[n]).trim()})}function bM(t){if(!(t instanceof Error))return"Request failed";const e=t.message.trim();if(!e.startsWith("{"))return e;try{const n=JSON.parse(e);if(typeof n.error=="string"&&n.error.trim())return n.error;if(n.error&&typeof n.error=="object"&&typeof n.error.message=="string"&&n.error.message.trim())return n.error.message;if(typeof n.message=="string"&&n.message.trim())return n.message}catch{}return e}function ite({title:t,count:e,schema:n,submitLabel:r,onClose:i,onPreview:s,onSubmit:o}){const l=E.useMemo(()=>QS(n),[n]),u=E.useMemo(()=>Object.entries(n),[n]),f=u.length>0,[h,m]=E.useState(l),[g,b]=E.useState(null),[x,S]=E.useState(null),[k,C]=E.useState(!1),[A,R]=E.useState(!1),_=!A&&(!f||yM(n,h)),M=u.filter(([I])=>y2(I,n,h)),O=E.useCallback(async I=>{if(f&&!yM(n,I)){b(null),S(null);return}C(!0),S(null);try{const P=await s(I);b(P)}catch(P){b(null),S(bM(P))}finally{C(!1)}},[f,s,n]);E.useEffect(()=>{const I=B=>{B.key==="Escape"&&i()};window.addEventListener("keydown",I);const P=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",I),document.body.style.overflow=P}},[i]),E.useEffect(()=>{if(!f){O({});return}const I=window.setTimeout(()=>{O(h)},280);return()=>window.clearTimeout(I)},[h,f,O]);const D=async()=>{if(_){R(!0);try{await o(f?h:{}),i()}catch(I){S(bM(I))}finally{R(!1)}}};return y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:i,children:y.jsxs("div",{className:"vertebr-modal vertebr-modal-form vertebr-mail-modal",role:"dialog","aria-modal":"true","aria-label":t,onClick:I=>I.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:e===1?"1 person":`${e} people`}),y.jsx("h2",{children:t})]}),y.jsx("div",{className:"vertebr-modal-actions",children:y.jsx("button",{type:"button",className:"vertebr-btn",onClick:i,"aria-label":"Close",children:"Close"})})]}),y.jsxs("div",{className:"vertebr-mail-layout",children:[y.jsxs("form",{className:"vertebr-mail-compose",onSubmit:I=>{I.preventDefault(),D()},children:[f?y.jsxs("div",{className:"vertebr-mail-fields",children:[M.map(([I,P])=>{const B=rte(I,P);return y.jsxs("label",{className:"vertebr-mail-field",children:[y.jsx("span",{children:P.label??I}),P.type==="enum"?y.jsx(JS,{id:`mail-${I}`,value:h[I],field:P,onChange:re=>m(K=>({...K,[I]:re}))}):B?y.jsx("textarea",{rows:7,value:Rc(h[I]),placeholder:"Plain text — the host template styles it.",onChange:re=>m(K=>({...K,[I]:re.target.value}))}):y.jsx("input",{type:"text",value:Rc(h[I]),onChange:re=>m(K=>({...K,[I]:re.target.value}))})]},I)}),n.preset&&!$m(n,h)?y.jsx("p",{className:"vertebr-mail-compose-hint",children:"Preview updates from the selected preset. Switch to Custom to write your own copy."}):null]}):y.jsx("p",{className:"vertebr-mail-compose-note",children:"Host template — Vertebr only delivers it."}),x?y.jsx("p",{className:"vertebr-mail-compose-error",children:x}):null,y.jsx("div",{className:"vertebr-mail-compose-foot",children:y.jsx("button",{type:"submit",className:"vertebr-btn vertebr-btn-primary",disabled:!_,children:A?"Sending…":r})})]}),y.jsxs("div",{className:"vertebr-mail-preview",children:[y.jsxs("div",{className:"vertebr-mail-preview-meta",children:[y.jsxs("p",{children:[y.jsx("span",{children:"To"}),y.jsx("strong",{children:g?nte(g.to):e===1?"—":`${e} recipients`})]}),y.jsxs("p",{children:[y.jsx("span",{children:"Subject"}),y.jsx("strong",{children:g?.subject??(k?"Updating…":"—")})]})]}),y.jsx("div",{className:"vertebr-mail-preview-stage",children:y.jsx("div",{className:"vertebr-mail-preview-frame",children:g?.html?y.jsx("iframe",{title:"Email preview",sandbox:"",srcDoc:g.html}):g?.text?y.jsx("pre",{children:g.text}):y.jsx("div",{className:"vertebr-mail-preview-empty",children:x??(k?"Rendering host template…":f?n.preset&&$m(n,h)?"Write a subject and body to preview.":n.preset?"Pick a preset to preview.":"Write a subject and body to preview.":"Loading preview…")})})})]})]})]})})}function ste(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function ote(t,e){for(const[n,r]of Object.entries(e)){if(typeof r!="string"||!/^https?:\/\//i.test(r))continue;const i=t[n];if(/(image|img|photo|avatar|thumbnail|thumb|cover)/i.test(n)||/(image|img|photo)/i.test(i?.label??"")||/(image|img|media|cdn|photo)/i.test(r))return r}return null}function ate({schema:t,row:e,title:n,canEdit:r,onClose:i,onEdit:s}){const o=Object.keys(t),l=o.length>0?o.map(f=>[f,e[f]]):Object.entries(e),u=ote(t,e);return E.useEffect(()=>{const f=m=>{m.key==="Escape"&&i()};window.addEventListener("keydown",f);const h=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",f),document.body.style.overflow=h}},[i]),y.jsx("div",{className:"vertebr-modal-backdrop",role:"presentation",onClick:i,children:y.jsxs("div",{className:"vertebr-modal",role:"dialog","aria-modal":"true","aria-label":n,onClick:f=>f.stopPropagation(),children:[y.jsxs("header",{className:"vertebr-modal-head",children:[y.jsxs("div",{className:"vertebr-modal-heading",children:[y.jsx("p",{className:"vertebr-modal-eyebrow",children:"Record"}),y.jsx("h2",{children:n})]}),y.jsxs("div",{className:"vertebr-modal-actions",children:[r&&s?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",onClick:s,children:"Edit"}):null,y.jsx("button",{type:"button",className:"vertebr-btn",onClick:i,"aria-label":"Close",children:"Close"})]})]}),y.jsxs("div",{className:"vertebr-modal-body",children:[u?y.jsx("div",{className:"vertebr-modal-hero",children:y.jsx("img",{src:u,alt:""})}):null,y.jsx("dl",{className:"vertebr-modal-fields",children:l.map(([f,h])=>y.jsxs("div",{className:"vertebr-modal-field",children:[y.jsx("dt",{children:t[f]?.label??ste(f)}),y.jsx("dd",{children:y.jsx(Sp,{fieldKey:f,field:t[f],value:h,variant:"detail"})})]},f))})]})]})})}function vM(t){return!!(t?.input&&Object.keys(t.input).length>0)}function xM(t){return!!t?.mail}function lte(t,e){const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}function ii(t,e){for(const n of e){const r=t[n];if(typeof r=="string"&&r.trim())return r;if(typeof r=="number")return String(r)}return null}function tp(t){return t.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").replace(/\bcents\b/i,"").trim()}function wM(t,e){for(const n of["name","title","label",...e]){const r=t[n];if(typeof r=="string"&&r.trim())return r}return"Record"}function cte(t,e){if(!(!t||typeof localStorage>"u"))try{localStorage.setItem(`vertebr:columns:v2:${t}`,JSON.stringify(e))}catch{}}function ute(t,e,n){return!!(/^show[A-Z]/.test(t)||e?.type==="richtext"||t==="updatedAt"||t==="createdAt"||(t==="imageSrc"||t==="imageAlt")&&"images"in n||t==="slug"&&"name"in n||e?.type==="string"&&/^(details|description)$/i.test(t))}function SM(t,e){return e?.type!=="boolean"||e.readOnly?!1:/^(active|visible|published)$/i.test(t)?!0:/\b(active|visible|published)\b/i.test(e.label??"")}function np(t,e){return t[e]!==!1}function dte(t){const e={};for(const[n,r]of Object.entries(t))ute(n,r,t)&&(e[n]=!1);return e}function kM(t,e){const n=dte(e);if(!t||typeof localStorage>"u")return n;try{const r=localStorage.getItem(`vertebr:columns:v2:${t}`);if(!r)return n;const i=JSON.parse(r);return!i||typeof i!="object"?n:{...n,...i}}catch{return n}}function fte(t){const e=t?.trim();return e?`Add ${(/ies$/i.test(e)?e.replace(/ies$/i,"y"):/s$/i.test(e)?e.slice(0,-1):e).toLowerCase()}`:"Add record"}function hte(t){return t.replace(/\.[^.]+$/,"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim()}function pte({schema:t,items:e,permissions:n,actions:r={},label:i,uploads:s,rowIdKeys:o=["id","slug","uid","email"],storageKey:l,onUpdate:u,onCreate:f,onDelete:h,onAction:m,onActionDone:g,onPreviewMail:b,collectionActions:x={},onCollectionAction:S,onUpload:k,galleryUpload:C,onListGallery:A,onUploadGallery:R}){const[_,M]=E.useState(null),[O,D]=E.useState(!1),[I,P]=E.useState(null),[B,re]=E.useState(!1),[K,ee]=E.useState(null),[Q,fe]=E.useState(new Set),[z,L]=E.useState(null),[G,he]=E.useState(null),ke=E.useRef(null),[H,Z]=E.useState({overflow:!1,canLeft:!1,canRight:!1}),[pe,ve]=E.useState(()=>kM(l,t)),[Ae,Re]=E.useState({}),[$e,_e]=E.useState(!1),ae=!!(n?.update&&u),me=!!(n?.create&&f),Ie=!!(n?.delete&&h),Ue=fte(i),Ze=!!(s&&k&&Object.keys(s).length),ct=Object.entries(r),yt=Object.entries(x),Pt=Object.keys(t),mn=E.useMemo(()=>Pt.filter(se=>SM(se,t[se])),[Pt,t]),Wt=!!(m&&ct.length>0);E.useEffect(()=>{Re({})},[e]),E.useEffect(()=>{const se=new Set(e.map(F=>ii(F,o)).filter(F=>!!F));fe(F=>{const ne=new Set([...F].filter(Ce=>se.has(Ce)));return ne.size===F.size?F:ne})},[e,o]);const yn=E.useMemo(()=>{let se=0;for(const[F,ne]of Object.entries(Ae)){const Ce=e.find(Ge=>ii(Ge,o)===F);if(!Ce){se+=Object.keys(ne).length;continue}for(const[Ge,Dt]of Object.entries(ne))np(Ce,Ge)!==Dt&&(se+=1)}return se},[Ae,e,o]),$n=E.useCallback((se,F,ne)=>{Re(Ce=>{const Ge=e.find(wi=>ii(wi,o)===se),Dt=Ge?np(Ge,F):null,Zn={...Ce[se]??{}};Dt===ne?delete Zn[F]:Zn[F]=ne;const or={...Ce};return Object.keys(Zn).length===0?delete or[se]:or[se]=Zn,or})},[e,o]),Dr=E.useCallback(async()=>{if(!u||yn===0)return;_e(!0);const se=[];try{for(const[F,ne]of Object.entries(Ae)){const Ce=e.find(Ge=>ii(Ge,o)===F);if(Ce)try{await u(F,{...Ce,...ne})}catch(Ge){se.push(`${F}: ${Ge instanceof Error?Ge.message:"Failed"}`)}}Re({}),se.length>0&&window.alert(`Saved with ${se.length} error(s).
|
|
330
|
+
|
|
331
|
+
${se.slice(0,8).join(`
|
|
332
|
+
`)}`)}finally{_e(!1)}},[u,yn,Ae,e,o]),sr=E.useCallback(async(se,F,ne)=>{if(!m||F.length===0)return;ee(se);const Ce=[];try{for(const Ge of F)try{await m(Ge,se,ne)}catch(Dt){Ce.push(`${Ge}: ${Dt instanceof Error?Dt.message:"Failed"}`)}await g?.(),fe(new Set),Ce.length>0&&window.alert(`Finished with ${Ce.length} error(s).
|
|
333
|
+
|
|
334
|
+
${Ce.slice(0,8).join(`
|
|
335
|
+
`)}`)}finally{ee(null)}},[m,g]),Ir=E.useCallback((se,F)=>{const ne=r[se];if(!ne||F.length===0||!m)return;if(xM(ne)||vM(ne)){L({actionId:se,rowIds:F});return}const Ce=F.length===1?"this person":`${F.length} people`;window.confirm(`${ne.label} for ${Ce}?`)&&sr(se,F)},[r,m,sr]),Ht=E.useCallback(async(se,F)=>{if(S){ee(se);try{const ne=await S(se,F);await g?.(),ne&&typeof ne=="object"&&"message"in ne&&typeof ne.message=="string"?window.alert(ne.message):ne&&typeof ne=="object"&&"result"in ne&&ne.result&&typeof ne.result=="object"&&"message"in ne.result&&typeof ne.result.message=="string"&&window.alert(ne.result.message)}catch(ne){window.alert(ne instanceof Error?ne.message:"Action failed")}finally{ee(null)}}},[S,g]),xi=E.useCallback(se=>{const F=x[se];if(!F||!S)return;if(vM(F)){he(se);return}const ne=F.confirm?`${F.label}?
|
|
336
|
+
|
|
337
|
+
${F.confirm}`:`${F.label}?`;window.confirm(ne)&&Ht(se)},[x,S,Ht]);E.useEffect(()=>{ve(kM(l,t))},[l]),E.useEffect(()=>{cte(l,pe)},[l,pe]);const yr=E.useCallback(()=>{const se=ke.current;if(!se){Z({overflow:!1,canLeft:!1,canRight:!1});return}const F=se.scrollWidth>se.clientWidth+2;Z({overflow:F,canLeft:F&&se.scrollLeft>2,canRight:F&&se.scrollLeft+se.clientWidth<se.scrollWidth-2})},[]);E.useEffect(()=>{const se=ke.current;if(!se)return;yr();const F=()=>yr();se.addEventListener("scroll",F,{passive:!0});const ne=new ResizeObserver(yr);ne.observe(se);const Ce=se.querySelector("table");return Ce&&ne.observe(Ce),()=>{se.removeEventListener("scroll",F),ne.disconnect()}},[yr,e.length,pe]);const ei=se=>{const F=ke.current;if(!F)return;const ne=Math.max(220,Math.round(F.clientWidth*.55));F.scrollBy({left:se==="left"?-ne:ne,behavior:"smooth"})},Bn=E.useMemo(()=>Pt.map(se=>({id:se,label:t[se]?.label??tp(se)})),[Pt,t]),ge=E.useMemo(()=>{const se=[];if(Wt){const F=e.map(Ce=>ii(Ce,o)).filter(Ce=>!!Ce),ne=F.length>0&&F.every(Ce=>Q.has(Ce));se.push({id:"_select",enableHiding:!1,header:()=>y.jsx("input",{type:"checkbox",className:"vertebr-row-check",checked:ne,"aria-label":"Select all",onChange:()=>{fe(Ce=>F.every(Ge=>Ce.has(Ge))?new Set:new Set(F))}}),cell:({row:Ce})=>{const Ge=ii(Ce.original,o);return Ge?y.jsx("input",{type:"checkbox",className:"vertebr-row-check",checked:Q.has(Ge),"aria-label":"Select row",onClick:Dt=>Dt.stopPropagation(),onChange:()=>fe(Dt=>lte(Dt,Ge))}):null},size:44})}return se.push(...Pt.length===0?[{id:"raw",header:"Item",cell:({row:F})=>y.jsx(Sp,{fieldKey:"raw",value:F.original})}]:Pt.map(F=>{const ne=t[F],Ce=/(image|img|photo|avatar|thumbnail|thumb|cover)/i.test(F)||/(image|img|photo)/i.test(ne?.label??""),Ge=ae&&SM(F,ne);return{id:F,accessorKey:F,header:ne?.label??tp(F),meta:{fieldKey:F,field:ne},cell:({row:Dt,getValue:Zn})=>{if(Ge){const or=ii(Dt.original,o);if(!or)return y.jsx(Sp,{fieldKey:F,field:ne,value:Zn()});const wi=Ae[or]?.[F]??np(Dt.original,F),Ps=Ae[or]?.[F]!==void 0&&Ae[or]?.[F]!==np(Dt.original,F);return y.jsx("div",{className:"vertebr-visibility-check","data-dirty":Ps?"true":void 0,onClick:$c=>$c.stopPropagation(),children:y.jsx(EO,{visible:wi,dirty:Ps,label:ne?.label??tp(F),disabled:$e,onChange:$c=>$n(or,F,$c)})})}return y.jsx(Sp,{fieldKey:F,field:ne,value:Zn()})},size:Ge?88:Ce?220:void 0}})),se.push({id:"_actions",header:()=>y.jsx("span",{className:"vertebr-sr-only",children:"Actions"}),enableHiding:!1,cell:({row:F})=>{const ne=ii(F.original,o);return y.jsxs("div",{className:"vertebr-row-actions",onClick:Ce=>Ce.stopPropagation(),onKeyDown:Ce=>Ce.stopPropagation(),children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>P(F.original),children:"View"}),ae?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>M(F.original),children:"Edit"}):null,ne?ct.map(([Ce,Ge])=>y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:K!=null,onClick:()=>Ir(Ce,[ne]),children:Ge.label},Ce)):null,Ie&&ne?y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-danger-quiet",onClick:()=>{window.confirm("Delete this row? This cannot be undone.")&&h?.(ne)},children:"Delete"}):null]})}}),se},[t,Pt,e,Q,Wt,ae,Ie,ct,K,Ir,h,o,Ae,$n]),Ne=Fee({data:e,columns:ge,state:{columnVisibility:pe},onColumnVisibilityChange:ve,getCoreRowModel:Bee()}),j=_?ii(_,o):null,$=Object.fromEntries(Object.entries(t).filter(([,se])=>!se.readOnly||se.required).map(([se,F])=>[se,F.readOnly?{...F,readOnly:!1}:F])),U=Object.fromEntries(Object.entries($).map(([se,F])=>[se,F.default??(F.type==="boolean"?!1:F.type==="number"?void 0:F.type==="file[]"?[]:"")]));if(_&&j&&u){const se=Object.fromEntries(Object.entries(t).filter(([,ne])=>!ne.readOnly)),F=wM(_,o);return y.jsxs("div",{className:"vertebr-resource-edit",children:[y.jsxs("div",{className:"vertebr-resource-edit-head",children:[y.jsxs("div",{className:"vertebr-resource-edit-heading",children:[y.jsx("p",{className:"vertebr-resource-edit-eyebrow",children:"Editing record"}),y.jsx("h2",{children:F}),y.jsx("p",{className:"vertebr-resource-edit-id",children:j})]}),y.jsx("button",{type:"button",className:"vertebr-btn",onClick:()=>M(null),children:"Back"})]}),y.jsx(jg,{variant:"record",schema:se,value:_,uploads:s,onUpload:k,galleryUpload:C,onListGallery:A,onUploadGallery:R,onSave:async ne=>{await u(j,ne),M(null)}})]})}const ie=y.jsxs("div",{className:"vertebr-table-toolbar",children:[y.jsxs("div",{className:"vertebr-table-toolbar-start",children:[Bn.length>0?y.jsx(Gee,{columns:Bn,visibility:pe,onChange:ve}):null,Ze?y.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon",onClick:()=>re(!0),children:[y.jsx(bte,{}),"Bulk upload"]}):null,mn.length>0&&yn>0?y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"vertebr-count",children:[yn," visibility change",yn===1?"":"s"]}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",disabled:$e,onClick:()=>{Dr()},children:$e?"Saving…":"Save visibility"}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:$e,onClick:()=>Re({}),children:"Discard"})]}):null,yt.map(([se,F])=>y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:K!=null,onClick:()=>xi(se),children:F.label},se)),Wt&&Q.size>0?y.jsxs(y.Fragment,{children:[y.jsxs("span",{className:"vertebr-count",children:[Q.size," selected"]}),ct.map(([se,F])=>y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",disabled:K!=null,onClick:()=>Ir(se,[...Q]),children:F.label},se)),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet",onClick:()=>fe(new Set),children:"Clear"})]}):null]}),H.overflow?y.jsxs("div",{className:"vertebr-table-scroll-controls",role:"group","aria-label":"Scroll columns",children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon vertebr-table-scroll-btn",disabled:!H.canLeft,onClick:()=>ei("left"),"aria-label":"Scroll columns left",children:y.jsx(gte,{})}),y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon vertebr-table-scroll-btn",disabled:!H.canRight,onClick:()=>ei("right"),"aria-label":"Scroll columns right",children:y.jsx(yte,{})})]}):null]}),le=B&&s&&k?y.jsx(qee,{uploads:s,canCreate:me,fieldLabels:Object.fromEntries(Object.keys(s).map(se=>[se,t[se]?.label??tp(se)])),onClose:()=>re(!1),onUpload:k,onCreateFromUploads:me&&f?async(se,F)=>{for(const ne of F){const Ce=hte(ne.name??"Image");await f({[se]:ne.url,name:Ce,title:Ce})}}:void 0}):null,be=O&&f?y.jsx(Jee,{title:Ue,schema:$,value:U,uploads:s,onUpload:k,galleryUpload:C,onListGallery:A,onUploadGallery:R,onClose:()=>D(!1),onCreate:f}):null,we=z?xM(r[z.actionId])&&b?y.jsx(ite,{title:r[z.actionId]?.label??"Send email",count:z.rowIds.length,schema:i0(r[z.actionId]?.input??{}),submitLabel:K?"Sending…":z.rowIds.length===1?"Send":`Send to ${z.rowIds.length}`,onClose:()=>L(null),onPreview:se=>b(z.rowIds[0],z.actionId,se),onSubmit:se=>sr(z.actionId,z.rowIds,se)}):r[z.actionId]?.input?y.jsx(lM,{title:r[z.actionId]?.label??"Run action",count:z.rowIds.length,schema:i0(r[z.actionId].input),submitLabel:K?"Sending…":z.rowIds.length===1?r[z.actionId]?.label??"Send":`Send to ${z.rowIds.length}`,onClose:()=>L(null),onSubmit:se=>sr(z.actionId,z.rowIds,se)}):null:null,Te=G&&x[G]?.input?y.jsx(lM,{title:x[G]?.label??"Run action",eyebrow:"This resource",schema:i0(x[G].input),submitLabel:K?"Working…":"Run",onClose:()=>he(null),onSubmit:se=>Ht(G,se)}):null,Be=y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:"Records"}),y.jsxs("div",{className:"vertebr-panel-head-actions",children:[me?y.jsxs("button",{type:"button",className:"vertebr-btn vertebr-btn-quiet vertebr-btn-icon",onClick:()=>D(!0),children:[y.jsx(mte,{}),Ue]}):null,y.jsx("span",{className:"vertebr-count",children:e.length})]})]});return e.length===0?y.jsxs("div",{className:"vertebr-resource-body",children:[Be,Ze||Bn.length>0||yt.length>0?ie:null,y.jsx("div",{className:"vertebr-empty",children:"No rows yet."}),le,be,we,Te]}):y.jsxs("div",{className:"vertebr-resource-body",children:[Be,ie,y.jsx("div",{className:"vertebr-table-wrap",ref:ke,"data-overflow":H.overflow?"true":void 0,"data-overflow-left":H.canLeft?"true":void 0,"data-overflow-right":H.canRight?"true":void 0,children:y.jsxs("table",{className:"vertebr-table",children:[y.jsx("thead",{children:Ne.getHeaderGroups().map(se=>y.jsx("tr",{children:se.headers.map(F=>y.jsx("th",{className:F.column.id==="_actions"?"vertebr-col-actions":F.column.id==="_select"?"vertebr-col-select":void 0,children:F.isPlaceholder?null:mM(F.column.columnDef.header,F.getContext())},F.id))},se.id))}),y.jsx("tbody",{children:Ne.getRowModel().rows.map(se=>y.jsx("tr",{className:"vertebr-table-row-clickable","data-selected":Wt&&ii(se.original,o)&&Q.has(ii(se.original,o))?"true":void 0,tabIndex:0,onClick:()=>P(se.original),onKeyDown:F=>{(F.key==="Enter"||F.key===" ")&&(F.preventDefault(),P(se.original))},children:se.getVisibleCells().map(F=>y.jsx("td",{className:F.column.id==="_actions"?"vertebr-col-actions":F.column.id==="_select"?"vertebr-col-select":void 0,children:mM(F.column.columnDef.cell,F.getContext())},F.id))},se.id))})]})}),I?y.jsx(ate,{schema:t,row:I,title:wM(I,o),canEdit:ae,onClose:()=>P(null),onEdit:()=>{M(I),P(null)}}):null,we,Te,le,be]})}function mte(){return y.jsxs("svg",{className:"vertebr-btn-glyph",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M12 5v14"}),y.jsx("path",{d:"M5 12h14"})]})}function gte(){return y.jsx("svg",{className:"vertebr-btn-glyph",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:y.jsx("path",{d:"m15 18-6-6 6-6"})})}function yte(){return y.jsx("svg",{className:"vertebr-btn-glyph",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:y.jsx("path",{d:"m9 18 6-6-6-6"})})}function bte(){return y.jsxs("svg",{className:"vertebr-btn-glyph",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("path",{d:"M16 5h6"}),y.jsx("path",{d:"M19 2v6"}),y.jsx("rect",{x:"3",y:"7",width:"14",height:"14",rx:"2"}),y.jsx("circle",{cx:"8.5",cy:"12.5",r:"1.5"}),y.jsx("path",{d:"m17 21-4.5-4.5L7 21"})]})}const vte=[{id:"desktop",label:"Desktop"},{id:"mobile",label:"Mobile"}],Zl=390,Yl=844;function xte({previewPath:t,controlId:e,draft:n}){const r=E.useRef(null),i=E.useRef(null),s=E.useRef(n),[o,l]=E.useState(!1),[u,f]=E.useState(!1),[h,m]=E.useState("desktop"),[g,b]=E.useState(1);s.current=n;const x=h==="mobile",S=E.useMemo(()=>xH(t,{controlId:e}),[t,e]),k=E.useCallback(()=>{const A=r.current?.contentWindow,R=s.current;!A||!R||kH(A,e,R)},[e]),C=E.useCallback(()=>{const A=r.current?.contentWindow;if(A)try{A.dispatchEvent(new Event("resize"))}catch{}},[]);return E.useEffect(()=>{l(!1),f(!1)},[S]),E.useEffect(()=>CH(A=>{const R=r.current?.contentWindow;!R||A!==R||(l(!0),k())}),[k,S]),E.useEffect(()=>{o&&k()},[n,o,k]),E.useEffect(()=>{if(!x){b(1);return}const A=i.current;if(!A||typeof ResizeObserver>"u")return;const R=()=>{const M=getComputedStyle(A),O=(Number.parseFloat(M.paddingLeft)||0)+(Number.parseFloat(M.paddingRight)||0),D=(Number.parseFloat(M.paddingTop)||0)+(Number.parseFloat(M.paddingBottom)||0),I=Math.max(0,A.clientWidth-O),P=Math.max(0,A.clientHeight-D),B=Math.min(1,I/Zl,P/Yl);b(Number.isFinite(B)&&B>0?B:1)};R();const _=new ResizeObserver(R);return _.observe(A),()=>_.disconnect()},[x]),E.useEffect(()=>{if(!o)return;const A=window.setTimeout(C,50);return()=>window.clearTimeout(A)},[h,g,o,C]),y.jsxs("div",{className:"vertebr-page-preview",children:[y.jsxs("div",{className:"vertebr-page-preview-meta",children:[y.jsxs("p",{children:[y.jsx("span",{children:"Preview"}),y.jsx("strong",{children:t})]}),y.jsxs("p",{children:[y.jsx("span",{children:"Status"}),y.jsx("strong",{children:u?"Unavailable":o?"Live":"Loading…"})]}),x?y.jsxs("p",{children:[y.jsx("span",{children:"Viewport"}),y.jsxs("strong",{children:[Zl,"×",Yl]})]}):null,y.jsx("div",{className:"vertebr-page-preview-viewports",role:"group","aria-label":"Preview viewport",children:vte.map(A=>y.jsx("button",{type:"button","data-active":h===A.id?"true":void 0,onClick:()=>m(A.id),children:A.label},A.id))})]}),y.jsx("div",{ref:i,className:"vertebr-page-preview-stage","data-viewport":h,children:y.jsx("div",{className:"vertebr-page-preview-shell",style:x?{width:Zl*g,height:Yl*g}:void 0,children:y.jsx("div",{className:"vertebr-page-preview-frame",style:x?{width:Zl,height:Yl,transform:`scale(${g})`,transformOrigin:"top left"}:void 0,children:u?y.jsxs("div",{className:"vertebr-page-preview-empty",children:["Could not load host preview at ",t,"."]}):y.jsx("iframe",{ref:r,title:`Preview ${e}`,src:S,width:x?Zl:void 0,height:x?Yl:void 0,style:x?{width:Zl,height:Yl}:void 0,onLoad:()=>{l(!0),k(),C()},onError:()=>f(!0)})})})})]})}function wte({client:t,configData:e,isPageSelection:n,previewPath:r,onConfigSaved:i,galleryPicker:s,fontLibraryPicker:o}){const[l,u]=E.useState(e.value),f=!!r,h=E.useCallback(g=>{u(g)},[]),m=y.jsx(jg,{schema:e.schema,value:e.value,onChange:f?h:void 0,onSave:async g=>{const b=await t.setConfig(e.id,g);i(b)},...s,...o});return y.jsxs("div",{className:"vertebr-config-editor",children:[f?y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:n?"Page content":e.label}),y.jsxs("span",{className:"vertebr-count",children:[Object.keys(e.schema).length," fields"]})]}):n?y.jsxs("div",{className:"vertebr-panel-head",children:[y.jsx("h2",{children:"Page content"}),y.jsxs("span",{className:"vertebr-count",children:[Object.keys(e.schema).length," fields"]})]}):null,f&&r?y.jsxs("div",{className:"vertebr-page-editor",children:[y.jsx("div",{className:"vertebr-page-editor-form",children:m}),y.jsx(xte,{previewPath:r,controlId:e.id,draft:l??e.value})]}):m]})}function Ste({client:t,catalog:e,selection:n,authRequired:r,loading:i,isPageSelection:s,metricsData:o,metricsLoading:l,metricsRange:u,onMetricsRangeChange:f,onRefreshMetrics:h,galleryData:m,galleryLoading:g,onRefreshGallery:b,fontLibraryData:x,fontLibraryLoading:S,onRefreshFonts:k,emailsData:C,emailsLoading:A,onRefreshEmails:R,resourceData:_,onRefreshResource:M,configData:O,onConfigSaved:D,galleryPicker:I,fontLibraryPicker:P}){return e?y.jsx("div",{className:"vertebr-content",children:y.jsxs("section",{className:"vertebr-panel",children:[n?.kind==="overview"?y.jsx(QQ,{label:o?.label??e.metrics?.label,windowLabel:o?.windowLabel,compareLabel:o?.compareLabel,metrics:o?.metrics??[],charts:o?.charts??[],range:u,onRangeChange:f,loading:l,onRefresh:()=>{h()}}):null,n?.kind==="gallery"&&m?y.jsx(zQ,{label:m.label,items:m.items,accept:m.accept,maxBytes:m.maxBytes,canDelete:m.canDelete,loading:g,onRefresh:()=>{b()},onUpload:async B=>{B.length===1&&B[0]?await t.uploadGalleryFile(B[0]):await t.uploadGalleryFiles(B),await b()},onDelete:m.canDelete?async B=>{await t.deleteGalleryItem(B),await b()}:void 0}):null,n?.kind==="fontLibrary"&&x?y.jsx(PQ,{label:x.label,data:x,loading:S,onRefresh:()=>{k()},onUpload:async(B,re)=>{for(const K of B)await t.uploadFontFile(K,re);await k()},onImportGoogle:x.canImportGoogle?async B=>{await t.importGoogleFont(B),await k()}:void 0,onDelete:x.canDelete?async B=>{await t.deleteFontItem(B),await k()}:void 0}):null,n?.kind==="emails"&&C?y.jsx(DQ,{data:C,loading:A,tab:n.tab??"compose",onRefresh:()=>{R()},onLoadRecipients:async B=>{const re=await t.listResource(B,{fresh:!0}),K=new Set,ee=[];for(const Q of re.items){const fe=String(Q.email??"").trim().toLowerCase();if(!fe.includes("@")||K.has(fe))continue;K.add(fe);const z=String(Q.id??Q.uid??Q.slug??fe),L=String(Q.displayName??Q.name??"").trim();ee.push({email:fe,id:z,...L?{label:L}:{}})}return ee.sort((Q,fe)=>Q.email.localeCompare(fe.email)),ee},onPreview:B=>t.previewEmails(B),onSend:async B=>{const re=await t.sendEmails(B);return{sent:re.sent,failed:re.failed}},onSchedule:C.canSchedule?async B=>{await t.scheduleEmails(B)}:void 0,onCancel:C.canSchedule?async B=>{await t.cancelEmailCampaign(B)}:void 0,onSaveLibrary:C.canLibrary?async B=>{await t.saveEmailLibraryTemplate(B)}:void 0,onDeleteLibrary:C.canLibrary?async B=>{await t.deleteEmailLibraryTemplate(B)}:void 0}):null,n?.kind==="resource"&&_?y.jsx(pte,{schema:_.schema,items:_.items,label:_.label,permissions:_.permissions,actions:_.actions,collectionActions:_.collectionActions,uploads:_.uploads,storageKey:_.id,onUpdate:_.permissions.update?async(B,re)=>{await t.updateResource(_.id,B,re),await M()}:void 0,onCreate:_.permissions.create?async B=>{await t.createResource(_.id,B),await M()}:void 0,onDelete:_.permissions.delete?async B=>{await t.deleteResource(_.id,B),await M()}:void 0,onAction:async(B,re,K)=>{await t.runResourceAction(_.id,B,re,K)},onActionDone:M,onPreviewMail:async(B,re,K)=>t.previewResourceMail(_.id,B,re,K),onCollectionAction:async(B,re)=>t.runCollectionAction(_.id,B,re),onUpload:_.uploads?async(B,re)=>{if(re.length===1&&re[0]){const ee=await t.uploadResourceFile(_.id,B,re[0]);return[{url:ee.url,name:ee.name}]}return(await t.uploadResourceFiles(_.id,B,re)).files}:void 0,...I}):null,n?.kind==="config"&&O?y.jsx(wte,{client:t,configData:O,isPageSelection:s,previewPath:e.configs.find(B=>B.id===O.id)?.previewPath,onConfigSaved:D,galleryPicker:I,fontLibraryPicker:P},O.id):null]})}):y.jsx("div",{className:"vertebr-content",children:y.jsx("section",{className:"vertebr-panel",children:y.jsx("div",{className:"vertebr-empty",children:r?"Authenticated access required for this environment.":i?"Loading…":"Unable to load catalog."})})})}function kte({catalogLoaded:t,authRequired:e,selection:n,isPageSelection:r,hasPagePreview:i}){return!t&&e?"Provide an access token to load this environment.":n?.kind==="overview"?"Commerce, growth, and catalog for the selected environment.":n?.kind==="gallery"?"Browse and upload shared media assets.":n?.kind==="fontLibrary"?"Upload custom fonts or add Google Fonts to your library.":n?.kind==="emails"?"Send or schedule branded email to a list or specific people.":n?.kind==="resource"?"Manage records scoped to the selected environment.":n?.kind==="config"?i?r?"Edit content — live storefront preview updates as you type.":"Edit settings — live storefront preview updates as you change typography and colors.":r?"Edit content for this page.":"Environment settings — changes apply to this environment only.":"Select a panel."}function Cte({activeLabel:t,activeEnv:e,catalogLoaded:n,authRequired:r,selection:i,isPageSelection:s,hasPagePreview:o,error:l}){return y.jsxs("header",{className:"vertebr-header",children:[y.jsxs("div",{children:[y.jsxs("div",{className:"vertebr-heading-row",children:[y.jsx("h1",{children:t}),e?y.jsx("span",{className:"vertebr-env-badge","data-tone":e.tone??"neutral",children:e.label}):null]}),y.jsx("p",{children:kte({catalogLoaded:n,authRequired:r,selection:i,isPageSelection:s,hasPagePreview:o})})]}),l?y.jsx("span",{className:"vertebr-status","data-tone":"danger",children:l}):null]})}function Ete({environments:t,value:e,onChange:n}){const r=t.find(i=>i.id===e);return y.jsxs(Cg,{value:e,onValueChange:n,children:[y.jsxs(Eg,{className:"vertebr-select-trigger","aria-label":"Environment","data-tone":r?.tone??"neutral",children:[y.jsxs("span",{className:"vertebr-select-value",children:[y.jsx("span",{className:"vertebr-select-dot","data-tone":r?.tone??"neutral"}),y.jsx(Tg,{placeholder:"Select environment"})]}),y.jsx(_g,{className:"vertebr-select-icon",children:y.jsx(Tte,{})})]}),y.jsx(Ag,{children:y.jsx(Rg,{className:"vertebr-select-content",position:"popper",sideOffset:6,children:y.jsx(Ng,{className:"vertebr-select-viewport",children:t.map(i=>y.jsxs(Og,{value:i.id,className:"vertebr-select-item","data-tone":i.tone??"neutral",children:[y.jsxs("span",{className:"vertebr-select-value",children:[y.jsx("span",{className:"vertebr-select-dot","data-tone":i.tone??"neutral"}),y.jsx(Dg,{children:i.label})]}),i.auth?.required?y.jsx("span",{className:"vertebr-env-lock",children:"auth"}):null,y.jsx(Ig,{className:"vertebr-select-check",children:y.jsx(_te,{})})]},i.id))})})})]})}function Tte(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 4.5 6 8l3.5-3.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})})}function _te(){return y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12","aria-hidden":"true",children:y.jsx("path",{d:"M2.5 6.2 4.8 8.5 9.5 3.8",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ate({theme:t,onChange:e}){return y.jsxs("div",{className:"vertebr-theme",children:[y.jsx("div",{className:"vertebr-nav-label",children:"Appearance"}),y.jsxs("div",{className:"vertebr-theme-toggle",role:"group","aria-label":"Color theme",children:[y.jsxs("button",{type:"button",className:"vertebr-theme-option","data-active":t==="light","aria-pressed":t==="light",onClick:()=>e("light"),children:[y.jsx(Rte,{}),"Light"]}),y.jsxs("button",{type:"button",className:"vertebr-theme-option","data-active":t==="dark","aria-pressed":t==="dark",onClick:()=>e("dark"),children:[y.jsx(Mte,{}),"Dark"]})]})]})}function Rte(){return y.jsxs("svg",{className:"vertebr-theme-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[y.jsx("circle",{cx:"12",cy:"12",r:"4"}),y.jsx("path",{d:"M12 2v2M12 20v2M4.93 4.93l1.41 1.41M17.66 17.66l1.41 1.41M2 12h2M20 12h2M4.93 19.07l1.41-1.41M17.66 6.34l1.41-1.41"})]})}function Mte(){return y.jsx("svg",{className:"vertebr-theme-icon",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:y.jsx("path",{d:"M21 14.5A8.5 8.5 0 0 1 9.5 3 7 7 0 1 0 21 14.5z"})})}function Nte({item:t}){const e=!!t.children?.length,n=t.children?.some(o=>o.active)??!1,r=t.active||n,[i,s]=E.useState(r);return E.useEffect(()=>{r&&s(!0)},[r]),e?y.jsxs("div",{className:"vertebr-nav-item","data-has-children":"true","data-open":i||void 0,children:[y.jsxs("div",{className:"vertebr-nav-parent",children:[y.jsx("button",{type:"button",className:"vertebr-nav-parent-label","data-active":r&&!n,"data-section":r||void 0,onClick:()=>{s(!0),t.onSelect()},children:t.label}),y.jsx("button",{type:"button",className:"vertebr-nav-parent-toggle","aria-label":i?`Collapse ${t.label}`:`Expand ${t.label}`,"aria-expanded":i,onClick:()=>s(o=>!o),children:y.jsx("span",{"aria-hidden":"true",children:i?"▾":"▸"})})]}),i?y.jsx("div",{className:"vertebr-nav-sub",role:"group",children:t.children.map(o=>y.jsx("button",{type:"button",className:"vertebr-nav-subitem","data-active":o.active,onClick:()=>{s(!0),o.onSelect()},children:o.label},o.key))}):null]}):y.jsx("button",{type:"button","data-active":t.active,onClick:t.onSelect,children:t.label})}function Ote({brand:t,title:e,envList:n,environment:r,onEnvironmentChange:i,navGroups:s,getAccessToken:o,authUserLabel:l,onSignOut:u,authRequired:f,activeEnv:h,token:m,tokenDraft:g,onTokenDraftChange:b,onSaveToken:x,onClearToken:S,theme:k,onThemeChange:C}){return y.jsxs("aside",{className:"vertebr-sidebar",children:[y.jsxs("div",{className:"vertebr-sidebar-top",children:[y.jsxs("div",{className:"vertebr-brand",children:[y.jsx("strong",{children:t}),y.jsx("span",{children:e})]}),n.length>0?y.jsxs("div",{className:"vertebr-env",children:[y.jsx("div",{className:"vertebr-nav-label",children:"Environment"}),y.jsx(Ete,{environments:n,value:r,onChange:i})]}):null,y.jsx("nav",{className:"vertebr-nav",children:s.map(A=>y.jsxs("div",{className:"vertebr-nav-group",children:[y.jsx("div",{className:"vertebr-nav-label",children:A.label}),A.items.map(R=>y.jsx(Nte,{item:R},R.key))]},A.label))})]}),y.jsxs("div",{className:"vertebr-sidebar-bottom",children:[o&&l?y.jsxs("div",{className:"vertebr-auth",children:[y.jsx("div",{className:"vertebr-nav-label",children:"Signed in"}),y.jsx("p",{className:"vertebr-auth-hint",children:l}),u?y.jsx("button",{type:"button",className:"vertebr-btn",onClick:()=>{u()},children:"Sign out"}):null]}):null,!o&&(f||m)?y.jsxs("div",{className:"vertebr-auth",children:[y.jsx("div",{className:"vertebr-nav-label",children:"Access"}),y.jsx("p",{className:"vertebr-auth-hint",children:f?`This environment requires auth${h?.auth?.claimKey?` (${h.auth.claimKey})`:""}.`:"Optional access token for protected environments."}),y.jsx("input",{className:"vertebr-auth-input",type:"password",placeholder:"Bearer token",value:g,onChange:A=>b(A.target.value),autoComplete:"off"}),y.jsxs("div",{className:"vertebr-auth-actions",children:[y.jsx("button",{type:"button",className:"vertebr-btn vertebr-btn-primary",onClick:x,children:"Use token"}),m?y.jsx("button",{type:"button",className:"vertebr-btn",onClick:S,children:"Clear"}):null]})]}):null,y.jsx(Ate,{theme:k,onChange:C})]})]})}const Dte=new Set(["compose","templates","activity"]);function Ite(t){const e=(t||"/admin/api").replace(/\/$/,"")||"/admin/api";return e.endsWith("/api")?e.slice(0,-4)||"/":e}function b2(t){return!t||t==="/"?"":t.replace(/\/$/,"")}function jte(t,e){if(!t)return"/overview";switch(t.kind){case"overview":return"/overview";case"gallery":return"/gallery";case"fontLibrary":return"/fonts";case"emails":return`/emails/${t.tab??"compose"}`;case"resource":return`/resources/${encodeURIComponent(t.id)}`;case"config":return`/${e.configs.find(i=>i.id===t.id)?.section==="page"?"pages":"config"}/${encodeURIComponent(t.id)}`;default:return"/overview"}}function Lte(t,e,n){const r=b2(t),i=jte(e,n);return`${r}${i}`||"/"}function Pte(t){return t&&Dte.has(t)?t:"compose"}function p0(t,e,n){const r=b2(e);let i=t||"/";if(r){if(i===r||i===`${r}/`)return null;(i.startsWith(`${r}/`)||i.startsWith(r))&&(i=i.slice(r.length))}const s=i.replace(/^\//,"").split("/").filter(Boolean);if(s.length===0)return null;const[o,...l]=s;if(o==="overview")return{kind:"overview"};if(o==="gallery")return{kind:"gallery"};if(o==="fonts")return{kind:"fontLibrary"};if(o==="emails")return{kind:"emails",tab:Pte(l[0])};if(o==="resources"&&l[0]){const u=decodeURIComponent(l[0]);return n&&!n.resources.some(f=>f.id===u)?null:{kind:"resource",id:u}}if((o==="pages"||o==="config")&&l[0]){const u=decodeURIComponent(l[0]);if(n){const f=n.configs.find(h=>h.id===u);if(!f||o==="pages"&&f.section!=="page"||o==="config"&&f.section==="page")return null}return{kind:"config",id:u}}return null}function Ni(t){if(t.metrics)return{kind:"overview"};const e=t.resources[0];if(e)return{kind:"resource",id:e.id};if(t.gallery)return{kind:"gallery"};if(t.fontLibrary)return{kind:"fontLibrary"};if(t.emails)return{kind:"emails",tab:"compose"};const n=t.configs[0];return n?{kind:"config",id:n.id}:{kind:"overview"}}function CM(t,e){return t?t.kind==="overview"?e.metrics?t:Ni(e):t.kind==="gallery"?e.gallery?t:Ni(e):t.kind==="fontLibrary"?e.fontLibrary?t:Ni(e):t.kind==="emails"?e.emails?t:Ni(e):t.kind==="resource"?e.resources.some(n=>n.id===t.id)?t:Ni(e):t.kind==="config"&&e.configs.some(n=>n.id===t.id)?t:Ni(e):Ni(e)}function zte(t,e){return t===e?!0:!t||!e?t===e:t.kind!==e.kind?!1:t.kind==="overview"||t.kind==="gallery"||t.kind==="fontLibrary"?!0:t.kind==="emails"&&e.kind==="emails"?(t.tab??"compose")===(e.tab??"compose"):t.kind==="resource"&&e.kind==="resource"||t.kind==="config"&&e.kind==="config"?t.id===e.id:!1}function $te(t){const e=[],n=new Map;for(const r of t){const i=r.group.trim()||"Resources";n.has(i)||(n.set(i,[]),e.push(i)),n.get(i).push(r)}return e.map(r=>({label:r,items:n.get(r)}))}function m0(t){try{return localStorage.getItem(t)}catch{return null}}function rp(t,e){try{localStorage.setItem(t,e)}catch{}}function EM(t){try{localStorage.removeItem(t)}catch{}}function Bte({apiBase:t="/admin/api",basePath:e,title:n="Control plane",envStorageKey:r="vertebr:env",tokenStorageKey:i="vertebr:token",themeStorageKey:s="vertebr:theme",metricsRangeStorageKey:o="vertebr:metrics-range",getAccessToken:l,authUserLabel:u,onSignOut:f}){const h=e??Ite(t),{theme:m,setTheme:g}=DH(s),[b,x]=E.useState(()=>m0(r)??""),[S,k]=E.useState(()=>m0(i)??""),[C,A]=E.useState(S),R=E.useCallback(()=>b,[b]),_=E.useMemo(()=>C0({apiBase:t,getEnvironment:R,getAccessToken:l??(()=>S||null)}),[t,R,l,S]),[M,O]=E.useState(null),[D,I]=E.useState(null),[P,B]=E.useState(()=>typeof window>"u"?{kind:"overview"}:p0(window.location.pathname,h,null)??{kind:"overview"}),[re,K]=E.useState(null),[ee,Q]=E.useState(null),[fe,z]=E.useState(null),[L,G]=E.useState(!1),[he,ke]=E.useState(()=>LH(m0(o))),[H,Z]=E.useState(null),[pe,ve]=E.useState(!1),[Ae,Re]=E.useState(null),[$e,_e]=E.useState(!1),[ae,me]=E.useState(null),[Ie,Ue]=E.useState(!1),[Ze,ct]=E.useState(null),[yt,Pt]=E.useState(!0),mn=E.useRef(!0),Wt=E.useCallback((F,ne,Ce=!1)=>{if(typeof window>"u"||!F)return;const Ge=Lte(h,F,ne);if(window.location.pathname===Ge)return;const Dt=Ce?"replaceState":"pushState";window.history[Dt](null,"",Ge)},[h]);E.useEffect(()=>{let F=!1;return(async()=>{try{const ne=await _.getBootstrap();if(F)return;O(ne);const Ce=ne.environments.map(Dt=>Dt.id),Ge=b&&Ce.includes(b)&&b||ne.defaultEnvironment;Ge!==b&&(x(Ge),rp(r,Ge))}catch(ne){F||ct(ne instanceof Error?ne.message:"Failed to load bootstrap")}})(),()=>{F=!0}},[_,b,r]),E.useEffect(()=>{if(!M||!b)return;let F=!1;return(async()=>{try{Pt(!0),ct(null);const ne=await _.getCatalog();if(F)return;I(ne);const Ce=p0(window.location.pathname,h,ne),Ge=CM(Ce??Ni(ne),ne);mn.current=!0,B(Ge),Wt(Ge,ne,!0)}catch(ne){F||(I(null),ct(ne instanceof Error?ne.message:"Failed to load catalog"))}finally{F||Pt(!1)}})(),()=>{F=!0}},[_,M,b,h,Wt]),E.useEffect(()=>{if(!(!D||!P)){if(mn.current){mn.current=!1;return}Wt(P,D,!1)}},[P,D,Wt]),E.useEffect(()=>{const F=()=>{if(!D)return;const ne=p0(window.location.pathname,h,D),Ce=CM(ne??Ni(D),D);mn.current=!0,B(Ge=>zte(Ge,Ce)?Ge:Ce)};return window.addEventListener("popstate",F),()=>window.removeEventListener("popstate",F)},[D,h]),E.useEffect(()=>{if(!P||!D)return;let F=!1;return(async()=>{try{if(ct(null),P.kind==="overview"){G(!0);const ne=await _.getMetrics({range:he});F||(z(ne),K(null),Q(null),Z(null),Re(null),me(null))}else if(P.kind==="gallery"){ve(!0);const ne=await _.getGallery();F||(Z(ne),K(null),Q(null),z(null),Re(null),me(null))}else if(P.kind==="fontLibrary"){_e(!0);const ne=await _.getFonts();F||(Re(ne),K(null),Q(null),z(null),Z(null),me(null))}else if(P.kind==="emails"){Ue(!0);const ne=await _.getEmails();F||(me(ne),K(null),Q(null),z(null),Z(null),Re(null))}else if(P.kind==="resource"){const ne=await _.listResource(P.id);F||(K(ne),Q(null),z(null),Z(null),Re(null),me(null))}else{const ne=await _.getConfig(P.id);if(!F&&(Q(ne),K(null),z(null),Z(null),me(null),D.fontLibrary)){_e(!0);try{const Ce=await _.getFonts();F||Re(Ce)}finally{F||_e(!1)}}}}catch(ne){F||ct(ne instanceof Error?ne.message:"Failed to load panel")}finally{F||(G(!1),ve(!1),_e(!1),Ue(!1))}})(),()=>{F=!0}},[_,P,D,b,he]);const yn=E.useCallback(async()=>{if(P?.kind!=="resource")return;const F=await _.listResource(P.id);K(F)},[_,P]),$n=E.useCallback(async()=>{G(!0);try{const F=await _.getMetrics({range:he,fresh:!0});z(F)}finally{G(!1)}},[_,he]),Dr=E.useCallback(F=>{ke(F),rp(o,F)},[o]),sr=E.useCallback(async()=>{ve(!0);try{const F=await _.getGallery({fresh:!0});Z(F)}finally{ve(!1)}},[_]),Ir=E.useCallback(async()=>{_e(!0);try{const F=await _.getFonts({fresh:!0});Re(F)}finally{_e(!1)}},[_]),Ht=E.useCallback(async()=>(await _.getFonts()).items,[_]),xi=E.useCallback(async()=>{Ue(!0);try{const F=await _.getEmails({fresh:!0});me(F)}finally{Ue(!1)}},[_]),yr=E.useCallback(async()=>(await _.getGallery()).items,[_]),ei=E.useCallback(async F=>{if(F.length===1&&F[0]){const{item:Ce}=await _.uploadGalleryFile(F[0]);return[Ce]}const{items:ne}=await _.uploadGalleryFiles(F);return ne},[_]),Bn=D?.gallery?{galleryUpload:{accept:D.gallery.accept,maxBytes:D.gallery.maxBytes},onListGallery:yr,onUploadGallery:ei}:{},ge=D?.fontLibrary?{fonts:Ae?.items??[],fontsLoading:$e,onListFonts:Ht,onRefreshFonts:Ir}:{},Ne=D?.environments??M?.environments??[],j=Ne.find(F=>F.id===b),$=!!j?.auth?.required,U=P?.kind==="config"?D?.configs.find(F=>F.id===P.id):void 0,ie=U?.section==="page",le=!!U?.previewPath,be=F=>{if(F===b)return;const ne=Ne.find(Ce=>Ce.id===F);ne?.tone==="danger"&&!window.confirm(`Switch to ${ne.label}? Writes will affect this environment.`)||(rp(r,F),x(F),K(null),Q(null),Z(null),Re(null))},we=()=>{const F=C.trim();k(F),F?rp(i,F):EM(i)},Te=()=>{k(""),A(""),EM(i)},Be=E.useMemo(()=>{if(!D)return[];const F=[];D.metrics&&F.push({key:"overview",group:D.metrics.group??"Analytics",label:D.metrics.label,active:P?.kind==="overview",onSelect:()=>B({kind:"overview"})});for(const ne of D.resources)F.push({key:`resource:${ne.id}`,group:ne.group??"Resources",label:ne.label,active:P?.kind==="resource"&&P.id===ne.id,onSelect:()=>B({kind:"resource",id:ne.id})});if(D.gallery&&F.push({key:"gallery",group:D.gallery.group??"Resources",label:D.gallery.label,active:P?.kind==="gallery",onSelect:()=>B({kind:"gallery"})}),D.fontLibrary&&F.push({key:"fonts",group:D.fontLibrary.group??"Resources",label:D.fontLibrary.label,active:P?.kind==="fontLibrary",onSelect:()=>B({kind:"fontLibrary"})}),D.emails){const ne=P?.kind==="emails"?P.tab??"compose":null;F.push({key:"emails",group:D.emails.group??"Growth",label:D.emails.label,active:P?.kind==="emails",onSelect:()=>B({kind:"emails",tab:"compose"}),children:[{key:"emails:compose",label:"Compose",active:ne==="compose",onSelect:()=>B({kind:"emails",tab:"compose"})},{key:"emails:templates",label:"Templates",active:ne==="templates",onSelect:()=>B({kind:"emails",tab:"templates"})},{key:"emails:activity",label:"Activity",active:ne==="activity",onSelect:()=>B({kind:"emails",tab:"activity"})}]})}for(const ne of D.configs){const Ce=ne.section==="page"?"Pages":"Config";F.push({key:`config:${ne.id}`,group:ne.group??Ce,label:ne.label,active:P?.kind==="config"&&P.id===ne.id,onSelect:()=>B({kind:"config",id:ne.id})})}return $te(F)},[D,P]);if(!M&&yt)return y.jsx("div",{className:"vertebr-loading",children:"Loading Vertebr…"});if(Ze&&!M)return y.jsx("div",{className:"vertebr-error",children:Ze});const se=P?.kind==="overview"?D?.metrics?.label??"Overview":P?.kind==="gallery"?D?.gallery?.label??"Gallery":P?.kind==="fontLibrary"?D?.fontLibrary?.label??"Font Library":P?.kind==="emails"?D?.emails?.label??"Emails":P?.kind==="resource"?D?.resources.find(F=>F.id===P.id)?.label:P?.kind==="config"?D?.configs.find(F=>F.id===P.id)?.label:null;return y.jsxs("div",{className:"vertebr-root","data-env":b,children:[y.jsx(Ote,{brand:M?.brand??D?.brand??"Vertebr",title:n,envList:Ne,environment:b,onEnvironmentChange:be,navGroups:Be,getAccessToken:l,authUserLabel:u,onSignOut:f,authRequired:$,activeEnv:j,token:S,tokenDraft:C,onTokenDraftChange:A,onSaveToken:we,onClearToken:Te,theme:m,onThemeChange:g}),y.jsxs("main",{className:"vertebr-main",children:[y.jsx(Cte,{activeLabel:se??(D?"Dashboard":"Sign in"),activeEnv:j,catalogLoaded:!!D,authRequired:$,selection:P,isPageSelection:ie,hasPagePreview:le,error:Ze}),y.jsx(Ste,{client:_,catalog:D,selection:P,authRequired:$,loading:yt,isPageSelection:ie,metricsData:fe,metricsLoading:L,metricsRange:he,onMetricsRangeChange:Dr,onRefreshMetrics:$n,galleryData:H,galleryLoading:pe,onRefreshGallery:sr,fontLibraryData:Ae,fontLibraryLoading:$e,onRefreshFonts:Ir,emailsData:ae,emailsLoading:Ie,onRefreshEmails:xi,resourceData:re,onRefreshResource:yn,configData:ee,onConfigSaved:Q,galleryPicker:Bn,fontLibraryPicker:ge})]})]})}E.createContext(null);E.createContext(null);const g0="/admin/api";function Vte(t){const e=t.environments.map(r=>r.auth?.client).find(r=>r?.provider==="firebase");if(!e)return null;const n=aB().length?BM():$M(e.config);return MV(n)}function Hte(){const[t,e]=E.useState(null),[n,r]=E.useState(null),[i,s]=E.useState(null),[o,l]=E.useState(!1),[u,f]=E.useState("idle"),[h,m]=E.useState(""),[g,b]=E.useState(""),[x,S]=E.useState(null),[k,C]=E.useState(!1),A=E.useMemo(()=>C0({apiBase:g0,getEnvironment:()=>""}),[]);E.useEffect(()=>{let O=!1;return A.getBootstrap().then(D=>{if(O)return;e(D);const I=Vte(D);r(I),I||l(!0)}).catch(D=>{O||(S(D instanceof Error?D.message:"Could not load auth"),l(!0))}),()=>{O=!0}},[A]),E.useEffect(()=>{if(n)return v3(n,O=>{s(O),f(O?"checking":"idle"),l(!0)})},[n]),E.useEffect(()=>{if(!t||!i)return;let O=!1;return(async()=>{f("checking");const D=localStorage.getItem("vertebr:env"),I=[...D?[D]:[],...t.environments.map(P=>P.id)].filter((P,B,re)=>re.indexOf(P)===B);for(const P of I)try{await C0({apiBase:g0,getEnvironment:()=>P,getAccessToken:()=>i.getIdToken()}).getCatalog(),O||(localStorage.setItem("vertebr:env",P),f("allowed"));return}catch{}O||f("denied")})(),()=>{O=!0}},[t,i]);const R=t?.environments.map(O=>O.auth?.client).find(O=>O?.provider==="firebase")?.methods??["email"],_=async O=>{if(O.preventDefault(),!!n){C(!0),S(null);try{await g3(n,h.trim(),g)}catch(D){S(D instanceof Error?D.message:"Sign-in failed")}finally{C(!1)}}},M=async()=>{if(n){C(!0),S(null);try{await $3(n,new gs)}catch(O){S(O instanceof Error?O.message:"Sign-in failed")}finally{C(!1)}}};return o?!n||!t?y.jsx("div",{className:"vertebr-error",children:x??"No browser auth provider is configured."}):i?u==="checking"||u==="idle"?y.jsx("div",{className:"vertebr-loading",children:"Checking admin access…"}):u==="denied"?y.jsx("main",{className:"vertebr-login",children:y.jsxs("section",{className:"vertebr-login-card",children:[y.jsxs("div",{className:"vertebr-brand",children:[y.jsx("strong",{children:t.brand}),y.jsx("span",{children:"Access denied"})]}),y.jsxs("div",{children:[y.jsx("h1",{children:"Administrator access required"}),y.jsxs("p",{children:["Signed in as ",i.email??i.uid,", but this account is not approved for any Vertebr environment."]})]}),y.jsx("button",{className:"vertebr-btn",type:"button",onClick:()=>{jT(n)},children:"Sign out"})]})}):y.jsx(Bte,{apiBase:g0,title:"Owner control plane",getAccessToken:()=>i.getIdToken(),authUserLabel:i.email??i.uid,onSignOut:()=>jT(n)}):y.jsx("main",{className:"vertebr-login",children:y.jsxs("section",{className:"vertebr-login-card",children:[y.jsxs("div",{className:"vertebr-brand",children:[y.jsx("strong",{children:t.brand}),y.jsx("span",{children:"Admin access"})]}),y.jsxs("div",{children:[y.jsx("h1",{children:"Sign in"}),y.jsx("p",{children:"Use an approved administrator account. Storefront accounts do not receive dashboard access."})]}),R.includes("email")?y.jsxs("form",{className:"vertebr-login-form",onSubmit:_,children:[y.jsxs("label",{className:"vertebr-field",children:[y.jsx("span",{children:"Email"}),y.jsx("input",{type:"email",autoComplete:"username",required:!0,value:h,onChange:O=>m(O.target.value)})]}),y.jsxs("label",{className:"vertebr-field",children:[y.jsx("span",{children:"Password"}),y.jsx("input",{type:"password",autoComplete:"current-password",required:!0,value:g,onChange:O=>b(O.target.value)})]}),y.jsx("button",{className:"vertebr-btn vertebr-btn-primary",type:"submit",disabled:k,children:k?"Signing in…":"Sign in"})]}):null,R.includes("google")?y.jsx("button",{className:"vertebr-btn",type:"button",disabled:k,onClick:()=>{M()},children:"Continue with Google"}):null,x?y.jsx("p",{className:"vertebr-status","data-tone":"danger",children:x}):null]})}):y.jsx("div",{className:"vertebr-loading",children:"Checking admin session…"})}$z.createRoot(document.getElementById("root")).render(y.jsx(E.StrictMode,{children:y.jsx(Hte,{})}));
|